2014-06-20 12:32:48 +08:00
|
|
|
; RUN: opt < %s -basicaa -slp-vectorizer -S | FileCheck %s
|
|
|
|
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
|
|
|
|
target triple = "x86_64-unknown-linux-gnu"
|
|
|
|
|
|
|
|
@b = common global [4 x i32] zeroinitializer, align 16
|
|
|
|
@c = common global [4 x i32] zeroinitializer, align 16
|
|
|
|
@d = common global [4 x i32] zeroinitializer, align 16
|
|
|
|
@e = common global [4 x i32] zeroinitializer, align 16
|
|
|
|
@a = common global [4 x i32] zeroinitializer, align 16
|
|
|
|
@fb = common global [4 x float] zeroinitializer, align 16
|
|
|
|
@fc = common global [4 x float] zeroinitializer, align 16
|
|
|
|
@fa = common global [4 x float] zeroinitializer, align 16
|
2015-01-20 14:11:00 +08:00
|
|
|
@fd = common global [4 x float] zeroinitializer, align 16
|
2014-06-20 12:32:48 +08:00
|
|
|
|
|
|
|
; CHECK-LABEL: @addsub
|
2014-09-04 01:40:30 +08:00
|
|
|
; CHECK: %5 = add nsw <4 x i32> %3, %4
|
|
|
|
; CHECK: %6 = add nsw <4 x i32> %2, %5
|
|
|
|
; CHECK: %7 = sub nsw <4 x i32> %2, %5
|
2014-06-20 12:32:48 +08:00
|
|
|
; CHECK: %8 = shufflevector <4 x i32> %6, <4 x i32> %7, <4 x i32> <i32 0, i32 5, i32 2, i32 7>
|
|
|
|
|
|
|
|
; Function Attrs: nounwind uwtable
|
|
|
|
define void @addsub() #0 {
|
|
|
|
entry:
|
2015-03-14 02:20:45 +08:00
|
|
|
%0 = load i32, i32* getelementptr inbounds ([4 x i32], [4 x i32]* @b, i32 0, i64 0), align 4
|
|
|
|
%1 = load i32, i32* getelementptr inbounds ([4 x i32], [4 x i32]* @c, i32 0, i64 0), align 4
|
2014-06-20 12:32:48 +08:00
|
|
|
%add = add nsw i32 %0, %1
|
2015-03-14 02:20:45 +08:00
|
|
|
%2 = load i32, i32* getelementptr inbounds ([4 x i32], [4 x i32]* @d, i32 0, i64 0), align 4
|
|
|
|
%3 = load i32, i32* getelementptr inbounds ([4 x i32], [4 x i32]* @e, i32 0, i64 0), align 4
|
2014-06-20 12:32:48 +08:00
|
|
|
%add1 = add nsw i32 %2, %3
|
|
|
|
%add2 = add nsw i32 %add, %add1
|
2015-03-14 02:20:45 +08:00
|
|
|
store i32 %add2, i32* getelementptr inbounds ([4 x i32], [4 x i32]* @a, i32 0, i64 0), align 4
|
|
|
|
%4 = load i32, i32* getelementptr inbounds ([4 x i32], [4 x i32]* @b, i32 0, i64 1), align 4
|
|
|
|
%5 = load i32, i32* getelementptr inbounds ([4 x i32], [4 x i32]* @c, i32 0, i64 1), align 4
|
2014-06-20 12:32:48 +08:00
|
|
|
%add3 = add nsw i32 %4, %5
|
2015-03-14 02:20:45 +08:00
|
|
|
%6 = load i32, i32* getelementptr inbounds ([4 x i32], [4 x i32]* @d, i32 0, i64 1), align 4
|
|
|
|
%7 = load i32, i32* getelementptr inbounds ([4 x i32], [4 x i32]* @e, i32 0, i64 1), align 4
|
2014-06-20 12:32:48 +08:00
|
|
|
%add4 = add nsw i32 %6, %7
|
|
|
|
%sub = sub nsw i32 %add3, %add4
|
2015-03-14 02:20:45 +08:00
|
|
|
store i32 %sub, i32* getelementptr inbounds ([4 x i32], [4 x i32]* @a, i32 0, i64 1), align 4
|
|
|
|
%8 = load i32, i32* getelementptr inbounds ([4 x i32], [4 x i32]* @b, i32 0, i64 2), align 4
|
|
|
|
%9 = load i32, i32* getelementptr inbounds ([4 x i32], [4 x i32]* @c, i32 0, i64 2), align 4
|
2014-06-20 12:32:48 +08:00
|
|
|
%add5 = add nsw i32 %8, %9
|
2015-03-14 02:20:45 +08:00
|
|
|
%10 = load i32, i32* getelementptr inbounds ([4 x i32], [4 x i32]* @d, i32 0, i64 2), align 4
|
|
|
|
%11 = load i32, i32* getelementptr inbounds ([4 x i32], [4 x i32]* @e, i32 0, i64 2), align 4
|
2014-06-20 12:32:48 +08:00
|
|
|
%add6 = add nsw i32 %10, %11
|
|
|
|
%add7 = add nsw i32 %add5, %add6
|
2015-03-14 02:20:45 +08:00
|
|
|
store i32 %add7, i32* getelementptr inbounds ([4 x i32], [4 x i32]* @a, i32 0, i64 2), align 4
|
|
|
|
%12 = load i32, i32* getelementptr inbounds ([4 x i32], [4 x i32]* @b, i32 0, i64 3), align 4
|
|
|
|
%13 = load i32, i32* getelementptr inbounds ([4 x i32], [4 x i32]* @c, i32 0, i64 3), align 4
|
2014-06-20 12:32:48 +08:00
|
|
|
%add8 = add nsw i32 %12, %13
|
2015-03-14 02:20:45 +08:00
|
|
|
%14 = load i32, i32* getelementptr inbounds ([4 x i32], [4 x i32]* @d, i32 0, i64 3), align 4
|
|
|
|
%15 = load i32, i32* getelementptr inbounds ([4 x i32], [4 x i32]* @e, i32 0, i64 3), align 4
|
2014-06-20 12:32:48 +08:00
|
|
|
%add9 = add nsw i32 %14, %15
|
|
|
|
%sub10 = sub nsw i32 %add8, %add9
|
2015-03-14 02:20:45 +08:00
|
|
|
store i32 %sub10, i32* getelementptr inbounds ([4 x i32], [4 x i32]* @a, i32 0, i64 3), align 4
|
2014-06-20 12:32:48 +08:00
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
; CHECK-LABEL: @subadd
|
2014-09-04 01:40:30 +08:00
|
|
|
; CHECK: %5 = add nsw <4 x i32> %3, %4
|
|
|
|
; CHECK: %6 = sub nsw <4 x i32> %2, %5
|
|
|
|
; CHECK: %7 = add nsw <4 x i32> %2, %5
|
2014-06-20 12:32:48 +08:00
|
|
|
; CHECK: %8 = shufflevector <4 x i32> %6, <4 x i32> %7, <4 x i32> <i32 0, i32 5, i32 2, i32 7>
|
|
|
|
|
|
|
|
; Function Attrs: nounwind uwtable
|
|
|
|
define void @subadd() #0 {
|
|
|
|
entry:
|
2015-03-14 02:20:45 +08:00
|
|
|
%0 = load i32, i32* getelementptr inbounds ([4 x i32], [4 x i32]* @b, i32 0, i64 0), align 4
|
|
|
|
%1 = load i32, i32* getelementptr inbounds ([4 x i32], [4 x i32]* @c, i32 0, i64 0), align 4
|
2014-06-20 12:32:48 +08:00
|
|
|
%add = add nsw i32 %0, %1
|
2015-03-14 02:20:45 +08:00
|
|
|
%2 = load i32, i32* getelementptr inbounds ([4 x i32], [4 x i32]* @d, i32 0, i64 0), align 4
|
|
|
|
%3 = load i32, i32* getelementptr inbounds ([4 x i32], [4 x i32]* @e, i32 0, i64 0), align 4
|
2014-06-20 12:32:48 +08:00
|
|
|
%add1 = add nsw i32 %2, %3
|
|
|
|
%sub = sub nsw i32 %add, %add1
|
2015-03-14 02:20:45 +08:00
|
|
|
store i32 %sub, i32* getelementptr inbounds ([4 x i32], [4 x i32]* @a, i32 0, i64 0), align 4
|
|
|
|
%4 = load i32, i32* getelementptr inbounds ([4 x i32], [4 x i32]* @b, i32 0, i64 1), align 4
|
|
|
|
%5 = load i32, i32* getelementptr inbounds ([4 x i32], [4 x i32]* @c, i32 0, i64 1), align 4
|
2014-06-20 12:32:48 +08:00
|
|
|
%add2 = add nsw i32 %4, %5
|
2015-03-14 02:20:45 +08:00
|
|
|
%6 = load i32, i32* getelementptr inbounds ([4 x i32], [4 x i32]* @d, i32 0, i64 1), align 4
|
|
|
|
%7 = load i32, i32* getelementptr inbounds ([4 x i32], [4 x i32]* @e, i32 0, i64 1), align 4
|
2014-06-20 12:32:48 +08:00
|
|
|
%add3 = add nsw i32 %6, %7
|
|
|
|
%add4 = add nsw i32 %add2, %add3
|
2015-03-14 02:20:45 +08:00
|
|
|
store i32 %add4, i32* getelementptr inbounds ([4 x i32], [4 x i32]* @a, i32 0, i64 1), align 4
|
|
|
|
%8 = load i32, i32* getelementptr inbounds ([4 x i32], [4 x i32]* @b, i32 0, i64 2), align 4
|
|
|
|
%9 = load i32, i32* getelementptr inbounds ([4 x i32], [4 x i32]* @c, i32 0, i64 2), align 4
|
2014-06-20 12:32:48 +08:00
|
|
|
%add5 = add nsw i32 %8, %9
|
2015-03-14 02:20:45 +08:00
|
|
|
%10 = load i32, i32* getelementptr inbounds ([4 x i32], [4 x i32]* @d, i32 0, i64 2), align 4
|
|
|
|
%11 = load i32, i32* getelementptr inbounds ([4 x i32], [4 x i32]* @e, i32 0, i64 2), align 4
|
2014-06-20 12:32:48 +08:00
|
|
|
%add6 = add nsw i32 %10, %11
|
|
|
|
%sub7 = sub nsw i32 %add5, %add6
|
2015-03-14 02:20:45 +08:00
|
|
|
store i32 %sub7, i32* getelementptr inbounds ([4 x i32], [4 x i32]* @a, i32 0, i64 2), align 4
|
|
|
|
%12 = load i32, i32* getelementptr inbounds ([4 x i32], [4 x i32]* @b, i32 0, i64 3), align 4
|
|
|
|
%13 = load i32, i32* getelementptr inbounds ([4 x i32], [4 x i32]* @c, i32 0, i64 3), align 4
|
2014-06-20 12:32:48 +08:00
|
|
|
%add8 = add nsw i32 %12, %13
|
2015-03-14 02:20:45 +08:00
|
|
|
%14 = load i32, i32* getelementptr inbounds ([4 x i32], [4 x i32]* @d, i32 0, i64 3), align 4
|
|
|
|
%15 = load i32, i32* getelementptr inbounds ([4 x i32], [4 x i32]* @e, i32 0, i64 3), align 4
|
2014-06-20 12:32:48 +08:00
|
|
|
%add9 = add nsw i32 %14, %15
|
|
|
|
%add10 = add nsw i32 %add8, %add9
|
2015-03-14 02:20:45 +08:00
|
|
|
store i32 %add10, i32* getelementptr inbounds ([4 x i32], [4 x i32]* @a, i32 0, i64 3), align 4
|
2014-06-20 12:32:48 +08:00
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
; CHECK-LABEL: @faddfsub
|
|
|
|
; CHECK: %2 = fadd <4 x float> %0, %1
|
|
|
|
; CHECK: %3 = fsub <4 x float> %0, %1
|
|
|
|
; CHECK: %4 = shufflevector <4 x float> %2, <4 x float> %3, <4 x i32> <i32 0, i32 5, i32 2, i32 7>
|
|
|
|
; Function Attrs: nounwind uwtable
|
|
|
|
define void @faddfsub() #0 {
|
|
|
|
entry:
|
2015-03-14 02:20:45 +08:00
|
|
|
%0 = load float, float* getelementptr inbounds ([4 x float], [4 x float]* @fb, i32 0, i64 0), align 4
|
|
|
|
%1 = load float, float* getelementptr inbounds ([4 x float], [4 x float]* @fc, i32 0, i64 0), align 4
|
2014-06-20 12:32:48 +08:00
|
|
|
%add = fadd float %0, %1
|
2015-03-14 02:20:45 +08:00
|
|
|
store float %add, float* getelementptr inbounds ([4 x float], [4 x float]* @fa, i32 0, i64 0), align 4
|
|
|
|
%2 = load float, float* getelementptr inbounds ([4 x float], [4 x float]* @fb, i32 0, i64 1), align 4
|
|
|
|
%3 = load float, float* getelementptr inbounds ([4 x float], [4 x float]* @fc, i32 0, i64 1), align 4
|
2014-06-20 12:32:48 +08:00
|
|
|
%sub = fsub float %2, %3
|
2015-03-14 02:20:45 +08:00
|
|
|
store float %sub, float* getelementptr inbounds ([4 x float], [4 x float]* @fa, i32 0, i64 1), align 4
|
|
|
|
%4 = load float, float* getelementptr inbounds ([4 x float], [4 x float]* @fb, i32 0, i64 2), align 4
|
|
|
|
%5 = load float, float* getelementptr inbounds ([4 x float], [4 x float]* @fc, i32 0, i64 2), align 4
|
2014-06-20 12:32:48 +08:00
|
|
|
%add1 = fadd float %4, %5
|
2015-03-14 02:20:45 +08:00
|
|
|
store float %add1, float* getelementptr inbounds ([4 x float], [4 x float]* @fa, i32 0, i64 2), align 4
|
|
|
|
%6 = load float, float* getelementptr inbounds ([4 x float], [4 x float]* @fb, i32 0, i64 3), align 4
|
|
|
|
%7 = load float, float* getelementptr inbounds ([4 x float], [4 x float]* @fc, i32 0, i64 3), align 4
|
2014-06-20 12:32:48 +08:00
|
|
|
%sub2 = fsub float %6, %7
|
2015-03-14 02:20:45 +08:00
|
|
|
store float %sub2, float* getelementptr inbounds ([4 x float], [4 x float]* @fa, i32 0, i64 3), align 4
|
2014-06-20 12:32:48 +08:00
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
; CHECK-LABEL: @fsubfadd
|
|
|
|
; CHECK: %2 = fsub <4 x float> %0, %1
|
|
|
|
; CHECK: %3 = fadd <4 x float> %0, %1
|
|
|
|
; CHECK: %4 = shufflevector <4 x float> %2, <4 x float> %3, <4 x i32> <i32 0, i32 5, i32 2, i32 7>
|
|
|
|
; Function Attrs: nounwind uwtable
|
|
|
|
define void @fsubfadd() #0 {
|
|
|
|
entry:
|
2015-03-14 02:20:45 +08:00
|
|
|
%0 = load float, float* getelementptr inbounds ([4 x float], [4 x float]* @fb, i32 0, i64 0), align 4
|
|
|
|
%1 = load float, float* getelementptr inbounds ([4 x float], [4 x float]* @fc, i32 0, i64 0), align 4
|
2014-06-20 12:32:48 +08:00
|
|
|
%sub = fsub float %0, %1
|
2015-03-14 02:20:45 +08:00
|
|
|
store float %sub, float* getelementptr inbounds ([4 x float], [4 x float]* @fa, i32 0, i64 0), align 4
|
|
|
|
%2 = load float, float* getelementptr inbounds ([4 x float], [4 x float]* @fb, i32 0, i64 1), align 4
|
|
|
|
%3 = load float, float* getelementptr inbounds ([4 x float], [4 x float]* @fc, i32 0, i64 1), align 4
|
2014-06-20 12:32:48 +08:00
|
|
|
%add = fadd float %2, %3
|
2015-03-14 02:20:45 +08:00
|
|
|
store float %add, float* getelementptr inbounds ([4 x float], [4 x float]* @fa, i32 0, i64 1), align 4
|
|
|
|
%4 = load float, float* getelementptr inbounds ([4 x float], [4 x float]* @fb, i32 0, i64 2), align 4
|
|
|
|
%5 = load float, float* getelementptr inbounds ([4 x float], [4 x float]* @fc, i32 0, i64 2), align 4
|
2014-06-20 12:32:48 +08:00
|
|
|
%sub1 = fsub float %4, %5
|
2015-03-14 02:20:45 +08:00
|
|
|
store float %sub1, float* getelementptr inbounds ([4 x float], [4 x float]* @fa, i32 0, i64 2), align 4
|
|
|
|
%6 = load float, float* getelementptr inbounds ([4 x float], [4 x float]* @fb, i32 0, i64 3), align 4
|
|
|
|
%7 = load float, float* getelementptr inbounds ([4 x float], [4 x float]* @fc, i32 0, i64 3), align 4
|
2014-06-20 12:32:48 +08:00
|
|
|
%add2 = fadd float %6, %7
|
2015-03-14 02:20:45 +08:00
|
|
|
store float %add2, float* getelementptr inbounds ([4 x float], [4 x float]* @fa, i32 0, i64 3), align 4
|
2014-06-20 12:32:48 +08:00
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
; CHECK-LABEL: @No_faddfsub
|
|
|
|
; CHECK-NOT: fadd <4 x float>
|
|
|
|
; CHECK-NOT: fsub <4 x float>
|
|
|
|
; CHECK-NOT: shufflevector
|
|
|
|
; Function Attrs: nounwind uwtable
|
|
|
|
define void @No_faddfsub() #0 {
|
|
|
|
entry:
|
2015-03-14 02:20:45 +08:00
|
|
|
%0 = load float, float* getelementptr inbounds ([4 x float], [4 x float]* @fb, i32 0, i64 0), align 4
|
|
|
|
%1 = load float, float* getelementptr inbounds ([4 x float], [4 x float]* @fc, i32 0, i64 0), align 4
|
2014-06-20 12:32:48 +08:00
|
|
|
%add = fadd float %0, %1
|
2015-03-14 02:20:45 +08:00
|
|
|
store float %add, float* getelementptr inbounds ([4 x float], [4 x float]* @fa, i32 0, i64 0), align 4
|
|
|
|
%2 = load float, float* getelementptr inbounds ([4 x float], [4 x float]* @fb, i32 0, i64 1), align 4
|
|
|
|
%3 = load float, float* getelementptr inbounds ([4 x float], [4 x float]* @fc, i32 0, i64 1), align 4
|
2014-06-20 12:32:48 +08:00
|
|
|
%add1 = fadd float %2, %3
|
2015-03-14 02:20:45 +08:00
|
|
|
store float %add1, float* getelementptr inbounds ([4 x float], [4 x float]* @fa, i32 0, i64 1), align 4
|
|
|
|
%4 = load float, float* getelementptr inbounds ([4 x float], [4 x float]* @fb, i32 0, i64 2), align 4
|
|
|
|
%5 = load float, float* getelementptr inbounds ([4 x float], [4 x float]* @fc, i32 0, i64 2), align 4
|
2014-06-20 12:32:48 +08:00
|
|
|
%add2 = fadd float %4, %5
|
2015-03-14 02:20:45 +08:00
|
|
|
store float %add2, float* getelementptr inbounds ([4 x float], [4 x float]* @fa, i32 0, i64 2), align 4
|
|
|
|
%6 = load float, float* getelementptr inbounds ([4 x float], [4 x float]* @fb, i32 0, i64 3), align 4
|
|
|
|
%7 = load float, float* getelementptr inbounds ([4 x float], [4 x float]* @fc, i32 0, i64 3), align 4
|
2014-06-20 12:32:48 +08:00
|
|
|
%sub = fsub float %6, %7
|
2015-03-14 02:20:45 +08:00
|
|
|
store float %sub, float* getelementptr inbounds ([4 x float], [4 x float]* @fa, i32 0, i64 3), align 4
|
2014-06-20 12:32:48 +08:00
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2015-01-20 14:11:00 +08:00
|
|
|
; Check vectorization of following code for float data type-
|
|
|
|
; fc[0] = fb[0]+fa[0]; //swapped fb and fa
|
|
|
|
; fc[1] = fa[1]-fb[1];
|
|
|
|
; fc[2] = fa[2]+fb[2];
|
|
|
|
; fc[3] = fa[3]-fb[3];
|
|
|
|
|
|
|
|
; CHECK-LABEL: @reorder_alt
|
|
|
|
; CHECK: %3 = fadd <4 x float> %1, %2
|
|
|
|
; CHECK: %4 = fsub <4 x float> %1, %2
|
|
|
|
; CHECK: %5 = shufflevector <4 x float> %3, <4 x float> %4, <4 x i32> <i32 0, i32 5, i32 2, i32 7>
|
|
|
|
define void @reorder_alt() #0 {
|
2015-03-14 02:20:45 +08:00
|
|
|
%1 = load float, float* getelementptr inbounds ([4 x float], [4 x float]* @fb, i32 0, i64 0), align 4
|
|
|
|
%2 = load float, float* getelementptr inbounds ([4 x float], [4 x float]* @fa, i32 0, i64 0), align 4
|
2015-01-20 14:11:00 +08:00
|
|
|
%3 = fadd float %1, %2
|
2015-03-14 02:20:45 +08:00
|
|
|
store float %3, float* getelementptr inbounds ([4 x float], [4 x float]* @fc, i32 0, i64 0), align 4
|
|
|
|
%4 = load float, float* getelementptr inbounds ([4 x float], [4 x float]* @fa, i32 0, i64 1), align 4
|
|
|
|
%5 = load float, float* getelementptr inbounds ([4 x float], [4 x float]* @fb, i32 0, i64 1), align 4
|
2015-01-20 14:11:00 +08:00
|
|
|
%6 = fsub float %4, %5
|
2015-03-14 02:20:45 +08:00
|
|
|
store float %6, float* getelementptr inbounds ([4 x float], [4 x float]* @fc, i32 0, i64 1), align 4
|
|
|
|
%7 = load float, float* getelementptr inbounds ([4 x float], [4 x float]* @fa, i32 0, i64 2), align 4
|
|
|
|
%8 = load float, float* getelementptr inbounds ([4 x float], [4 x float]* @fb, i32 0, i64 2), align 4
|
2015-01-20 14:11:00 +08:00
|
|
|
%9 = fadd float %7, %8
|
2015-03-14 02:20:45 +08:00
|
|
|
store float %9, float* getelementptr inbounds ([4 x float], [4 x float]* @fc, i32 0, i64 2), align 4
|
|
|
|
%10 = load float, float* getelementptr inbounds ([4 x float], [4 x float]* @fa, i32 0, i64 3), align 4
|
|
|
|
%11 = load float, float* getelementptr inbounds ([4 x float], [4 x float]* @fb, i32 0, i64 3), align 4
|
2015-01-20 14:11:00 +08:00
|
|
|
%12 = fsub float %10, %11
|
2015-03-14 02:20:45 +08:00
|
|
|
store float %12, float* getelementptr inbounds ([4 x float], [4 x float]* @fc, i32 0, i64 3), align 4
|
2015-01-20 14:11:00 +08:00
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
; Check vectorization of following code for float data type-
|
|
|
|
; fc[0] = fa[0]+(fb[0]-fd[0]);
|
|
|
|
; fc[1] = fa[1]-(fb[1]+fd[1]);
|
|
|
|
; fc[2] = fa[2]+(fb[2]-fd[2]);
|
|
|
|
; fc[3] = fa[3]-(fd[3]+fb[3]); //swapped fd and fb
|
|
|
|
|
|
|
|
; CHECK-LABEL: @reorder_alt_subTree
|
|
|
|
; CHECK: %4 = fsub <4 x float> %3, %2
|
|
|
|
; CHECK: %5 = fadd <4 x float> %3, %2
|
|
|
|
; CHECK: %6 = shufflevector <4 x float> %4, <4 x float> %5, <4 x i32> <i32 0, i32 5, i32 2, i32 7>
|
|
|
|
; CHECK: %7 = fadd <4 x float> %1, %6
|
|
|
|
; CHECK: %8 = fsub <4 x float> %1, %6
|
|
|
|
; CHECK: %9 = shufflevector <4 x float> %7, <4 x float> %8, <4 x i32> <i32 0, i32 5, i32 2, i32 7>
|
|
|
|
define void @reorder_alt_subTree() #0 {
|
2015-03-14 02:20:45 +08:00
|
|
|
%1 = load float, float* getelementptr inbounds ([4 x float], [4 x float]* @fa, i32 0, i64 0), align 4
|
|
|
|
%2 = load float, float* getelementptr inbounds ([4 x float], [4 x float]* @fb, i32 0, i64 0), align 4
|
|
|
|
%3 = load float, float* getelementptr inbounds ([4 x float], [4 x float]* @fd, i32 0, i64 0), align 4
|
2015-01-20 14:11:00 +08:00
|
|
|
%4 = fsub float %2, %3
|
|
|
|
%5 = fadd float %1, %4
|
2015-03-14 02:20:45 +08:00
|
|
|
store float %5, float* getelementptr inbounds ([4 x float], [4 x float]* @fc, i32 0, i64 0), align 4
|
|
|
|
%6 = load float, float* getelementptr inbounds ([4 x float], [4 x float]* @fa, i32 0, i64 1), align 4
|
|
|
|
%7 = load float, float* getelementptr inbounds ([4 x float], [4 x float]* @fb, i32 0, i64 1), align 4
|
|
|
|
%8 = load float, float* getelementptr inbounds ([4 x float], [4 x float]* @fd, i32 0, i64 1), align 4
|
2015-01-20 14:11:00 +08:00
|
|
|
%9 = fadd float %7, %8
|
|
|
|
%10 = fsub float %6, %9
|
2015-03-14 02:20:45 +08:00
|
|
|
store float %10, float* getelementptr inbounds ([4 x float], [4 x float]* @fc, i32 0, i64 1), align 4
|
|
|
|
%11 = load float, float* getelementptr inbounds ([4 x float], [4 x float]* @fa, i32 0, i64 2), align 4
|
|
|
|
%12 = load float, float* getelementptr inbounds ([4 x float], [4 x float]* @fb, i32 0, i64 2), align 4
|
|
|
|
%13 = load float, float* getelementptr inbounds ([4 x float], [4 x float]* @fd, i32 0, i64 2), align 4
|
2015-01-20 14:11:00 +08:00
|
|
|
%14 = fsub float %12, %13
|
|
|
|
%15 = fadd float %11, %14
|
2015-03-14 02:20:45 +08:00
|
|
|
store float %15, float* getelementptr inbounds ([4 x float], [4 x float]* @fc, i32 0, i64 2), align 4
|
|
|
|
%16 = load float, float* getelementptr inbounds ([4 x float], [4 x float]* @fa, i32 0, i64 3), align 4
|
|
|
|
%17 = load float, float* getelementptr inbounds ([4 x float], [4 x float]* @fd, i32 0, i64 3), align 4
|
|
|
|
%18 = load float, float* getelementptr inbounds ([4 x float], [4 x float]* @fb, i32 0, i64 3), align 4
|
2015-01-20 14:11:00 +08:00
|
|
|
%19 = fadd float %17, %18
|
|
|
|
%20 = fsub float %16, %19
|
2015-03-14 02:20:45 +08:00
|
|
|
store float %20, float* getelementptr inbounds ([4 x float], [4 x float]* @fc, i32 0, i64 3), align 4
|
2015-01-20 14:11:00 +08:00
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
; Check vectorization of following code for double data type-
|
|
|
|
; c[0] = (a[0]+b[0])-d[0];
|
|
|
|
; c[1] = d[1]+(a[1]+b[1]); //swapped d[1] and (a[1]+b[1])
|
|
|
|
|
|
|
|
; CHECK-LABEL: @reorder_alt_rightsubTree
|
|
|
|
; CHECK: fadd <2 x double>
|
|
|
|
; CHECK: fsub <2 x double>
|
|
|
|
; CHECK: shufflevector <2 x double>
|
|
|
|
define void @reorder_alt_rightsubTree(double* nocapture %c, double* noalias nocapture readonly %a, double* noalias nocapture readonly %b, double* noalias nocapture readonly %d) {
|
2015-02-28 05:17:42 +08:00
|
|
|
%1 = load double, double* %a
|
|
|
|
%2 = load double, double* %b
|
2015-01-20 14:11:00 +08:00
|
|
|
%3 = fadd double %1, %2
|
2015-02-28 05:17:42 +08:00
|
|
|
%4 = load double, double* %d
|
2015-01-20 14:11:00 +08:00
|
|
|
%5 = fsub double %3, %4
|
|
|
|
store double %5, double* %c
|
[opaque pointer type] Add textual IR support for explicit type parameter to getelementptr instruction
One of several parallel first steps to remove the target type of pointers,
replacing them with a single opaque pointer type.
This adds an explicit type parameter to the gep instruction so that when the
first parameter becomes an opaque pointer type, the type to gep through is
still available to the instructions.
* This doesn't modify gep operators, only instructions (operators will be
handled separately)
* Textual IR changes only. Bitcode (including upgrade) and changing the
in-memory representation will be in separate changes.
* geps of vectors are transformed as:
getelementptr <4 x float*> %x, ...
->getelementptr float, <4 x float*> %x, ...
Then, once the opaque pointer type is introduced, this will ultimately look
like:
getelementptr float, <4 x ptr> %x
with the unambiguous interpretation that it is a vector of pointers to float.
* address spaces remain on the pointer, not the type:
getelementptr float addrspace(1)* %x
->getelementptr float, float addrspace(1)* %x
Then, eventually:
getelementptr float, ptr addrspace(1) %x
Importantly, the massive amount of test case churn has been automated by
same crappy python code. I had to manually update a few test cases that
wouldn't fit the script's model (r228970,r229196,r229197,r229198). The
python script just massages stdin and writes the result to stdout, I
then wrapped that in a shell script to handle replacing files, then
using the usual find+xargs to migrate all the files.
update.py:
import fileinput
import sys
import re
ibrep = re.compile(r"(^.*?[^%\w]getelementptr inbounds )(((?:<\d* x )?)(.*?)(| addrspace\(\d\)) *\*(|>)(?:$| *(?:%|@|null|undef|blockaddress|getelementptr|addrspacecast|bitcast|inttoptr|\[\[[a-zA-Z]|\{\{).*$))")
normrep = re.compile( r"(^.*?[^%\w]getelementptr )(((?:<\d* x )?)(.*?)(| addrspace\(\d\)) *\*(|>)(?:$| *(?:%|@|null|undef|blockaddress|getelementptr|addrspacecast|bitcast|inttoptr|\[\[[a-zA-Z]|\{\{).*$))")
def conv(match, line):
if not match:
return line
line = match.groups()[0]
if len(match.groups()[5]) == 0:
line += match.groups()[2]
line += match.groups()[3]
line += ", "
line += match.groups()[1]
line += "\n"
return line
for line in sys.stdin:
if line.find("getelementptr ") == line.find("getelementptr inbounds"):
if line.find("getelementptr inbounds") != line.find("getelementptr inbounds ("):
line = conv(re.match(ibrep, line), line)
elif line.find("getelementptr ") != line.find("getelementptr ("):
line = conv(re.match(normrep, line), line)
sys.stdout.write(line)
apply.sh:
for name in "$@"
do
python3 `dirname "$0"`/update.py < "$name" > "$name.tmp" && mv "$name.tmp" "$name"
rm -f "$name.tmp"
done
The actual commands:
From llvm/src:
find test/ -name *.ll | xargs ./apply.sh
From llvm/src/tools/clang:
find test/ -name *.mm -o -name *.m -o -name *.cpp -o -name *.c | xargs -I '{}' ../../apply.sh "{}"
From llvm/src/tools/polly:
find test/ -name *.ll | xargs ./apply.sh
After that, check-all (with llvm, clang, clang-tools-extra, lld,
compiler-rt, and polly all checked out).
The extra 'rm' in the apply.sh script is due to a few files in clang's test
suite using interesting unicode stuff that my python script was throwing
exceptions on. None of those files needed to be migrated, so it seemed
sufficient to ignore those cases.
Reviewers: rafael, dexonsmith, grosser
Differential Revision: http://reviews.llvm.org/D7636
llvm-svn: 230786
2015-02-28 03:29:02 +08:00
|
|
|
%6 = getelementptr inbounds double, double* %d, i64 1
|
2015-02-28 05:17:42 +08:00
|
|
|
%7 = load double, double* %6
|
[opaque pointer type] Add textual IR support for explicit type parameter to getelementptr instruction
One of several parallel first steps to remove the target type of pointers,
replacing them with a single opaque pointer type.
This adds an explicit type parameter to the gep instruction so that when the
first parameter becomes an opaque pointer type, the type to gep through is
still available to the instructions.
* This doesn't modify gep operators, only instructions (operators will be
handled separately)
* Textual IR changes only. Bitcode (including upgrade) and changing the
in-memory representation will be in separate changes.
* geps of vectors are transformed as:
getelementptr <4 x float*> %x, ...
->getelementptr float, <4 x float*> %x, ...
Then, once the opaque pointer type is introduced, this will ultimately look
like:
getelementptr float, <4 x ptr> %x
with the unambiguous interpretation that it is a vector of pointers to float.
* address spaces remain on the pointer, not the type:
getelementptr float addrspace(1)* %x
->getelementptr float, float addrspace(1)* %x
Then, eventually:
getelementptr float, ptr addrspace(1) %x
Importantly, the massive amount of test case churn has been automated by
same crappy python code. I had to manually update a few test cases that
wouldn't fit the script's model (r228970,r229196,r229197,r229198). The
python script just massages stdin and writes the result to stdout, I
then wrapped that in a shell script to handle replacing files, then
using the usual find+xargs to migrate all the files.
update.py:
import fileinput
import sys
import re
ibrep = re.compile(r"(^.*?[^%\w]getelementptr inbounds )(((?:<\d* x )?)(.*?)(| addrspace\(\d\)) *\*(|>)(?:$| *(?:%|@|null|undef|blockaddress|getelementptr|addrspacecast|bitcast|inttoptr|\[\[[a-zA-Z]|\{\{).*$))")
normrep = re.compile( r"(^.*?[^%\w]getelementptr )(((?:<\d* x )?)(.*?)(| addrspace\(\d\)) *\*(|>)(?:$| *(?:%|@|null|undef|blockaddress|getelementptr|addrspacecast|bitcast|inttoptr|\[\[[a-zA-Z]|\{\{).*$))")
def conv(match, line):
if not match:
return line
line = match.groups()[0]
if len(match.groups()[5]) == 0:
line += match.groups()[2]
line += match.groups()[3]
line += ", "
line += match.groups()[1]
line += "\n"
return line
for line in sys.stdin:
if line.find("getelementptr ") == line.find("getelementptr inbounds"):
if line.find("getelementptr inbounds") != line.find("getelementptr inbounds ("):
line = conv(re.match(ibrep, line), line)
elif line.find("getelementptr ") != line.find("getelementptr ("):
line = conv(re.match(normrep, line), line)
sys.stdout.write(line)
apply.sh:
for name in "$@"
do
python3 `dirname "$0"`/update.py < "$name" > "$name.tmp" && mv "$name.tmp" "$name"
rm -f "$name.tmp"
done
The actual commands:
From llvm/src:
find test/ -name *.ll | xargs ./apply.sh
From llvm/src/tools/clang:
find test/ -name *.mm -o -name *.m -o -name *.cpp -o -name *.c | xargs -I '{}' ../../apply.sh "{}"
From llvm/src/tools/polly:
find test/ -name *.ll | xargs ./apply.sh
After that, check-all (with llvm, clang, clang-tools-extra, lld,
compiler-rt, and polly all checked out).
The extra 'rm' in the apply.sh script is due to a few files in clang's test
suite using interesting unicode stuff that my python script was throwing
exceptions on. None of those files needed to be migrated, so it seemed
sufficient to ignore those cases.
Reviewers: rafael, dexonsmith, grosser
Differential Revision: http://reviews.llvm.org/D7636
llvm-svn: 230786
2015-02-28 03:29:02 +08:00
|
|
|
%8 = getelementptr inbounds double, double* %a, i64 1
|
2015-02-28 05:17:42 +08:00
|
|
|
%9 = load double, double* %8
|
[opaque pointer type] Add textual IR support for explicit type parameter to getelementptr instruction
One of several parallel first steps to remove the target type of pointers,
replacing them with a single opaque pointer type.
This adds an explicit type parameter to the gep instruction so that when the
first parameter becomes an opaque pointer type, the type to gep through is
still available to the instructions.
* This doesn't modify gep operators, only instructions (operators will be
handled separately)
* Textual IR changes only. Bitcode (including upgrade) and changing the
in-memory representation will be in separate changes.
* geps of vectors are transformed as:
getelementptr <4 x float*> %x, ...
->getelementptr float, <4 x float*> %x, ...
Then, once the opaque pointer type is introduced, this will ultimately look
like:
getelementptr float, <4 x ptr> %x
with the unambiguous interpretation that it is a vector of pointers to float.
* address spaces remain on the pointer, not the type:
getelementptr float addrspace(1)* %x
->getelementptr float, float addrspace(1)* %x
Then, eventually:
getelementptr float, ptr addrspace(1) %x
Importantly, the massive amount of test case churn has been automated by
same crappy python code. I had to manually update a few test cases that
wouldn't fit the script's model (r228970,r229196,r229197,r229198). The
python script just massages stdin and writes the result to stdout, I
then wrapped that in a shell script to handle replacing files, then
using the usual find+xargs to migrate all the files.
update.py:
import fileinput
import sys
import re
ibrep = re.compile(r"(^.*?[^%\w]getelementptr inbounds )(((?:<\d* x )?)(.*?)(| addrspace\(\d\)) *\*(|>)(?:$| *(?:%|@|null|undef|blockaddress|getelementptr|addrspacecast|bitcast|inttoptr|\[\[[a-zA-Z]|\{\{).*$))")
normrep = re.compile( r"(^.*?[^%\w]getelementptr )(((?:<\d* x )?)(.*?)(| addrspace\(\d\)) *\*(|>)(?:$| *(?:%|@|null|undef|blockaddress|getelementptr|addrspacecast|bitcast|inttoptr|\[\[[a-zA-Z]|\{\{).*$))")
def conv(match, line):
if not match:
return line
line = match.groups()[0]
if len(match.groups()[5]) == 0:
line += match.groups()[2]
line += match.groups()[3]
line += ", "
line += match.groups()[1]
line += "\n"
return line
for line in sys.stdin:
if line.find("getelementptr ") == line.find("getelementptr inbounds"):
if line.find("getelementptr inbounds") != line.find("getelementptr inbounds ("):
line = conv(re.match(ibrep, line), line)
elif line.find("getelementptr ") != line.find("getelementptr ("):
line = conv(re.match(normrep, line), line)
sys.stdout.write(line)
apply.sh:
for name in "$@"
do
python3 `dirname "$0"`/update.py < "$name" > "$name.tmp" && mv "$name.tmp" "$name"
rm -f "$name.tmp"
done
The actual commands:
From llvm/src:
find test/ -name *.ll | xargs ./apply.sh
From llvm/src/tools/clang:
find test/ -name *.mm -o -name *.m -o -name *.cpp -o -name *.c | xargs -I '{}' ../../apply.sh "{}"
From llvm/src/tools/polly:
find test/ -name *.ll | xargs ./apply.sh
After that, check-all (with llvm, clang, clang-tools-extra, lld,
compiler-rt, and polly all checked out).
The extra 'rm' in the apply.sh script is due to a few files in clang's test
suite using interesting unicode stuff that my python script was throwing
exceptions on. None of those files needed to be migrated, so it seemed
sufficient to ignore those cases.
Reviewers: rafael, dexonsmith, grosser
Differential Revision: http://reviews.llvm.org/D7636
llvm-svn: 230786
2015-02-28 03:29:02 +08:00
|
|
|
%10 = getelementptr inbounds double, double* %b, i64 1
|
2015-02-28 05:17:42 +08:00
|
|
|
%11 = load double, double* %10
|
2015-01-20 14:11:00 +08:00
|
|
|
%12 = fadd double %9, %11
|
|
|
|
%13 = fadd double %7, %12
|
[opaque pointer type] Add textual IR support for explicit type parameter to getelementptr instruction
One of several parallel first steps to remove the target type of pointers,
replacing them with a single opaque pointer type.
This adds an explicit type parameter to the gep instruction so that when the
first parameter becomes an opaque pointer type, the type to gep through is
still available to the instructions.
* This doesn't modify gep operators, only instructions (operators will be
handled separately)
* Textual IR changes only. Bitcode (including upgrade) and changing the
in-memory representation will be in separate changes.
* geps of vectors are transformed as:
getelementptr <4 x float*> %x, ...
->getelementptr float, <4 x float*> %x, ...
Then, once the opaque pointer type is introduced, this will ultimately look
like:
getelementptr float, <4 x ptr> %x
with the unambiguous interpretation that it is a vector of pointers to float.
* address spaces remain on the pointer, not the type:
getelementptr float addrspace(1)* %x
->getelementptr float, float addrspace(1)* %x
Then, eventually:
getelementptr float, ptr addrspace(1) %x
Importantly, the massive amount of test case churn has been automated by
same crappy python code. I had to manually update a few test cases that
wouldn't fit the script's model (r228970,r229196,r229197,r229198). The
python script just massages stdin and writes the result to stdout, I
then wrapped that in a shell script to handle replacing files, then
using the usual find+xargs to migrate all the files.
update.py:
import fileinput
import sys
import re
ibrep = re.compile(r"(^.*?[^%\w]getelementptr inbounds )(((?:<\d* x )?)(.*?)(| addrspace\(\d\)) *\*(|>)(?:$| *(?:%|@|null|undef|blockaddress|getelementptr|addrspacecast|bitcast|inttoptr|\[\[[a-zA-Z]|\{\{).*$))")
normrep = re.compile( r"(^.*?[^%\w]getelementptr )(((?:<\d* x )?)(.*?)(| addrspace\(\d\)) *\*(|>)(?:$| *(?:%|@|null|undef|blockaddress|getelementptr|addrspacecast|bitcast|inttoptr|\[\[[a-zA-Z]|\{\{).*$))")
def conv(match, line):
if not match:
return line
line = match.groups()[0]
if len(match.groups()[5]) == 0:
line += match.groups()[2]
line += match.groups()[3]
line += ", "
line += match.groups()[1]
line += "\n"
return line
for line in sys.stdin:
if line.find("getelementptr ") == line.find("getelementptr inbounds"):
if line.find("getelementptr inbounds") != line.find("getelementptr inbounds ("):
line = conv(re.match(ibrep, line), line)
elif line.find("getelementptr ") != line.find("getelementptr ("):
line = conv(re.match(normrep, line), line)
sys.stdout.write(line)
apply.sh:
for name in "$@"
do
python3 `dirname "$0"`/update.py < "$name" > "$name.tmp" && mv "$name.tmp" "$name"
rm -f "$name.tmp"
done
The actual commands:
From llvm/src:
find test/ -name *.ll | xargs ./apply.sh
From llvm/src/tools/clang:
find test/ -name *.mm -o -name *.m -o -name *.cpp -o -name *.c | xargs -I '{}' ../../apply.sh "{}"
From llvm/src/tools/polly:
find test/ -name *.ll | xargs ./apply.sh
After that, check-all (with llvm, clang, clang-tools-extra, lld,
compiler-rt, and polly all checked out).
The extra 'rm' in the apply.sh script is due to a few files in clang's test
suite using interesting unicode stuff that my python script was throwing
exceptions on. None of those files needed to be migrated, so it seemed
sufficient to ignore those cases.
Reviewers: rafael, dexonsmith, grosser
Differential Revision: http://reviews.llvm.org/D7636
llvm-svn: 230786
2015-02-28 03:29:02 +08:00
|
|
|
%14 = getelementptr inbounds double, double* %c, i64 1
|
2015-01-20 14:11:00 +08:00
|
|
|
store double %13, double* %14
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
; Dont vectorization of following code for float data type as sub is not commutative-
|
|
|
|
; fc[0] = fb[0]+fa[0];
|
|
|
|
; fc[1] = fa[1]-fb[1];
|
|
|
|
; fc[2] = fa[2]+fb[2];
|
|
|
|
; fc[3] = fb[3]-fa[3];
|
|
|
|
; In the above code we can swap the 1st and 2nd operation as fadd is commutative
|
|
|
|
; but not 2nd or 4th as fsub is not commutative.
|
|
|
|
|
|
|
|
; CHECK-LABEL: @no_vec_shuff_reorder
|
|
|
|
; CHECK-NOT: fadd <4 x float>
|
|
|
|
; CHECK-NOT: fsub <4 x float>
|
|
|
|
; CHECK-NOT: shufflevector
|
|
|
|
define void @no_vec_shuff_reorder() #0 {
|
2015-03-14 02:20:45 +08:00
|
|
|
%1 = load float, float* getelementptr inbounds ([4 x float], [4 x float]* @fb, i32 0, i64 0), align 4
|
|
|
|
%2 = load float, float* getelementptr inbounds ([4 x float], [4 x float]* @fa, i32 0, i64 0), align 4
|
2015-01-20 14:11:00 +08:00
|
|
|
%3 = fadd float %1, %2
|
2015-03-14 02:20:45 +08:00
|
|
|
store float %3, float* getelementptr inbounds ([4 x float], [4 x float]* @fc, i32 0, i64 0), align 4
|
|
|
|
%4 = load float, float* getelementptr inbounds ([4 x float], [4 x float]* @fa, i32 0, i64 1), align 4
|
|
|
|
%5 = load float, float* getelementptr inbounds ([4 x float], [4 x float]* @fb, i32 0, i64 1), align 4
|
2015-01-20 14:11:00 +08:00
|
|
|
%6 = fsub float %4, %5
|
2015-03-14 02:20:45 +08:00
|
|
|
store float %6, float* getelementptr inbounds ([4 x float], [4 x float]* @fc, i32 0, i64 1), align 4
|
|
|
|
%7 = load float, float* getelementptr inbounds ([4 x float], [4 x float]* @fa, i32 0, i64 2), align 4
|
|
|
|
%8 = load float, float* getelementptr inbounds ([4 x float], [4 x float]* @fb, i32 0, i64 2), align 4
|
2015-01-20 14:11:00 +08:00
|
|
|
%9 = fadd float %7, %8
|
2015-03-14 02:20:45 +08:00
|
|
|
store float %9, float* getelementptr inbounds ([4 x float], [4 x float]* @fc, i32 0, i64 2), align 4
|
|
|
|
%10 = load float, float* getelementptr inbounds ([4 x float], [4 x float]* @fb, i32 0, i64 3), align 4
|
|
|
|
%11 = load float, float* getelementptr inbounds ([4 x float], [4 x float]* @fa, i32 0, i64 3), align 4
|
2015-01-20 14:11:00 +08:00
|
|
|
%12 = fsub float %10, %11
|
2015-03-14 02:20:45 +08:00
|
|
|
store float %12, float* getelementptr inbounds ([4 x float], [4 x float]* @fc, i32 0, i64 3), align 4
|
2015-01-20 14:11:00 +08:00
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-06-20 12:32:48 +08:00
|
|
|
attributes #0 = { nounwind }
|
|
|
|
|