Imported Upstream version 5.18.0.167

Former-commit-id: 289509151e0fee68a1b591a20c9f109c3c789d3a
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2018-10-20 08:25:10 +00:00
parent e19d552987
commit b084638f15
28489 changed files with 184 additions and 3866856 deletions

View File

@ -1,10 +0,0 @@
; RUN: opt < %s -reassociate -S | FileCheck %s
define i32 @test1(i32 %A) {
; CHECK-LABEL: test1
; CHECK: ret i32 0
%X = add i32 %A, 1
%Y = add i32 %A, 1
%r = sub i32 %X, %Y
ret i32 %r
}

View File

@ -1,11 +0,0 @@
; RUN: opt < %s -reassociate -instcombine -S | FileCheck %s
define i32 @test1(i32 %A, i32 %B) {
; CHECK-LABEL: test1
; CHECK: %Z = add i32 %B, %A
; CHECK: ret i32 %Z
%W = add i32 %B, -5
%Y = add i32 %A, 5
%Z = add i32 %W, %Y
ret i32 %Z
}

View File

@ -1,31 +0,0 @@
; RUN: opt < %s -reassociate -constprop -instcombine -dce -S | FileCheck %s
; With sub reassociation, constant folding can eliminate all of the constants.
define i32 @test1(i32 %A, i32 %B) {
; CHECK-LABEL: @test1(
; CHECK-NEXT: [[Z:%.*]] = sub i32 %A, %B
; CHECK-NEXT: ret i32 [[Z]]
;
%W = add i32 5, %B
%X = add i32 -7, %A
%Y = sub i32 %X, %W
%Z = add i32 %Y, 12
ret i32 %Z
}
; With sub reassociation, constant folding can eliminate the two 12 constants.
define i32 @test2(i32 %A, i32 %B, i32 %C, i32 %D) {
; CHECK-LABEL: @test2(
; CHECK-NEXT: [[SUM:%.*]] = add i32 %B, %A
; CHECK-NEXT: [[SUM1:%.*]] = add i32 [[SUM]], %C
; CHECK-NEXT: [[Q:%.*]] = sub i32 %D, [[SUM1]]
; CHECK-NEXT: ret i32 [[Q]]
;
%M = add i32 %A, 12
%N = add i32 %M, %B
%O = add i32 %N, %C
%P = sub i32 %D, %O
%Q = add i32 %P, 12
ret i32 %Q
}

View File

@ -1,10 +0,0 @@
; The reassociate pass is not preserving dominance properties correctly
;
; RUN: opt < %s -reassociate
define i32 @compute_dist(i32 %i, i32 %j) {
%reg119 = sub i32 %j, %i ; <i32> [#uses=1]
ret i32 %reg119
}

View File

@ -1,9 +0,0 @@
; RUN: opt < %s -reassociate -disable-output
define i32 @test(i32 %A.1, i32 %B.1, i32 %C.1, i32 %D.1) {
%tmp.16 = and i32 %A.1, %B.1 ; <i32> [#uses=1]
%tmp.18 = and i32 %tmp.16, %C.1 ; <i32> [#uses=1]
%tmp.20 = and i32 %tmp.18, %D.1 ; <i32> [#uses=1]
ret i32 %tmp.20
}

View File

@ -1,24 +0,0 @@
; RUN: opt < %s -reassociate -instcombine -S | FileCheck %s
define i32 @f1(i32 %a0, i32 %a1, i32 %a2, i32 %a3, i32 %a4) {
; CHECK-LABEL: f1
; CHECK-NEXT: ret i32 0
%tmp.2 = add i32 %a4, %a3
%tmp.4 = add i32 %tmp.2, %a2
%tmp.6 = add i32 %tmp.4, %a1
%tmp.8 = add i32 %tmp.6, %a0
%tmp.11 = add i32 %a3, %a2
%tmp.13 = add i32 %tmp.11, %a1
%tmp.15 = add i32 %tmp.13, %a0
%tmp.18 = add i32 %a2, %a1
%tmp.20 = add i32 %tmp.18, %a0
%tmp.23 = add i32 %a1, %a0
%tmp.26 = sub i32 %tmp.8, %tmp.15
%tmp.28 = add i32 %tmp.26, %tmp.20
%tmp.30 = sub i32 %tmp.28, %tmp.23
%tmp.32 = sub i32 %tmp.30, %a4
%tmp.34 = sub i32 %tmp.32, %a2
%T = mul i32 %tmp.34, %tmp.34
ret i32 %T
}

View File

@ -1,12 +0,0 @@
; RUN: opt < %s -reassociate -S | FileCheck %s
define <4 x float> @test1() {
; CHECK-LABEL: test1
; CHECK-NEXT: %tmp1 = fsub <4 x float> zeroinitializer, zeroinitializer
; CHECK-NEXT: %tmp2 = fmul <4 x float> %tmp1, zeroinitializer
; CHECK-NEXT: ret <4 x float> %tmp2
%tmp1 = fsub <4 x float> zeroinitializer, zeroinitializer
%tmp2 = fmul <4 x float> zeroinitializer, %tmp1
ret <4 x float> %tmp2
}

View File

@ -1,33 +0,0 @@
; RUN: opt < %s -reassociate
; PR9039
target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32-n8:16:32"
target triple = "i386-gnu-linux"
define void @exp_averages_intraday__deviation() {
entry:
%0 = load i32, i32* undef, align 4
%1 = shl i32 %0, 2
%2 = add nsw i32 undef, %1
%3 = add nsw i32 %2, undef
%4 = mul nsw i32 %0, 12
%5 = add nsw i32 %3, %4
%6 = add nsw i32 %5, %4
%7 = add nsw i32 %6, undef
br i1 false, label %"4", label %"12"
"4": ; preds = %entry
br i1 undef, label %"5", label %"8"
"5": ; preds = %"4"
unreachable
"8": ; preds = %"4"
%8 = getelementptr inbounds i8, i8* undef, i32 %6
br i1 undef, label %"13", label %"12"
"12": ; preds = %"8", %entry
ret void
"13": ; preds = %"8"
ret void
}

View File

@ -1,85 +0,0 @@
; RUN: opt < %s -reassociate -S | FileCheck %s
; PR12169
; PR12764
; XFAIL: *
; Transform disabled until PR13021 is fixed.
define i64 @f(i64 %x0) {
; CHECK-LABEL: @f(
; CHECK-NEXT: mul i64 %x0, 208
; CHECK-NEXT: add i64 %{{.*}}, 1617
; CHECK-NEXT: ret i64
%t0 = add i64 %x0, 1
%t1 = add i64 %x0, 2
%t2 = add i64 %x0, 3
%t3 = add i64 %x0, 4
%t4 = add i64 %x0, 5
%t5 = add i64 %x0, 6
%t6 = add i64 %x0, 7
%t7 = add i64 %x0, 8
%t8 = add i64 %x0, 9
%t9 = add i64 %x0, 10
%t10 = add i64 %x0, 11
%t11 = add i64 %x0, 12
%t12 = add i64 %x0, 13
%t13 = add i64 %x0, 14
%t14 = add i64 %x0, 15
%t15 = add i64 %x0, 16
%t16 = add i64 %x0, 17
%t17 = add i64 %x0, 18
%t18 = add i64 %t17, %t0
%t19 = add i64 %t18, %t1
%t20 = add i64 %t19, %t2
%t21 = add i64 %t20, %t3
%t22 = add i64 %t21, %t4
%t23 = add i64 %t22, %t5
%t24 = add i64 %t23, %t6
%t25 = add i64 %t24, %t7
%t26 = add i64 %t25, %t8
%t27 = add i64 %t26, %t9
%t28 = add i64 %t27, %t10
%t29 = add i64 %t28, %t11
%t30 = add i64 %t29, %t12
%t31 = add i64 %t30, %t13
%t32 = add i64 %t31, %t14
%t33 = add i64 %t32, %t15
%t34 = add i64 %t33, %t16
%t35 = add i64 %t34, %x0
%t36 = add i64 %t0, %t1
%t37 = add i64 %t36, %t2
%t38 = add i64 %t37, %t3
%t39 = add i64 %t38, %t4
%t40 = add i64 %t39, %t5
%t41 = add i64 %t40, %t6
%t42 = add i64 %t41, %t7
%t43 = add i64 %t42, %t8
%t44 = add i64 %t43, %t9
%t45 = add i64 %t44, %t10
%t46 = add i64 %t45, %t11
%t47 = add i64 %t46, %t12
%t48 = add i64 %t47, %t13
%t49 = add i64 %t48, %t14
%t50 = add i64 %t49, %t15
%t51 = add i64 %t50, %t16
%t52 = add i64 %t51, %t17
%t53 = add i64 %t52, %t18
%t54 = add i64 %t53, %t19
%t55 = add i64 %t54, %t20
%t56 = add i64 %t55, %t21
%t57 = add i64 %t56, %t22
%t58 = add i64 %t57, %t23
%t59 = add i64 %t58, %t24
%t60 = add i64 %t59, %t25
%t61 = add i64 %t60, %t26
%t62 = add i64 %t61, %t27
%t63 = add i64 %t62, %t28
%t64 = add i64 %t63, %t29
%t65 = add i64 %t64, %t30
%t66 = add i64 %t65, %t31
%t67 = add i64 %t66, %t32
%t68 = add i64 %t67, %t33
%t69 = add i64 %t68, %t34
%t70 = add i64 %t69, %t35
%t71 = add i64 %t70, %x0
ret i64 %t71
}

View File

@ -1,21 +0,0 @@
; RUN: opt < %s -reassociate -disable-output
; PR13041
define void @foo() {
entry:
br label %while.cond
while.cond: ; preds = %while.body, %entry
%b.0 = phi i32 [ undef, %entry ], [ %sub2, %while.body ]
%c.0 = phi i32 [ undef, %entry ], [ %sub3, %while.body ]
br i1 undef, label %while.end, label %while.body
while.body: ; preds = %while.cond
%sub = sub nsw i32 0, %b.0
%sub2 = sub nsw i32 %sub, %c.0
%sub3 = sub nsw i32 0, %c.0
br label %while.cond
while.end: ; preds = %while.cond
ret void
}

View File

@ -1,11 +0,0 @@
; RUN: opt -S -reassociate < %s | FileCheck %s
; Check that if constants combine to an absorbing value then the expression is
; evaluated as the absorbing value.
define i8 @foo(i8 %x) {
%tmp1 = or i8 %x, 127
%tmp2 = or i8 %tmp1, 128
ret i8 %tmp2
; CHECK-LABEL: @foo(
; CHECK: ret i8 -1
}

View File

@ -1,30 +0,0 @@
; RUN: opt < %s -reassociate -S | FileCheck %s
; This test is to make sure while processing a block, uses of instructions
; from a different basic block don't get added to be re-optimized
define void @main() {
; CHECK-LABEL: @main(
; CHECK-NEXT: entry:
; CHECK-NEXT: br i1 undef, label %bb1, label %bb2
; CHECK: bb1:
; CHECK-NEXT: ret void
; CHECK: bb2:
; CHECK-NEXT: ret void
;
entry:
%0 = fadd fast float undef, undef
br i1 undef, label %bb1, label %bb2
bb1:
%1 = fmul fast float undef, -2.000000e+00
%2 = fmul fast float %1, 2.000000e+00
%3 = fadd fast float %2, 2.000000e+00
%4 = fadd fast float %3, %0
%mul351 = fmul fast float %4, 5.000000e-01
ret void
bb2:
ret void
}

View File

@ -1,259 +0,0 @@
; RUN: opt < %s -reassociate -gvn -instcombine -S | FileCheck %s
; RUN: opt < %s -passes='reassociate,gvn,instcombine' -S | FileCheck %s
define i32 @test1(i32 %arg) {
%tmp1 = sub i32 -12, %arg
%tmp2 = add i32 %tmp1, 12
ret i32 %tmp2
; CHECK-LABEL: @test1
; CHECK-NEXT: sub i32 0, %arg
; CHECK-NEXT: ret i32
}
define i32 @test2(i32 %reg109, i32 %reg1111) {
%reg115 = add i32 %reg109, -30
%reg116 = add i32 %reg115, %reg1111
%reg117 = add i32 %reg116, 30
ret i32 %reg117
; CHECK-LABEL: @test2
; CHECK-NEXT: %reg117 = add i32 %reg1111, %reg109
; CHECK-NEXT: ret i32 %reg117
}
@e = external global i32
@a = external global i32
@b = external global i32
@c = external global i32
@f = external global i32
define void @test3() {
%A = load i32, i32* @a
%B = load i32, i32* @b
%C = load i32, i32* @c
%t1 = add i32 %A, %B
%t2 = add i32 %t1, %C
%t3 = add i32 %C, %A
%t4 = add i32 %t3, %B
; e = (a+b)+c;
store i32 %t2, i32* @e
; f = (a+c)+b
store i32 %t4, i32* @f
ret void
; CHECK-LABEL: @test3
; CHECK: add i32
; CHECK: add i32
; CHECK-NOT: add i32
; CHECK: ret void
}
define void @test4() {
%A = load i32, i32* @a
%B = load i32, i32* @b
%C = load i32, i32* @c
%t1 = add i32 %A, %B
%t2 = add i32 %t1, %C
%t3 = add i32 %C, %A
%t4 = add i32 %t3, %B
; e = c+(a+b)
store i32 %t2, i32* @e
; f = (c+a)+b
store i32 %t4, i32* @f
ret void
; CHECK-LABEL: @test4
; CHECK: add i32
; CHECK: add i32
; CHECK-NOT: add i32
; CHECK: ret void
}
define void @test5() {
%A = load i32, i32* @a
%B = load i32, i32* @b
%C = load i32, i32* @c
%t1 = add i32 %B, %A
%t2 = add i32 %t1, %C
%t3 = add i32 %C, %A
%t4 = add i32 %t3, %B
; e = c+(b+a)
store i32 %t2, i32* @e
; f = (c+a)+b
store i32 %t4, i32* @f
ret void
; CHECK-LABEL: @test5
; CHECK: add i32
; CHECK: add i32
; CHECK-NOT: add i32
; CHECK: ret void
}
define i32 @test6() {
%tmp.0 = load i32, i32* @a
%tmp.1 = load i32, i32* @b
; (a+b)
%tmp.2 = add i32 %tmp.0, %tmp.1
%tmp.4 = load i32, i32* @c
; (a+b)+c
%tmp.5 = add i32 %tmp.2, %tmp.4
; (a+c)
%tmp.8 = add i32 %tmp.0, %tmp.4
; (a+c)+b
%tmp.11 = add i32 %tmp.8, %tmp.1
; X ^ X = 0
%RV = xor i32 %tmp.5, %tmp.11
ret i32 %RV
; CHECK-LABEL: @test6
; CHECK: ret i32 0
}
; This should be one add and two multiplies.
define i32 @test7(i32 %A, i32 %B, i32 %C) {
; A*A*B + A*C*A
%aa = mul i32 %A, %A
%aab = mul i32 %aa, %B
%ac = mul i32 %A, %C
%aac = mul i32 %ac, %A
%r = add i32 %aab, %aac
ret i32 %r
; CHECK-LABEL: @test7
; CHECK-NEXT: add i32 %C, %B
; CHECK-NEXT: mul i32
; CHECK-NEXT: mul i32
; CHECK-NEXT: ret i32
}
define i32 @test8(i32 %X, i32 %Y, i32 %Z) {
%A = sub i32 0, %X
%B = mul i32 %A, %Y
; (-X)*Y + Z -> Z-X*Y
%C = add i32 %B, %Z
ret i32 %C
; CHECK-LABEL: @test8
; CHECK-NEXT: %A = mul i32 %Y, %X
; CHECK-NEXT: %C = sub i32 %Z, %A
; CHECK-NEXT: ret i32 %C
}
; PR5458
define i32 @test9(i32 %X) {
%Y = mul i32 %X, 47
%Z = add i32 %Y, %Y
ret i32 %Z
; CHECK-LABEL: @test9
; CHECK-NEXT: mul i32 %X, 94
; CHECK-NEXT: ret i32
}
define i32 @test10(i32 %X) {
%Y = add i32 %X ,%X
%Z = add i32 %Y, %X
ret i32 %Z
; CHECK-LABEL: @test10
; CHECK-NEXT: mul i32 %X, 3
; CHECK-NEXT: ret i32
}
define i32 @test11(i32 %W) {
%X = mul i32 %W, 127
%Y = add i32 %X ,%X
%Z = add i32 %Y, %X
ret i32 %Z
; CHECK-LABEL: @test11
; CHECK-NEXT: mul i32 %W, 381
; CHECK-NEXT: ret i32
}
declare void @mumble(i32)
define i32 @test12(i32 %X) {
%X.neg = sub nsw nuw i32 0, %X
call void @mumble(i32 %X.neg)
%A = sub i32 1, %X
%B = sub i32 2, %X
%C = sub i32 3, %X
%Y = add i32 %A ,%B
%Z = add i32 %Y, %C
ret i32 %Z
; CHECK-LABEL: @test12
; CHECK: %[[mul:.*]] = mul i32 %X, -3
; CHECK-NEXT: add i32 %[[mul]], 6
; CHECK-NEXT: ret i32
}
define i32 @test13(i32 %X1, i32 %X2, i32 %X3) {
%A = sub i32 0, %X1
%B = mul i32 %A, %X2 ; -X1*X2
%C = mul i32 %X1, %X3 ; X1*X3
%D = add i32 %B, %C ; -X1*X2 + X1*X3 -> X1*(X3-X2)
ret i32 %D
; CHECK-LABEL: @test13
; CHECK-NEXT: sub i32 %X3, %X2
; CHECK-NEXT: mul i32 {{.*}}, %X1
; CHECK-NEXT: ret i32
}
; PR5359
define i32 @test14(i32 %X1, i32 %X2) {
%B = mul i32 %X1, 47 ; X1*47
%C = mul i32 %X2, -47 ; X2*-47
%D = add i32 %B, %C ; X1*47 + X2*-47 -> 47*(X1-X2)
ret i32 %D
; CHECK-LABEL: @test14
; CHECK-NEXT: %[[SUB:.*]] = sub i32 %X1, %X2
; CHECK-NEXT: mul i32 %[[SUB]], 47
; CHECK-NEXT: ret i32
}
; Do not reassociate expressions of type i1
define i32 @test15(i32 %X1, i32 %X2, i32 %X3) {
%A = icmp ne i32 %X1, 0
%B = icmp slt i32 %X2, %X3
%C = and i1 %A, %B
%D = select i1 %C, i32 %X1, i32 0
ret i32 %D
; CHECK-LABEL: @test15
; CHECK: and i1 %A, %B
}
; PR30256 - previously this asserted.
; CHECK-LABEL: @test16
; CHECK: %[[FACTOR:.*]] = mul i64 %a, -4
; CHECK-NEXT: %[[RES:.*]] = add i64 %[[FACTOR]], %b
; CHECK-NEXT: ret i64 %[[RES]]
define i64 @test16(i1 %cmp, i64 %a, i64 %b) {
entry:
%shl = shl i64 %a, 1
%shl.neg = sub i64 0, %shl
br i1 %cmp, label %if.then, label %if.end
if.then: ; preds = %entry
%add1 = add i64 %shl.neg, %shl.neg
%add2 = add i64 %add1, %b
ret i64 %add2
if.end: ; preds = %entry
ret i64 0
}
; CHECK-LABEL: @test17
; CHECK: %[[A:.*]] = mul i32 %X4, %X3
; CHECK-NEXT: %[[C:.*]] = mul i32 %[[A]], %X1
; CHECK-NEXT: %[[D:.*]] = mul i32 %[[A]], %X2
; CHECK-NEXT: %[[E:.*]] = xor i32 %[[C]], %[[D]]
; CHECK-NEXT: ret i32 %[[E]]
define i32 @test17(i32 %X1, i32 %X2, i32 %X3, i32 %X4) {
%A = mul i32 %X3, %X1
%B = mul i32 %X3, %X2
%C = mul i32 %A, %X4
%D = mul i32 %B, %X4
%E = xor i32 %C, %D
ret i32 %E
}

View File

@ -1,185 +0,0 @@
; RUN: opt -reassociate -gvn -S < %s | FileCheck %s
; (x + 0.1234 * y) * (x + -0.1234 * y) -> (x + 0.1234 * y) * (x - 0.1234 * y)
define double @test1(double %x, double %y) {
; CHECK-LABEL: @test1(
; CHECK-NEXT: [[MUL:%.*]] = fmul double %y, 1.234000e-01
; CHECK-NEXT: [[ADD:%.*]] = fadd double %x, [[MUL]]
; CHECK-NEXT: [[ADD21:%.*]] = fsub double %x, [[MUL]]
; CHECK-NEXT: [[MUL3:%.*]] = fmul double [[ADD]], [[ADD21]]
; CHECK-NEXT: ret double [[MUL3]]
;
%mul = fmul double 1.234000e-01, %y
%add = fadd double %mul, %x
%mul1 = fmul double -1.234000e-01, %y
%add2 = fadd double %mul1, %x
%mul3 = fmul double %add, %add2
ret double %mul3
}
; (x + -0.1234 * y) * (x + -0.1234 * y) -> (x - 0.1234 * y) * (x - 0.1234 * y)
define double @test2(double %x, double %y) {
; CHECK-LABEL: @test2(
; CHECK-NEXT: [[MUL:%.*]] = fmul double %y, 1.234000e-01
; CHECK-NEXT: [[ADD1:%.*]] = fsub double %x, [[MUL]]
; CHECK-NEXT: [[MUL3:%.*]] = fmul double [[ADD1]], [[ADD1]]
; CHECK-NEXT: ret double [[MUL3]]
;
%mul = fmul double %y, -1.234000e-01
%add = fadd double %mul, %x
%mul1 = fmul double %y, -1.234000e-01
%add2 = fadd double %mul1, %x
%mul3 = fmul double %add, %add2
ret double %mul3
}
; (x + 0.1234 * y) * (x - -0.1234 * y) -> (x + 0.1234 * y) * (x + 0.1234 * y)
define double @test3(double %x, double %y) {
; CHECK-LABEL: @test3(
; CHECK-NEXT: [[MUL:%.*]] = fmul double %y, 1.234000e-01
; CHECK-NEXT: [[ADD:%.*]] = fadd double %x, [[MUL]]
; CHECK-NEXT: [[MUL3:%.*]] = fmul double [[ADD]], [[ADD]]
; CHECK-NEXT: ret double [[MUL3]]
;
%mul = fmul double %y, 1.234000e-01
%add = fadd double %mul, %x
%mul1 = fmul double %y, -1.234000e-01
%add2 = fsub double %x, %mul1
%mul3 = fmul double %add, %add2
ret double %mul3
}
; Canonicalize (x - -0.1234 * y)
define double @test5(double %x, double %y) {
; CHECK-LABEL: @test5(
; CHECK-NEXT: [[MUL:%.*]] = fmul double %y, 1.234000e-01
; CHECK-NEXT: [[SUB1:%.*]] = fadd double %x, [[MUL]]
; CHECK-NEXT: ret double [[SUB1]]
;
%mul = fmul double -1.234000e-01, %y
%sub = fsub double %x, %mul
ret double %sub
}
; Don't modify (-0.1234 * y - x)
define double @test6(double %x, double %y) {
; CHECK-LABEL: @test6(
; CHECK-NEXT: [[MUL:%.*]] = fmul double %y, -1.234000e-01
; CHECK-NEXT: [[SUB:%.*]] = fsub double [[MUL]], %x
; CHECK-NEXT: ret double [[SUB]]
;
%mul = fmul double -1.234000e-01, %y
%sub = fsub double %mul, %x
ret double %sub
}
; Canonicalize (-0.1234 * y + x) -> (x - 0.1234 * y)
define double @test7(double %x, double %y) {
; CHECK-LABEL: @test7(
; CHECK-NEXT: [[MUL:%.*]] = fmul double %y, 1.234000e-01
; CHECK-NEXT: [[ADD1:%.*]] = fsub double %x, [[MUL]]
; CHECK-NEXT: ret double [[ADD1]]
;
%mul = fmul double -1.234000e-01, %y
%add = fadd double %mul, %x
ret double %add
}
; Canonicalize (y * -0.1234 + x) -> (x - 0.1234 * y)
define double @test8(double %x, double %y) {
; CHECK-LABEL: @test8(
; CHECK-NEXT: [[MUL:%.*]] = fmul double %y, 1.234000e-01
; CHECK-NEXT: [[ADD1:%.*]] = fsub double %x, [[MUL]]
; CHECK-NEXT: ret double [[ADD1]]
;
%mul = fmul double %y, -1.234000e-01
%add = fadd double %mul, %x
ret double %add
}
; Canonicalize (x - -0.1234 / y)
define double @test9(double %x, double %y) {
; CHECK-LABEL: @test9(
; CHECK-NEXT: [[DIV:%.*]] = fdiv double 1.234000e-01, %y
; CHECK-NEXT: [[SUB1:%.*]] = fadd double %x, [[DIV]]
; CHECK-NEXT: ret double [[SUB1]]
;
%div = fdiv double -1.234000e-01, %y
%sub = fsub double %x, %div
ret double %sub
}
; Don't modify (-0.1234 / y - x)
define double @test10(double %x, double %y) {
; CHECK-LABEL: @test10(
; CHECK-NEXT: [[DIV:%.*]] = fdiv double -1.234000e-01, %y
; CHECK-NEXT: [[SUB:%.*]] = fsub double [[DIV]], %x
; CHECK-NEXT: ret double [[SUB]]
;
%div = fdiv double -1.234000e-01, %y
%sub = fsub double %div, %x
ret double %sub
}
; Canonicalize (-0.1234 / y + x) -> (x - 0.1234 / y)
define double @test11(double %x, double %y) {
; CHECK-LABEL: @test11(
; CHECK-NEXT: [[DIV:%.*]] = fdiv double 1.234000e-01, %y
; CHECK-NEXT: [[ADD1:%.*]] = fsub double %x, [[DIV]]
; CHECK-NEXT: ret double [[ADD1]]
;
%div = fdiv double -1.234000e-01, %y
%add = fadd double %div, %x
ret double %add
}
; Canonicalize (y / -0.1234 + x) -> (x - y / 0.1234)
define double @test12(double %x, double %y) {
; CHECK-LABEL: @test12(
; CHECK-NEXT: [[DIV:%.*]] = fdiv double %y, 1.234000e-01
; CHECK-NEXT: [[ADD1:%.*]] = fsub double %x, [[DIV]]
; CHECK-NEXT: ret double [[ADD1]]
;
%div = fdiv double %y, -1.234000e-01
%add = fadd double %div, %x
ret double %add
}
; Don't create an NSW violation
define i4 @test13(i4 %x) {
; CHECK-LABEL: @test13(
; CHECK-NEXT: [[MUL:%.*]] = mul nsw i4 %x, -2
; CHECK-NEXT: [[ADD:%.*]] = add i4 [[MUL]], 3
; CHECK-NEXT: ret i4 [[ADD]]
;
%mul = mul nsw i4 %x, -2
%add = add i4 %mul, 3
ret i4 %add
}
; This tests used to cause an infinite loop where we would loop between
; canonicalizing the negated constant (i.e., (X + Y*-5.0) -> (X - Y*5.0)) and
; breaking up a subtract (i.e., (X - Y*5.0) -> X + (0 - Y*5.0)). To break the
; cycle, we don't canonicalize the negative constant if we're going to later
; break up the subtract.
;
; Check to make sure we don't canonicalize
; (%pow2*-5.0 + %sub) -> (%sub - %pow2*5.0)
; as we would later break up this subtract causing a cycle.
define double @pr34078(double %A) {
; CHECK-LABEL: @pr34078(
; CHECK-NEXT: [[SUB:%.*]] = fsub fast double 1.000000e+00, %A
; CHECK-NEXT: [[POW2:%.*]] = fmul double %A, %A
; CHECK-NEXT: [[MUL5_NEG:%.*]] = fmul fast double [[POW2]], -5.000000e-01
; CHECK-NEXT: [[SUB1:%.*]] = fadd fast double [[MUL5_NEG]], [[SUB]]
; CHECK-NEXT: [[FACTOR:%.*]] = fmul fast double [[SUB1]], 2.000000e+00
; CHECK-NEXT: ret double [[FACTOR]]
;
%sub = fsub fast double 1.000000e+00, %A
%pow2 = fmul double %A, %A
%mul5 = fmul fast double %pow2, 5.000000e-01
%sub1 = fsub fast double %sub, %mul5
%add = fadd fast double %sub1, %sub1
ret double %add
}

View File

@ -1,19 +0,0 @@
; RUN: opt -reassociate -S < %s | FileCheck %s
declare void @use(i32)
define void @test1(i32 %x, i32 %y) {
; CHECK-LABEL: test1
; CHECK: mul i32 %y, %x
; CHECK: mul i32 %y, %x
; CHECK: sub i32 %1, %2
; CHECK: call void @use(i32 %{{.*}})
; CHECK: call void @use(i32 %{{.*}})
%1 = mul i32 %x, %y
%2 = mul i32 %y, %x
%3 = sub i32 %1, %2
call void @use(i32 %1)
call void @use(i32 %3)
ret void
}

View File

@ -1,174 +0,0 @@
; RUN: opt -reassociate -disable-output < %s
; rdar://7507855
define fastcc i32 @test1() nounwind {
entry:
%cond = select i1 undef, i32 1, i32 -1 ; <i32> [#uses=2]
br label %for.cond
for.cond: ; preds = %for.body, %entry
%sub889 = sub i32 undef, undef ; <i32> [#uses=1]
%sub891 = sub i32 %sub889, %cond ; <i32> [#uses=0]
%add896 = sub i32 0, %cond ; <i32> [#uses=0]
ret i32 undef
}
; PR5981
define i32 @test2() nounwind ssp {
entry:
%0 = load i32, i32* undef, align 4
%1 = mul nsw i32 undef, %0
%2 = mul nsw i32 undef, %0
%3 = add nsw i32 undef, %1
%4 = add nsw i32 %3, %2
%5 = add nsw i32 %4, 4
%6 = shl i32 %0, 3
%7 = add nsw i32 %5, %6
br label %bb4.i9
bb4.i9:
%8 = add nsw i32 undef, %1
ret i32 0
}
define i32 @test3(i32 %Arg, i32 %x1, i32 %x2, i32 %x3) {
%A = mul i32 %x1, %Arg
%B = mul i32 %Arg, %x2 ;; Part of add operation being factored, also used by C
%C = mul i32 %x3, %B
%D = add i32 %A, %B
%E = add i32 %D, %C
ret i32 %E
}
; rdar://9096268
define void @x66303361ae3f602889d1b7d0f86e5455(i8* %arg) nounwind {
_:
br label %_33
_33: ; preds = %_33, %_
%tmp348 = load i8, i8* %arg, align 1
%tmp349 = lshr i8 %tmp348, 7
%tmp350 = or i8 %tmp349, 42
%tmp351 = add i8 %tmp350, -42
%tmp352 = zext i8 %tmp351 to i32
%tmp358 = add i32 %tmp352, -501049439
%tmp359 = mul i32 %tmp358, %tmp358
%tmp360 = mul i32 %tmp352, %tmp352
%tmp361 = sub i32 %tmp359, %tmp360
%tmp362 = mul i32 %tmp361, -920056735
%tmp363 = add i32 %tmp362, 501049439
%tmp364 = add i32 %tmp362, -2000262972
%tmp365 = sub i32 %tmp363, %tmp364
%tmp366 = sub i32 -501049439, %tmp362
%tmp367 = add i32 %tmp365, %tmp366
br label %_33
}
define void @test(i32 %a, i32 %b, i32 %c, i32 %d) {
%tmp.2 = xor i32 %a, %b ; <i32> [#uses=1]
%tmp.5 = xor i32 %c, %d ; <i32> [#uses=1]
%tmp.6 = xor i32 %tmp.2, %tmp.5 ; <i32> [#uses=1]
%tmp.9 = xor i32 %c, %a ; <i32> [#uses=1]
%tmp.12 = xor i32 %b, %d ; <i32> [#uses=1]
%tmp.13 = xor i32 %tmp.9, %tmp.12 ; <i32> [#uses=1]
%tmp.16 = xor i32 %tmp.6, %tmp.13 ; <i32> [#uses=0]
ret void
}
define i128 @foo() {
%mul = mul i128 0, 0
ret i128 %mul
}
define void @infinite_loop() {
entry:
br label %loop
loop:
%x = phi i32 [undef, %entry], [%x, %loop]
%dead = add i32 %x, 0
br label %loop
unreachable1:
%y1 = add i32 %y1, 0
%z1 = add i32 %y1, 0
ret void
unreachable2:
%y2 = add i32 %y2, 0
%z2 = add i32 %y2, %y2
ret void
unreachable3:
%y3 = add i32 %y3, %y3
%z3 = add i32 %y3, 0
ret void
unreachable4:
%y4 = add i32 %y4, %y4
%z4 = add i32 %y4, %y4
ret void
}
; PR13185
define void @pr13185(i16 %p) {
entry:
br label %for.cond
for.cond: ; preds = %for.cond, %entry
%x.0 = phi i32 [ undef, %entry ], [ %conv, %for.cond ]
%conv = zext i16 %p to i32
br label %for.cond
}
; PR12963
@a = external global i8
define i8 @f0(i8 %x) {
%t0 = load i8, i8* @a
%t1 = mul i8 %x, %x
%t2 = mul i8 %t1, %t1
%t3 = mul i8 %t2, %t2
%t4 = mul i8 %t3, %x
%t5 = mul i8 %t4, %t4
%t6 = mul i8 %t5, %x
%t7 = mul i8 %t6, %t0
ret i8 %t7
}
define i32 @sozefx_(i32 %x, i32 %y) {
%t0 = sub i32 %x, %x
%t1 = mul i32 %t0, %t0
%t2 = mul i32 %x, %t0
%t3 = mul i32 %t1, %t1
%t4 = add i32 %t2, %t3
%t5 = mul i32 %x, %y
%t6 = add i32 %t4, %t5
ret i32 %t6
}
define i32 @bar(i32 %arg, i32 %arg1, i32 %arg2) {
%tmp1 = mul i32 %arg1, 2
%tmp2 = mul i32 %tmp1, 3
%tmp3 = mul i32 %arg2, 2
%tmp4 = add i32 %tmp1, 1 ; dead code
%ret = add i32 %tmp2, %tmp3
ret i32 %ret
}
; PR14060
define i8 @hang(i8 %p, i8 %p0, i8 %p1, i8 %p2, i8 %p3, i8 %p4, i8 %p5, i8 %p6, i8 %p7, i8 %p8, i8 %p9) {
%tmp = zext i1 false to i8
%tmp16 = or i8 %tmp, 1
%tmp22 = or i8 %p7, %p0
%tmp23 = or i8 %tmp16, %tmp22
%tmp28 = or i8 %p9, %p1
%tmp31 = or i8 %tmp23, %p2
%tmp32 = or i8 %tmp31, %tmp28
%tmp38 = or i8 %p8, %p3
%tmp39 = or i8 %tmp16, %tmp38
%tmp43 = or i8 %tmp39, %p4
%tmp44 = or i8 %tmp43, 1
%tmp47 = or i8 %tmp32, %p5
%tmp50 = or i8 %tmp47, %p6
%tmp51 = or i8 %tmp44, %tmp50
ret i8 %tmp51
}

View File

@ -1,25 +0,0 @@
; RUN: opt -reassociate %s -S -o - | FileCheck %s
; Reassociate pass used to crash on these example
define float @undef1() {
wrapper_entry:
; CHECK-LABEL: @undef1
; CHECK: ret float fadd (float undef, float fadd (float undef, float fadd (float fsub (float -0.000000e+00, float undef), float fsub (float -0.000000e+00, float undef))))
%0 = fadd fast float undef, undef
%1 = fsub fast float undef, %0
%2 = fadd fast float undef, %1
ret float %2
}
define void @undef2() {
wrapper_entry:
; CHECK-LABEL: @undef2
; CHECK: unreachable
%0 = fadd fast float undef, undef
%1 = fadd fast float %0, 1.000000e+00
%2 = fsub fast float %0, %1
%3 = fmul fast float %2, 2.000000e+00
unreachable
}

View File

@ -1,37 +0,0 @@
; RUN: opt < %s -reassociate -disable-output
; It has been detected that dead loops like the one in this test case can be
; created by -jump-threading (it was detected by a csmith generated program).
;
; According to -verify this is valid input (even if it could be discussed if
; the dead loop really satisfies SSA form).
;
; The problem found was that the -reassociate pass ends up in an infinite loop
; when analysing the 'deadloop1' basic block. See "Bugzilla - Bug 30818".
define void @deadloop1() {
br label %endlabel
deadloop1:
%1 = xor i32 %2, 7
%2 = xor i32 %1, 8
br label %deadloop1
endlabel:
ret void
}
; Another example showing that dead code could result in infinite loops in
; reassociate pass. See "Bugzilla - Bug 30818".
define void @deadloop2() {
br label %endlabel
deadloop2:
%1 = and i32 %2, 7
%2 = and i32 %3, 8
%3 = and i32 %1, 6
br label %deadloop2
endlabel:
ret void
}

View File

@ -1,29 +0,0 @@
; RUN: opt < %s -inline -reassociate -S | FileCheck %s
; This test case exposed a bug in reassociate where EraseInst's
; removal of a dead call wasn't recognized as changing the IR.
; So when runOnFunction propagated the "made changes" upwards
; to the CallGraphSCCPass it signalled that no changes had been
; made, so CallGraphSCCPass assumed that the old CallGraph,
; as known by that pass manager, still was up-to-date.
;
; This was detected as an assert when trying to remove the
; no longer used function 'bar' (due to incorrect reference
; count in the CallGraph).
define void @foo() {
; CHECK-LABEL: @foo(
; CHECK-NEXT: entry:
; CHECK-NEXT: ret void
entry:
call void @bar()
ret void
}
define internal void @bar() noinline nounwind readnone {
; CHECK-NOT: bar
entry:
ret void
}

View File

@ -1,44 +0,0 @@
; RUN: opt -S -reassociate < %s | FileCheck %s
define void @main(float, float) {
; CHECK-LABEL: @main(
; CHECK-NEXT: wrapper_entry:
; CHECK-NEXT: [[TMP2:%.*]] = fsub float undef, %0
; CHECK-NEXT: [[TMP3:%.*]] = fsub float undef, %1
; CHECK-NEXT: [[TMP4:%.*]] = call float @llvm.rsqrt.f32(float undef)
; CHECK-NEXT: [[REASS_ADD2:%.*]] = fadd fast float [[TMP3]], [[TMP2]]
; CHECK-NEXT: [[REASS_MUL3:%.*]] = fmul fast float [[REASS_ADD2]], undef
; CHECK-NEXT: [[REASS_ADD1:%.*]] = fadd fast float [[REASS_MUL3]], fmul (float undef, float undef)
; CHECK-NEXT: [[REASS_MUL:%.*]] = fmul fast float [[REASS_ADD1]], [[TMP4]]
; CHECK-NEXT: [[TMP5:%.*]] = call float @foo2(float [[REASS_MUL]], float 0.000000e+00)
; CHECK-NEXT: [[MUL36:%.*]] = fmul fast float [[TMP5]], 1.500000e+00
; CHECK-NEXT: call void @foo1(i32 4, float [[MUL36]])
; CHECK-NEXT: ret void
;
wrapper_entry:
%2 = fsub float undef, %0
%3 = fsub float undef, %1
%4 = call float @llvm.rsqrt.f32(float undef)
%5 = fmul fast float undef, %4
%6 = fmul fast float %2, %4
%7 = fmul fast float %3, %4
%8 = fmul fast float %5, undef
%9 = fmul fast float %6, undef
%10 = fmul fast float %7, undef
%11 = fadd fast float %8, %9
%12 = fadd fast float %11, %10
%13 = call float @foo2(float %12, float 0.000000e+00)
%mul36 = fmul fast float %13, 1.500000e+00
call void @foo1(i32 4, float %mul36)
ret void
}
declare void @foo1(i32, float)
declare float @foo2(float, float) #1
declare float @llvm.rsqrt.f32(float) #1
attributes #0 = { argmemonly nounwind }
attributes #1 = { nounwind readnone }

Some files were not shown because too many files have changed in this diff Show More