diff options
Diffstat (limited to 'test/Transforms')
376 files changed, 5289 insertions, 1747 deletions
diff --git a/test/Transforms/ArgumentPromotion/2008-07-02-array-indexing.ll b/test/Transforms/ArgumentPromotion/2008-07-02-array-indexing.ll index d7d5eb548a1c..210eb97bc1dc 100644 --- a/test/Transforms/ArgumentPromotion/2008-07-02-array-indexing.ll +++ b/test/Transforms/ArgumentPromotion/2008-07-02-array-indexing.ll @@ -1,5 +1,5 @@ ; RUN: opt < %s -argpromotion -S > %t -; RUN: cat %t | grep {define.*@callee(.*i32\\*} +; RUN: cat %t | grep "define.*@callee(.*i32\*" ; PR2498 ; This test tries to convince argpromotion about promoting the load from %A + 2, diff --git a/test/Transforms/ArgumentPromotion/byval-2.ll b/test/Transforms/ArgumentPromotion/byval-2.ll index bd62c6835f3b..368c6896cf82 100644 --- a/test/Transforms/ArgumentPromotion/byval-2.ll +++ b/test/Transforms/ArgumentPromotion/byval-2.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -argpromotion -S | grep -F {i32* byval} | count 2 +; RUN: opt < %s -argpromotion -S | grep -F "i32* byval" | count 2 ; Argpromote + scalarrepl should change this to passing the two integers by value. %struct.ss = type { i32, i64 } diff --git a/test/Transforms/ArgumentPromotion/control-flow.ll b/test/Transforms/ArgumentPromotion/control-flow.ll index 08ca6bccd632..e4a61da45cf3 100644 --- a/test/Transforms/ArgumentPromotion/control-flow.ll +++ b/test/Transforms/ArgumentPromotion/control-flow.ll @@ -1,5 +1,5 @@ ; RUN: opt < %s -argpromotion -S | \ -; RUN: not grep {load i32\* null} +; RUN: not grep "load i32* null" define internal i32 @callee(i1 %C, i32* %P) { br i1 %C, label %T, label %F diff --git a/test/Transforms/ArgumentPromotion/control-flow2.ll b/test/Transforms/ArgumentPromotion/control-flow2.ll index 9a8afc32a891..2543218bafe8 100644 --- a/test/Transforms/ArgumentPromotion/control-flow2.ll +++ b/test/Transforms/ArgumentPromotion/control-flow2.ll @@ -1,5 +1,5 @@ ; RUN: opt < %s -argpromotion -S | \ -; RUN: grep {load i32\\* %A} +; RUN: grep "load i32\* %A" target datalayout = "E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128" define internal i32 @callee(i1 %C, i32* %P) { diff --git a/test/Transforms/BBVectorize/metadata.ll b/test/Transforms/BBVectorize/metadata.ll new file mode 100644 index 000000000000..1e3aaa127a0e --- /dev/null +++ b/test/Transforms/BBVectorize/metadata.ll @@ -0,0 +1,49 @@ +target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128" +; RUN: opt < %s -bb-vectorize -bb-vectorize-req-chain-depth=3 -S | FileCheck %s + +; Simple 3-pair chain with loads and stores (with fpmath) +define void @test1(double* %a, double* %b, double* %c) nounwind uwtable readonly { +entry: + %i0 = load double* %a, align 8 + %i1 = load double* %b, align 8 + %mul = fmul double %i0, %i1, !fpmath !2 + %arrayidx3 = getelementptr inbounds double* %a, i64 1 + %i3 = load double* %arrayidx3, align 8 + %arrayidx4 = getelementptr inbounds double* %b, i64 1 + %i4 = load double* %arrayidx4, align 8 + %mul5 = fmul double %i3, %i4, !fpmath !3 + store double %mul, double* %c, align 8 + %arrayidx5 = getelementptr inbounds double* %c, i64 1 + store double %mul5, double* %arrayidx5, align 8 + ret void +; CHECK: @test1 +; CHECK: !fpmath +; CHECK: ret void +} + +; Simple 3-pair chain with loads and stores (ints with range) +define void @test2(i64* %a, i64* %b, i64* %c) nounwind uwtable readonly { +entry: + %i0 = load i64* %a, align 8, !range !0 + %i1 = load i64* %b, align 8 + %mul = mul i64 %i0, %i1 + %arrayidx3 = getelementptr inbounds i64* %a, i64 1 + %i3 = load i64* %arrayidx3, align 8, !range !1 + %arrayidx4 = getelementptr inbounds i64* %b, i64 1 + %i4 = load i64* %arrayidx4, align 8 + %mul5 = mul i64 %i3, %i4 + store i64 %mul, i64* %c, align 8 + %arrayidx5 = getelementptr inbounds i64* %c, i64 1 + store i64 %mul5, i64* %arrayidx5, align 8 + ret void +; CHECK: @test2 +; CHECK-NOT: !range +; CHECK: ret void +} + +!0 = metadata !{i64 0, i64 2} +!1 = metadata !{i64 3, i64 5} + +!2 = metadata !{ float 5.0 } +!3 = metadata !{ float 2.5 } + diff --git a/test/Transforms/BBVectorize/simple-sel.ll b/test/Transforms/BBVectorize/simple-sel.ll index 4daa5714fbd3..325792a5dca1 100644 --- a/test/Transforms/BBVectorize/simple-sel.ll +++ b/test/Transforms/BBVectorize/simple-sel.ll @@ -1,5 +1,6 @@ target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128" ; RUN: opt < %s -bb-vectorize -bb-vectorize-req-chain-depth=3 -instcombine -gvn -S | FileCheck %s +; RUN: opt < %s -bb-vectorize -bb-vectorize-req-chain-depth=3 -bb-vectorize-no-bools -instcombine -gvn -S | FileCheck %s -check-prefix=CHECK-NB ; Basic depth-3 chain with select define double @test1(double %A1, double %A2, double %B1, double %B2, i1 %C1, i1 %C2) { @@ -27,4 +28,32 @@ define double @test1(double %A1, double %A2, double %B1, double %B2, i1 %C1, i1 ; CHECK: ret double %R } +; Basic depth-3 chain with select (and vect. compare) +define double @test2(double %A1, double %A2, double %B1, double %B2) { +; CHECK: @test2 +; CHECK-NB: @test2 +; CHECK: %X1.v.i1.1 = insertelement <2 x double> undef, double %B1, i32 0 +; CHECK: %X1.v.i0.1 = insertelement <2 x double> undef, double %A1, i32 0 +; CHECK: %X1.v.i1.2 = insertelement <2 x double> %X1.v.i1.1, double %B2, i32 1 +; CHECK: %X1.v.i0.2 = insertelement <2 x double> %X1.v.i0.1, double %A2, i32 1 + %X1 = fsub double %A1, %B1 + %X2 = fsub double %A2, %B2 +; CHECK: %X1 = fsub <2 x double> %X1.v.i0.2, %X1.v.i1.2 + %Y1 = fmul double %X1, %A1 + %Y2 = fmul double %X2, %A2 +; CHECK: %Y1 = fmul <2 x double> %X1, %X1.v.i0.2 + %C1 = fcmp ogt double %X1, %A1 + %C2 = fcmp ogt double %X2, %A2 +; CHECK: %C1 = fcmp ogt <2 x double> %X1, %X1.v.i0.2 +; CHECK-NB: fcmp ogt double + %Z1 = select i1 %C1, double %Y1, double %B1 + %Z2 = select i1 %C2, double %Y2, double %B2 +; CHECK: %Z1 = select <2 x i1> %C1, <2 x double> %Y1, <2 x double> %X1.v.i1.2 + %R = fmul double %Z1, %Z2 +; CHECK: %Z1.v.r1 = extractelement <2 x double> %Z1, i32 0 +; CHECK: %Z1.v.r2 = extractelement <2 x double> %Z1, i32 1 +; CHECK: %R = fmul double %Z1.v.r1, %Z1.v.r2 + ret double %R +; CHECK: ret double %R +} diff --git a/test/Transforms/BBVectorize/simple-tst.ll b/test/Transforms/BBVectorize/simple-tst.ll new file mode 100644 index 000000000000..42146c6d14a2 --- /dev/null +++ b/test/Transforms/BBVectorize/simple-tst.ll @@ -0,0 +1,18 @@ +target datalayout = "E-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v128:128:128-n32:64" +target triple = "powerpc64-unknown-linux" +; RUN: opt < %s -bb-vectorize -bb-vectorize-req-chain-depth=3 -bb-vectorize-vector-bits=256 -instcombine -gvn -S | FileCheck %s + +; Basic depth-3 chain (target-specific type should not vectorize) +define ppc_fp128 @test7(ppc_fp128 %A1, ppc_fp128 %A2, ppc_fp128 %B1, ppc_fp128 %B2) { +; CHECK: @test7 +; CHECK-NOT: <2 x ppc_fp128> + %X1 = fsub ppc_fp128 %A1, %B1 + %X2 = fsub ppc_fp128 %A2, %B2 + %Y1 = fmul ppc_fp128 %X1, %A1 + %Y2 = fmul ppc_fp128 %X2, %A2 + %Z1 = fadd ppc_fp128 %Y1, %B1 + %Z2 = fadd ppc_fp128 %Y2, %B2 + %R = fmul ppc_fp128 %Z1, %Z2 + ret ppc_fp128 %R +} + diff --git a/test/Transforms/BBVectorize/simple.ll b/test/Transforms/BBVectorize/simple.ll index 904d766bb673..88eb9c90f7ee 100644 --- a/test/Transforms/BBVectorize/simple.ll +++ b/test/Transforms/BBVectorize/simple.ll @@ -138,8 +138,7 @@ define <8 x i8> @test6(<8 x i8> %A1, <8 x i8> %A2, <8 x i8> %B1, <8 x i8> %B2) { ; CHECK: %Z1 = add <16 x i8> %Y1, %X1.v.i1 %Q1 = shufflevector <8 x i8> %Z1, <8 x i8> %Z2, <8 x i32> <i32 15, i32 8, i32 6, i32 1, i32 13, i32 10, i32 4, i32 3> %Q2 = shufflevector <8 x i8> %Z2, <8 x i8> %Z2, <8 x i32> <i32 6, i32 7, i32 0, i32 1, i32 2, i32 4, i32 4, i32 1> -; CHECK: %Z1.v.r2 = shufflevector <16 x i8> %Z1, <16 x i8> undef, <8 x i32> <i32 8, i32 undef, i32 10, i32 undef, i32 undef, i32 13, i32 undef, i32 15> -; CHECK: %Q1.v.i1 = shufflevector <8 x i8> %Z1.v.r2, <8 x i8> undef, <16 x i32> <i32 0, i32 undef, i32 2, i32 undef, i32 undef, i32 5, i32 undef, i32 7, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef> +; CHECK: %Q1.v.i1 = shufflevector <16 x i8> %Z1, <16 x i8> undef, <16 x i32> <i32 8, i32 undef, i32 10, i32 undef, i32 undef, i32 13, i32 undef, i32 15, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef> ; CHECK: %Q1 = shufflevector <16 x i8> %Z1, <16 x i8> %Q1.v.i1, <16 x i32> <i32 23, i32 16, i32 6, i32 1, i32 21, i32 18, i32 4, i32 3, i32 14, i32 15, i32 8, i32 9, i32 10, i32 12, i32 12, i32 9> %R = mul <8 x i8> %Q1, %Q2 ; CHECK: %Q1.v.r1 = shufflevector <16 x i8> %Q1, <16 x i8> undef, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7> diff --git a/test/Transforms/BBVectorize/simple3.ll b/test/Transforms/BBVectorize/simple3.ll new file mode 100644 index 000000000000..153be73f832f --- /dev/null +++ b/test/Transforms/BBVectorize/simple3.ll @@ -0,0 +1,35 @@ +target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128" +; RUN: opt < %s -bb-vectorize -bb-vectorize-req-chain-depth=3 -bb-vectorize-vector-bits=192 -instcombine -gvn -S | FileCheck %s + +; Basic depth-3 chain +define double @test1(double %A1, double %A2, double %A3, double %B1, double %B2, double %B3) { +; CHECK: @test1 +; CHECK: %X1.v.i1.11 = insertelement <3 x double> undef, double %B1, i32 0 +; CHECK: %X1.v.i1.22 = insertelement <3 x double> %X1.v.i1.11, double %B2, i32 1 +; CHECK: %X1.v.i1 = insertelement <3 x double> %X1.v.i1.22, double %B3, i32 2 +; CHECK: %X1.v.i0.13 = insertelement <3 x double> undef, double %A1, i32 0 +; CHECK: %X1.v.i0.24 = insertelement <3 x double> %X1.v.i0.13, double %A2, i32 1 +; CHECK: %X1.v.i0 = insertelement <3 x double> %X1.v.i0.24, double %A3, i32 2 + %X1 = fsub double %A1, %B1 + %X2 = fsub double %A2, %B2 + %X3 = fsub double %A3, %B3 +; CHECK: %X1 = fsub <3 x double> %X1.v.i0, %X1.v.i1 + %Y1 = fmul double %X1, %A1 + %Y2 = fmul double %X2, %A2 + %Y3 = fmul double %X3, %A3 +; CHECK: %Y1 = fmul <3 x double> %X1, %X1.v.i0 + %Z1 = fadd double %Y1, %B1 + %Z2 = fadd double %Y2, %B2 + %Z3 = fadd double %Y3, %B3 +; CHECK: %Z1 = fadd <3 x double> %Y1, %X1.v.i1 + %R1 = fmul double %Z1, %Z2 + %R = fmul double %R1, %Z3 +; CHECK: %Z1.v.r210 = extractelement <3 x double> %Z1, i32 2 +; CHECK: %Z1.v.r1 = extractelement <3 x double> %Z1, i32 0 +; CHECK: %Z1.v.r2 = extractelement <3 x double> %Z1, i32 1 +; CHECK: %R1 = fmul double %Z1.v.r1, %Z1.v.r2 +; CHECK: %R = fmul double %R1, %Z1.v.r210 + ret double %R +; CHECK: ret double %R +} + diff --git a/test/Transforms/CodeGenPrepare/basic.ll b/test/Transforms/CodeGenPrepare/basic.ll index ebf10f0e9df2..c68e77eb555a 100644 --- a/test/Transforms/CodeGenPrepare/basic.ll +++ b/test/Transforms/CodeGenPrepare/basic.ll @@ -5,7 +5,7 @@ target triple = "x86_64-apple-darwin10.0.0" ; CHECK: @test1 ; objectsize should fold to a constant, which causes the branch to fold to an -; uncond branch. +; uncond branch. Next, we fold the control flow alltogether. ; rdar://8785296 define i32 @test1(i8* %ptr) nounwind ssp noredzone align 2 { entry: @@ -13,8 +13,8 @@ entry: %1 = icmp ugt i64 %0, 3 br i1 %1, label %T, label %trap -; CHECK: entry: -; CHECK-NEXT: br label %T +; CHECK: T: +; CHECK-NOT: br label % trap: ; preds = %0, %entry tail call void @llvm.trap() noreturn nounwind diff --git a/test/Transforms/ConstProp/2002-05-03-NotOperator.ll b/test/Transforms/ConstProp/2002-05-03-NotOperator.ll index b957220aa9cc..ca1d6180c758 100644 --- a/test/Transforms/ConstProp/2002-05-03-NotOperator.ll +++ b/test/Transforms/ConstProp/2002-05-03-NotOperator.ll @@ -5,7 +5,7 @@ ; Fix #2: The unary not instruction now no longer exists. Change to xor. ; RUN: opt < %s -constprop -S | \ -; RUN: not grep {i32 0} +; RUN: not grep "i32 0" define i32 @test1() { %R = xor i32 123, -1 ; <i32> [#uses=1] diff --git a/test/Transforms/ConstProp/2005-01-28-SetCCGEP.ll b/test/Transforms/ConstProp/2005-01-28-SetCCGEP.ll index 0b44b99f6a95..d68cb26da348 100644 --- a/test/Transforms/ConstProp/2005-01-28-SetCCGEP.ll +++ b/test/Transforms/ConstProp/2005-01-28-SetCCGEP.ll @@ -1,5 +1,5 @@ ; RUN: opt < %s -constprop -S | \ -; RUN: not grep {ret i1 false} +; RUN: not grep "ret i1 false" @b = external global [2 x { }] ; <[2 x { }]*> [#uses=2] diff --git a/test/Transforms/ConstProp/2006-11-30-vector-cast.ll b/test/Transforms/ConstProp/2006-11-30-vector-cast.ll index be76783e8b73..4a93144d2d51 100644 --- a/test/Transforms/ConstProp/2006-11-30-vector-cast.ll +++ b/test/Transforms/ConstProp/2006-11-30-vector-cast.ll @@ -1,5 +1,5 @@ ; RUN: opt < %s -constprop -S | \ -; RUN: grep {i32 -1} +; RUN: grep "i32 -1" ; RUN: opt < %s -constprop -S | \ ; RUN: not grep zeroinitializer diff --git a/test/Transforms/ConstProp/2006-12-01-TruncBoolBug.ll b/test/Transforms/ConstProp/2006-12-01-TruncBoolBug.ll index e46a875a7cfa..ce66c706488d 100644 --- a/test/Transforms/ConstProp/2006-12-01-TruncBoolBug.ll +++ b/test/Transforms/ConstProp/2006-12-01-TruncBoolBug.ll @@ -1,5 +1,5 @@ ; RUN: opt < %s -instcombine -S | \ -; RUN: grep {ret i1 false} +; RUN: grep "ret i1 false" define i1 @test() { %X = trunc i32 320 to i1 ; <i1> [#uses=1] ret i1 %X diff --git a/test/Transforms/ConstProp/2006-12-01-bool-casts.ll b/test/Transforms/ConstProp/2006-12-01-bool-casts.ll index 3c06693b100d..71db4211c5d2 100644 --- a/test/Transforms/ConstProp/2006-12-01-bool-casts.ll +++ b/test/Transforms/ConstProp/2006-12-01-bool-casts.ll @@ -1,7 +1,7 @@ ; RUN: opt < %s -constprop -S | \ -; RUN: grep {ret i32 -1} +; RUN: grep "ret i32 -1" ; RUN: opt < %s -constprop -S | \ -; RUN: grep {ret i32 1} +; RUN: grep "ret i32 1" define i32 @test1() { %A = sext i1 true to i32 ; <i32> [#uses=1] diff --git a/test/Transforms/ConstProp/2007-02-23-sdiv.ll b/test/Transforms/ConstProp/2007-02-23-sdiv.ll index 721199fc7f14..75f58b573fff 100644 --- a/test/Transforms/ConstProp/2007-02-23-sdiv.ll +++ b/test/Transforms/ConstProp/2007-02-23-sdiv.ll @@ -1,4 +1,4 @@ -; RUN: llvm-as < %s | llvm-dis | grep {global i32 0} +; RUN: llvm-as < %s | llvm-dis | grep "global i32 0" ; PR1215 @G = global i32 sdiv (i32 0, i32 -1) diff --git a/test/Transforms/ConstProp/2007-11-23-cttz.ll b/test/Transforms/ConstProp/2007-11-23-cttz.ll index a28c9b0a2f13..6d34cb17fffd 100644 --- a/test/Transforms/ConstProp/2007-11-23-cttz.ll +++ b/test/Transforms/ConstProp/2007-11-23-cttz.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -constprop -S | grep {ret i13 13} +; RUN: opt < %s -constprop -S | grep "ret i13 13" ; PR1816 declare i13 @llvm.cttz.i13(i13, i1) diff --git a/test/Transforms/ConstProp/div-zero.ll b/test/Transforms/ConstProp/div-zero.ll index f78a34fe703d..a2c59d3c002a 100644 --- a/test/Transforms/ConstProp/div-zero.ll +++ b/test/Transforms/ConstProp/div-zero.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -instcombine -S | grep {ret i32 0} +; RUN: opt < %s -instcombine -S | grep "ret i32 0" ; PR4424 declare void @ext() diff --git a/test/Transforms/CorrelatedValuePropagation/range.ll b/test/Transforms/CorrelatedValuePropagation/range.ll index 9b70ed200eda..6750546ba187 100644 --- a/test/Transforms/CorrelatedValuePropagation/range.ll +++ b/test/Transforms/CorrelatedValuePropagation/range.ll @@ -41,3 +41,127 @@ end: ; CHECK: then: ; CHECK-NEXT: br i1 false, label %end, label %else } + +; CHECK: @test3 +define i32 @test3(i32 %c) nounwind { + %cmp = icmp slt i32 %c, 2 + br i1 %cmp, label %if.then, label %if.end + +if.then: + ret i32 1 + +if.end: + %cmp1 = icmp slt i32 %c, 3 + br i1 %cmp1, label %if.then2, label %if.end8 + +; CHECK: if.then2 +if.then2: + %cmp2 = icmp eq i32 %c, 2 +; CHECK: br i1 true + br i1 %cmp2, label %if.then4, label %if.end6 + +; CHECK: if.end6 +if.end6: + ret i32 2 + +if.then4: + ret i32 3 + +if.end8: + ret i32 4 +} + +; CHECK: @test4 +define i32 @test4(i32 %c) nounwind { + switch i32 %c, label %sw.default [ + i32 1, label %sw.bb + i32 2, label %sw.bb + i32 4, label %sw.bb + ] + +; CHECK: sw.bb +sw.bb: + %cmp = icmp sge i32 %c, 1 +; CHECK: br i1 true + br i1 %cmp, label %if.then, label %if.end + +if.then: + br label %return + +if.end: + br label %return + +sw.default: + br label %return + +return: + %retval.0 = phi i32 [ 42, %sw.default ], [ 4, %if.then ], [ 9, %if.end ] + ret i32 %retval.0 +} + +; CHECK: @test5 +define i1 @test5(i32 %c) nounwind { + %cmp = icmp slt i32 %c, 5 + br i1 %cmp, label %if.then, label %if.end + +if.then: + %cmp1 = icmp eq i32 %c, 4 + br i1 %cmp1, label %if.end, label %if.end8 + +if.end: + ret i1 true + +if.end8: + %cmp2 = icmp eq i32 %c, 3 + %cmp3 = icmp eq i32 %c, 4 + %cmp4 = icmp eq i32 %c, 6 +; CHECK: %or = or i1 false, false + %or = or i1 %cmp3, %cmp4 +; CHECK: ret i1 %cmp2 + ret i1 %cmp2 +} + +; CHECK: @test6 +define i1 @test6(i32 %c) nounwind { + %cmp = icmp ule i32 %c, 7 + br i1 %cmp, label %if.then, label %if.end + +if.then: +; CHECK: icmp eq i32 %c, 6 +; CHECK: br i1 + switch i32 %c, label %if.end [ + i32 6, label %sw.bb + i32 8, label %sw.bb + ] + +if.end: + ret i1 true + +sw.bb: + %cmp2 = icmp eq i32 %c, 6 +; CHECK: ret i1 true + ret i1 %cmp2 +} + +; CHECK: @test7 +define i1 @test7(i32 %c) nounwind { +entry: + switch i32 %c, label %sw.default [ + i32 6, label %sw.bb + i32 7, label %sw.bb + ] + +sw.bb: + ret i1 true + +sw.default: + %cmp5 = icmp eq i32 %c, 5 + %cmp6 = icmp eq i32 %c, 6 + %cmp7 = icmp eq i32 %c, 7 + %cmp8 = icmp eq i32 %c, 8 +; CHECK: %or = or i1 %cmp5, false + %or = or i1 %cmp5, %cmp6 +; CHECK: %or2 = or i1 false, %cmp8 + %or2 = or i1 %cmp7, %cmp8 + ret i1 false +} diff --git a/test/Transforms/DeadArgElim/2007-02-07-FuncRename.ll b/test/Transforms/DeadArgElim/2007-02-07-FuncRename.ll index d5bd6c4df53c..e5419f72f60a 100644 --- a/test/Transforms/DeadArgElim/2007-02-07-FuncRename.ll +++ b/test/Transforms/DeadArgElim/2007-02-07-FuncRename.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -deadargelim -S | grep {@test(} +; RUN: opt < %s -deadargelim -S | grep "@test(" ; RUN: opt < %s -deadargelim -S | not grep dead define internal i32 @test(i32 %X, i32 %dead) { diff --git a/test/Transforms/DeadArgElim/2007-10-18-VarargsReturn.ll b/test/Transforms/DeadArgElim/2007-10-18-VarargsReturn.ll index d4edce9baf65..cdd893faba26 100644 --- a/test/Transforms/DeadArgElim/2007-10-18-VarargsReturn.ll +++ b/test/Transforms/DeadArgElim/2007-10-18-VarargsReturn.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -deadargelim -S | not grep {ret i32 0} +; RUN: opt < %s -deadargelim -S | not grep "ret i32 0" ; PR1735 define internal i32 @test(i32 %A, ...) { diff --git a/test/Transforms/DeadArgElim/canon.ll b/test/Transforms/DeadArgElim/canon.ll index 11cd482b7b28..79c15a04c4cb 100644 --- a/test/Transforms/DeadArgElim/canon.ll +++ b/test/Transforms/DeadArgElim/canon.ll @@ -1,9 +1,9 @@ ; This test shows a few canonicalizations made by deadargelim ; RUN: opt < %s -deadargelim -S > %t ; This test should remove {} and replace it with void -; RUN: cat %t | grep {define internal void @test} +; RUN: cat %t | grep "define internal void @test" ; This test shouls replace the {i32} return value with just i32 -; RUN: cat %t | grep {define internal i32 @test2} +; RUN: cat %t | grep "define internal i32 @test2" define internal {} @test() { ret {} undef diff --git a/test/Transforms/DeadArgElim/keepalive.ll b/test/Transforms/DeadArgElim/keepalive.ll index 4d6aae37a3ef..dc92dc9f171a 100644 --- a/test/Transforms/DeadArgElim/keepalive.ll +++ b/test/Transforms/DeadArgElim/keepalive.ll @@ -1,6 +1,6 @@ ; RUN: opt < %s -deadargelim -S > %t -; RUN: grep {define internal zeroext i32 @test1() nounwind} %t -; RUN: grep {define internal <{ i32, i32 }> @test2} %t +; RUN: grep "define internal zeroext i32 @test1() nounwind" %t +; RUN: grep "define internal <{ i32, i32 }> @test2" %t %Ty = type <{ i32, i32 }> diff --git a/test/Transforms/DeadStoreElimination/simple.ll b/test/Transforms/DeadStoreElimination/simple.ll index 81eb5a8c705e..7a8cdd531b55 100644 --- a/test/Transforms/DeadStoreElimination/simple.ll +++ b/test/Transforms/DeadStoreElimination/simple.ll @@ -164,7 +164,7 @@ define i32* @test13() { } declare noalias i8* @malloc(i32) - +declare noalias i8* @calloc(i32, i32) define void @test14(i32* %Q) { @@ -258,3 +258,55 @@ define void @test20() { } ; CHECK: @test20 ; CHECK-NEXT: ret void + +; CHECK: @test21 +define void @test21() { + %m = call i8* @calloc(i32 9, i32 7) + store i8 0, i8* %m +; CHECK-NEXT: ret void + ret void +} + +; CHECK: @test22( +define void @test22(i1 %i, i32 %k, i32 %m) nounwind { + %k.addr = alloca i32 + %m.addr = alloca i32 + %k.addr.m.addr = select i1 %i, i32* %k.addr, i32* %m.addr + store i32 0, i32* %k.addr.m.addr, align 4 +; CHECK-NEXT: ret void + ret void +} + +; PR13547 +; CHECK: @test23 +; CHECK: store i8 97 +; CHECK: store i8 0 +declare noalias i8* @strdup(i8* nocapture) nounwind +define noalias i8* @test23() nounwind uwtable ssp { + %x = alloca [2 x i8], align 1 + %arrayidx = getelementptr inbounds [2 x i8]* %x, i64 0, i64 0 + store i8 97, i8* %arrayidx, align 1 + %arrayidx1 = getelementptr inbounds [2 x i8]* %x, i64 0, i64 1 + store i8 0, i8* %arrayidx1, align 1 + %call = call i8* @strdup(i8* %arrayidx) nounwind + ret i8* %call +} + +; Make sure same sized store to later element is deleted +; CHECK: @test24 +; CHECK-NOT: store i32 0 +; CHECK-NOT: store i32 0 +; CHECK: store i32 %b +; CHECK: store i32 %c +; CHECK: ret void +define void @test24([2 x i32]* %a, i32 %b, i32 %c) nounwind { + %1 = getelementptr inbounds [2 x i32]* %a, i64 0, i64 0 + store i32 0, i32* %1, align 4 + %2 = getelementptr inbounds [2 x i32]* %a, i64 0, i64 1 + store i32 0, i32* %2, align 4 + %3 = getelementptr inbounds [2 x i32]* %a, i64 0, i64 0 + store i32 %b, i32* %3, align 4 + %4 = getelementptr inbounds [2 x i32]* %a, i64 0, i64 1 + store i32 %c, i32* %4, align 4 + ret void +} diff --git a/test/Transforms/FunctionAttrs/2009-01-02-LocalStores.ll b/test/Transforms/FunctionAttrs/2009-01-02-LocalStores.ll index 7ef5f06f0613..f38c03acca34 100644 --- a/test/Transforms/FunctionAttrs/2009-01-02-LocalStores.ll +++ b/test/Transforms/FunctionAttrs/2009-01-02-LocalStores.ll @@ -1,5 +1,5 @@ -; RUN: opt < %s -functionattrs -S | not grep {nocapture *%%q} -; RUN: opt < %s -functionattrs -S | grep {nocapture *%%p} +; RUN: opt < %s -functionattrs -S | not grep "nocapture *%%q" +; RUN: opt < %s -functionattrs -S | grep "nocapture *%%p" define i32* @a(i32** %p) { %tmp = load i32** %p diff --git a/test/Transforms/GVN/2007-07-25-InfiniteLoop.ll b/test/Transforms/GVN/2007-07-25-InfiniteLoop.ll index 9983374b154e..7e9c982de51c 100644 --- a/test/Transforms/GVN/2007-07-25-InfiniteLoop.ll +++ b/test/Transforms/GVN/2007-07-25-InfiniteLoop.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -basicaa -gvn -S | not grep {tmp10 =} +; RUN: opt < %s -basicaa -gvn -S | not grep "tmp10 =" %struct.INT2 = type { i32, i32 } @blkshifts = external global %struct.INT2* ; <%struct.INT2**> [#uses=2] diff --git a/test/Transforms/GVN/2007-07-31-NoDomInherit.ll b/test/Transforms/GVN/2007-07-31-NoDomInherit.ll index f2c001296f63..5018a0747aff 100644 --- a/test/Transforms/GVN/2007-07-31-NoDomInherit.ll +++ b/test/Transforms/GVN/2007-07-31-NoDomInherit.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -basicaa -gvn -S | grep {tmp47 = phi i32 } +; RUN: opt < %s -basicaa -gvn -S | grep "tmp47 = phi i32 " %struct.anon = type { i32 (i32, i32, i32)*, i32, i32, [3 x i32], i8*, i8*, i8* } @debug = external constant i32 ; <i32*> [#uses=0] diff --git a/test/Transforms/GVN/2007-07-31-RedundantPhi.ll b/test/Transforms/GVN/2007-07-31-RedundantPhi.ll index a570e3571ee0..13419d19e1d5 100644 --- a/test/Transforms/GVN/2007-07-31-RedundantPhi.ll +++ b/test/Transforms/GVN/2007-07-31-RedundantPhi.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -basicaa -gvn -S | not grep {tmp701 =} +; RUN: opt < %s -basicaa -gvn -S | not grep "tmp701 =" @img_width = external global i16 ; <i16*> [#uses=2] diff --git a/test/Transforms/GVN/2008-07-02-Unreachable.ll b/test/Transforms/GVN/2008-07-02-Unreachable.ll index 407940b87d73..4f07868a1ccb 100644 --- a/test/Transforms/GVN/2008-07-02-Unreachable.ll +++ b/test/Transforms/GVN/2008-07-02-Unreachable.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -basicaa -gvn -S | grep {ret i8 \[%\]tmp3} +; RUN: opt < %s -basicaa -gvn -S | grep "ret i8 [%]tmp3" ; PR2503 @g_3 = external global i8 ; <i8*> [#uses=2] diff --git a/test/Transforms/GVN/2012-05-22-PreCrash.ll b/test/Transforms/GVN/2012-05-22-PreCrash.ll new file mode 100644 index 000000000000..b488dda9c384 --- /dev/null +++ b/test/Transforms/GVN/2012-05-22-PreCrash.ll @@ -0,0 +1,33 @@ +; RUN: opt < %s -gvn +; PR12858 + +define void @fn5(i16 signext %p1, i8 signext %p2) nounwind uwtable { +entry: + br i1 undef, label %if.else, label %if.then + +if.then: ; preds = %entry + br label %if.end + +if.else: ; preds = %entry + %conv = sext i16 %p1 to i32 + br label %if.end + +if.end: ; preds = %if.else, %if.then + %conv1 = sext i16 %p1 to i32 + br i1 undef, label %if.then3, label %if.else4 + +if.then3: ; preds = %if.end + br label %if.end12 + +if.else4: ; preds = %if.end + %conv7 = sext i8 %p2 to i32 + %cmp8 = icmp eq i32 %conv1, %conv7 + br i1 %cmp8, label %if.then10, label %if.end12 + +if.then10: ; preds = %if.else4 + br label %if.end12 + +if.end12: ; preds = %if.then10, %if.else4, %if.then3 + %conv13 = sext i8 %p2 to i32 + ret void +} diff --git a/test/Transforms/GVN/basic.ll b/test/Transforms/GVN/basic.ll index 1decafac8c4f..6f4aace45fde 100644 --- a/test/Transforms/GVN/basic.ll +++ b/test/Transforms/GVN/basic.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -gvn -S | not grep {%z2 =} +; RUN: opt < %s -gvn -S | not grep "%z2 =" define i32 @main() { block1: diff --git a/test/Transforms/GVN/calls-readonly.ll b/test/Transforms/GVN/calls-readonly.ll index 97ec91512e32..a4777401b190 100644 --- a/test/Transforms/GVN/calls-readonly.ll +++ b/test/Transforms/GVN/calls-readonly.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -basicaa -gvn -S | grep {call.*strlen} | count 1 +; RUN: opt < %s -basicaa -gvn -S | grep "call.*strlen" | count 1 ; Should delete the second call to strlen even though the intervening strchr call exists. 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:128:128" diff --git a/test/Transforms/GVN/fpmath.ll b/test/Transforms/GVN/fpmath.ll new file mode 100644 index 000000000000..8ab285448fbb --- /dev/null +++ b/test/Transforms/GVN/fpmath.ll @@ -0,0 +1,45 @@ +; RUN: opt %s -gvn -S -o - | FileCheck %s + +define double @test1(double %x, double %y) { +; CHECK: @test1(double %x, double %y) +; CHECK: %add1 = fadd double %x, %y +; CHECK-NOT: fpmath +; CHECK: %foo = fadd double %add1, %add1 + %add1 = fadd double %x, %y, !fpmath !0 + %add2 = fadd double %x, %y + %foo = fadd double %add1, %add2 + ret double %foo +} + +define double @test2(double %x, double %y) { +; CHECK: @test2(double %x, double %y) +; CHECK: %add1 = fadd double %x, %y, !fpmath !0 +; CHECK: %foo = fadd double %add1, %add1 + %add1 = fadd double %x, %y, !fpmath !0 + %add2 = fadd double %x, %y, !fpmath !0 + %foo = fadd double %add1, %add2 + ret double %foo +} + +define double @test3(double %x, double %y) { +; CHECK: @test3(double %x, double %y) +; CHECK: %add1 = fadd double %x, %y, !fpmath !1 +; CHECK: %foo = fadd double %add1, %add1 + %add1 = fadd double %x, %y, !fpmath !1 + %add2 = fadd double %x, %y, !fpmath !0 + %foo = fadd double %add1, %add2 + ret double %foo +} + +define double @test4(double %x, double %y) { +; CHECK: @test4(double %x, double %y) +; CHECK: %add1 = fadd double %x, %y, !fpmath !1 +; CHECK: %foo = fadd double %add1, %add1 + %add1 = fadd double %x, %y, !fpmath !0 + %add2 = fadd double %x, %y, !fpmath !1 + %foo = fadd double %add1, %add2 + ret double %foo +} + +!0 = metadata !{ float 5.0 } +!1 = metadata !{ float 2.5 } diff --git a/test/Transforms/GVN/load-constant-mem.ll b/test/Transforms/GVN/load-constant-mem.ll index 314c8069cace..a7dacea6b5da 100644 --- a/test/Transforms/GVN/load-constant-mem.ll +++ b/test/Transforms/GVN/load-constant-mem.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -basicaa -gvn -instcombine -S | grep {ret i32 0} +; RUN: opt < %s -basicaa -gvn -instcombine -S | grep "ret i32 0" ; PR4189 @G = external constant [4 x i32] diff --git a/test/Transforms/GVN/local-pre.ll b/test/Transforms/GVN/local-pre.ll index 5f03984653a9..1d0dadfbe0fc 100644 --- a/test/Transforms/GVN/local-pre.ll +++ b/test/Transforms/GVN/local-pre.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -gvn -enable-pre -S | grep {b.pre} +; RUN: opt < %s -gvn -enable-pre -S | grep "b.pre" define i32 @main(i32 %p) { block1: diff --git a/test/Transforms/GVN/nonescaping-malloc.ll b/test/Transforms/GVN/nonescaping-malloc.ll index dba9d81405c0..afcb7fe3bb0f 100644 --- a/test/Transforms/GVN/nonescaping-malloc.ll +++ b/test/Transforms/GVN/nonescaping-malloc.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -basicaa -gvn -stats -disable-output |& grep {Number of loads deleted} +; RUN: opt < %s -basicaa -gvn -stats -disable-output 2>&1 | grep "Number of loads deleted" ; rdar://7363102 ; GVN should be able to eliminate load %tmp22.i, because it is redundant with diff --git a/test/Transforms/GVN/pr12979.ll b/test/Transforms/GVN/pr12979.ll new file mode 100644 index 000000000000..669da9127d0b --- /dev/null +++ b/test/Transforms/GVN/pr12979.ll @@ -0,0 +1,79 @@ +; RUN: opt %s -gvn -S -o - | FileCheck %s + +define i32 @test1(i32 %x, i32 %y) { +; CHECK: @test1(i32 %x, i32 %y) +; CHECK: %add1 = add i32 %x, %y +; CHECK: %foo = add i32 %add1, %add1 + + %add1 = add nsw i32 %x, %y + %add2 = add i32 %x, %y + %foo = add i32 %add1, %add2 + ret i32 %foo +} + +define i32 @test2(i32 %x, i32 %y) { +; CHECK: @test2(i32 %x, i32 %y) +; CHECK: %add1 = add i32 %x, %y +; CHECK: %foo = add i32 %add1, %add1 + + %add1 = add nuw i32 %x, %y + %add2 = add i32 %x, %y + %foo = add i32 %add1, %add2 + ret i32 %foo +} + +define i32 @test3(i32 %x, i32 %y) { +; CHECK: @test3(i32 %x, i32 %y) +; CHECK: %add1 = add i32 %x, %y +; CHECK: %foo = add i32 %add1, %add1 + + %add1 = add nuw nsw i32 %x, %y + %add2 = add i32 %x, %y + %foo = add i32 %add1, %add2 + ret i32 %foo +} + +define i32 @test4(i32 %x, i32 %y) { +; CHECK: @test4(i32 %x, i32 %y) +; CHECK: %add1 = add nsw i32 %x, %y +; CHECK: %foo = add i32 %add1, %add1 + + %add1 = add nsw i32 %x, %y + %add2 = add nsw i32 %x, %y + %foo = add i32 %add1, %add2 + ret i32 %foo +} + +define i32 @test5(i32 %x, i32 %y) { +; CHECK: @test5(i32 %x, i32 %y) +; CHECK: %add1 = add i32 %x, %y +; CHECK: %foo = add i32 %add1, %add1 + + %add1 = add nuw i32 %x, %y + %add2 = add nsw i32 %x, %y + %foo = add i32 %add1, %add2 + ret i32 %foo +} + +define i32 @test6(i32 %x, i32 %y) { +; CHECK: @test6(i32 %x, i32 %y) +; CHECK: %add1 = add nsw i32 %x, %y +; CHECK: %foo = add i32 %add1, %add1 + + %add1 = add nuw nsw i32 %x, %y + %add2 = add nsw i32 %x, %y + %foo = add i32 %add1, %add2 + ret i32 %foo +} + +define i32 @test7(i32 %x, i32 %y) { +; CHECK: @test7(i32 %x, i32 %y) +; CHECK: %add1 = add i32 %x, %y +; CHECK-NOT: what_is_this +; CHECK: %foo = add i32 %add1, %add1 + + %add1 = add i32 %x, %y, !what_is_this !{} + %add2 = add i32 %x, %y + %foo = add i32 %add1, %add2 + ret i32 %foo +} diff --git a/test/Transforms/GVN/pre-basic-add.ll b/test/Transforms/GVN/pre-basic-add.ll index c13099fe7349..4bde05c3387f 100644 --- a/test/Transforms/GVN/pre-basic-add.ll +++ b/test/Transforms/GVN/pre-basic-add.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -gvn -enable-pre -S | grep {.pre} +; RUN: opt < %s -gvn -enable-pre -S | grep ".pre" @H = common global i32 0 ; <i32*> [#uses=2] @G = common global i32 0 ; <i32*> [#uses=1] diff --git a/test/Transforms/GVN/range.ll b/test/Transforms/GVN/range.ll new file mode 100644 index 000000000000..3759c415dabc --- /dev/null +++ b/test/Transforms/GVN/range.ll @@ -0,0 +1,101 @@ +; RUN: opt %s -basicaa -gvn -S -o - | FileCheck %s + +define i32 @test1(i32* %p) { +; CHECK: @test1(i32* %p) +; CHECK: %a = load i32* %p, !range !0 +; CHECK: %c = add i32 %a, %a + %a = load i32* %p, !range !0 + %b = load i32* %p, !range !0 + %c = add i32 %a, %b + ret i32 %c +} + +define i32 @test2(i32* %p) { +; CHECK: @test2(i32* %p) +; CHECK: %a = load i32* %p +; CHECK-NOT: range +; CHECK: %c = add i32 %a, %a + %a = load i32* %p, !range !0 + %b = load i32* %p + %c = add i32 %a, %b + ret i32 %c +} + +define i32 @test3(i32* %p) { +; CHECK: @test3(i32* %p) +; CHECK: %a = load i32* %p, !range ![[DISJOINT_RANGE:[0-9]+]] +; CHECK: %c = add i32 %a, %a + %a = load i32* %p, !range !0 + %b = load i32* %p, !range !1 + %c = add i32 %a, %b + ret i32 %c +} + +define i32 @test4(i32* %p) { +; CHECK: @test4(i32* %p) +; CHECK: %a = load i32* %p, !range ![[MERGED_RANGE:[0-9]+]] +; CHECK: %c = add i32 %a, %a + %a = load i32* %p, !range !0 + %b = load i32* %p, !range !2 + %c = add i32 %a, %b + ret i32 %c +} + +define i32 @test5(i32* %p) { +; CHECK: @test5(i32* %p) +; CHECK: %a = load i32* %p, !range ![[MERGED_SIGNED_RANGE:[0-9]+]] +; CHECK: %c = add i32 %a, %a + %a = load i32* %p, !range !3 + %b = load i32* %p, !range !4 + %c = add i32 %a, %b + ret i32 %c +} + +define i32 @test6(i32* %p) { +; CHECK: @test6(i32* %p) +; CHECK: %a = load i32* %p, !range ![[MERGED_TEST6:[0-9]+]] +; CHECK: %c = add i32 %a, %a + %a = load i32* %p, !range !5 + %b = load i32* %p, !range !6 + %c = add i32 %a, %b + ret i32 %c +} + +define i32 @test7(i32* %p) { +; CHECK: @test7(i32* %p) +; CHECK: %a = load i32* %p, !range ![[MERGED_TEST7:[0-9]+]] +; CHECK: %c = add i32 %a, %a + %a = load i32* %p, !range !7 + %b = load i32* %p, !range !8 + %c = add i32 %a, %b + ret i32 %c +} + +define i32 @test8(i32* %p) { +; CHECK: @test8(i32* %p) +; CHECK: %a = load i32* %p +; CHECK-NOT: range +; CHECK: %c = add i32 %a, %a + %a = load i32* %p, !range !9 + %b = load i32* %p, !range !10 + %c = add i32 %a, %b + ret i32 %c +} + +; CHECK: ![[DISJOINT_RANGE]] = metadata !{i32 0, i32 2, i32 3, i32 5} +; CHECK: ![[MERGED_RANGE]] = metadata !{i32 0, i32 5} +; CHECK: ![[MERGED_SIGNED_RANGE]] = metadata !{i32 -3, i32 -2, i32 1, i32 2} +; CHECK: ![[MERGED_TEST6]] = metadata !{i32 10, i32 1} +; CHECK: ![[MERGED_TEST7]] = metadata !{i32 3, i32 4, i32 5, i32 2} + +!0 = metadata !{i32 0, i32 2} +!1 = metadata !{i32 3, i32 5} +!2 = metadata !{i32 2, i32 5} +!3 = metadata !{i32 -3, i32 -2} +!4 = metadata !{i32 1, i32 2} +!5 = metadata !{i32 10, i32 1} +!6 = metadata !{i32 12, i32 13} +!7 = metadata !{i32 1, i32 2, i32 3, i32 4} +!8 = metadata !{i32 5, i32 1} +!9 = metadata !{i32 1, i32 5} +!10 = metadata !{i32 5, i32 1} diff --git a/test/Transforms/GVN/rle-must-alias.ll b/test/Transforms/GVN/rle-must-alias.ll index 479724063e0b..e7dc9c423fcb 100644 --- a/test/Transforms/GVN/rle-must-alias.ll +++ b/test/Transforms/GVN/rle-must-alias.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -basicaa -gvn -S | grep {DEAD = phi i32 } +; RUN: opt < %s -basicaa -gvn -S | grep "DEAD = phi i32 " ; GVN should eliminate the fully redundant %9 GEP which ; allows DEAD to be removed. This is PR3198. diff --git a/test/Transforms/GVN/rle-semidominated.ll b/test/Transforms/GVN/rle-semidominated.ll index c6cd1fdc00c5..71aa548ab11e 100644 --- a/test/Transforms/GVN/rle-semidominated.ll +++ b/test/Transforms/GVN/rle-semidominated.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -basicaa -gvn -S | grep {DEAD = phi i32 } +; RUN: opt < %s -basicaa -gvn -S | grep "DEAD = phi i32 " define i32 @main(i32* %p) { block1: diff --git a/test/Transforms/GVN/tbaa.ll b/test/Transforms/GVN/tbaa.ll new file mode 100644 index 000000000000..90661c62507b --- /dev/null +++ b/test/Transforms/GVN/tbaa.ll @@ -0,0 +1,81 @@ +; RUN: opt %s -basicaa -gvn -S -o - | FileCheck %s + +define i32 @test1(i8* %p, i8* %q) { +; CHECK: @test1(i8* %p, i8* %q) +; CHECK: call i32 @foo(i8* %p) +; CHECK-NOT: tbaa +; CHECK: %c = add i32 %a, %a + %a = call i32 @foo(i8* %p), !tbaa !0 + %b = call i32 @foo(i8* %p) + %c = add i32 %a, %b + ret i32 %c +} + +define i32 @test2(i8* %p, i8* %q) { +; CHECK: @test2(i8* %p, i8* %q) +; CHECK: call i32 @foo(i8* %p), !tbaa !0 +; CHECK: %c = add i32 %a, %a + %a = call i32 @foo(i8* %p), !tbaa !0 + %b = call i32 @foo(i8* %p), !tbaa !0 + %c = add i32 %a, %b + ret i32 %c +} + +define i32 @test3(i8* %p, i8* %q) { +; CHECK: @test3(i8* %p, i8* %q) +; CHECK: call i32 @foo(i8* %p), !tbaa !3 +; CHECK: %c = add i32 %a, %a + %a = call i32 @foo(i8* %p), !tbaa !3 + %b = call i32 @foo(i8* %p), !tbaa !3 + %c = add i32 %a, %b + ret i32 %c +} + +define i32 @test4(i8* %p, i8* %q) { +; CHECK: @test4(i8* %p, i8* %q) +; CHECK: call i32 @foo(i8* %p), !tbaa !1 +; CHECK: %c = add i32 %a, %a + %a = call i32 @foo(i8* %p), !tbaa !1 + %b = call i32 @foo(i8* %p), !tbaa !0 + %c = add i32 %a, %b + ret i32 %c +} + +define i32 @test5(i8* %p, i8* %q) { +; CHECK: @test5(i8* %p, i8* %q) +; CHECK: call i32 @foo(i8* %p), !tbaa !1 +; CHECK: %c = add i32 %a, %a + %a = call i32 @foo(i8* %p), !tbaa !0 + %b = call i32 @foo(i8* %p), !tbaa !1 + %c = add i32 %a, %b + ret i32 %c +} + +define i32 @test6(i8* %p, i8* %q) { +; CHECK: @test6(i8* %p, i8* %q) +; CHECK: call i32 @foo(i8* %p), !tbaa !1 +; CHECK: %c = add i32 %a, %a + %a = call i32 @foo(i8* %p), !tbaa !0 + %b = call i32 @foo(i8* %p), !tbaa !3 + %c = add i32 %a, %b + ret i32 %c +} + +define i32 @test7(i8* %p, i8* %q) { +; CHECK: @test7(i8* %p, i8* %q) +; CHECK: call i32 @foo(i8* %p) +; CHECK-NOT: tbaa +; CHECK: %c = add i32 %a, %a + %a = call i32 @foo(i8* %p), !tbaa !4 + %b = call i32 @foo(i8* %p), !tbaa !3 + %c = add i32 %a, %b + ret i32 %c +} + +declare i32 @foo(i8*) readonly + +!0 = metadata !{metadata !"C", metadata !1} +!1 = metadata !{metadata !"A", metadata !2} +!2 = metadata !{metadata !"tbaa root", null} +!3 = metadata !{metadata !"B", metadata !1} +!4 = metadata !{metadata !"another root", null} diff --git a/test/Transforms/GlobalOpt/2008-01-13-OutOfRangeSROA.ll b/test/Transforms/GlobalOpt/2008-01-13-OutOfRangeSROA.ll index 82abc8fe546b..7c07d5d9a23a 100644 --- a/test/Transforms/GlobalOpt/2008-01-13-OutOfRangeSROA.ll +++ b/test/Transforms/GlobalOpt/2008-01-13-OutOfRangeSROA.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -globalopt -S | grep {16 x .31 x double.. zeroinitializer} +; RUN: opt < %s -globalopt -S | grep "16 x .31 x double.. zeroinitializer" ; The 'X' indices could be larger than 31. Do not SROA the outer indices of this array. @mm = internal global [16 x [31 x double]] zeroinitializer, align 32 diff --git a/test/Transforms/GlobalOpt/2008-01-29-VolatileGlobal.ll b/test/Transforms/GlobalOpt/2008-01-29-VolatileGlobal.ll index 588d5c9a6844..08b2cb1eb6f2 100644 --- a/test/Transforms/GlobalOpt/2008-01-29-VolatileGlobal.ll +++ b/test/Transforms/GlobalOpt/2008-01-29-VolatileGlobal.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -globalopt -S | grep {load volatile} +; RUN: opt < %s -globalopt -S | grep "load volatile" @t0.1441 = internal global double 0x3FD5555555555555, align 8 ; <double*> [#uses=1] define double @foo() nounwind { diff --git a/test/Transforms/GlobalOpt/2008-04-26-SROA-Global-Align.ll b/test/Transforms/GlobalOpt/2008-04-26-SROA-Global-Align.ll index 5b06fea5d92c..d58becd53078 100644 --- a/test/Transforms/GlobalOpt/2008-04-26-SROA-Global-Align.ll +++ b/test/Transforms/GlobalOpt/2008-04-26-SROA-Global-Align.ll @@ -2,9 +2,9 @@ ; alignments. Elements 0 and 2 must be 16-byte aligned, and element ; 1 must be at least 8 byte aligned (but could be more). -; RUN: opt < %s -globalopt -S | grep {@G.0 = internal unnamed_addr global .*align 16} -; RUN: opt < %s -globalopt -S | grep {@G.1 = internal unnamed_addr global .*align 8} -; RUN: opt < %s -globalopt -S | grep {@G.2 = internal unnamed_addr global .*align 16} +; RUN: opt < %s -globalopt -S | grep "@G.0 = internal unnamed_addr global .*align 16" +; RUN: opt < %s -globalopt -S | grep "@G.1 = internal unnamed_addr global .*align 8" +; RUN: opt < %s -globalopt -S | grep "@G.2 = internal unnamed_addr global .*align 16" ; rdar://5891920 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:32:32-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128" diff --git a/test/Transforms/GlobalOpt/2009-01-13-phi-user.ll b/test/Transforms/GlobalOpt/2009-01-13-phi-user.ll index c4b6e52e7127..e76c44dbd044 100644 --- a/test/Transforms/GlobalOpt/2009-01-13-phi-user.ll +++ b/test/Transforms/GlobalOpt/2009-01-13-phi-user.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -globalopt -S | grep {phi.*@head} +; RUN: opt < %s -globalopt -S | grep "phi.*@head" ; PR3321 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128" target triple = "x86_64-unknown-linux-gnu" diff --git a/test/Transforms/GlobalOpt/2009-03-05-dbg.ll b/test/Transforms/GlobalOpt/2009-03-05-dbg.ll index 31548565745f..0f3efa09a1da 100644 --- a/test/Transforms/GlobalOpt/2009-03-05-dbg.ll +++ b/test/Transforms/GlobalOpt/2009-03-05-dbg.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -globalopt -stats -disable-output |& grep "1 globalopt - Number of global vars shrunk to booleans" +; RUN: opt < %s -globalopt -stats -disable-output 2>&1 | grep "1 globalopt - Number of global vars shrunk to booleans" @Stop = internal global i32 0 ; <i32*> [#uses=3] diff --git a/test/Transforms/GlobalOpt/2009-03-07-PromotePtrToBool.ll b/test/Transforms/GlobalOpt/2009-03-07-PromotePtrToBool.ll index d645ce49438b..059af1cfeac8 100644 --- a/test/Transforms/GlobalOpt/2009-03-07-PromotePtrToBool.ll +++ b/test/Transforms/GlobalOpt/2009-03-07-PromotePtrToBool.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -globalopt -S | grep {@X = internal unnamed_addr global i32} +; RUN: opt < %s -globalopt -S | grep "@X = internal unnamed_addr global i32" 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:128:128" target triple = "i386-apple-darwin7" @X = internal global i32* null ; <i32**> [#uses=2] diff --git a/test/Transforms/GlobalOpt/2009-11-16-BrokenPerformHeapAllocSRoA.ll b/test/Transforms/GlobalOpt/2009-11-16-BrokenPerformHeapAllocSRoA.ll index 54e8f9097906..40862bd038e1 100644 --- a/test/Transforms/GlobalOpt/2009-11-16-BrokenPerformHeapAllocSRoA.ll +++ b/test/Transforms/GlobalOpt/2009-11-16-BrokenPerformHeapAllocSRoA.ll @@ -17,7 +17,7 @@ define void @test() nounwind ssp { %2 = sext i32 %1 to i64 ; <i64> [#uses=1] %3 = mul i64 %2, ptrtoint (%struct.strchartype* getelementptr (%struct.strchartype* null, i64 1) to i64) ; <i64> [#uses=1] %4 = tail call i8* @malloc(i64 %3) ; <i8*> [#uses=1] -; CHECK: call i8* @malloc(i64 +; CHECK-NOT: call i8* @malloc(i64 %5 = bitcast i8* %4 to %struct.strchartype* ; <%struct.strchartype*> [#uses=1] store %struct.strchartype* %5, %struct.strchartype** @chartypes, align 8 ret void diff --git a/test/Transforms/GlobalOpt/2012-05-11-blockaddress.ll b/test/Transforms/GlobalOpt/2012-05-11-blockaddress.ll new file mode 100644 index 000000000000..0c58c1a9d9c7 --- /dev/null +++ b/test/Transforms/GlobalOpt/2012-05-11-blockaddress.ll @@ -0,0 +1,16 @@ +; RUN: opt < %s -globalopt -S | FileCheck %s +; Check that the mere presence of a blockaddress doesn't prevent -globalopt +; from promoting @f to fastcc. + +; CHECK: define{{.*}}fastcc{{.*}}@f +define internal i8* @f() { + ret i8* blockaddress(@f, %L1) +L1: + ret i8* null +} + +define void @g() { + ; CHECK: call{{.*}}fastcc{{.*}}@f + %p = call i8* @f() + ret void +} diff --git a/test/Transforms/GlobalOpt/cleanup-pointer-root-users.ll b/test/Transforms/GlobalOpt/cleanup-pointer-root-users.ll new file mode 100644 index 000000000000..a472f1033ff9 --- /dev/null +++ b/test/Transforms/GlobalOpt/cleanup-pointer-root-users.ll @@ -0,0 +1,49 @@ +; RUN: opt -globalopt -S -o - < %s | FileCheck %s + +@glbl = internal global i8* null + +define void @test1a() { +; CHECK: @test1a +; CHECK-NOT: store +; CHECK-NEXT: ret void + store i8* null, i8** @glbl + ret void +} + +define void @test1b(i8* %p) { +; CHECK: @test1b +; CHECK-NEXT: store +; CHECK-NEXT: ret void + store i8* %p, i8** @glbl + ret void +} + +define void @test2() { +; CHECK: @test2 +; CHECK: alloca i8 + %txt = alloca i8 + call void @foo2(i8* %txt) + %call2 = call i8* @strdup(i8* %txt) + store i8* %call2, i8** @glbl + ret void +} +declare i8* @strdup(i8*) +declare void @foo2(i8*) + +define void @test3() uwtable { +; CHECK: @test3 +; CHECK-NOT: bb1: +; CHECK-NOT: bb2: +; CHECK: invoke + %ptr = invoke i8* @_Znwm(i64 1) + to label %bb1 unwind label %bb2 +bb1: + store i8* %ptr, i8** @glbl + unreachable +bb2: + %tmp1 = landingpad { i8*, i32 } personality i32 (i32, i64, i8*, i8*)* @__gxx_personality_v0 + cleanup + resume { i8*, i32 } %tmp1 +} +declare i32 @__gxx_personality_v0(i32, i64, i8*, i8*) +declare i8* @_Znwm(i64) diff --git a/test/Transforms/GlobalOpt/constantexpr-dangle.ll b/test/Transforms/GlobalOpt/constantexpr-dangle.ll index 099c607509b2..be13a9811898 100644 --- a/test/Transforms/GlobalOpt/constantexpr-dangle.ll +++ b/test/Transforms/GlobalOpt/constantexpr-dangle.ll @@ -1,5 +1,5 @@ ; RUN: opt < %s -instcombine -globalopt -S | \ -; RUN: grep {internal fastcc float @foo} +; RUN: grep "internal fastcc float @foo" define internal float @foo() { ret float 0.000000e+00 diff --git a/test/Transforms/GlobalOpt/deadglobal.ll b/test/Transforms/GlobalOpt/deadglobal.ll index c8d8e7674d62..cad5a91488ab 100644 --- a/test/Transforms/GlobalOpt/deadglobal.ll +++ b/test/Transforms/GlobalOpt/deadglobal.ll @@ -1,9 +1,25 @@ -; RUN: opt < %s -globalopt -S | not grep internal +; RUN: opt < %s -globalopt -S | FileCheck %s -@G = internal global i32 123 ; <i32*> [#uses=1] +@G1 = internal global i32 123 ; <i32*> [#uses=1] -define void @foo() { - store i32 1, i32* @G +; CHECK-NOT: @G1 +; CHECK: @G2 +; CHECK-NOT: @G3 + +define void @foo1() { +; CHECK: define void @foo +; CHECK-NEXT: ret + store i32 1, i32* @G1 + ret void +} + +@G2 = linkonce_odr constant i32 42 + +define void @foo2() { +; CHECK: define void @foo2 +; CHECK-NEXT: store + store i32 1, i32* @G2 ret void } +@G3 = linkonce_odr constant i32 42 diff --git a/test/Transforms/GlobalOpt/globalsra-unknown-index.ll b/test/Transforms/GlobalOpt/globalsra-unknown-index.ll index 1e0db6a998bd..cc655e9a2d1d 100644 --- a/test/Transforms/GlobalOpt/globalsra-unknown-index.ll +++ b/test/Transforms/GlobalOpt/globalsra-unknown-index.ll @@ -1,7 +1,7 @@ ; RUN: opt < %s -globalopt -S > %t -; RUN: grep {@Y = internal unnamed_addr global \\\[3 x \[%\]struct.X\\\] zeroinitializer} %t +; RUN: grep "@Y = internal unnamed_addr global \[3 x [%]struct.X\] zeroinitializer" %t ; RUN: grep load %t | count 6 -; RUN: grep {add i32 \[%\]a, \[%\]b} %t | count 3 +; RUN: grep "add i32 [%]a, [%]b" %t | count 3 ; globalopt should not sra the global, because it can't see the index. diff --git a/test/Transforms/GlobalOpt/heap-sra-phi.ll b/test/Transforms/GlobalOpt/heap-sra-phi.ll index 6188e5af988a..123ad851f717 100644 --- a/test/Transforms/GlobalOpt/heap-sra-phi.ll +++ b/test/Transforms/GlobalOpt/heap-sra-phi.ll @@ -1,5 +1,5 @@ -; RUN: opt < %s -globalopt -S | grep {tmp.f1 = phi i32. } -; RUN: opt < %s -globalopt -S | grep {tmp.f0 = phi i32. } +; RUN: opt < %s -globalopt -S | grep "tmp.f1 = phi i32. " +; RUN: opt < %s -globalopt -S | grep "tmp.f0 = phi i32. " target datalayout = "E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128" %struct.foo = type { i32, i32 } diff --git a/test/Transforms/GlobalOpt/integer-bool.ll b/test/Transforms/GlobalOpt/integer-bool.ll index 59403b18d9d7..5a34a9c4dabd 100644 --- a/test/Transforms/GlobalOpt/integer-bool.ll +++ b/test/Transforms/GlobalOpt/integer-bool.ll @@ -1,5 +1,5 @@ ; RUN: opt < %s -globalopt -instcombine | \ -; RUN: llvm-dis | grep {ret i1 true} +; RUN: llvm-dis | grep "ret i1 true" ;; check that global opt turns integers that only hold 0 or 1 into bools. diff --git a/test/Transforms/GlobalOpt/memcpy.ll b/test/Transforms/GlobalOpt/memcpy.ll index 94e07a0848ea..dcfe009e330c 100644 --- a/test/Transforms/GlobalOpt/memcpy.ll +++ b/test/Transforms/GlobalOpt/memcpy.ll @@ -1,5 +1,5 @@ ; RUN: opt < %s -globalopt -S | \ -; RUN: grep {G1 = internal unnamed_addr constant} +; RUN: grep "G1 = internal unnamed_addr constant" @G1 = internal global [58 x i8] c"asdlfkajsdlfkajsd;lfkajds;lfkjasd;flkajsd;lkfja;sdlkfjasd\00" ; <[58 x i8]*> [#uses=1] diff --git a/test/Transforms/GlobalOpt/storepointer-compare.ll b/test/Transforms/GlobalOpt/storepointer-compare.ll index 2f5ae869b7c2..09e20a8adb26 100644 --- a/test/Transforms/GlobalOpt/storepointer-compare.ll +++ b/test/Transforms/GlobalOpt/storepointer-compare.ll @@ -1,5 +1,5 @@ ; RUN: opt < %s -globalopt -S | \ -; RUN: grep {call void @Actual} +; RUN: grep "call void @Actual" ; Check that a comparison does not prevent an indirect call from being made ; direct. The global will still remain, but indirect call elim is still good. diff --git a/test/Transforms/GlobalOpt/unnamed-addr.ll b/test/Transforms/GlobalOpt/unnamed-addr.ll index be0282122775..ee7505873126 100644 --- a/test/Transforms/GlobalOpt/unnamed-addr.ll +++ b/test/Transforms/GlobalOpt/unnamed-addr.ll @@ -4,17 +4,31 @@ @b = internal global i32 0, align 4 @c = internal global i32 0, align 4 @d = internal constant [4 x i8] c"foo\00", align 1 +@e = linkonce_odr global i32 0 ; CHECK: @a = internal global i32 0, align 4 ; CHECK: @b = internal global i32 0, align 4 ; CHECK: @c = internal unnamed_addr global i32 0, align 4 ; CHECK: @d = internal unnamed_addr constant [4 x i8] c"foo\00", align 1 +; CHECK: @e = linkonce_odr global i32 0 + +define i32 @get_e() { + %t = load i32* @e + ret i32 %t +} + +define void @set_e(i32 %x) { + store i32 %x, i32* @e + ret void +} define i1 @bah(i64 %i) nounwind readonly optsize ssp { entry: %arrayidx4 = getelementptr inbounds [4 x i8]* @d, i64 0, i64 %i %tmp5 = load i8* %arrayidx4, align 1 - %cmp = icmp eq i8 %tmp5, 42 + %array0 = bitcast [4 x i8]* @d to i8* + %tmp6 = load i8* %array0, align 1 + %cmp = icmp eq i8 %tmp5, %tmp6 ret i1 %cmp } diff --git a/test/Transforms/IPConstantProp/2008-06-09-WeakProp.ll b/test/Transforms/IPConstantProp/2008-06-09-WeakProp.ll index 66403363bf93..54a65d61da37 100644 --- a/test/Transforms/IPConstantProp/2008-06-09-WeakProp.ll +++ b/test/Transforms/IPConstantProp/2008-06-09-WeakProp.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -ipconstprop -S | grep {ret i32 %r} +; RUN: opt < %s -ipconstprop -S | grep "ret i32 %r" ; Should not propagate the result of a weak function. ; PR2411 diff --git a/test/Transforms/IPConstantProp/return-argument.ll b/test/Transforms/IPConstantProp/return-argument.ll index f4b7018222e9..2a14f05985d0 100644 --- a/test/Transforms/IPConstantProp/return-argument.ll +++ b/test/Transforms/IPConstantProp/return-argument.ll @@ -1,6 +1,6 @@ ; RUN: opt < %s -ipconstprop -S > %t -; RUN: cat %t | grep {store i32 %Z, i32\\* %Q} -; RUN: cat %t | grep {add i32 1, 3} +; RUN: cat %t | grep "store i32 %Z, i32\* %Q" +; RUN: cat %t | grep "add i32 1, 3" ;; This function returns its second argument on all return statements define internal i32* @incdec(i1 %C, i32* %V) { diff --git a/test/Transforms/IPConstantProp/return-constant.ll b/test/Transforms/IPConstantProp/return-constant.ll index ff15df738816..499d38329522 100644 --- a/test/Transforms/IPConstantProp/return-constant.ll +++ b/test/Transforms/IPConstantProp/return-constant.ll @@ -1,5 +1,5 @@ ; RUN: opt < %s -ipconstprop -instcombine | \ -; RUN: llvm-dis | grep {ret i1 true} | count 2 +; RUN: llvm-dis | grep "ret i1 true" | count 2 define internal i32 @foo(i1 %C) { br i1 %C, label %T, label %F diff --git a/test/Transforms/IPConstantProp/return-constants.ll b/test/Transforms/IPConstantProp/return-constants.ll index 2cd99fe3b74d..be2ca71c55c6 100644 --- a/test/Transforms/IPConstantProp/return-constants.ll +++ b/test/Transforms/IPConstantProp/return-constants.ll @@ -1,8 +1,8 @@ ; RUN: opt < %s -ipconstprop -S > %t ;; Check that the 21 constants got propagated properly -; RUN: cat %t | grep {%M = add i32 21, 21} +; RUN: cat %t | grep "%M = add i32 21, 21" ;; Check that the second return values didn't get propagated -; RUN: cat %t | grep {%N = add i32 %B, %D} +; RUN: cat %t | grep "%N = add i32 %B, %D" %0 = type { i32, i32 } diff --git a/test/Transforms/IndVarSimplify/2005-02-26-ExitValueCompute.ll b/test/Transforms/IndVarSimplify/2005-02-26-ExitValueCompute.ll index 1ba69826faf9..edeead164884 100644 --- a/test/Transforms/IndVarSimplify/2005-02-26-ExitValueCompute.ll +++ b/test/Transforms/IndVarSimplify/2005-02-26-ExitValueCompute.ll @@ -1,5 +1,5 @@ ; RUN: opt < %s -indvars -S | \ -; RUN: grep {ret i32 152} +; RUN: grep "ret i32 152" define i32 @main() { entry: diff --git a/test/Transforms/IndVarSimplify/2006-03-31-NegativeStride.ll b/test/Transforms/IndVarSimplify/2006-03-31-NegativeStride.ll index 1bbc63108086..c4e6cd4b346f 100644 --- a/test/Transforms/IndVarSimplify/2006-03-31-NegativeStride.ll +++ b/test/Transforms/IndVarSimplify/2006-03-31-NegativeStride.ll @@ -1,6 +1,6 @@ ; PR726 ; RUN: opt < %s -indvars -S | \ -; RUN: grep {ret i32 27} +; RUN: grep "ret i32 27" ; Make sure to compute the right exit value based on negative strides. diff --git a/test/Transforms/IndVarSimplify/2007-01-06-TripCount.ll b/test/Transforms/IndVarSimplify/2007-01-06-TripCount.ll index 268b8d1a7e47..6366c8c0516c 100644 --- a/test/Transforms/IndVarSimplify/2007-01-06-TripCount.ll +++ b/test/Transforms/IndVarSimplify/2007-01-06-TripCount.ll @@ -1,5 +1,5 @@ ; PR1015 -; RUN: opt < %s -indvars -S | not grep {ret i32 0} +; RUN: opt < %s -indvars -S | not grep "ret i32 0" target datalayout = "e-p:32:32" target triple = "i686-apple-darwin8" diff --git a/test/Transforms/IndVarSimplify/2009-04-14-shorten_iv_vars.ll b/test/Transforms/IndVarSimplify/2009-04-14-shorten_iv_vars.ll index dd400beaa5fa..b4615668136b 100644 --- a/test/Transforms/IndVarSimplify/2009-04-14-shorten_iv_vars.ll +++ b/test/Transforms/IndVarSimplify/2009-04-14-shorten_iv_vars.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -indvars -S | not grep {sext} +; RUN: opt < %s -indvars -S | not grep "sext" ; ModuleID = '<stdin>' target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n32:64" target triple = "x86_64-apple-darwin9.6" diff --git a/test/Transforms/IndVarSimplify/2009-04-15-shorten-iv-vars-2.ll b/test/Transforms/IndVarSimplify/2009-04-15-shorten-iv-vars-2.ll index 55e8a5073cf1..0722d8958517 100644 --- a/test/Transforms/IndVarSimplify/2009-04-15-shorten-iv-vars-2.ll +++ b/test/Transforms/IndVarSimplify/2009-04-15-shorten-iv-vars-2.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -indvars -instcombine -S | not grep {\[sz\]ext} +; RUN: opt < %s -indvars -instcombine -S | not grep "[sz]ext" ; ModuleID = '<stdin>' ;extern int *a, *b, *c, *d, *e, *f; /* 64 bit */ ;extern int K[256]; diff --git a/test/Transforms/IndVarSimplify/2012-07-17-lftr-undef.ll b/test/Transforms/IndVarSimplify/2012-07-17-lftr-undef.ll new file mode 100644 index 000000000000..7c5f81896f16 --- /dev/null +++ b/test/Transforms/IndVarSimplify/2012-07-17-lftr-undef.ll @@ -0,0 +1,22 @@ +; RUN: opt < %s -indvars -S | FileCheck %s +; PR13371: indvars pass incorrectly substitutes 'undef' values +; +; LFTR should not user %undef as the loop counter. +; CHECK: @test +; CHECK-NOT: icmp{{.*}}undef +@.str3 = private constant [6 x i8] c"%lld\0A\00", align 1 +declare i32 @printf(i8* noalias nocapture, ...) nounwind +define i64 @test() nounwind { +func_start: + br label %block9 +block9: ; preds = %block9,%func_start + %undef = phi i64 [ %next_undef, %block9 ], [ undef, %func_start ] + %iter = phi i64 [ %next_iter, %block9 ], [ 1, %func_start ] + %next_iter = add nsw i64 %iter, 1 + %0 = tail call i32 (i8*, ...)* @printf(i8* noalias nocapture getelementptr inbounds ([6 x i8]* @.str3, i64 0, i64 0), i64 %next_iter, i64 %undef) + %next_undef = add nsw i64 %undef, 1 + %_tmp_3 = icmp slt i64 %next_iter, 100 + br i1 %_tmp_3, label %block9, label %exit +exit: ; preds = %block9 + ret i64 0 +} diff --git a/test/Transforms/IndVarSimplify/eliminate-max.ll b/test/Transforms/IndVarSimplify/eliminate-max.ll index c25bd0e35418..98510eaed3f4 100644 --- a/test/Transforms/IndVarSimplify/eliminate-max.ll +++ b/test/Transforms/IndVarSimplify/eliminate-max.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -S -indvars | grep {= icmp} | count 3 +; RUN: opt < %s -S -indvars | grep "= icmp" | count 3 ; PR4914.ll ; Indvars should be able to do range analysis and eliminate icmps. diff --git a/test/Transforms/IndVarSimplify/lftr-reuse.ll b/test/Transforms/IndVarSimplify/lftr-reuse.ll index 9abfe13407fc..7fb36e509aed 100644 --- a/test/Transforms/IndVarSimplify/lftr-reuse.ll +++ b/test/Transforms/IndVarSimplify/lftr-reuse.ll @@ -153,6 +153,9 @@ return: ; Remove %i which is only used by the exit test. ; Verify that SCEV can still compute a backedge count from the sign ; extended %n, used for pointer comparison by LFTR. +; +; TODO: Fix for PR13371 currently makes this impossible. See +; IndVarSimplify.cpp hasConcreteDef(). We may want to change to undef rules. define void @geplftr(i8* %base, i32 %x, i32 %y, i32 %n) nounwind { entry: %x.ext = sext i32 %x to i64 @@ -162,13 +165,13 @@ entry: %lim = add i32 %x, %n %cmp.ph = icmp ult i32 %x, %lim br i1 %cmp.ph, label %loop, label %exit - +; CHECK: @geplftr ; CHECK: loop: ; CHECK: phi i8* -; CHECK-NOT: phi +; DISABLE-NOT: phi // This check is currently disabled ; CHECK: getelementptr ; CHECK: store -; CHECK: icmp ne i8* +; DISABLE: icmp ne i8* // This check is currently disabled ; CHECK: br i1 loop: %i = phi i32 [ %x, %entry ], [ %inc, %loop ] @@ -187,7 +190,7 @@ exit: define void @nevertaken() nounwind uwtable ssp { entry: br label %loop - +; CHECK: @nevertaken ; CHECK: loop: ; CHECK-NOT: phi ; CHECK-NOT: add diff --git a/test/Transforms/IndVarSimplify/loop_evaluate10.ll b/test/Transforms/IndVarSimplify/loop_evaluate10.ll index c3619f640b33..e51a3410e35a 100644 --- a/test/Transforms/IndVarSimplify/loop_evaluate10.ll +++ b/test/Transforms/IndVarSimplify/loop_evaluate10.ll @@ -1,5 +1,5 @@ ; RUN: opt < %s -indvars -S \ -; RUN: | grep {%b.1 = phi i32 \\\[ 2, %bb \\\], \\\[ 1, %bb2 \\\]} +; RUN: | grep "%b.1 = phi i32 [ 2, %bb ], [ 1, %bb2 ]" ; ; This loop has multiple exits, and the value of %b1 depends on which ; exit is taken. Indvars should correctly compute the exit values. diff --git a/test/Transforms/IndVarSimplify/loop_evaluate9.ll b/test/Transforms/IndVarSimplify/loop_evaluate9.ll index 9f3bcaf21bed..21fb7ef93167 100644 --- a/test/Transforms/IndVarSimplify/loop_evaluate9.ll +++ b/test/Transforms/IndVarSimplify/loop_evaluate9.ll @@ -1,6 +1,6 @@ ; RUN: opt < %s -indvars -S > %t -; RUN: grep {\[%\]tmp7 = icmp eq i8 -28, -28} %t -; RUN: grep {\[%\]tmp8 = icmp eq i8 63, 63} %t +; RUN: grep "[%]tmp7 = icmp eq i8 -28, -28" %t +; RUN: grep "[%]tmp8 = icmp eq i8 63, 63" %t ; PR4477 ; Indvars should compute the exit values in loop. ; diff --git a/test/Transforms/IndVarSimplify/loop_evaluate_3.ll b/test/Transforms/IndVarSimplify/loop_evaluate_3.ll index 65c66f7f5aca..0c1b590c4f84 100644 --- a/test/Transforms/IndVarSimplify/loop_evaluate_3.ll +++ b/test/Transforms/IndVarSimplify/loop_evaluate_3.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -indvars -S | grep {ret i32 600000} +; RUN: opt < %s -indvars -S | grep "ret i32 600000" ; PR1179 define i32 @foo() { diff --git a/test/Transforms/IndVarSimplify/loop_evaluate_4.ll b/test/Transforms/IndVarSimplify/loop_evaluate_4.ll index e4b642c7f58e..d7eb4063b916 100644 --- a/test/Transforms/IndVarSimplify/loop_evaluate_4.ll +++ b/test/Transforms/IndVarSimplify/loop_evaluate_4.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -indvars -S | grep {ret i32 9900} +; RUN: opt < %s -indvars -S | grep "ret i32 9900" ; PR1179 define i32 @test4() { diff --git a/test/Transforms/IndVarSimplify/loop_evaluate_5.ll b/test/Transforms/IndVarSimplify/loop_evaluate_5.ll index 80b961ac7c34..38f95bf1f50c 100644 --- a/test/Transforms/IndVarSimplify/loop_evaluate_5.ll +++ b/test/Transforms/IndVarSimplify/loop_evaluate_5.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -indvars -S | grep {120, %bb2.bb3_crit_edge} +; RUN: opt < %s -indvars -S | grep "120, %bb2.bb3_crit_edge" 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" target triple = "i686-pc-linux-gnu" diff --git a/test/Transforms/IndVarSimplify/shrunk-constant.ll b/test/Transforms/IndVarSimplify/shrunk-constant.ll index 271f8edf1980..45297d624645 100644 --- a/test/Transforms/IndVarSimplify/shrunk-constant.ll +++ b/test/Transforms/IndVarSimplify/shrunk-constant.ll @@ -1,5 +1,5 @@ ; RUN: opt < %s -scalar-evolution -analyze \ -; RUN: | grep {\\--> (zext i4 {-7,+,-8}<%loop> to i32)} +; RUN: | grep "\--> (zext i4 {-7,+,-8}<%loop> to i32)" define fastcc void @foo() nounwind { entry: diff --git a/test/Transforms/IndVarSimplify/ult-sub-to-eq.ll b/test/Transforms/IndVarSimplify/ult-sub-to-eq.ll new file mode 100644 index 000000000000..c58a3af62fcc --- /dev/null +++ b/test/Transforms/IndVarSimplify/ult-sub-to-eq.ll @@ -0,0 +1,42 @@ +; RUN: opt -S -indvars < %s | FileCheck %s + +define void @test1(float* nocapture %autoc, float* nocapture %data, float %d, i32 %data_len, i32 %sample) nounwind { +entry: + %sub = sub i32 %data_len, %sample + %cmp4 = icmp eq i32 %data_len, %sample + br i1 %cmp4, label %for.end, label %for.body + +for.body: ; preds = %entry, %for.body + %indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ 0, %entry ] + %0 = trunc i64 %indvars.iv to i32 + %add = add i32 %0, %sample + %idxprom = zext i32 %add to i64 + %arrayidx = getelementptr inbounds float* %data, i64 %idxprom + %1 = load float* %arrayidx, align 4 + %mul = fmul float %1, %d + %arrayidx2 = getelementptr inbounds float* %autoc, i64 %indvars.iv + %2 = load float* %arrayidx2, align 4 + %add3 = fadd float %2, %mul + store float %add3, float* %arrayidx2, align 4 + %indvars.iv.next = add i64 %indvars.iv, 1 + %3 = trunc i64 %indvars.iv.next to i32 + %cmp = icmp ult i32 %3, %sub + br i1 %cmp, label %for.body, label %for.end + +for.end: ; preds = %for.body, %entry + ret void + +; CHECK: @test1 + +; First check that we move the sub into the preheader, it doesn't have to be +; executed if %cmp4 == false +; CHECK: for.body.preheader: +; CHECK: sub i32 %data_len, %sample +; CHECK: br label %for.body + +; Second, check that we turn the IV test into an eq. +; CHECK: %lftr.wideiv = trunc i64 %indvars.iv.next to i32 +; CHECK: %exitcond = icmp ne i32 %lftr.wideiv, %0 +; CHECK: br i1 %exitcond, label %for.body, label %for.end.loopexit +} + diff --git a/test/Transforms/Inline/2007-04-15-InlineEH.ll b/test/Transforms/Inline/2007-04-15-InlineEH.ll index 8fbcf929d024..b114537490c8 100644 --- a/test/Transforms/Inline/2007-04-15-InlineEH.ll +++ b/test/Transforms/Inline/2007-04-15-InlineEH.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -inline -S | not grep {invoke void asm} +; RUN: opt < %s -inline -S | not grep "invoke void asm" ; PR1335 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" diff --git a/test/Transforms/Inline/casts.ll b/test/Transforms/Inline/casts.ll index 166185a545d1..a7b051b067ca 100644 --- a/test/Transforms/Inline/casts.ll +++ b/test/Transforms/Inline/casts.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -inline -S | grep {ret i32 1} +; RUN: opt < %s -inline -S | grep "ret i32 1" ; ModuleID = 'short.opt.bc' define i32 @testBool(i1 %X) { diff --git a/test/Transforms/Inline/delete-call.ll b/test/Transforms/Inline/delete-call.ll index 3505608b8283..7716d6a47bec 100644 --- a/test/Transforms/Inline/delete-call.ll +++ b/test/Transforms/Inline/delete-call.ll @@ -1,5 +1,5 @@ -; RUN: opt %s -S -inline -functionattrs -stats |& grep {Number of call sites deleted, not inlined} -; RUN: opt %s -S -inline -stats |& grep {Number of functions inlined} +; RUN: opt %s -S -inline -functionattrs -stats 2>&1 | grep "Number of call sites deleted, not inlined" +; RUN: opt %s -S -inline -stats 2>&1 | grep "Number of functions inlined" 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:128:128-n8:16:32" target triple = "i386-apple-darwin9.8" diff --git a/test/Transforms/Inline/externally_available.ll b/test/Transforms/Inline/externally_available.ll index 08b56385ac07..07274e7ecd25 100644 --- a/test/Transforms/Inline/externally_available.ll +++ b/test/Transforms/Inline/externally_available.ll @@ -1,6 +1,6 @@ ; RUN: opt < %s -inline -constprop -S > %t ; RUN: not grep test_function %t -; RUN: grep {ret i32 5} %t +; RUN: grep "ret i32 5" %t ; test_function should not be emitted to the .s file. diff --git a/test/Transforms/Inline/inline-byval-bonus.ll b/test/Transforms/Inline/inline-byval-bonus.ll new file mode 100644 index 000000000000..f3ed819a7f38 --- /dev/null +++ b/test/Transforms/Inline/inline-byval-bonus.ll @@ -0,0 +1,193 @@ +; RUN: opt -S -inline -inline-threshold=275 < %s | FileCheck %s +; PR13095 + +; The performance of the c-ray benchmark largely depends on the inlining of a +; specific call to @ray_sphere. This test case is designed to verify that it's +; inlined at -O3. + +target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128" +target triple = "x86_64-apple-macosx10.8.0" + +%struct.sphere = type { %struct.vec3, double, %struct.material, %struct.sphere* } +%struct.vec3 = type { double, double, double } +%struct.material = type { %struct.vec3, double, double } +%struct.ray = type { %struct.vec3, %struct.vec3 } +%struct.spoint = type { %struct.vec3, %struct.vec3, %struct.vec3, double } + +define i32 @caller(%struct.sphere* %i) { + %shadow_ray = alloca %struct.ray, align 8 + call void @fix(%struct.ray* %shadow_ray) + + %call = call i32 @ray_sphere(%struct.sphere* %i, %struct.ray* byval align 8 %shadow_ray, %struct.spoint* null) + ret i32 %call + +; CHECK: @caller +; CHECK-NOT: call i32 @ray_sphere +; CHECK: ret i32 +} + +declare void @fix(%struct.ray*) + +define i32 @ray_sphere(%struct.sphere* nocapture %sph, %struct.ray* nocapture byval align 8 %ray, %struct.spoint* %sp) nounwind uwtable ssp { + %1 = getelementptr inbounds %struct.ray* %ray, i64 0, i32 1, i32 0 + %2 = load double* %1, align 8 + %3 = fmul double %2, %2 + %4 = getelementptr inbounds %struct.ray* %ray, i64 0, i32 1, i32 1 + %5 = load double* %4, align 8 + %6 = fmul double %5, %5 + %7 = fadd double %3, %6 + %8 = getelementptr inbounds %struct.ray* %ray, i64 0, i32 1, i32 2 + %9 = load double* %8, align 8 + %10 = fmul double %9, %9 + %11 = fadd double %7, %10 + %12 = fmul double %2, 2.000000e+00 + %13 = getelementptr inbounds %struct.ray* %ray, i64 0, i32 0, i32 0 + %14 = load double* %13, align 8 + %15 = getelementptr inbounds %struct.sphere* %sph, i64 0, i32 0, i32 0 + %16 = load double* %15, align 8 + %17 = fsub double %14, %16 + %18 = fmul double %12, %17 + %19 = fmul double %5, 2.000000e+00 + %20 = getelementptr inbounds %struct.ray* %ray, i64 0, i32 0, i32 1 + %21 = load double* %20, align 8 + %22 = getelementptr inbounds %struct.sphere* %sph, i64 0, i32 0, i32 1 + %23 = load double* %22, align 8 + %24 = fsub double %21, %23 + %25 = fmul double %19, %24 + %26 = fadd double %18, %25 + %27 = fmul double %9, 2.000000e+00 + %28 = getelementptr inbounds %struct.ray* %ray, i64 0, i32 0, i32 2 + %29 = load double* %28, align 8 + %30 = getelementptr inbounds %struct.sphere* %sph, i64 0, i32 0, i32 2 + %31 = load double* %30, align 8 + %32 = fsub double %29, %31 + %33 = fmul double %27, %32 + %34 = fadd double %26, %33 + %35 = fmul double %16, %16 + %36 = fmul double %23, %23 + %37 = fadd double %35, %36 + %38 = fmul double %31, %31 + %39 = fadd double %37, %38 + %40 = fmul double %14, %14 + %41 = fadd double %40, %39 + %42 = fmul double %21, %21 + %43 = fadd double %42, %41 + %44 = fmul double %29, %29 + %45 = fadd double %44, %43 + %46 = fsub double -0.000000e+00, %16 + %47 = fmul double %14, %46 + %48 = fmul double %21, %23 + %49 = fsub double %47, %48 + %50 = fmul double %29, %31 + %51 = fsub double %49, %50 + %52 = fmul double %51, 2.000000e+00 + %53 = fadd double %52, %45 + %54 = getelementptr inbounds %struct.sphere* %sph, i64 0, i32 1 + %55 = load double* %54, align 8 + %56 = fmul double %55, %55 + %57 = fsub double %53, %56 + %58 = fmul double %34, %34 + %59 = fmul double %11, 4.000000e+00 + %60 = fmul double %59, %57 + %61 = fsub double %58, %60 + %62 = fcmp olt double %61, 0.000000e+00 + br i1 %62, label %130, label %63 + +; <label>:63 ; preds = %0 + %64 = tail call double @sqrt(double %61) nounwind readnone + %65 = fsub double -0.000000e+00, %34 + %66 = fsub double %64, %34 + %67 = fmul double %11, 2.000000e+00 + %68 = fdiv double %66, %67 + %69 = fsub double %65, %64 + %70 = fdiv double %69, %67 + %71 = fcmp olt double %68, 1.000000e-06 + %72 = fcmp olt double %70, 1.000000e-06 + %or.cond = and i1 %71, %72 + br i1 %or.cond, label %130, label %73 + +; <label>:73 ; preds = %63 + %74 = fcmp ogt double %68, 1.000000e+00 + %75 = fcmp ogt double %70, 1.000000e+00 + %or.cond1 = and i1 %74, %75 + br i1 %or.cond1, label %130, label %76 + +; <label>:76 ; preds = %73 + %77 = icmp eq %struct.spoint* %sp, null + br i1 %77, label %130, label %78 + +; <label>:78 ; preds = %76 + %t1.0 = select i1 %71, double %70, double %68 + %t2.0 = select i1 %72, double %t1.0, double %70 + %79 = fcmp olt double %t1.0, %t2.0 + %80 = select i1 %79, double %t1.0, double %t2.0 + %81 = getelementptr inbounds %struct.spoint* %sp, i64 0, i32 3 + store double %80, double* %81, align 8 + %82 = fmul double %80, %2 + %83 = fadd double %14, %82 + %84 = getelementptr inbounds %struct.spoint* %sp, i64 0, i32 0, i32 0 + store double %83, double* %84, align 8 + %85 = fmul double %5, %80 + %86 = fadd double %21, %85 + %87 = getelementptr inbounds %struct.spoint* %sp, i64 0, i32 0, i32 1 + store double %86, double* %87, align 8 + %88 = fmul double %9, %80 + %89 = fadd double %29, %88 + %90 = getelementptr inbounds %struct.spoint* %sp, i64 0, i32 0, i32 2 + store double %89, double* %90, align 8 + %91 = load double* %15, align 8 + %92 = fsub double %83, %91 + %93 = load double* %54, align 8 + %94 = fdiv double %92, %93 + %95 = getelementptr inbounds %struct.spoint* %sp, i64 0, i32 1, i32 0 + store double %94, double* %95, align 8 + %96 = load double* %22, align 8 + %97 = fsub double %86, %96 + %98 = load double* %54, align 8 + %99 = fdiv double %97, %98 + %100 = getelementptr inbounds %struct.spoint* %sp, i64 0, i32 1, i32 1 + store double %99, double* %100, align 8 + %101 = load double* %30, align 8 + %102 = fsub double %89, %101 + %103 = load double* %54, align 8 + %104 = fdiv double %102, %103 + %105 = getelementptr inbounds %struct.spoint* %sp, i64 0, i32 1, i32 2 + store double %104, double* %105, align 8 + %106 = fmul double %2, %94 + %107 = fmul double %5, %99 + %108 = fadd double %106, %107 + %109 = fmul double %9, %104 + %110 = fadd double %108, %109 + %111 = fmul double %110, 2.000000e+00 + %112 = fmul double %94, %111 + %113 = fsub double %112, %2 + %114 = fsub double -0.000000e+00, %113 + %115 = fmul double %99, %111 + %116 = fsub double %115, %5 + %117 = fsub double -0.000000e+00, %116 + %118 = fmul double %104, %111 + %119 = fsub double %118, %9 + %120 = fsub double -0.000000e+00, %119 + %.06 = getelementptr inbounds %struct.spoint* %sp, i64 0, i32 2, i32 0 + %.18 = getelementptr inbounds %struct.spoint* %sp, i64 0, i32 2, i32 1 + %.210 = getelementptr inbounds %struct.spoint* %sp, i64 0, i32 2, i32 2 + %121 = fmul double %113, %113 + %122 = fmul double %116, %116 + %123 = fadd double %121, %122 + %124 = fmul double %119, %119 + %125 = fadd double %123, %124 + %126 = tail call double @sqrt(double %125) nounwind readnone + %127 = fdiv double %114, %126 + store double %127, double* %.06, align 8 + %128 = fdiv double %117, %126 + store double %128, double* %.18, align 8 + %129 = fdiv double %120, %126 + store double %129, double* %.210, align 8 + br label %130 + +; <label>:130 ; preds = %78, %76, %73, %63, %0 + %.0 = phi i32 [ 0, %0 ], [ 0, %73 ], [ 0, %63 ], [ 1, %76 ], [ 1, %78 ] + ret i32 %.0 +} + +declare double @sqrt(double) nounwind readnone diff --git a/test/Transforms/Inline/inline-invoke-tail.ll b/test/Transforms/Inline/inline-invoke-tail.ll index 1f34113a1809..e07752396a30 100644 --- a/test/Transforms/Inline/inline-invoke-tail.ll +++ b/test/Transforms/Inline/inline-invoke-tail.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -inline -S | not grep {tail call void @llvm.memcpy.i32} +; RUN: opt < %s -inline -S | not grep "tail call void @llvm.memcpy.i32" ; PR3550 define internal void @foo(i32* %p, i32* %q) { diff --git a/test/Transforms/Inline/inline-optsize.ll b/test/Transforms/Inline/inline-optsize.ll new file mode 100644 index 000000000000..20d7426abd13 --- /dev/null +++ b/test/Transforms/Inline/inline-optsize.ll @@ -0,0 +1,33 @@ +; RUN: opt -S -Oz %s | FileCheck %s -check-prefix=OZ +; RUN: opt -S -O2 %s | FileCheck %s -check-prefix=O2 + +; The inline threshold for a function with the optsize attribute is currently +; the same as the global inline threshold for -Os. Check that the optsize +; function attribute don't alter the function specific inline threshold if the +; global inline threshold is lower (as for -Oz). + +@a = global i32 4 + +; This function should be larger than the inline threshold for -Oz (25), but +; smaller than the inline threshold for optsize (75). +define i32 @inner() { + %a1 = load volatile i32* @a + %x1 = add i32 %a1, %a1 + %a2 = load volatile i32* @a + %x2 = add i32 %x1, %a2 + %a3 = load volatile i32* @a + %x3 = add i32 %x2, %a3 + %a4 = load volatile i32* @a + %x4 = add i32 %x3, %a4 + %a5 = load volatile i32* @a + %x5 = add i32 %x3, %a5 + ret i32 %x5 +} + +; @inner() should be inlined for -O2 but not for -Oz. +; OZ: call +; O2-NOT: call +define i32 @outer() optsize { + %r = call i32 @inner() + ret i32 %r +} diff --git a/test/Transforms/Inline/inline_constprop.ll b/test/Transforms/Inline/inline_constprop.ll index dc35b60ba39c..0b48a7282f45 100644 --- a/test/Transforms/Inline/inline_constprop.ll +++ b/test/Transforms/Inline/inline_constprop.ll @@ -110,3 +110,65 @@ bb.merge: bb.false: ret i32 %sub } + + +define i32 @PR13412.main() { +; This is a somewhat complicated three layer subprogram that was reported to +; compute the wrong value for a branch due to assuming that an argument +; mid-inline couldn't be equal to another pointer. +; +; After inlining, the branch should point directly to the exit block, not to +; the intermediate block. +; CHECK: @PR13412.main +; CHECK: br i1 true, label %[[TRUE_DEST:.*]], label %[[FALSE_DEST:.*]] +; CHECK: [[FALSE_DEST]]: +; CHECK-NEXT: call void @PR13412.fail() +; CHECK: [[TRUE_DEST]]: +; CHECK-NEXT: ret i32 0 + +entry: + %i1 = alloca i64 + store i64 0, i64* %i1 + %arraydecay = bitcast i64* %i1 to i32* + %call = call i1 @PR13412.first(i32* %arraydecay, i32* %arraydecay) + br i1 %call, label %cond.end, label %cond.false + +cond.false: + call void @PR13412.fail() + br label %cond.end + +cond.end: + ret i32 0 +} + +define internal i1 @PR13412.first(i32* %a, i32* %b) { +entry: + %call = call i32* @PR13412.second(i32* %a, i32* %b) + %cmp = icmp eq i32* %call, %b + ret i1 %cmp +} + +declare void @PR13412.fail() + +define internal i32* @PR13412.second(i32* %a, i32* %b) { +entry: + %sub.ptr.lhs.cast = ptrtoint i32* %b to i64 + %sub.ptr.rhs.cast = ptrtoint i32* %a to i64 + %sub.ptr.sub = sub i64 %sub.ptr.lhs.cast, %sub.ptr.rhs.cast + %sub.ptr.div = ashr exact i64 %sub.ptr.sub, 2 + %cmp = icmp ugt i64 %sub.ptr.div, 1 + br i1 %cmp, label %if.then, label %if.end3 + +if.then: + %0 = load i32* %a + %1 = load i32* %b + %cmp1 = icmp eq i32 %0, %1 + br i1 %cmp1, label %return, label %if.end3 + +if.end3: + br label %return + +return: + %retval.0 = phi i32* [ %b, %if.end3 ], [ %a, %if.then ] + ret i32* %retval.0 +} diff --git a/test/Transforms/Inline/inline_prune.ll b/test/Transforms/Inline/inline_prune.ll index 658a422540ae..4c1574d83cf0 100644 --- a/test/Transforms/Inline/inline_prune.ll +++ b/test/Transforms/Inline/inline_prune.ll @@ -1,5 +1,5 @@ ; RUN: opt < %s -inline -S | \ -; RUN: not grep {callee\[12\](} +; RUN: not grep "callee[12](" ; RUN: opt < %s -inline -S | not grep mul define internal i32 @callee1(i32 %A, i32 %B) { diff --git a/test/Transforms/Inline/invoke_test-1.ll b/test/Transforms/Inline/invoke_test-1.ll index e0e6d600bbb3..922351fd461c 100644 --- a/test/Transforms/Inline/invoke_test-1.ll +++ b/test/Transforms/Inline/invoke_test-1.ll @@ -2,7 +2,7 @@ ; instructions ; RUN: opt < %s -inline -S | \ -; RUN: not grep {call\[^e\]} +; RUN: not grep "call[^e]" declare void @might_throw() diff --git a/test/Transforms/InstCombine/2004-08-10-BoolSetCC.ll b/test/Transforms/InstCombine/2004-08-10-BoolSetCC.ll index 1154bb481d30..4233797b6d72 100644 --- a/test/Transforms/InstCombine/2004-08-10-BoolSetCC.ll +++ b/test/Transforms/InstCombine/2004-08-10-BoolSetCC.ll @@ -1,5 +1,5 @@ ; RUN: opt < %s -instcombine -S | \ -; RUN: grep {ret i1 false} +; RUN: grep "ret i1 false" define i1 @test(i1 %V) { %Y = icmp ult i1 %V, false ; <i1> [#uses=1] diff --git a/test/Transforms/InstCombine/2004-09-20-BadLoadCombine.ll b/test/Transforms/InstCombine/2004-09-20-BadLoadCombine.ll index 8169d2127f7f..d17db8d7eac2 100644 --- a/test/Transforms/InstCombine/2004-09-20-BadLoadCombine.ll +++ b/test/Transforms/InstCombine/2004-09-20-BadLoadCombine.ll @@ -1,5 +1,5 @@ ; RUN: opt < %s -instcombine -mem2reg -S | \ -; RUN: not grep {i32 1} +; RUN: not grep "i32 1" ; When propagating the load through the select, make sure that the load is ; inserted where the original load was, not where the select is. Not doing diff --git a/test/Transforms/InstCombine/2004-09-20-BadLoadCombine2.ll b/test/Transforms/InstCombine/2004-09-20-BadLoadCombine2.ll index e646edf0296c..0d5fc810a8ae 100644 --- a/test/Transforms/InstCombine/2004-09-20-BadLoadCombine2.ll +++ b/test/Transforms/InstCombine/2004-09-20-BadLoadCombine2.ll @@ -1,5 +1,5 @@ ; RUN: opt < %s -instcombine -mem2reg -simplifycfg | \ -; RUN: llvm-dis | grep -v store | not grep {i32 1} +; RUN: llvm-dis | grep -v store | not grep "i32 1" ; Test to make sure that instcombine does not accidentally propagate the load ; into the PHI, which would break the program. diff --git a/test/Transforms/InstCombine/2005-03-04-ShiftOverflow.ll b/test/Transforms/InstCombine/2005-03-04-ShiftOverflow.ll index 38553d798810..02bc043da0db 100644 --- a/test/Transforms/InstCombine/2005-03-04-ShiftOverflow.ll +++ b/test/Transforms/InstCombine/2005-03-04-ShiftOverflow.ll @@ -1,5 +1,5 @@ ; RUN: opt < %s -instcombine -S | \ -; RUN: not grep {ret i1 false} +; RUN: not grep "ret i1 false" define i1 @test(i64 %tmp.169) { %tmp.1710 = lshr i64 %tmp.169, 1 ; <i64> [#uses=1] diff --git a/test/Transforms/InstCombine/2005-06-16-SetCCOrSetCCMiscompile.ll b/test/Transforms/InstCombine/2005-06-16-SetCCOrSetCCMiscompile.ll index 3d887ddad02b..0a513c647c12 100644 --- a/test/Transforms/InstCombine/2005-06-16-SetCCOrSetCCMiscompile.ll +++ b/test/Transforms/InstCombine/2005-06-16-SetCCOrSetCCMiscompile.ll @@ -1,5 +1,5 @@ ; RUN: opt < %s -instcombine -S | \ -; RUN: grep {ret i1 true} +; RUN: grep "ret i1 true" ; PR586 @g_07918478 = external global i32 ; <i32*> [#uses=1] diff --git a/test/Transforms/InstCombine/2006-12-08-Phi-ICmp-Op-Fold.ll b/test/Transforms/InstCombine/2006-12-08-Phi-ICmp-Op-Fold.ll index 5a74bd2ab7d6..295006ca2318 100644 --- a/test/Transforms/InstCombine/2006-12-08-Phi-ICmp-Op-Fold.ll +++ b/test/Transforms/InstCombine/2006-12-08-Phi-ICmp-Op-Fold.ll @@ -1,5 +1,5 @@ ; RUN: opt < %s -instcombine -S | \ -; RUN: grep {icmp sgt} +; RUN: grep "icmp sgt" ; END. target datalayout = "e-p:32:32" target triple = "i686-pc-linux-gnu" diff --git a/test/Transforms/InstCombine/2006-12-15-Range-Test.ll b/test/Transforms/InstCombine/2006-12-15-Range-Test.ll index c3700a00c428..0c8eeceec81c 100644 --- a/test/Transforms/InstCombine/2006-12-15-Range-Test.ll +++ b/test/Transforms/InstCombine/2006-12-15-Range-Test.ll @@ -1,7 +1,7 @@ ; RUN: opt < %s -instcombine -S | \ ; RUN: grep icmp | count 1 ; RUN: opt < %s -instcombine -S | \ -; RUN: grep {icmp ugt} | count 1 +; RUN: grep "icmp ugt" | count 1 ; END. target datalayout = "e-p:32:32" diff --git a/test/Transforms/InstCombine/2007-01-13-ExtCompareMiscompile.ll b/test/Transforms/InstCombine/2007-01-13-ExtCompareMiscompile.ll index e5238a577d2d..635a09ca93c7 100644 --- a/test/Transforms/InstCombine/2007-01-13-ExtCompareMiscompile.ll +++ b/test/Transforms/InstCombine/2007-01-13-ExtCompareMiscompile.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -instcombine -S | grep {icmp ugt} +; RUN: opt < %s -instcombine -S | grep "icmp ugt" ; PR1107 ; PR1940 diff --git a/test/Transforms/InstCombine/2007-01-14-FcmpSelf.ll b/test/Transforms/InstCombine/2007-01-14-FcmpSelf.ll index d2d215fa86d3..4fcfd264f452 100644 --- a/test/Transforms/InstCombine/2007-01-14-FcmpSelf.ll +++ b/test/Transforms/InstCombine/2007-01-14-FcmpSelf.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -instcombine -S | grep {fcmp uno.*0.0} +; RUN: opt < %s -instcombine -S | grep "fcmp uno.*0.0" ; PR1111 define i1 @test(double %X) { %tmp = fcmp une double %X, %X diff --git a/test/Transforms/InstCombine/2007-01-27-AndICmp.ll b/test/Transforms/InstCombine/2007-01-27-AndICmp.ll index bd15dce11acb..4d1b982f6766 100644 --- a/test/Transforms/InstCombine/2007-01-27-AndICmp.ll +++ b/test/Transforms/InstCombine/2007-01-27-AndICmp.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -instcombine -S | grep {ugt.*, 1} +; RUN: opt < %s -instcombine -S | grep "ugt.*, 1" define i1 @test(i32 %tmp1030) { %tmp1037 = icmp ne i32 %tmp1030, 40 ; <i1> [#uses=1] diff --git a/test/Transforms/InstCombine/2007-02-01-LoadSinkAlloca.ll b/test/Transforms/InstCombine/2007-02-01-LoadSinkAlloca.ll index 05891a203ab0..e2bebecded52 100644 --- a/test/Transforms/InstCombine/2007-02-01-LoadSinkAlloca.ll +++ b/test/Transforms/InstCombine/2007-02-01-LoadSinkAlloca.ll @@ -1,6 +1,6 @@ -; RUN: opt < %s -instcombine -mem2reg -S | grep {%A = alloca} +; RUN: opt < %s -instcombine -mem2reg -S | grep "%A = alloca" ; RUN: opt < %s -instcombine -mem2reg -S | \ -; RUN: not grep {%B = alloca} +; RUN: not grep "%B = alloca" ; END. ; Ensure that instcombine doesn't sink the loads in entry/cond_true into diff --git a/test/Transforms/InstCombine/2007-03-13-CompareMerge.ll b/test/Transforms/InstCombine/2007-03-13-CompareMerge.ll index 109e4a217fb5..826d68aefc1a 100644 --- a/test/Transforms/InstCombine/2007-03-13-CompareMerge.ll +++ b/test/Transforms/InstCombine/2007-03-13-CompareMerge.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -instcombine -S | grep {icmp sle} +; RUN: opt < %s -instcombine -S | grep "icmp sle" ; PR1244 define i1 @test(i32 %c.3.i, i32 %d.292.2.i) { diff --git a/test/Transforms/InstCombine/2007-03-21-SignedRangeTest.ll b/test/Transforms/InstCombine/2007-03-21-SignedRangeTest.ll index ca93af3a6910..719da7083afc 100644 --- a/test/Transforms/InstCombine/2007-03-21-SignedRangeTest.ll +++ b/test/Transforms/InstCombine/2007-03-21-SignedRangeTest.ll @@ -1,5 +1,5 @@ ; For PR1248 -; RUN: opt < %s -instcombine -S | grep {ugt i32 .*, 11} +; RUN: opt < %s -instcombine -S | grep "ugt i32 .*, 11" define i1 @test(i32 %tmp6) { %tmp7 = sdiv i32 %tmp6, 12 ; <i32> [#uses=1] icmp ne i32 %tmp7, -6 ; <i1>:1 [#uses=1] diff --git a/test/Transforms/InstCombine/2007-03-25-BadShiftMask.ll b/test/Transforms/InstCombine/2007-03-25-BadShiftMask.ll index c79400413ff3..7e9c9e28c94b 100644 --- a/test/Transforms/InstCombine/2007-03-25-BadShiftMask.ll +++ b/test/Transforms/InstCombine/2007-03-25-BadShiftMask.ll @@ -1,6 +1,6 @@ ; PR1271 ; RUN: opt < %s -instcombine -S | \ -; RUN: grep {icmp eq i32 .tmp.*, 2146435072} +; RUN: grep "icmp eq i32 .tmp.*, 2146435072" %struct..0anon = type { i32, i32 } %struct..1anon = type { double } diff --git a/test/Transforms/InstCombine/2007-03-26-BadShiftMask.ll b/test/Transforms/InstCombine/2007-03-26-BadShiftMask.ll index 807efcf29f19..c4070a1b1dbe 100644 --- a/test/Transforms/InstCombine/2007-03-26-BadShiftMask.ll +++ b/test/Transforms/InstCombine/2007-03-26-BadShiftMask.ll @@ -1,6 +1,6 @@ ; PR1271 ; RUN: opt < %s -instcombine -S | \ -; RUN: grep {ashr exact i32 %.mp137, 2} +; RUN: grep "ashr exact i32 %.mp137, 2" 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" target triple = "i686-pc-linux-gnu" diff --git a/test/Transforms/InstCombine/2007-05-18-CastFoldBug.ll b/test/Transforms/InstCombine/2007-05-18-CastFoldBug.ll index 15988b6dd99a..eb0c364bfa25 100644 --- a/test/Transforms/InstCombine/2007-05-18-CastFoldBug.ll +++ b/test/Transforms/InstCombine/2007-05-18-CastFoldBug.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -instcombine -S | grep {call.*sret} +; RUN: opt < %s -instcombine -S | grep "call.*sret" ; Make sure instcombine doesn't drop the sret attribute. define void @blah(i16* %tmp10) { diff --git a/test/Transforms/InstCombine/2007-06-06-AshrSignBit.ll b/test/Transforms/InstCombine/2007-06-06-AshrSignBit.ll index 62b93513b76c..082b2155a010 100644 --- a/test/Transforms/InstCombine/2007-06-06-AshrSignBit.ll +++ b/test/Transforms/InstCombine/2007-06-06-AshrSignBit.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -instcombine -S | grep {ashr} +; RUN: opt < %s -instcombine -S | grep "ashr" ; PR1499 define void @av_cmp_q_cond_true(i32* %retval, i32* %tmp9, i64* %tmp10) { diff --git a/test/Transforms/InstCombine/2007-06-21-DivCompareMiscomp.ll b/test/Transforms/InstCombine/2007-06-21-DivCompareMiscomp.ll index af539c12a339..b2b04d6bd2f7 100644 --- a/test/Transforms/InstCombine/2007-06-21-DivCompareMiscomp.ll +++ b/test/Transforms/InstCombine/2007-06-21-DivCompareMiscomp.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -instcombine -S | grep {ret i1 true} +; RUN: opt < %s -instcombine -S | grep "ret i1 true" ; rdar://5278853 define i1 @test(i32 %tmp468) { diff --git a/test/Transforms/InstCombine/2007-10-28-stacksave.ll b/test/Transforms/InstCombine/2007-10-28-stacksave.ll index 4c5c367bcfae..95a445c54357 100644 --- a/test/Transforms/InstCombine/2007-10-28-stacksave.ll +++ b/test/Transforms/InstCombine/2007-10-28-stacksave.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -instcombine -S | grep {call.*stacksave} +; RUN: opt < %s -instcombine -S | grep "call.*stacksave" ; PR1745 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:128:128" target triple = "i686-apple-darwin8" diff --git a/test/Transforms/InstCombine/2007-11-15-CompareMiscomp.ll b/test/Transforms/InstCombine/2007-11-15-CompareMiscomp.ll index 5282739d5c7f..6b83dd982dc8 100644 --- a/test/Transforms/InstCombine/2007-11-15-CompareMiscomp.ll +++ b/test/Transforms/InstCombine/2007-11-15-CompareMiscomp.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -instcombine -S | grep {icmp eq i32 %In, 1} +; RUN: opt < %s -instcombine -S | grep "icmp eq i32 %In, 1" ; PR1800 define i1 @test(i32 %In) { diff --git a/test/Transforms/InstCombine/2007-12-10-ConstFoldCompare.ll b/test/Transforms/InstCombine/2007-12-10-ConstFoldCompare.ll index 6420537b9de7..89f867252bf9 100644 --- a/test/Transforms/InstCombine/2007-12-10-ConstFoldCompare.ll +++ b/test/Transforms/InstCombine/2007-12-10-ConstFoldCompare.ll @@ -1,6 +1,6 @@ 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" target triple = "i686-pc-linux-gnu" -; RUN: opt < %s -instcombine -S | not grep {ret i1 0} +; RUN: opt < %s -instcombine -S | not grep "ret i1 0" ; PR1850 define i1 @test() { diff --git a/test/Transforms/InstCombine/2007-12-18-AddSelCmpSub.ll b/test/Transforms/InstCombine/2007-12-18-AddSelCmpSub.ll index cc89f6dd2056..3745e872eee6 100644 --- a/test/Transforms/InstCombine/2007-12-18-AddSelCmpSub.ll +++ b/test/Transforms/InstCombine/2007-12-18-AddSelCmpSub.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -instcombine -S | grep {add} | count 1 +; RUN: opt < %s -instcombine -S | grep "add" | count 1 define i32 @foo(i32 %a) { entry: diff --git a/test/Transforms/InstCombine/2008-01-29-AddICmp.ll b/test/Transforms/InstCombine/2008-01-29-AddICmp.ll index 28a94ce07ad2..1f9c47c4f1ee 100644 --- a/test/Transforms/InstCombine/2008-01-29-AddICmp.ll +++ b/test/Transforms/InstCombine/2008-01-29-AddICmp.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -instcombine -S | not grep {a.off} +; RUN: opt < %s -instcombine -S | not grep "a.off" ; PR1949 define i1 @test1(i32 %a) { diff --git a/test/Transforms/InstCombine/2008-02-16-SDivOverflow.ll b/test/Transforms/InstCombine/2008-02-16-SDivOverflow.ll index af61c150a7f8..917d3d9436bc 100644 --- a/test/Transforms/InstCombine/2008-02-16-SDivOverflow.ll +++ b/test/Transforms/InstCombine/2008-02-16-SDivOverflow.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -instcombine -S | grep {ret i.* 0} | count 2 +; RUN: opt < %s -instcombine -S | grep "ret i.* 0" | count 2 ; PR2048 define i32 @i(i32 %a) { diff --git a/test/Transforms/InstCombine/2008-02-16-SDivOverflow2.ll b/test/Transforms/InstCombine/2008-02-16-SDivOverflow2.ll index d26dec11e25d..854f8cb0b562 100644 --- a/test/Transforms/InstCombine/2008-02-16-SDivOverflow2.ll +++ b/test/Transforms/InstCombine/2008-02-16-SDivOverflow2.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -instcombine -S | grep {sdiv i8 \%a, 9} +; RUN: opt < %s -instcombine -S | grep "sdiv i8 \%a, 9" ; PR2048 define i8 @i(i8 %a) { diff --git a/test/Transforms/InstCombine/2008-03-13-IntToPtr.ll b/test/Transforms/InstCombine/2008-03-13-IntToPtr.ll index da7e49ee8475..0fa4d715f289 100644 --- a/test/Transforms/InstCombine/2008-03-13-IntToPtr.ll +++ b/test/Transforms/InstCombine/2008-03-13-IntToPtr.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -instcombine -S | grep {16} | count 1 +; RUN: opt < %s -instcombine -S | grep "16" | count 1 define i8* @bork(i8** %qux) { %tmp275 = load i8** %qux, align 1 diff --git a/test/Transforms/InstCombine/2008-04-28-VolatileStore.ll b/test/Transforms/InstCombine/2008-04-28-VolatileStore.ll index de08c32fb40e..dba6cdb56547 100644 --- a/test/Transforms/InstCombine/2008-04-28-VolatileStore.ll +++ b/test/Transforms/InstCombine/2008-04-28-VolatileStore.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -instcombine -S | grep {store volatile} +; RUN: opt < %s -instcombine -S | grep "store volatile" define void @test() { %votf = alloca <4 x float> ; <<4 x float>*> [#uses=1] diff --git a/test/Transforms/InstCombine/2008-04-29-VolatileLoadDontMerge.ll b/test/Transforms/InstCombine/2008-04-29-VolatileLoadDontMerge.ll index 1286e3d63b27..fd0217e9f4d7 100644 --- a/test/Transforms/InstCombine/2008-04-29-VolatileLoadDontMerge.ll +++ b/test/Transforms/InstCombine/2008-04-29-VolatileLoadDontMerge.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -instcombine -S | grep {load volatile} | count 2 +; RUN: opt < %s -instcombine -S | grep "load volatile" | count 2 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:128:128" target triple = "i386-apple-darwin8" @g_1 = internal global i32 0 ; <i32*> [#uses=3] diff --git a/test/Transforms/InstCombine/2008-04-29-VolatileLoadMerge.ll b/test/Transforms/InstCombine/2008-04-29-VolatileLoadMerge.ll index ebbd3a743f1c..8022414d6fc9 100644 --- a/test/Transforms/InstCombine/2008-04-29-VolatileLoadMerge.ll +++ b/test/Transforms/InstCombine/2008-04-29-VolatileLoadMerge.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -instcombine -S | grep {load volatile} | count 2 +; RUN: opt < %s -instcombine -S | grep "load volatile" | count 2 ; PR2262 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:128:128" target triple = "i386-apple-darwin8" diff --git a/test/Transforms/InstCombine/2008-05-08-LiveStoreDelete.ll b/test/Transforms/InstCombine/2008-05-08-LiveStoreDelete.ll index bbd004213d0a..7a1c84474153 100644 --- a/test/Transforms/InstCombine/2008-05-08-LiveStoreDelete.ll +++ b/test/Transforms/InstCombine/2008-05-08-LiveStoreDelete.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -instcombine -S | grep {store i8} | count 3 +; RUN: opt < %s -instcombine -S | grep "store i8" | count 3 ; PR2297 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:128:128" target triple = "i386-apple-darwin8" diff --git a/test/Transforms/InstCombine/2008-05-18-FoldIntToPtr.ll b/test/Transforms/InstCombine/2008-05-18-FoldIntToPtr.ll index b34fc1e991d4..a0e95a93982c 100644 --- a/test/Transforms/InstCombine/2008-05-18-FoldIntToPtr.ll +++ b/test/Transforms/InstCombine/2008-05-18-FoldIntToPtr.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -instcombine -S | grep {ret i1 false} | count 2 +; RUN: opt < %s -instcombine -S | grep "ret i1 false" | count 2 ; PR2329 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" diff --git a/test/Transforms/InstCombine/2008-05-23-CompareFold.ll b/test/Transforms/InstCombine/2008-05-23-CompareFold.ll index 2de5af735737..acb259be5eb1 100644 --- a/test/Transforms/InstCombine/2008-05-23-CompareFold.ll +++ b/test/Transforms/InstCombine/2008-05-23-CompareFold.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -instcombine -S | grep {ret i1 false} +; RUN: opt < %s -instcombine -S | grep "ret i1 false" ; PR2359 define i1 @f(i8* %x) { entry: diff --git a/test/Transforms/InstCombine/2008-05-31-AddBool.ll b/test/Transforms/InstCombine/2008-05-31-AddBool.ll index 541669365bdb..ed2069041d1b 100644 --- a/test/Transforms/InstCombine/2008-05-31-AddBool.ll +++ b/test/Transforms/InstCombine/2008-05-31-AddBool.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -instcombine -S | grep {xor} +; RUN: opt < %s -instcombine -S | grep "xor" ; PR2389 define i1 @test(i1 %a, i1 %b) { diff --git a/test/Transforms/InstCombine/2008-05-31-Bools.ll b/test/Transforms/InstCombine/2008-05-31-Bools.ll index a0fe47a6257b..7c33f2dd05ee 100644 --- a/test/Transforms/InstCombine/2008-05-31-Bools.ll +++ b/test/Transforms/InstCombine/2008-05-31-Bools.ll @@ -1,7 +1,7 @@ ; RUN: opt < %s -instcombine -S > %t -; RUN: grep {xor} %t -; RUN: grep {and} %t -; RUN: not grep {div} %t +; RUN: grep "xor" %t +; RUN: grep "and" %t +; RUN: not grep "div" %t define i1 @foo1(i1 %a, i1 %b) { %A = sub i1 %a, %b diff --git a/test/Transforms/InstCombine/2008-06-08-ICmpPHI.ll b/test/Transforms/InstCombine/2008-06-08-ICmpPHI.ll index 917d3ae1f843..ec946238d897 100644 --- a/test/Transforms/InstCombine/2008-06-08-ICmpPHI.ll +++ b/test/Transforms/InstCombine/2008-06-08-ICmpPHI.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -instcombine -S | grep {phi i32} | count 2 +; RUN: opt < %s -instcombine -S | grep "phi i32" | count 2 define void @test() nounwind { entry: diff --git a/test/Transforms/InstCombine/2008-06-13-InfiniteLoopStore.ll b/test/Transforms/InstCombine/2008-06-13-InfiniteLoopStore.ll index 08959c9c7c08..cc469262d53a 100644 --- a/test/Transforms/InstCombine/2008-06-13-InfiniteLoopStore.ll +++ b/test/Transforms/InstCombine/2008-06-13-InfiniteLoopStore.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -instcombine -S | grep {store i32} | count 2 +; RUN: opt < %s -instcombine -S | grep "store i32" | count 2 @g_139 = global i32 0 ; <i32*> [#uses=2] diff --git a/test/Transforms/InstCombine/2008-06-13-ReadOnlyCallStore.ll b/test/Transforms/InstCombine/2008-06-13-ReadOnlyCallStore.ll index aed1b14ce316..bf5e96b763f0 100644 --- a/test/Transforms/InstCombine/2008-06-13-ReadOnlyCallStore.ll +++ b/test/Transforms/InstCombine/2008-06-13-ReadOnlyCallStore.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -instcombine -S | grep {store i8} | count 2 +; RUN: opt < %s -instcombine -S | grep "store i8" | count 2 define i32 @a(i8* %s) nounwind { entry: diff --git a/test/Transforms/InstCombine/2008-06-21-CompareMiscomp.ll b/test/Transforms/InstCombine/2008-06-21-CompareMiscomp.ll index c3371c6ae73d..80bd83bc6ba0 100644 --- a/test/Transforms/InstCombine/2008-06-21-CompareMiscomp.ll +++ b/test/Transforms/InstCombine/2008-06-21-CompareMiscomp.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -instcombine -S | grep {icmp eq i32 %In, 15} +; RUN: opt < %s -instcombine -S | grep "icmp eq i32 %In, 15" ; PR2479 ; (See also PR1800.) diff --git a/test/Transforms/InstCombine/2008-06-24-StackRestore.ll b/test/Transforms/InstCombine/2008-06-24-StackRestore.ll index 4f4709b6f27a..9c4c1b538c4b 100644 --- a/test/Transforms/InstCombine/2008-06-24-StackRestore.ll +++ b/test/Transforms/InstCombine/2008-06-24-StackRestore.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -instcombine -S | grep {call.*llvm.stackrestore} +; RUN: opt < %s -instcombine -S | grep "call.*llvm.stackrestore" ; PR2488 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" target triple = "i386-pc-linux-gnu" diff --git a/test/Transforms/InstCombine/2008-07-08-ShiftOneAndOne.ll b/test/Transforms/InstCombine/2008-07-08-ShiftOneAndOne.ll index 8245b4d017b0..cfca72adf87d 100644 --- a/test/Transforms/InstCombine/2008-07-08-ShiftOneAndOne.ll +++ b/test/Transforms/InstCombine/2008-07-08-ShiftOneAndOne.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -instcombine -S | grep {icmp ne i32 \%a} +; RUN: opt < %s -instcombine -S | grep "icmp ne i32 \%a" ; PR2330 define i1 @foo(i32 %a) nounwind { diff --git a/test/Transforms/InstCombine/2008-07-08-SubAnd.ll b/test/Transforms/InstCombine/2008-07-08-SubAnd.ll index 009115966f58..a3d44cb2467a 100644 --- a/test/Transforms/InstCombine/2008-07-08-SubAnd.ll +++ b/test/Transforms/InstCombine/2008-07-08-SubAnd.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -instcombine -S | grep -v {i32 8} +; RUN: opt < %s -instcombine -S | grep -v "i32 8" ; PR2330 define i32 @a(i32 %a) nounwind { diff --git a/test/Transforms/InstCombine/2008-07-08-VolatileLoadMerge.ll b/test/Transforms/InstCombine/2008-07-08-VolatileLoadMerge.ll index 1ed53237aab3..dcf4befa8605 100644 --- a/test/Transforms/InstCombine/2008-07-08-VolatileLoadMerge.ll +++ b/test/Transforms/InstCombine/2008-07-08-VolatileLoadMerge.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -instcombine -S | grep {load volatile} | count 2 +; RUN: opt < %s -instcombine -S | grep "load volatile" | count 2 ; PR2496 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:128:128" target triple = "i386-apple-darwin8" diff --git a/test/Transforms/InstCombine/2008-07-09-SubAndError.ll b/test/Transforms/InstCombine/2008-07-09-SubAndError.ll index 47a7590076c7..ed0141403bbe 100644 --- a/test/Transforms/InstCombine/2008-07-09-SubAndError.ll +++ b/test/Transforms/InstCombine/2008-07-09-SubAndError.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -instcombine -S | not grep {sub i32 0} +; RUN: opt < %s -instcombine -S | not grep "sub i32 0" ; PR2330 define i32 @foo(i32 %a) nounwind { diff --git a/test/Transforms/InstCombine/2008-07-10-CastSextBool.ll b/test/Transforms/InstCombine/2008-07-10-CastSextBool.ll index e91153202519..786f0c55bbe2 100644 --- a/test/Transforms/InstCombine/2008-07-10-CastSextBool.ll +++ b/test/Transforms/InstCombine/2008-07-10-CastSextBool.ll @@ -1,5 +1,5 @@ -; RUN: opt < %s -instcombine -S | grep {%C = xor i1 %A, true} -; RUN: opt < %s -instcombine -S | grep {ret i1 false} +; RUN: opt < %s -instcombine -S | grep "%C = xor i1 %A, true" +; RUN: opt < %s -instcombine -S | grep "ret i1 false" ; PR2539 define i1 @test1(i1 %A) { diff --git a/test/Transforms/InstCombine/2008-07-13-DivZero.ll b/test/Transforms/InstCombine/2008-07-13-DivZero.ll index be1f8c294375..18c995428343 100644 --- a/test/Transforms/InstCombine/2008-07-13-DivZero.ll +++ b/test/Transforms/InstCombine/2008-07-13-DivZero.ll @@ -1,5 +1,5 @@ -; RUN: opt < %s -instcombine -S | grep {lshr.*3} -; RUN: opt < %s -instcombine -S | grep {call .*%cond} +; RUN: opt < %s -instcombine -S | grep "lshr.*3" +; RUN: opt < %s -instcombine -S | grep "call .*%cond" ; PR2506 ; We can simplify the operand of udiv to '8', but not the operand to the diff --git a/test/Transforms/InstCombine/2008-07-16-sse2_storel_dq.ll b/test/Transforms/InstCombine/2008-07-16-sse2_storel_dq.ll index 501d8a66c3e6..b469887ba25c 100644 --- a/test/Transforms/InstCombine/2008-07-16-sse2_storel_dq.ll +++ b/test/Transforms/InstCombine/2008-07-16-sse2_storel_dq.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -instcombine -S | not grep {store } +; RUN: opt < %s -instcombine -S | not grep "store " ; PR2296 @G = common global double 0.000000e+00, align 16 diff --git a/test/Transforms/InstCombine/2008-09-29-FoldingOr.ll b/test/Transforms/InstCombine/2008-09-29-FoldingOr.ll index 31ea94a5d832..4d00d495a07f 100644 --- a/test/Transforms/InstCombine/2008-09-29-FoldingOr.ll +++ b/test/Transforms/InstCombine/2008-09-29-FoldingOr.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -instcombine -S | grep {or i1} +; RUN: opt < %s -instcombine -S | grep "or i1" ; PR2844 define i32 @test(i32 %p_74) { diff --git a/test/Transforms/InstCombine/2008-10-11-DivCompareFold.ll b/test/Transforms/InstCombine/2008-10-11-DivCompareFold.ll index fd36d86a9484..cf29f8d9bf24 100644 --- a/test/Transforms/InstCombine/2008-10-11-DivCompareFold.ll +++ b/test/Transforms/InstCombine/2008-10-11-DivCompareFold.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -instcombine -S | grep {ret i1 false} +; RUN: opt < %s -instcombine -S | grep "ret i1 false" ; PR2697 define i1 @x(i32 %x) nounwind { diff --git a/test/Transforms/InstCombine/2008-11-01-SRemDemandedBits.ll b/test/Transforms/InstCombine/2008-11-01-SRemDemandedBits.ll index aa077e2ac3b3..679cc5f73d77 100644 --- a/test/Transforms/InstCombine/2008-11-01-SRemDemandedBits.ll +++ b/test/Transforms/InstCombine/2008-11-01-SRemDemandedBits.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -instcombine -S | grep {ret i1 true} +; RUN: opt < %s -instcombine -S | grep "ret i1 true" ; PR2993 define i1 @foo(i32 %x) { diff --git a/test/Transforms/InstCombine/2008-11-08-FCmp.ll b/test/Transforms/InstCombine/2008-11-08-FCmp.ll index c636288661b1..f33a1f59f61b 100644 --- a/test/Transforms/InstCombine/2008-11-08-FCmp.ll +++ b/test/Transforms/InstCombine/2008-11-08-FCmp.ll @@ -45,3 +45,12 @@ define i1 @test6(i32 %val) { ret i1 %2 ; CHECK: ret i1 false } + +; Check that optimizing unsigned >= comparisons correctly distinguishes +; positive and negative constants. <rdar://problem/12029145> +define i1 @test7(i32 %val) { + %1 = uitofp i32 %val to double + %2 = fcmp oge double %1, 3.200000e+00 + ret i1 %2 +; CHECK: icmp ugt i32 %val, 3 +} diff --git a/test/Transforms/InstCombine/2008-12-17-SRemNegConstVec.ll b/test/Transforms/InstCombine/2008-12-17-SRemNegConstVec.ll index e4c7ebcefc7e..75bd5e0175f9 100644 --- a/test/Transforms/InstCombine/2008-12-17-SRemNegConstVec.ll +++ b/test/Transforms/InstCombine/2008-12-17-SRemNegConstVec.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -instcombine -S | grep {i8 2, i8 2} +; RUN: opt < %s -instcombine -S | grep "i8 2, i8 2" ; PR2756 define <2 x i8> @foo(<2 x i8> %x) { diff --git a/test/Transforms/InstCombine/2009-01-08-AlignAlloca.ll b/test/Transforms/InstCombine/2009-01-08-AlignAlloca.ll index a61a94ecbf3a..50ea2f42b0ca 100644 --- a/test/Transforms/InstCombine/2009-01-08-AlignAlloca.ll +++ b/test/Transforms/InstCombine/2009-01-08-AlignAlloca.ll @@ -1,6 +1,6 @@ ; RUN: opt < %s -instcombine -S > %t -; RUN: grep {, align 4} %t | count 3 -; RUN: grep {, align 8} %t | count 3 +; RUN: grep ", align 4" %t | count 3 +; RUN: grep ", align 8" %t | count 3 ; rdar://6480438 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:128:128" target triple = "i386-apple-darwin9.6" diff --git a/test/Transforms/InstCombine/2009-01-16-PointerAddrSpace.ll b/test/Transforms/InstCombine/2009-01-16-PointerAddrSpace.ll index ce62f35c1035..949fc592203f 100644 --- a/test/Transforms/InstCombine/2009-01-16-PointerAddrSpace.ll +++ b/test/Transforms/InstCombine/2009-01-16-PointerAddrSpace.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -instcombine -S | grep {store.*addrspace(1)} +; RUN: opt < %s -instcombine -S | grep "store.*addrspace(1)" ; PR3335 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:128:128" target triple = "i386-apple-darwin9.6" diff --git a/test/Transforms/InstCombine/2009-01-19-fmod-constant-float-specials.ll b/test/Transforms/InstCombine/2009-01-19-fmod-constant-float-specials.ll index 142134791efe..68c51b43fc3a 100644 --- a/test/Transforms/InstCombine/2009-01-19-fmod-constant-float-specials.ll +++ b/test/Transforms/InstCombine/2009-01-19-fmod-constant-float-specials.ll @@ -1,6 +1,6 @@ ; RUN: opt < %s -simplifycfg -instcombine -S | grep 0x7FF8000000000000 | count 12 -; RUN: opt < %s -simplifycfg -instcombine -S | grep {0\\.0} | count 3 -; RUN: opt < %s -simplifycfg -instcombine -S | grep {3\\.5} | count 1 +; RUN: opt < %s -simplifycfg -instcombine -S | grep "0\.0" | count 3 +; RUN: opt < %s -simplifycfg -instcombine -S | grep "3\.5" | count 1 ; ; ModuleID = 'apf.c' diff --git a/test/Transforms/InstCombine/2009-01-31-Pressure.ll b/test/Transforms/InstCombine/2009-01-31-Pressure.ll index c3ee9a35ba39..666b02e8ed09 100644 --- a/test/Transforms/InstCombine/2009-01-31-Pressure.ll +++ b/test/Transforms/InstCombine/2009-01-31-Pressure.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -instcombine -S | grep {%B = add i8 %b, %x} +; RUN: opt < %s -instcombine -S | grep "%B = add i8 %b, %x" ; PR2698 declare void @use1(i1) diff --git a/test/Transforms/InstCombine/2009-02-20-InstCombine-SROA.ll b/test/Transforms/InstCombine/2009-02-20-InstCombine-SROA.ll index a51c47d42373..9146a8ee0117 100644 --- a/test/Transforms/InstCombine/2009-02-20-InstCombine-SROA.ll +++ b/test/Transforms/InstCombine/2009-02-20-InstCombine-SROA.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -instcombine -scalarrepl -S | not grep { = alloca} +; RUN: opt < %s -instcombine -scalarrepl -S | not grep " = alloca" ; rdar://6417724 ; Instcombine shouldn't do anything to this function that prevents promoting the allocas inside it. diff --git a/test/Transforms/InstCombine/2009-02-21-LoadCST.ll b/test/Transforms/InstCombine/2009-02-21-LoadCST.ll index f56fc388eb5b..cb8a77c23bac 100644 --- a/test/Transforms/InstCombine/2009-02-21-LoadCST.ll +++ b/test/Transforms/InstCombine/2009-02-21-LoadCST.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -instcombine -S | grep {ret i32 3679669} +; RUN: opt < %s -instcombine -S | grep "ret i32 3679669" ; PR3595 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" diff --git a/test/Transforms/InstCombine/2009-03-20-AShrOverShift.ll b/test/Transforms/InstCombine/2009-03-20-AShrOverShift.ll index 0a07bf34bac9..4d4797720c53 100644 --- a/test/Transforms/InstCombine/2009-03-20-AShrOverShift.ll +++ b/test/Transforms/InstCombine/2009-03-20-AShrOverShift.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -instcombine -S | grep {ashr i32 %val, 31} +; RUN: opt < %s -instcombine -S | grep "ashr i32 %val, 31" ; PR3851 define i32 @foo2(i32 %val) nounwind { diff --git a/test/Transforms/InstCombine/2009-04-07-MulPromoteToI96.ll b/test/Transforms/InstCombine/2009-04-07-MulPromoteToI96.ll index 244b22a14dec..b79edf66b261 100644 --- a/test/Transforms/InstCombine/2009-04-07-MulPromoteToI96.ll +++ b/test/Transforms/InstCombine/2009-04-07-MulPromoteToI96.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -instcombine -S | grep {mul i64} +; RUN: opt < %s -instcombine -S | grep "mul i64" ; rdar://6762288 ; Instcombine should not promote the mul to i96 because it is definitely diff --git a/test/Transforms/InstCombine/2009-06-11-StoreAddrSpace.ll b/test/Transforms/InstCombine/2009-06-11-StoreAddrSpace.ll index e5355b8d3c56..468c1cd8bbc4 100644 --- a/test/Transforms/InstCombine/2009-06-11-StoreAddrSpace.ll +++ b/test/Transforms/InstCombine/2009-06-11-StoreAddrSpace.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -instcombine -S | grep {store i32 0,} +; RUN: opt < %s -instcombine -S | grep "store i32 0," ; PR4366 define void @a() { diff --git a/test/Transforms/InstCombine/2010-11-01-lshr-mask.ll b/test/Transforms/InstCombine/2010-11-01-lshr-mask.ll index 441d5f9b0b64..eb2899475695 100644 --- a/test/Transforms/InstCombine/2010-11-01-lshr-mask.ll +++ b/test/Transforms/InstCombine/2010-11-01-lshr-mask.ll @@ -5,8 +5,8 @@ define i32 @main(i32 %argc) nounwind ssp { entry: %tmp3151 = trunc i32 %argc to i8 -; CHECK: %tmp3162 = shl i8 %tmp3151, 5 -; CHECK: and i8 %tmp3162, 64 +; CHECK: %tmp3163 = shl i8 %tmp3162, 6 +; CHECK: and i8 %tmp3163, 64 ; CHECK-NOT: shl ; CHECK-NOT: shr %tmp3161 = or i8 %tmp3151, -17 @@ -38,8 +38,8 @@ bb: %tmp10 = lshr i8 %tmp8, 7 %tmp11 = shl i8 %tmp10, 5 -; CHECK: %0 = lshr i8 %tmp8, 2 -; CHECK: %tmp11 = and i8 %0, 32 +; CHECK: %tmp10 = lshr i8 %tmp8, 7 +; CHECK: %tmp11 = shl nuw nsw i8 %tmp10, 5 %tmp12 = xor i8 %tmp11, %tmp9 ret i8 %tmp12 diff --git a/test/Transforms/InstCombine/2011-06-13-nsw-alloca.ll b/test/Transforms/InstCombine/2011-06-13-nsw-alloca.ll index 2f72b73801de..fedb46dd24ad 100644 --- a/test/Transforms/InstCombine/2011-06-13-nsw-alloca.ll +++ b/test/Transforms/InstCombine/2011-06-13-nsw-alloca.ll @@ -2,8 +2,10 @@ 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:128:128-n8:16:32" target triple = "i386-apple-darwin10.0.0" +; CHECK: define void @fu1 define void @fu1(i32 %parm) nounwind ssp { %1 = alloca i32, align 4 +; CHECK: alloca double* %ptr = alloca double*, align 4 store i32 %parm, i32* %1, align 4 store double* null, double** %ptr, align 4 @@ -16,12 +18,12 @@ define void @fu1(i32 %parm) nounwind ssp { %6 = mul nsw i32 %5, 8 ; With "nsw", the alloca and its bitcast can be fused: %7 = add nsw i32 %6, 2048 -; CHECK: alloca double* +; CHECK: alloca double %8 = alloca i8, i32 %7 %9 = bitcast i8* %8 to double* +; CHECK-NEXT: store double* store double* %9, double** %ptr, align 4 br label %10 - ; <label>:10 ; preds = %4, %0 %11 = load double** %ptr, align 4 call void @bar(double* %11) @@ -31,6 +33,7 @@ define void @fu1(i32 %parm) nounwind ssp { declare void @bar(double*) +; CHECK: define void @fu2 define void @fu2(i32 %parm) nounwind ssp { %1 = alloca i32, align 4 %ptr = alloca double*, align 4 diff --git a/test/Transforms/InstCombine/2012-04-23-Neon-Intrinsics.ll b/test/Transforms/InstCombine/2012-04-23-Neon-Intrinsics.ll new file mode 100644 index 000000000000..0907c490bb35 --- /dev/null +++ b/test/Transforms/InstCombine/2012-04-23-Neon-Intrinsics.ll @@ -0,0 +1,68 @@ +target datalayout = "e-p:32:32:32-i1:8:32-i8:8:32-i16:16:32-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:32:64-v128:32:128-a0:0:32-n32-S32" +target triple = "thumbv7-apple-ios0" + +; RUN: opt -S -instcombine < %s | FileCheck %s + +define <4 x i32> @mulByZero(<4 x i16> %x) nounwind readnone ssp { +entry: + %a = tail call <4 x i32> @llvm.arm.neon.vmulls.v4i32(<4 x i16> %x, <4 x i16> zeroinitializer) nounwind + ret <4 x i32> %a +; CHECK: entry: +; CHECK-NEXT: ret <4 x i32> zeroinitializer +} + +define <4 x i32> @mulByOne(<4 x i16> %x) nounwind readnone ssp { +entry: + %a = tail call <4 x i32> @llvm.arm.neon.vmulls.v4i32(<4 x i16> %x, <4 x i16> <i16 1, i16 1, i16 1, i16 1>) nounwind + ret <4 x i32> %a +; CHECK: entry: +; CHECK-NEXT: %a = sext <4 x i16> %x to <4 x i32> +; CHECK-NEXT: ret <4 x i32> %a +} + +define <4 x i32> @constantMul() nounwind readnone ssp { +entry: + %a = tail call <4 x i32> @llvm.arm.neon.vmulls.v4i32(<4 x i16> <i16 3, i16 3, i16 3, i16 3>, <4 x i16> <i16 2, i16 2, i16 2, i16 2>) nounwind + ret <4 x i32> %a +; CHECK: entry: +; CHECK-NEXT: ret <4 x i32> <i32 6, i32 6, i32 6, i32 6> +} + +define <4 x i32> @constantMulS() nounwind readnone ssp { +entry: + %b = tail call <4 x i32> @llvm.arm.neon.vmulls.v4i32(<4 x i16> <i16 -1, i16 -1, i16 -1, i16 -1>, <4 x i16> <i16 1, i16 1, i16 1, i16 1>) nounwind + ret <4 x i32> %b +; CHECK: entry: +; CHECK-NEXT: ret <4 x i32> <i32 -1, i32 -1, i32 -1, i32 -1> +} + +define <4 x i32> @constantMulU() nounwind readnone ssp { +entry: + %b = tail call <4 x i32> @llvm.arm.neon.vmullu.v4i32(<4 x i16> <i16 -1, i16 -1, i16 -1, i16 -1>, <4 x i16> <i16 1, i16 1, i16 1, i16 1>) nounwind + ret <4 x i32> %b +; CHECK: entry: +; CHECK-NEXT: ret <4 x i32> <i32 65535, i32 65535, i32 65535, i32 65535> +} + +define <4 x i32> @complex1(<4 x i16> %x) nounwind readnone ssp { +entry: + %a = tail call <4 x i32> @llvm.arm.neon.vmulls.v4i32(<4 x i16> <i16 2, i16 2, i16 2, i16 2>, <4 x i16> %x) nounwind + %b = add <4 x i32> zeroinitializer, %a + ret <4 x i32> %b +; CHECK: entry: +; CHECK-NEXT: %a = tail call <4 x i32> @llvm.arm.neon.vmulls.v4i32(<4 x i16> <i16 2, i16 2, i16 2, i16 2>, <4 x i16> %x) nounwind +; CHECK-NEXT: ret <4 x i32> %a +} + +define <4 x i32> @complex2(<4 x i32> %x) nounwind readnone ssp { +entry: + %a = tail call <4 x i32> @llvm.arm.neon.vmulls.v4i32(<4 x i16> <i16 3, i16 3, i16 3, i16 3>, <4 x i16> <i16 2, i16 2, i16 2, i16 2>) nounwind + %b = add <4 x i32> %x, %a + ret <4 x i32> %b +; CHECK: entry: +; CHECK-NEXT: %b = add <4 x i32> %x, <i32 6, i32 6, i32 6, i32 6> +; CHECK-NEXT: ret <4 x i32> %b +} + +declare <4 x i32> @llvm.arm.neon.vmulls.v4i32(<4 x i16>, <4 x i16>) nounwind readnone +declare <4 x i32> @llvm.arm.neon.vmullu.v4i32(<4 x i16>, <4 x i16>) nounwind readnone diff --git a/test/Transforms/InstCombine/2012-04-24-vselect.ll b/test/Transforms/InstCombine/2012-04-24-vselect.ll new file mode 100644 index 000000000000..8d2de2b2431c --- /dev/null +++ b/test/Transforms/InstCombine/2012-04-24-vselect.ll @@ -0,0 +1,13 @@ +; RUN: opt -instcombine -S < %s | FileCheck %s + +; CHECK: @foo +; CHECK: <i32 1, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0> + +define <8 x i32> @foo() nounwind { +entry: + %v1.i = select <8 x i1> <i1 true, i1 false, i1 false, i1 false, i1 false, i1 false, i1 false, i1 false>, + <8 x i32> <i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1>, + <8 x i32> <i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0> + ret <8 x i32> %v1.i +} + diff --git a/test/Transforms/InstCombine/2012-05-27-Negative-Shift-Crash.ll b/test/Transforms/InstCombine/2012-05-27-Negative-Shift-Crash.ll new file mode 100644 index 000000000000..2ec0a32ffcbf --- /dev/null +++ b/test/Transforms/InstCombine/2012-05-27-Negative-Shift-Crash.ll @@ -0,0 +1,61 @@ +; RUN: opt -inline -instcombine -S < %s +; PR12967 + +target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128" +target triple = "x86_64-apple-macosx10.7.0" + +@d = common global i32 0, align 4 +@c = common global i32 0, align 4 +@e = common global i32 0, align 4 +@f = common global i32 0, align 4 +@a = common global i32 0, align 4 +@b = common global i32 0, align 4 + +define signext i8 @fn1(i32 %p1) nounwind uwtable readnone ssp { +entry: + %shr = lshr i32 1, %p1 + %conv = trunc i32 %shr to i8 + ret i8 %conv +} + +define void @fn4() nounwind uwtable ssp { +entry: + %0 = load i32* @d, align 4, !tbaa !0 + %cmp = icmp eq i32 %0, 0 + %conv = zext i1 %cmp to i32 + store i32 %conv, i32* @c, align 4, !tbaa !0 + tail call void @fn3(i32 %conv) nounwind + ret void +} + +define void @fn3(i32 %p1) nounwind uwtable ssp { +entry: + %and = and i32 %p1, 8 + store i32 %and, i32* @e, align 4, !tbaa !0 + %sub = add nsw i32 %and, -1 + store i32 %sub, i32* @f, align 4, !tbaa !0 + %0 = load i32* @a, align 4, !tbaa !0 + %tobool = icmp eq i32 %0, 0 + br i1 %tobool, label %if.else, label %if.then + +if.then: ; preds = %entry + %1 = load i32* @b, align 4, !tbaa !0 + %.lobit = lshr i32 %1, 31 + %2 = trunc i32 %.lobit to i8 + %.not = xor i8 %2, 1 + br label %if.end + +if.else: ; preds = %entry + %call = tail call signext i8 @fn1(i32 %sub) nounwind + br label %if.end + +if.end: ; preds = %if.else, %if.then + %storemerge.in = phi i8 [ %call, %if.else ], [ %.not, %if.then ] + %storemerge = sext i8 %storemerge.in to i32 + store i32 %storemerge, i32* @b, align 4 + ret void +} + +!0 = metadata !{metadata !"int", metadata !1} +!1 = metadata !{metadata !"omnipotent char", metadata !2} +!2 = metadata !{metadata !"Simple C/C++ TBAA"} diff --git a/test/Transforms/InstCombine/2012-05-28-select-hang.ll b/test/Transforms/InstCombine/2012-05-28-select-hang.ll new file mode 100644 index 000000000000..c580bacb0dcb --- /dev/null +++ b/test/Transforms/InstCombine/2012-05-28-select-hang.ll @@ -0,0 +1,39 @@ +; RUN: opt -S -instcombine < %s | FileCheck %s + +@c = common global i8 0, align 1 +@a = common global i8 0, align 1 +@b = common global i8 0, align 1 + +define void @func() nounwind uwtable ssp { +entry: + %0 = load i8* @c, align 1 + %conv = zext i8 %0 to i32 + %or = or i32 %conv, 1 + %conv1 = trunc i32 %or to i8 + store i8 %conv1, i8* @a, align 1 + %conv2 = zext i8 %conv1 to i32 + %neg = xor i32 %conv2, -1 + %and = and i32 1, %neg + %conv3 = trunc i32 %and to i8 + store i8 %conv3, i8* @b, align 1 + %1 = load i8* @a, align 1 + %conv4 = zext i8 %1 to i32 + %conv5 = zext i8 %conv3 to i32 + %tobool = icmp ne i32 %conv4, 0 + br i1 %tobool, label %land.rhs, label %land.end + +land.rhs: ; preds = %entry + %tobool8 = icmp ne i32 %conv5, 0 + br label %land.end + +land.end: ; preds = %land.rhs, %entry + %2 = phi i1 [ false, %entry ], [ %tobool8, %land.rhs ] + %land.ext = zext i1 %2 to i32 + %mul = mul nsw i32 3, %land.ext + %conv9 = trunc i32 %mul to i8 + store i8 %conv9, i8* @a, align 1 + ret void + +; CHECK: @func +; CHECK-NOT: select +} diff --git a/test/Transforms/InstCombine/2012-06-06-LoadOfPHIs.ll b/test/Transforms/InstCombine/2012-06-06-LoadOfPHIs.ll new file mode 100644 index 000000000000..22466a96b667 --- /dev/null +++ b/test/Transforms/InstCombine/2012-06-06-LoadOfPHIs.ll @@ -0,0 +1,162 @@ +; RUN: opt < %s -instcombine -S | FileCheck %s +; <rdar://problem/10889741> + +define void @func(double %r, double %g, double %b, double* %outH, double* %outS, double* %outL) nounwind uwtable ssp { +bb: + %tmp = alloca double, align 8 + %tmp1 = alloca double, align 8 + %tmp2 = alloca double, align 8 + store double %r, double* %tmp, align 8 + store double %g, double* %tmp1, align 8 + store double %b, double* %tmp2, align 8 + %tmp3 = fcmp ogt double %r, %g + br i1 %tmp3, label %bb4, label %bb8 + +bb4: ; preds = %bb + %tmp5 = fcmp ogt double %r, %b + br i1 %tmp5, label %bb6, label %bb7 + +bb6: ; preds = %bb4 + br label %bb12 + +bb7: ; preds = %bb4 + br label %bb12 + +bb8: ; preds = %bb + %tmp9 = fcmp ogt double %g, %b + br i1 %tmp9, label %bb10, label %bb11 + +bb10: ; preds = %bb8 + br label %bb12 + +bb11: ; preds = %bb8 + br label %bb12 + +bb12: ; preds = %bb11, %bb10, %bb7, %bb6 + %max.0 = phi double* [ %tmp, %bb6 ], [ %tmp2, %bb7 ], [ %tmp1, %bb10 ], [ %tmp2, %bb11 ] +; CHECK: %tmp13 = load double* %tmp, align 8 +; CHECK: %tmp14 = load double* %tmp1, align 8 +; CHECK: %tmp15 = fcmp olt double %tmp13, %tmp14 + %tmp13 = load double* %tmp, align 8 + %tmp14 = load double* %tmp1, align 8 + %tmp15 = fcmp olt double %tmp13, %tmp14 + br i1 %tmp15, label %bb16, label %bb21 + +bb16: ; preds = %bb12 + %tmp17 = load double* %tmp2, align 8 + %tmp18 = fcmp olt double %tmp13, %tmp17 + br i1 %tmp18, label %bb19, label %bb20 + +bb19: ; preds = %bb16 + br label %bb26 + +bb20: ; preds = %bb16 + br label %bb26 + +bb21: ; preds = %bb12 + %tmp22 = load double* %tmp2, align 8 + %tmp23 = fcmp olt double %tmp14, %tmp22 + br i1 %tmp23, label %bb24, label %bb25 + +bb24: ; preds = %bb21 + br label %bb26 + +bb25: ; preds = %bb21 + br label %bb26 + +bb26: ; preds = %bb25, %bb24, %bb20, %bb19 + %min.0 = phi double* [ %tmp, %bb19 ], [ %tmp2, %bb20 ], [ %tmp1, %bb24 ], [ %tmp2, %bb25 ] +; CHECK: %tmp27 = load double* %min.0, align 8 +; CHECK: %tmp28 = load double* %max.0 +; CHECK: %tmp29 = fadd double %tmp27, %tmp28 + %tmp27 = load double* %min.0, align 8 + %tmp28 = load double* %max.0 + %tmp29 = fadd double %tmp27, %tmp28 + %tmp30 = fdiv double %tmp29, 2.000000e+00 + store double %tmp30, double* %outL + %tmp31 = load double* %min.0 + %tmp32 = load double* %max.0 + %tmp33 = fcmp oeq double %tmp31, %tmp32 + br i1 %tmp33, label %bb34, label %bb35 + +bb34: ; preds = %bb26 + store double 0.000000e+00, double* %outS + store double 0.000000e+00, double* %outH + br label %bb81 + +bb35: ; preds = %bb26 + %tmp36 = fcmp olt double %tmp30, 5.000000e-01 + %tmp37 = fsub double %tmp32, %tmp31 + br i1 %tmp36, label %bb38, label %bb41 + +bb38: ; preds = %bb35 + %tmp39 = fadd double %tmp32, %tmp31 + %tmp40 = fdiv double %tmp37, %tmp39 + store double %tmp40, double* %outS + br label %bb45 + +bb41: ; preds = %bb35 + %tmp42 = fsub double 2.000000e+00, %tmp32 + %tmp43 = fsub double %tmp42, %tmp31 + %tmp44 = fdiv double %tmp37, %tmp43 + store double %tmp44, double* %outS + br label %bb45 + +bb45: ; preds = %bb41, %bb38 + %tmp46 = icmp eq double* %max.0, %tmp + br i1 %tmp46, label %bb47, label %bb55 + +bb47: ; preds = %bb45 + %tmp48 = load double* %tmp1, align 8 + %tmp49 = load double* %tmp2, align 8 + %tmp50 = fsub double %tmp48, %tmp49 + %tmp51 = load double* %max.0 + %tmp52 = load double* %min.0 + %tmp53 = fsub double %tmp51, %tmp52 + %tmp54 = fdiv double %tmp50, %tmp53 + store double %tmp54, double* %outH + br label %bb75 + +bb55: ; preds = %bb45 + %tmp56 = icmp eq double* %max.0, %tmp1 + br i1 %tmp56, label %bb57, label %bb66 + +bb57: ; preds = %bb55 + %tmp58 = load double* %tmp2, align 8 + %tmp59 = load double* %tmp, align 8 + %tmp60 = fsub double %tmp58, %tmp59 + %tmp61 = load double* %max.0 + %tmp62 = load double* %min.0 + %tmp63 = fsub double %tmp61, %tmp62 + %tmp64 = fdiv double %tmp60, %tmp63 + %tmp65 = fadd double 2.000000e+00, %tmp64 + store double %tmp65, double* %outH + br label %bb75 + +bb66: ; preds = %bb55 + %tmp67 = load double* %tmp, align 8 + %tmp68 = load double* %tmp1, align 8 + %tmp69 = fsub double %tmp67, %tmp68 + %tmp70 = load double* %max.0 + %tmp71 = load double* %min.0 + %tmp72 = fsub double %tmp70, %tmp71 + %tmp73 = fdiv double %tmp69, %tmp72 + %tmp74 = fadd double 4.000000e+00, %tmp73 + store double %tmp74, double* %outH + br label %bb75 + +bb75: ; preds = %bb66, %bb57, %bb47 + %tmp76 = load double* %outH + %tmp77 = fdiv double %tmp76, 6.000000e+00 + store double %tmp77, double* %outH + %tmp78 = fcmp olt double %tmp77, 0.000000e+00 + br i1 %tmp78, label %bb79, label %bb81 + +bb79: ; preds = %bb75 + %tmp80 = fadd double %tmp77, 1.000000e+00 + store double %tmp80, double* %outH + br label %bb81 + +bb81: ; preds = %bb79, %bb75, %bb34 + ret void +} diff --git a/test/Transforms/InstCombine/2012-07-25-LoadPart.ll b/test/Transforms/InstCombine/2012-07-25-LoadPart.ll new file mode 100644 index 000000000000..73e5a6653e80 --- /dev/null +++ b/test/Transforms/InstCombine/2012-07-25-LoadPart.ll @@ -0,0 +1,12 @@ +; RUN: opt < %s -instcombine -S | FileCheck %s +; PR13442 + +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-S128" + +@test = constant [4 x i32] [i32 1, i32 2, i32 3, i32 4] + +define i64 @foo() { + %ret = load i64* bitcast (i8* getelementptr (i8* bitcast ([4 x i32]* @test to i8*), i64 2) to i64*), align 1 + ret i64 %ret + ; CHECK: ret i64 844424930263040 +} diff --git a/test/Transforms/InstCombine/2012-07-30-addrsp-bitcast.ll b/test/Transforms/InstCombine/2012-07-30-addrsp-bitcast.ll new file mode 100644 index 000000000000..6f3df5b2fd99 --- /dev/null +++ b/test/Transforms/InstCombine/2012-07-30-addrsp-bitcast.ll @@ -0,0 +1,10 @@ +; RUN: opt < %s -instcombine -S | FileCheck %s +; CHECK: bitcast + +@base = internal addrspace(3) unnamed_addr global [16 x i32] zeroinitializer, align 16 +declare void @foo(i32*) + +define void @test() nounwind { + call void @foo(i32* getelementptr (i32* bitcast ([16 x i32] addrspace(3)* @base to i32*), i64 2147483647)) nounwind + ret void +} diff --git a/test/Transforms/InstCombine/2012-6-7-vselect-bitcast.ll b/test/Transforms/InstCombine/2012-6-7-vselect-bitcast.ll new file mode 100644 index 000000000000..cb527f864068 --- /dev/null +++ b/test/Transforms/InstCombine/2012-6-7-vselect-bitcast.ll @@ -0,0 +1,11 @@ +; RUN: opt < %s -instcombine -S | FileCheck %s +; CHECK: bitcast + +define void @foo(<16 x i8> %a, <16 x i8> %b, <4 x i32>* %c) { + %aa = bitcast <16 x i8> %a to <4 x i32> + %bb = bitcast <16 x i8> %b to <4 x i32> + %select_v = select <4 x i1> zeroinitializer, <4 x i32> %aa, <4 x i32> %bb + store <4 x i32> %select_v, <4 x i32>* %c, align 4 + ret void +} + diff --git a/test/Transforms/InstCombine/CPP_min_max.ll b/test/Transforms/InstCombine/CPP_min_max.ll index 531ce2b07b30..b3d081b613a6 100644 --- a/test/Transforms/InstCombine/CPP_min_max.ll +++ b/test/Transforms/InstCombine/CPP_min_max.ll @@ -1,5 +1,5 @@ ; RUN: opt < %s -instcombine -S | \ -; RUN: grep select | not grep {i32\\*} +; RUN: grep select | not grep 'i32\*' ; This testcase corresponds to PR362, which notices that this horrible code ; is generated by the C++ front-end and LLVM optimizers, which has lots of diff --git a/test/Transforms/InstCombine/JavaCompare.ll b/test/Transforms/InstCombine/JavaCompare.ll index 46b6c19f9a5b..8c1f307c79c0 100644 --- a/test/Transforms/InstCombine/JavaCompare.ll +++ b/test/Transforms/InstCombine/JavaCompare.ll @@ -1,7 +1,7 @@ ; This is the sequence of stuff that the Java front-end expands for a single ; <= comparison. Check to make sure we turn it into a <= (only) -; RUN: opt < %s -instcombine -S | grep {icmp sle i32 %A, %B} +; RUN: opt < %s -instcombine -S | grep "icmp sle i32 %A, %B" define i1 @le(i32 %A, i32 %B) { %c1 = icmp sgt i32 %A, %B ; <i1> [#uses=1] diff --git a/test/Transforms/InstCombine/add-shrink.ll b/test/Transforms/InstCombine/add-shrink.ll index cc5747866311..3edb392ed184 100644 --- a/test/Transforms/InstCombine/add-shrink.ll +++ b/test/Transforms/InstCombine/add-shrink.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -instcombine -S | grep {add nsw i32} +; RUN: opt < %s -instcombine -S | grep "add nsw i32" ; RUN: opt < %s -instcombine -S | grep sext | count 1 ; Should only have one sext and the add should be i32 instead of i64. diff --git a/test/Transforms/InstCombine/add-sitofp.ll b/test/Transforms/InstCombine/add-sitofp.ll index 98a8cb452a6c..40edf7114a06 100644 --- a/test/Transforms/InstCombine/add-sitofp.ll +++ b/test/Transforms/InstCombine/add-sitofp.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -instcombine -S | grep {add nsw i32} +; RUN: opt < %s -instcombine -S | grep "add nsw i32" define double @x(i32 %a, i32 %b) nounwind { %m = lshr i32 %a, 24 diff --git a/test/Transforms/InstCombine/addnegneg.ll b/test/Transforms/InstCombine/addnegneg.ll index a3a09f27ed95..ad8791d1e7ee 100644 --- a/test/Transforms/InstCombine/addnegneg.ll +++ b/test/Transforms/InstCombine/addnegneg.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -instcombine -S | grep { sub } | count 1 +; RUN: opt < %s -instcombine -S | grep " sub " | count 1 ; PR2047 define i32 @l(i32 %a, i32 %b, i32 %c, i32 %d) { diff --git a/test/Transforms/InstCombine/adjust-for-sminmax.ll b/test/Transforms/InstCombine/adjust-for-sminmax.ll index b9b6f702eb62..1fb719382166 100644 --- a/test/Transforms/InstCombine/adjust-for-sminmax.ll +++ b/test/Transforms/InstCombine/adjust-for-sminmax.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -instcombine -S | grep {icmp s\[lg\]t i32 %n, 0} | count 16 +; RUN: opt < %s -instcombine -S | grep "icmp s[lg]t i32 %n, 0" | count 16 ; Instcombine should recognize that this code can be adjusted ; to fit the canonical smax/smin pattern. diff --git a/test/Transforms/InstCombine/align-2d-gep.ll b/test/Transforms/InstCombine/align-2d-gep.ll index eeca5c0b1f61..5bca46d5a21d 100644 --- a/test/Transforms/InstCombine/align-2d-gep.ll +++ b/test/Transforms/InstCombine/align-2d-gep.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -instcombine -S | grep {align 16} | count 1 +; RUN: opt < %s -instcombine -S | grep "align 16" | count 1 target datalayout = "E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128" ; A multi-dimensional array in a nested loop doing vector stores that diff --git a/test/Transforms/InstCombine/alloca.ll b/test/Transforms/InstCombine/alloca.ll index ef7185cc81e0..50e03479f650 100644 --- a/test/Transforms/InstCombine/alloca.ll +++ b/test/Transforms/InstCombine/alloca.ll @@ -5,8 +5,11 @@ target datalayout = "E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:1 declare void @use(...) -; Zero byte allocas should be deleted. +@int = global i32 zeroinitializer + +; Zero byte allocas should be merged if they can't be deleted. ; CHECK: @test +; CHECK: alloca ; CHECK-NOT: alloca define void @test() { %X = alloca [0 x i32] ; <[0 x i32]*> [#uses=1] @@ -15,6 +18,9 @@ define void @test() { call void (...)* @use( i32* %Y ) %Z = alloca { } ; <{ }*> [#uses=1] call void (...)* @use( { }* %Z ) + %size = load i32* @int + %A = alloca {{}}, i32 %size + call void (...)* @use( {{}}* %A ) ret void } diff --git a/test/Transforms/InstCombine/and-fcmp.ll b/test/Transforms/InstCombine/and-fcmp.ll index 91868d1d0759..838c2f73fb91 100644 --- a/test/Transforms/InstCombine/and-fcmp.ll +++ b/test/Transforms/InstCombine/and-fcmp.ll @@ -1,5 +1,4 @@ -; RUN: opt < %s -instcombine -S | grep fcmp | count 3 -; RUN: opt < %s -instcombine -S | grep ret | grep 0 +; RUN: opt < %s -instcombine -S | FileCheck %s define zeroext i8 @t1(float %x, float %y) nounwind { %a = fcmp ueq float %x, %y @@ -7,6 +6,11 @@ define zeroext i8 @t1(float %x, float %y) nounwind { %c = and i1 %a, %b %retval = zext i1 %c to i8 ret i8 %retval +; CHECK: t1 +; CHECK: fcmp oeq float %x, %y +; CHECK-NOT: fcmp ueq float %x, %y +; CHECK-NOT: fcmp ord float %x, %y +; CHECK-NOW: and } define zeroext i8 @t2(float %x, float %y) nounwind { @@ -15,6 +19,10 @@ define zeroext i8 @t2(float %x, float %y) nounwind { %c = and i1 %a, %b %retval = zext i1 %c to i8 ret i8 %retval +; CHECK: t2 +; CHECK: fcmp olt float %x, %y +; CHECK-NOT: fcmp ord float %x, %y +; CHECK-NOT: and } define zeroext i8 @t3(float %x, float %y) nounwind { @@ -23,6 +31,8 @@ define zeroext i8 @t3(float %x, float %y) nounwind { %c = and i1 %a, %b %retval = zext i1 %c to i8 ret i8 %retval +; CHECK: t3 +; CHECK: ret i8 0 } define zeroext i8 @t4(float %x, float %y) nounwind { @@ -31,4 +41,39 @@ define zeroext i8 @t4(float %x, float %y) nounwind { %c = and i1 %a, %b %retval = zext i1 %c to i8 ret i8 %retval +; CHECK: t4 +; CHECK: fcmp one float %y, %x +; CHECK-NOT: fcmp ord float %x, %y +; CHECK-NOT: and +} + +define zeroext i8 @t5(float %x, float %y) nounwind { + %a = fcmp ord float %x, %y + %b = fcmp uno float %x, %y + %c = and i1 %a, %b + %retval = zext i1 %c to i8 + ret i8 %retval +; CHECK: t5 +; CHECK: ret i8 0 +} + +define zeroext i8 @t6(float %x, float %y) nounwind { + %a = fcmp uno float %x, %y + %b = fcmp ord float %x, %y + %c = and i1 %a, %b + %retval = zext i1 %c to i8 + ret i8 %retval +; CHECK: t6 +; CHECK: ret i8 0 +} + +define zeroext i8 @t7(float %x, float %y) nounwind { + %a = fcmp uno float %x, %y + %b = fcmp ult float %x, %y + %c = and i1 %a, %b + %retval = zext i1 %c to i8 + ret i8 %retval +; CHECK: t7 +; CHECK: fcmp uno +; CHECK-NOT: fcmp ult } diff --git a/test/Transforms/InstCombine/and-not-or.ll b/test/Transforms/InstCombine/and-not-or.ll index 9dce7b4e6fb3..a42140be2805 100644 --- a/test/Transforms/InstCombine/and-not-or.ll +++ b/test/Transforms/InstCombine/and-not-or.ll @@ -1,5 +1,5 @@ -; RUN: opt < %s -instcombine -S | grep {and i32 %x, %y} | count 4 -; RUN: opt < %s -instcombine -S | not grep {or} +; RUN: opt < %s -instcombine -S | grep "and i32 %x, %y" | count 4 +; RUN: opt < %s -instcombine -S | not grep "or" define i32 @func1(i32 %x, i32 %y) nounwind { entry: diff --git a/test/Transforms/InstCombine/and-or-and.ll b/test/Transforms/InstCombine/and-or-and.ll index 216cd46775a5..34cad82f4f19 100644 --- a/test/Transforms/InstCombine/and-or-and.ll +++ b/test/Transforms/InstCombine/and-or-and.ll @@ -10,7 +10,7 @@ ; Which corresponds to test1. ; RUN: opt < %s -instcombine -S | \ -; RUN: not grep {or } +; RUN: not grep "or " define i32 @test1(i32 %X, i32 %Y) { %A = and i32 %X, 7 ; <i32> [#uses=1] diff --git a/test/Transforms/InstCombine/and-or-not.ll b/test/Transforms/InstCombine/and-or-not.ll index bd878b04a350..cc661d50c896 100644 --- a/test/Transforms/InstCombine/and-or-not.ll +++ b/test/Transforms/InstCombine/and-or-not.ll @@ -1,6 +1,6 @@ ; RUN: opt < %s -instcombine -S | grep xor | count 4 ; RUN: opt < %s -instcombine -S | not grep and -; RUN: opt < %s -instcombine -S | not grep { or} +; RUN: opt < %s -instcombine -S | not grep " or" ; PR1510 diff --git a/test/Transforms/InstCombine/and-or.ll b/test/Transforms/InstCombine/and-or.ll index b4224b38b1c2..0ae12a36c2b8 100644 --- a/test/Transforms/InstCombine/and-or.ll +++ b/test/Transforms/InstCombine/and-or.ll @@ -1,5 +1,5 @@ -; RUN: opt < %s -instcombine -S | grep {and i32 %a, 1} | count 4 -; RUN: opt < %s -instcombine -S | grep {or i32 %0, %b} | count 4 +; RUN: opt < %s -instcombine -S | grep "and i32 %a, 1" | count 4 +; RUN: opt < %s -instcombine -S | grep "or i32 %0, %b" | count 4 define i32 @func1(i32 %a, i32 %b) nounwind readnone { diff --git a/test/Transforms/InstCombine/and-xor-or.ll b/test/Transforms/InstCombine/and-xor-or.ll new file mode 100644 index 000000000000..7ff810b6eeec --- /dev/null +++ b/test/Transforms/InstCombine/and-xor-or.ll @@ -0,0 +1,24 @@ +; RUN: opt < %s -instcombine -S | FileCheck %s + +; rdar://10770603 +; (x & y) | (x ^ y) -> x | y +define i64 @or(i64 %x, i64 %y) nounwind uwtable readnone ssp { + %1 = and i64 %y, %x + %2 = xor i64 %y, %x + %3 = add i64 %1, %2 + ret i64 %3 +; CHECK: @or +; CHECK: or i64 +; CHECK-NEXT: ret +} + +; (x & y) + (x ^ y) -> x | y +define i64 @or2(i64 %x, i64 %y) nounwind uwtable readnone ssp { + %1 = and i64 %y, %x + %2 = xor i64 %y, %x + %3 = or i64 %1, %2 + ret i64 %3 +; CHECK: @or2 +; CHECK: or i64 +; CHECK-NEXT: ret +} diff --git a/test/Transforms/InstCombine/apint-and-or-and.ll b/test/Transforms/InstCombine/apint-and-or-and.ll index 17d29b601e69..43536d72e9ba 100644 --- a/test/Transforms/InstCombine/apint-and-or-and.ll +++ b/test/Transforms/InstCombine/apint-and-or-and.ll @@ -11,7 +11,7 @@ ; ; This tests arbitrary precision integers. -; RUN: opt < %s -instcombine -S | not grep {or } +; RUN: opt < %s -instcombine -S | not grep "or " ; END. define i17 @test1(i17 %X, i17 %Y) { diff --git a/test/Transforms/InstCombine/apint-and1.ll b/test/Transforms/InstCombine/apint-and1.ll index cd4cbb9cf454..fcd2dcd23ad1 100644 --- a/test/Transforms/InstCombine/apint-and1.ll +++ b/test/Transforms/InstCombine/apint-and1.ll @@ -1,7 +1,7 @@ ; This test makes sure that and instructions are properly eliminated. ; This test is for Integer BitWidth <= 64 && BitWidth % 8 != 0. -; RUN: opt < %s -instcombine -S | not grep {and } +; RUN: opt < %s -instcombine -S | not grep "and " ; END. define i39 @test0(i39 %A) { diff --git a/test/Transforms/InstCombine/apint-and2.ll b/test/Transforms/InstCombine/apint-and2.ll index ae74472b3d08..78dc8f990d08 100644 --- a/test/Transforms/InstCombine/apint-and2.ll +++ b/test/Transforms/InstCombine/apint-and2.ll @@ -1,7 +1,7 @@ ; This test makes sure that and instructions are properly eliminated. ; This test is for Integer BitWidth > 64 && BitWidth <= 1024. -; RUN: opt < %s -instcombine -S | not grep {and } +; RUN: opt < %s -instcombine -S | not grep "and " ; END. diff --git a/test/Transforms/InstCombine/apint-shift-simplify.ll b/test/Transforms/InstCombine/apint-shift-simplify.ll index 1a3340ac5667..818ae6659b26 100644 --- a/test/Transforms/InstCombine/apint-shift-simplify.ll +++ b/test/Transforms/InstCombine/apint-shift-simplify.ll @@ -1,5 +1,5 @@ ; RUN: opt < %s -instcombine -S | \ -; RUN: egrep {shl|lshr|ashr} | count 3 +; RUN: egrep "shl|lshr|ashr" | count 3 define i41 @test0(i41 %A, i41 %B, i41 %C) { %X = shl i41 %A, %C diff --git a/test/Transforms/InstCombine/apint-shift.ll b/test/Transforms/InstCombine/apint-shift.ll index 0ea73a058c05..73f630ebfec6 100644 --- a/test/Transforms/InstCombine/apint-shift.ll +++ b/test/Transforms/InstCombine/apint-shift.ll @@ -47,13 +47,21 @@ define i32 @test5a(i32 %A) { } ; CHECK: @test6 -; CHECK-NOT: sh +; CHECK: mul i55 %A, 6 define i55 @test6(i55 %A) { %B = shl i55 %A, 1 ; <i55> [#uses=1] %C = mul i55 %B, 3 ; <i55> [#uses=1] ret i55 %C } +; CHECK: @test6a +; CHECK: mul i55 %A, 6 +define i55 @test6a(i55 %A) { + %B = mul i55 %A, 3 ; <i55> [#uses=1] + %C = shl i55 %B, 1 ; <i55> [#uses=1] + ret i55 %C +} + ; CHECK: @test7 ; CHECK-NOT: sh define i29 @test7(i8 %X) { @@ -87,7 +95,8 @@ define i19 @test10(i19 %A) { } ; CHECK: @test11 -; CHECK-NOT: sh +; Don't hide the shl from scalar evolution. DAGCombine will get it. +; CHECK: shl define i23 @test11(i23 %A) { %a = mul i23 %A, 3 ; <i23> [#uses=1] %B = lshr i23 %a, 11 ; <i23> [#uses=1] @@ -104,7 +113,8 @@ define i47 @test12(i47 %A) { } ; CHECK: @test13 -; CHECK-NOT: sh +; Don't hide the shl from scalar evolution. DAGCombine will get it. +; CHECK: shl define i18 @test13(i18 %A) { %a = mul i18 %A, 3 ; <i18> [#uses=1] %B = ashr i18 %a, 8 ; <i18> [#uses=1] diff --git a/test/Transforms/InstCombine/apint-sub.ll b/test/Transforms/InstCombine/apint-sub.ll index 8b9ff143ea4e..df8ec52b5abd 100644 --- a/test/Transforms/InstCombine/apint-sub.ll +++ b/test/Transforms/InstCombine/apint-sub.ll @@ -3,7 +3,7 @@ ; ; RUN: opt < %s -instcombine -S | \ -; RUN: grep -v {sub i19 %Cok, %Bok} | grep -v {sub i25 0, %Aok} | not grep sub +; RUN: grep -v "sub i19 %Cok, %Bok" | grep -v "sub i25 0, %Aok" | not grep sub ; END. define i23 @test1(i23 %A) { diff --git a/test/Transforms/InstCombine/apint-xor1.ll b/test/Transforms/InstCombine/apint-xor1.ll index 849c65983328..01cbcf158cd9 100644 --- a/test/Transforms/InstCombine/apint-xor1.ll +++ b/test/Transforms/InstCombine/apint-xor1.ll @@ -1,7 +1,7 @@ ; This test makes sure that xor instructions are properly eliminated. ; This test is for Integer BitWidth <= 64 && BitWidth % 8 != 0. -; RUN: opt < %s -instcombine -S | not grep {xor } +; RUN: opt < %s -instcombine -S | not grep "xor " define i47 @test1(i47 %A, i47 %B) { diff --git a/test/Transforms/InstCombine/apint-xor2.ll b/test/Transforms/InstCombine/apint-xor2.ll index cacc17958eb9..ab93c9238152 100644 --- a/test/Transforms/InstCombine/apint-xor2.ll +++ b/test/Transforms/InstCombine/apint-xor2.ll @@ -1,7 +1,7 @@ ; This test makes sure that xor instructions are properly eliminated. ; This test is for Integer BitWidth > 64 && BitWidth <= 1024. -; RUN: opt < %s -instcombine -S | not grep {xor } +; RUN: opt < %s -instcombine -S | not grep "xor " ; END. diff --git a/test/Transforms/InstCombine/badmalloc.ll b/test/Transforms/InstCombine/badmalloc.ll index f5a623dc77cd..3abe28aede5d 100644 --- a/test/Transforms/InstCombine/badmalloc.ll +++ b/test/Transforms/InstCombine/badmalloc.ll @@ -16,5 +16,26 @@ define i1 @test1() { ret i1 %B ; CHECK: @test1 -; CHECK: ret i1 %B +; CHECK: ret i1 false +} + +; CHECK: @test2 +define noalias i8* @test2() nounwind { +entry: +; CHECK: @malloc + %A = call noalias i8* @malloc(i64 4) nounwind +; CHECK: icmp eq + %tobool = icmp eq i8* %A, null +; CHECK: br i1 + br i1 %tobool, label %return, label %if.end + +if.end: +; CHECK: store + store i8 7, i8* %A + br label %return + +return: +; CHECK: phi + %retval.0 = phi i8* [ %A, %if.end ], [ null, %entry ] + ret i8* %retval.0 } diff --git a/test/Transforms/InstCombine/bit-checks.ll b/test/Transforms/InstCombine/bit-checks.ll index 79a096ff0f19..62c9ddc8c3aa 100644 --- a/test/Transforms/InstCombine/bit-checks.ll +++ b/test/Transforms/InstCombine/bit-checks.ll @@ -1,7 +1,7 @@ ; This test makes sure that these instructions are properly eliminated. ; ; RUN: opt < %s -instcombine -S | \ -; RUN: not grep {tobool} +; RUN: not grep "tobool" ; END. define i32 @main(i32 %argc, i8** %argv) nounwind ssp { entry: diff --git a/test/Transforms/InstCombine/bitcount.ll b/test/Transforms/InstCombine/bitcount.ll index a6fd83742c28..318ca7339f1a 100644 --- a/test/Transforms/InstCombine/bitcount.ll +++ b/test/Transforms/InstCombine/bitcount.ll @@ -1,5 +1,5 @@ ; Tests to make sure bit counts of constants are folded -; RUN: opt < %s -instcombine -S | grep {ret i32 19} +; RUN: opt < %s -instcombine -S | grep "ret i32 19" ; RUN: opt < %s -instcombine -S | \ ; RUN: grep -v declare | not grep llvm.ct diff --git a/test/Transforms/InstCombine/bittest.ll b/test/Transforms/InstCombine/bittest.ll index 92863d59470a..84ee7dd602d5 100644 --- a/test/Transforms/InstCombine/bittest.ll +++ b/test/Transforms/InstCombine/bittest.ll @@ -1,5 +1,5 @@ ; RUN: opt < %s -instcombine -simplifycfg -S |\ -; RUN: not grep {call void @abort} +; RUN: not grep "call void @abort" @b_rec.0 = external global i32 ; <i32*> [#uses=2] diff --git a/test/Transforms/InstCombine/bswap.ll b/test/Transforms/InstCombine/bswap.ll index 168b3e83330d..ba7df3125f4e 100644 --- a/test/Transforms/InstCombine/bswap.ll +++ b/test/Transforms/InstCombine/bswap.ll @@ -1,7 +1,7 @@ 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:128:128-n8:16:32" ; RUN: opt < %s -instcombine -S | \ -; RUN: grep {call.*llvm.bswap} | count 6 +; RUN: grep "call.*llvm.bswap" | count 6 define i32 @test1(i32 %i) { %tmp1 = lshr i32 %i, 24 ; <i32> [#uses=1] diff --git a/test/Transforms/InstCombine/cast.ll b/test/Transforms/InstCombine/cast.ll index 19d5a0ae772d..56e5ca3ff720 100644 --- a/test/Transforms/InstCombine/cast.ll +++ b/test/Transforms/InstCombine/cast.ll @@ -457,10 +457,12 @@ define i64 @test50(i64 %A) { %E = sext i32 %D to i64 ret i64 %E ; CHECK: @test50 -; CHECK-NEXT: shl i64 %A, 30 +; lshr+shl will be handled by DAGCombine. +; CHECK-NEXT: lshr i64 %A, 2 +; CHECK-NEXT: shl i64 %a, 32 ; CHECK-NEXT: add i64 {{.*}}, -4294967296 -; CHECK-NEXT: %sext = ashr i64 {{.*}}, 32 -; CHECK-NEXT: ret i64 %sext +; CHECK-NEXT: %E = ashr exact i64 {{.*}}, 32 +; CHECK-NEXT: ret i64 %E } define i64 @test51(i64 %A, i1 %cond) { @@ -677,3 +679,18 @@ define i64 @test_mmx_const(<2 x i32> %c) nounwind { ; CHECK: @test_mmx_const ; CHECK-NOT: x86_mmx } + +; PR12514 +define i1 @test67(i1 %a, i32 %b) { + %tmp2 = zext i1 %a to i32 + %conv6 = xor i32 %tmp2, 1 + %and = and i32 %b, %conv6 + %sext = shl nuw nsw i32 %and, 24 + %neg.i = xor i32 %sext, -16777216 + %conv.i.i = ashr exact i32 %neg.i, 24 + %trunc = trunc i32 %conv.i.i to i8 + %tobool.i = icmp eq i8 %trunc, 0 + ret i1 %tobool.i +; CHECK: @test67 +; CHECK: ret i1 false +} diff --git a/test/Transforms/InstCombine/crash.ll b/test/Transforms/InstCombine/crash.ll index d5af5321dec3..2ef6ac64c7f3 100644 --- a/test/Transforms/InstCombine/crash.ll +++ b/test/Transforms/InstCombine/crash.ll @@ -132,12 +132,14 @@ define i32 @test5a() { } define void @test5() { - store i1 true, i1* undef - %1 = invoke i32 @test5a() to label %exit unwind label %exit + store i1 true, i1* undef + %r = invoke i32 @test5a() to label %exit unwind label %unwind +unwind: + %exn = landingpad {i8*, i32} personality i32 (...)* @__gxx_personality_v0 + cleanup + br label %exit exit: - %exn = landingpad {i8*, i32} personality i32 (...)* @__gxx_personality_v0 - cleanup - ret void + ret void } diff --git a/test/Transforms/InstCombine/dce-iterate.ll b/test/Transforms/InstCombine/dce-iterate.ll index 1d2cc53210fe..1dd452254101 100644 --- a/test/Transforms/InstCombine/dce-iterate.ll +++ b/test/Transforms/InstCombine/dce-iterate.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -instcombine -S | grep {ret double .sy} +; RUN: opt < %s -instcombine -S | grep "ret double .sy" define internal double @ScaleObjectAdd(double %sx, double %sy, double %sz) nounwind { entry: diff --git a/test/Transforms/InstCombine/deadcode.ll b/test/Transforms/InstCombine/deadcode.ll index 7c7f1abc0ca6..8fe673d8c9c0 100644 --- a/test/Transforms/InstCombine/deadcode.ll +++ b/test/Transforms/InstCombine/deadcode.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -instcombine -S | grep {ret i32 %A} +; RUN: opt < %s -instcombine -S | grep "ret i32 %A" ; RUN: opt < %s -die -S | not grep call.*llvm define i32 @test(i32 %A) { diff --git a/test/Transforms/InstCombine/div-shift.ll b/test/Transforms/InstCombine/div-shift.ll new file mode 100644 index 000000000000..a07f3ea94914 --- /dev/null +++ b/test/Transforms/InstCombine/div-shift.ll @@ -0,0 +1,23 @@ +; RUN: opt < %s -instcombine -S | FileCheck %s + +define i32 @t1(i16 zeroext %x, i32 %y) nounwind { +entry: +; CHECK: t1 +; CHECK-NOT: sdiv +; CHECK: lshr i32 %conv + %conv = zext i16 %x to i32 + %s = shl i32 2, %y + %d = sdiv i32 %conv, %s + ret i32 %d +} + +; rdar://11721329 +define i64 @t2(i64 %x, i32 %y) nounwind { +; CHECK: t2 +; CHECK-NOT: udiv +; CHECK: lshr i64 %x + %1 = shl i32 1, %y + %2 = zext i32 %1 to i64 + %3 = udiv i64 %x, %2 + ret i64 %3 +} diff --git a/test/Transforms/InstCombine/enforce-known-alignment.ll b/test/Transforms/InstCombine/enforce-known-alignment.ll index 9e9be7f56575..6645d99035fa 100644 --- a/test/Transforms/InstCombine/enforce-known-alignment.ll +++ b/test/Transforms/InstCombine/enforce-known-alignment.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -instcombine -S | grep alloca | grep {align 16} +; RUN: opt < %s -instcombine -S | grep alloca | grep "align 16" 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:128:128" target triple = "i386-apple-darwin9.6" diff --git a/test/Transforms/InstCombine/fp-ret-bitcast.ll b/test/Transforms/InstCombine/fp-ret-bitcast.ll index 35ece426617c..b2fbc0b882db 100644 --- a/test/Transforms/InstCombine/fp-ret-bitcast.ll +++ b/test/Transforms/InstCombine/fp-ret-bitcast.ll @@ -1,5 +1,5 @@ ; RUN: opt < %s -instcombine -S | \ -; RUN: grep {call float bitcast} | count 1 +; RUN: grep "call float bitcast" | count 1 target datalayout = "E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128" %struct.NSObject = type { %struct.objc_class* } %struct.NSArray = type { %struct.NSObject } diff --git a/test/Transforms/InstCombine/icmp.ll b/test/Transforms/InstCombine/icmp.ll index a9ae221d8f96..eaff87d695ed 100644 --- a/test/Transforms/InstCombine/icmp.ll +++ b/test/Transforms/InstCombine/icmp.ll @@ -637,3 +637,25 @@ define i1 @test62(i8* %a) { ; CHECK: @test62 ; CHECK-NEXT: ret i1 true } + +define i1 @test63(i8 %a, i32 %b) nounwind { + %z = zext i8 %a to i32 + %t = and i32 %b, 255 + %c = icmp eq i32 %z, %t + ret i1 %c +; CHECK: @test63 +; CHECK-NEXT: %1 = trunc i32 %b to i8 +; CHECK-NEXT: %c = icmp eq i8 %1, %a +; CHECK-NEXT: ret i1 %c +} + +define i1 @test64(i8 %a, i32 %b) nounwind { + %t = and i32 %b, 255 + %z = zext i8 %a to i32 + %c = icmp eq i32 %t, %z + ret i1 %c +; CHECK: @test64 +; CHECK-NEXT: %1 = trunc i32 %b to i8 +; CHECK-NEXT: %c = icmp eq i8 %1, %a +; CHECK-NEXT: ret i1 %c +} diff --git a/test/Transforms/InstCombine/invoke.ll b/test/Transforms/InstCombine/invoke.ll new file mode 100644 index 000000000000..04eaf86a287b --- /dev/null +++ b/test/Transforms/InstCombine/invoke.ll @@ -0,0 +1,65 @@ +; RUN: opt < %s -instcombine -S | FileCheck %s +target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128" + +declare i32 @__gxx_personality_v0(...) +declare void @__cxa_call_unexpected(i8*) +declare i64 @llvm.objectsize.i64(i8*, i1) nounwind readonly +declare i8* @_Znwm(i64) + + +; CHECK: @f1 +define i64 @f1() nounwind uwtable ssp { +entry: +; CHECK: nvoke noalias i8* undef() + %call = invoke noalias i8* undef() + to label %invoke.cont unwind label %lpad + +invoke.cont: +; CHECK: ret i64 0 + %0 = tail call i64 @llvm.objectsize.i64(i8* %call, i1 false) + ret i64 %0 + +lpad: + %1 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) + filter [0 x i8*] zeroinitializer + %2 = extractvalue { i8*, i32 } %1, 0 + tail call void @__cxa_call_unexpected(i8* %2) noreturn nounwind + unreachable +} + +; CHECK: @f2 +define i64 @f2() nounwind uwtable ssp { +entry: +; CHECK: nvoke noalias i8* null() + %call = invoke noalias i8* null() + to label %invoke.cont unwind label %lpad + +invoke.cont: +; CHECK: ret i64 0 + %0 = tail call i64 @llvm.objectsize.i64(i8* %call, i1 false) + ret i64 %0 + +lpad: + %1 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) + filter [0 x i8*] zeroinitializer + %2 = extractvalue { i8*, i32 } %1, 0 + tail call void @__cxa_call_unexpected(i8* %2) noreturn nounwind + unreachable +} + +; CHECK: @f3 +define void @f3() nounwind uwtable ssp { +; CHECK: invoke void @llvm.donothing() + %call = invoke noalias i8* @_Znwm(i64 13) + to label %invoke.cont unwind label %lpad + +invoke.cont: + ret void + +lpad: + %1 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) + filter [0 x i8*] zeroinitializer + %2 = extractvalue { i8*, i32 } %1, 0 + tail call void @__cxa_call_unexpected(i8* %2) noreturn nounwind + unreachable +} diff --git a/test/Transforms/InstCombine/known_align.ll b/test/Transforms/InstCombine/known_align.ll index 5382abf82125..0249951966dc 100644 --- a/test/Transforms/InstCombine/known_align.ll +++ b/test/Transforms/InstCombine/known_align.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -instcombine -S | grep {align 1} +; RUN: opt < %s -instcombine -S | grep "align 1" ; END. %struct.p = type <{ i8, i32 }> diff --git a/test/Transforms/InstCombine/loadstore-alignment.ll b/test/Transforms/InstCombine/loadstore-alignment.ll index 1d932d27f78d..2263cb20ec5e 100644 --- a/test/Transforms/InstCombine/loadstore-alignment.ll +++ b/test/Transforms/InstCombine/loadstore-alignment.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -instcombine -S | grep {, align 16} | count 14 +; RUN: opt < %s -instcombine -S | grep ", align 16" | count 14 target datalayout = "E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128" @x = external global <2 x i64>, align 16 diff --git a/test/Transforms/InstCombine/malloc-free-delete.ll b/test/Transforms/InstCombine/malloc-free-delete.ll index eae973df0a54..4e3217dc2d96 100644 --- a/test/Transforms/InstCombine/malloc-free-delete.ll +++ b/test/Transforms/InstCombine/malloc-free-delete.ll @@ -1,17 +1,17 @@ ; RUN: opt < %s -instcombine -S | FileCheck %s ; PR1201 define i32 @main(i32 %argc, i8** %argv) { +; CHECK: @main %c_19 = alloca i8* %malloc_206 = tail call i8* @malloc(i32 mul (i32 ptrtoint (i8* getelementptr (i8* null, i32 1) to i32), i32 10)) store i8* %malloc_206, i8** %c_19 %tmp_207 = load i8** %c_19 tail call void @free(i8* %tmp_207) ret i32 0 -; CHECK-NOT: malloc -; CHECK-NOT: free -; CHECK: ret i32 0 +; CHECK-NEXT: ret i32 0 } +declare noalias i8* @calloc(i32, i32) nounwind declare noalias i8* @malloc(i32) declare void @free(i8*) @@ -26,13 +26,24 @@ define i1 @foo() { declare void @llvm.lifetime.start(i64, i8*) declare void @llvm.lifetime.end(i64, i8*) +declare i64 @llvm.objectsize.i64(i8*, i1) +declare void @llvm.memcpy.p0i8.p0i8.i32(i8* nocapture, i8* nocapture, i32, i32, i1) nounwind +declare void @llvm.memmove.p0i8.p0i8.i32(i8* nocapture, i8* nocapture, i32, i32, i1) nounwind +declare void @llvm.memset.p0i8.i32(i8*, i8, i32, i32, i1) nounwind -define void @test3() { +define void @test3(i8* %src) { ; CHECK: @test3 ; CHECK-NEXT: ret void %a = call noalias i8* @malloc(i32 10) call void @llvm.lifetime.start(i64 10, i8* %a) call void @llvm.lifetime.end(i64 10, i8* %a) + %size = call i64 @llvm.objectsize.i64(i8* %a, i1 true) + store i8 42, i8* %a + call void @llvm.memcpy.p0i8.p0i8.i32(i8* %a, i8* %src, i32 32, i32 1, i1 false) + call void @llvm.memmove.p0i8.p0i8.i32(i8* %a, i8* %src, i32 32, i32 1, i1 false) + call void @llvm.memset.p0i8.i32(i8* %a, i8 5, i32 32, i32 1, i1 false) + %alloc2 = call noalias i8* @calloc(i32 5, i32 7) nounwind + %z = icmp ne i8* %alloc2, null ret void } @@ -46,3 +57,37 @@ define void @test4() { call void @free(i8* %C) ret void } + +; CHECK: @test5 +define void @test5(i8* %ptr, i8** %esc) { +; CHECK-NEXT: call i8* @malloc +; CHECK-NEXT: call i8* @malloc +; CHECK-NEXT: call i8* @malloc +; CHECK-NEXT: call i8* @malloc +; CHECK-NEXT: call i8* @malloc +; CHECK-NEXT: call i8* @malloc +; CHECK-NEXT: call i8* @malloc +; CHECK-NEXT: call void @llvm.memcpy +; CHECK-NEXT: call void @llvm.memmove +; CHECK-NEXT: store +; CHECK-NEXT: call void @llvm.memcpy +; CHECK-NEXT: call void @llvm.memmove +; CHECK-NEXT: call void @llvm.memset +; CHECK-NEXT: store volatile +; CHECK-NEXT: ret + %a = call i8* @malloc(i32 700) + %b = call i8* @malloc(i32 700) + %c = call i8* @malloc(i32 700) + %d = call i8* @malloc(i32 700) + %e = call i8* @malloc(i32 700) + %f = call i8* @malloc(i32 700) + %g = call i8* @malloc(i32 700) + call void @llvm.memcpy.p0i8.p0i8.i32(i8* %ptr, i8* %a, i32 32, i32 1, i1 false) + call void @llvm.memmove.p0i8.p0i8.i32(i8* %ptr, i8* %b, i32 32, i32 1, i1 false) + store i8* %c, i8** %esc + call void @llvm.memcpy.p0i8.p0i8.i32(i8* %d, i8* %ptr, i32 32, i32 1, i1 true) + call void @llvm.memmove.p0i8.p0i8.i32(i8* %e, i8* %ptr, i32 32, i32 1, i1 true) + call void @llvm.memset.p0i8.i32(i8* %f, i8 5, i32 32, i32 1, i1 true) + store volatile i8 4, i8* %g + ret void +} diff --git a/test/Transforms/InstCombine/memcpy-to-load.ll b/test/Transforms/InstCombine/memcpy-to-load.ll index 04aac9814575..bcc9e188b965 100644 --- a/test/Transforms/InstCombine/memcpy-to-load.ll +++ b/test/Transforms/InstCombine/memcpy-to-load.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -instcombine -S | grep {load double} +; RUN: opt < %s -instcombine -S | grep "load double" 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:128:128" target triple = "i686-apple-darwin8" diff --git a/test/Transforms/InstCombine/memmove.ll b/test/Transforms/InstCombine/memmove.ll index 4602c1268039..9d51ea0e70bb 100644 --- a/test/Transforms/InstCombine/memmove.ll +++ b/test/Transforms/InstCombine/memmove.ll @@ -1,6 +1,6 @@ ; This test makes sure that memmove instructions are properly eliminated. ; -; RUN: opt < %s -instcombine -S | not grep {call void @llvm.memmove} +; RUN: opt < %s -instcombine -S | not grep "call void @llvm.memmove" @S = internal constant [33 x i8] c"panic: restorelist inconsistency\00" ; <[33 x i8]*> [#uses=1] @h = constant [2 x i8] c"h\00" ; <[2 x i8]*> [#uses=1] diff --git a/test/Transforms/InstCombine/memset.ll b/test/Transforms/InstCombine/memset.ll index 7f7bc9f86e1f..7f02dad58a7a 100644 --- a/test/Transforms/InstCombine/memset.ll +++ b/test/Transforms/InstCombine/memset.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -instcombine -S | not grep {call.*llvm.memset} +; RUN: opt < %s -instcombine -S | not grep "call.*llvm.memset" define i32 @main() { %target = alloca [1024 x i8] diff --git a/test/Transforms/InstCombine/mul.ll b/test/Transforms/InstCombine/mul.ll index edb530585ce1..6c8e6347634c 100644 --- a/test/Transforms/InstCombine/mul.ll +++ b/test/Transforms/InstCombine/mul.ll @@ -138,8 +138,9 @@ define i32 @test16(i32 %b, i1 %c) { ; e = b & (a >> 31) %e = mul i32 %d, %b ; <i32> [#uses=1] ret i32 %e -; CHECK: [[TEST16:%.*]] = sext i1 %c to i32 -; CHECK-NEXT: %e = and i32 [[TEST16]], %b +; CHECK: [[TEST16:%.*]] = zext i1 %c to i32 +; CHECK-NEXT: %1 = sub i32 0, [[TEST16]] +; CHECK-NEXT: %e = and i32 %1, %b ; CHECK-NEXT: ret i32 %e } diff --git a/test/Transforms/InstCombine/multi-use-or.ll b/test/Transforms/InstCombine/multi-use-or.ll index 8c6a0e0bbcec..8b90e0d7f619 100644 --- a/test/Transforms/InstCombine/multi-use-or.ll +++ b/test/Transforms/InstCombine/multi-use-or.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -instcombine -S | grep {fadd double .sx, .sy} +; RUN: opt < %s -instcombine -S | grep "fadd double .sx, .sy" ; The 'or' has multiple uses, make sure that this doesn't prevent instcombine ; from propagating the extends to the truncs. diff --git a/test/Transforms/InstCombine/narrow.ll b/test/Transforms/InstCombine/narrow.ll index 1b96a06eeb7f..5dd13a096621 100644 --- a/test/Transforms/InstCombine/narrow.ll +++ b/test/Transforms/InstCombine/narrow.ll @@ -1,7 +1,7 @@ ; This file contains various testcases that check to see that instcombine ; is narrowing computations when possible. ; RUN: opt < %s -instcombine -S | \ -; RUN: grep {ret i1 false} +; RUN: grep "ret i1 false" ; test1 - Eliminating the casts in this testcase (by narrowing the AND ; operation) allows instcombine to realize the function always returns false. diff --git a/test/Transforms/InstCombine/objsize-64.ll b/test/Transforms/InstCombine/objsize-64.ll new file mode 100644 index 000000000000..530e1234b4a6 --- /dev/null +++ b/test/Transforms/InstCombine/objsize-64.ll @@ -0,0 +1,39 @@ +; RUN: opt < %s -instcombine -S | FileCheck %s +target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128" + +declare noalias i8* @malloc(i32) nounwind +declare noalias i8* @_Znwm(i64) ; new(unsigned long) +declare i32 @__gxx_personality_v0(...) +declare void @__cxa_call_unexpected(i8*) +declare i64 @llvm.objectsize.i64(i8*, i1) nounwind readonly + +; CHECK: @f1 +define i64 @f1(i8 **%esc) { + %call = call i8* @malloc(i32 4) + store i8* %call, i8** %esc + %size = call i64 @llvm.objectsize.i64(i8* %call, i1 false) +; CHECK: ret i64 4 + ret i64 %size +} + + +; CHECK: @f2 +define i64 @f2(i8** %esc) nounwind uwtable ssp { +entry: +; CHECK: invoke noalias i8* @_Znwm(i64 13) + %call = invoke noalias i8* @_Znwm(i64 13) + to label %invoke.cont unwind label %lpad + +invoke.cont: +; CHECK: ret i64 13 + store i8* %call, i8** %esc + %0 = tail call i64 @llvm.objectsize.i64(i8* %call, i1 false) + ret i64 %0 + +lpad: + %1 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) + filter [0 x i8*] zeroinitializer + %2 = extractvalue { i8*, i32 } %1, 0 + tail call void @__cxa_call_unexpected(i8* %2) noreturn nounwind + unreachable +} diff --git a/test/Transforms/InstCombine/objsize.ll b/test/Transforms/InstCombine/objsize.ll index 28ceb68b49ab..dbb0ffcd6742 100644 --- a/test/Transforms/InstCombine/objsize.ll +++ b/test/Transforms/InstCombine/objsize.ll @@ -42,7 +42,7 @@ define i32 @f() nounwind { define i1 @baz() nounwind { ; CHECK: @baz -; CHECK-NEXT: ret i1 true +; CHECK-NEXT: objectsize %1 = tail call i32 @llvm.objectsize.i32(i8* getelementptr inbounds ([0 x i8]* @window, i32 0, i32 0), i1 false) %2 = icmp eq i32 %1, -1 ret i1 %2 @@ -106,7 +106,7 @@ bb12: %struct.data = type { [100 x i32], [100 x i32], [1024 x i8] } -define i32 @test4() nounwind ssp { +define i32 @test4(i8** %esc) nounwind ssp { ; CHECK: @test4 entry: %0 = alloca %struct.data, align 8 @@ -115,13 +115,14 @@ entry: ; CHECK-NOT: @llvm.objectsize ; CHECK: @llvm.memset.p0i8.i32(i8* %1, i8 0, i32 1824, i32 8, i1 false) %3 = call i8* @__memset_chk(i8* %1, i32 0, i32 1824, i32 %2) nounwind + store i8* %1, i8** %esc ret i32 0 } ; rdar://7782496 @s = external global i8* -define void @test5(i32 %n) nounwind ssp { +define i8* @test5(i32 %n) nounwind ssp { ; CHECK: @test5 entry: %0 = tail call noalias i8* @malloc(i32 20) nounwind @@ -130,7 +131,7 @@ entry: ; CHECK-NOT: @llvm.objectsize ; CHECK: @llvm.memcpy.p0i8.p0i8.i32(i8* %0, i8* %1, i32 10, i32 1, i1 false) %3 = tail call i8* @__memcpy_chk(i8* %0, i8* %2, i32 10, i32 %1) nounwind - ret void + ret i8* %0 } define void @test6(i32 %n) nounwind ssp { @@ -149,12 +150,91 @@ declare i8* @__memset_chk(i8*, i32, i32, i32) nounwind declare noalias i8* @malloc(i32) nounwind -define i32 @test7() { +define i32 @test7(i8** %esc) { ; CHECK: @test7 %alloc = call noalias i8* @malloc(i32 48) nounwind + store i8* %alloc, i8** %esc %gep = getelementptr inbounds i8* %alloc, i32 16 %objsize = call i32 @llvm.objectsize.i32(i8* %gep, i1 false) nounwind readonly -; CHECK-NEXT: ret i32 32 +; CHECK: ret i32 32 + ret i32 %objsize +} + +declare noalias i8* @calloc(i32, i32) nounwind + +define i32 @test8(i8** %esc) { +; CHECK: @test8 + %alloc = call noalias i8* @calloc(i32 5, i32 7) nounwind + store i8* %alloc, i8** %esc + %gep = getelementptr inbounds i8* %alloc, i32 5 + %objsize = call i32 @llvm.objectsize.i32(i8* %gep, i1 false) nounwind readonly +; CHECK: ret i32 30 ret i32 %objsize } +declare noalias i8* @strdup(i8* nocapture) nounwind +declare noalias i8* @strndup(i8* nocapture, i32) nounwind + +; CHECK: @test9 +define i32 @test9(i8** %esc) { + %call = tail call i8* @strdup(i8* getelementptr inbounds ([8 x i8]* @.str, i64 0, i64 0)) nounwind + store i8* %call, i8** %esc, align 8 + %1 = tail call i32 @llvm.objectsize.i32(i8* %call, i1 true) +; CHECK: ret i32 8 + ret i32 %1 +} + +; CHECK: @test10 +define i32 @test10(i8** %esc) { + %call = tail call i8* @strndup(i8* getelementptr inbounds ([8 x i8]* @.str, i64 0, i64 0), i32 3) nounwind + store i8* %call, i8** %esc, align 8 + %1 = tail call i32 @llvm.objectsize.i32(i8* %call, i1 true) +; CHECK: ret i32 4 + ret i32 %1 +} + +; CHECK: @test11 +define i32 @test11(i8** %esc) { + %call = tail call i8* @strndup(i8* getelementptr inbounds ([8 x i8]* @.str, i64 0, i64 0), i32 7) nounwind + store i8* %call, i8** %esc, align 8 + %1 = tail call i32 @llvm.objectsize.i32(i8* %call, i1 true) +; CHECK: ret i32 8 + ret i32 %1 +} + +; CHECK: @test12 +define i32 @test12(i8** %esc) { + %call = tail call i8* @strndup(i8* getelementptr inbounds ([8 x i8]* @.str, i64 0, i64 0), i32 8) nounwind + store i8* %call, i8** %esc, align 8 + %1 = tail call i32 @llvm.objectsize.i32(i8* %call, i1 true) +; CHECK: ret i32 8 + ret i32 %1 +} + +; CHECK: @test13 +define i32 @test13(i8** %esc) { + %call = tail call i8* @strndup(i8* getelementptr inbounds ([8 x i8]* @.str, i64 0, i64 0), i32 57) nounwind + store i8* %call, i8** %esc, align 8 + %1 = tail call i32 @llvm.objectsize.i32(i8* %call, i1 true) +; CHECK: ret i32 8 + ret i32 %1 +} + +; CHECK: @PR13390 +define i32 @PR13390(i1 %bool, i8* %a) { +entry: + %cond = or i1 %bool, true + br i1 %cond, label %return, label %xpto + +xpto: + %select = select i1 %bool, i8* %select, i8* %a + %select2 = select i1 %bool, i8* %a, i8* %select2 + %0 = tail call i32 @llvm.objectsize.i32(i8* %select, i1 true) + %1 = tail call i32 @llvm.objectsize.i32(i8* %select2, i1 true) + %2 = add i32 %0, %1 +; CHECK: ret i32 undef + ret i32 %2 + +return: + ret i32 42 +} diff --git a/test/Transforms/InstCombine/odr-linkage.ll b/test/Transforms/InstCombine/odr-linkage.ll index 61365b4848ab..2ce62468dc77 100644 --- a/test/Transforms/InstCombine/odr-linkage.ll +++ b/test/Transforms/InstCombine/odr-linkage.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -instcombine -S | grep {ret i32 10} +; RUN: opt < %s -instcombine -S | grep "ret i32 10" @g1 = available_externally constant i32 1 @g2 = linkonce_odr constant i32 2 diff --git a/test/Transforms/InstCombine/or-to-xor.ll b/test/Transforms/InstCombine/or-to-xor.ll index 1495ee49709f..8847cb73281a 100644 --- a/test/Transforms/InstCombine/or-to-xor.ll +++ b/test/Transforms/InstCombine/or-to-xor.ll @@ -1,5 +1,5 @@ -; RUN: opt < %s -instcombine -S | grep {xor i32 %a, %b} | count 4 -; RUN: opt < %s -instcombine -S | not grep {and} +; RUN: opt < %s -instcombine -S | grep "xor i32 %a, %b" | count 4 +; RUN: opt < %s -instcombine -S | not grep "and" define i32 @func1(i32 %a, i32 %b) nounwind readnone { entry: diff --git a/test/Transforms/InstCombine/phi-merge-gep.ll b/test/Transforms/InstCombine/phi-merge-gep.ll index 267174970941..25c9cea9b770 100644 --- a/test/Transforms/InstCombine/phi-merge-gep.ll +++ b/test/Transforms/InstCombine/phi-merge-gep.ll @@ -1,6 +1,6 @@ ; RUN: opt < %s -S -instcombine > %t -; RUN: grep {= getelementptr} %t | count 20 -; RUN: grep {= phi} %t | count 13 +; RUN: grep "= getelementptr" %t | count 20 +; RUN: grep "= phi" %t | count 13 ; Don't push the geps through these phis, because they would require ; two phis each, which burdens the loop with high register pressure. diff --git a/test/Transforms/InstCombine/phi.ll b/test/Transforms/InstCombine/phi.ll index 219545c2eaa8..1c307d430f3f 100644 --- a/test/Transforms/InstCombine/phi.ll +++ b/test/Transforms/InstCombine/phi.ll @@ -620,3 +620,13 @@ end: ; CHECK-NOT: phi i32 ; CHECK: ret i1 %z } + +; CHECK: @test27( +; CHECK: ret i32 undef +define i32 @test27(i1 %b) { +entry: + br label %done +done: + %y = phi i32 [ undef, %entry ] + ret i32 %y +} diff --git a/test/Transforms/InstCombine/pr12338.ll b/test/Transforms/InstCombine/pr12338.ll new file mode 100644 index 000000000000..2b5c8f8a74ed --- /dev/null +++ b/test/Transforms/InstCombine/pr12338.ll @@ -0,0 +1,24 @@ +; RUN: opt < %s -instcombine -S | FileCheck %s + +define void @entry() nounwind {
+entry:
+ br label %for.cond
+
+for.cond:
+ %local = phi <1 x i32> [ <i32 0>, %entry ], [ %phi2, %cond.end47 ] +; CHECK: sub <1 x i32> <i32 92>, %local
+ %phi3 = sub <1 x i32> zeroinitializer, %local
+ br label %cond.end
+
+cond.false:
+ br label %cond.end
+
+cond.end:
+ %cond = phi <1 x i32> [ %phi3, %for.cond ], [ undef, %cond.false ]
+ br label %cond.end47
+
+cond.end47:
+ %sum = add <1 x i32> %cond, <i32 92>
+ %phi2 = sub <1 x i32> zeroinitializer, %sum
+ br label %for.cond
+}
diff --git a/test/Transforms/InstCombine/pr2645-0.ll b/test/Transforms/InstCombine/pr2645-0.ll index 9bcaa43a80ba..e8aeb2afb9cf 100644 --- a/test/Transforms/InstCombine/pr2645-0.ll +++ b/test/Transforms/InstCombine/pr2645-0.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -instcombine -S | grep {insertelement <4 x float> undef} +; RUN: opt < %s -instcombine -S | grep "insertelement <4 x float> undef" ; Instcombine should be able to prove that none of the ; insertelement's first operand's elements are needed. diff --git a/test/Transforms/InstCombine/sdiv-shift.ll b/test/Transforms/InstCombine/sdiv-shift.ll deleted file mode 100644 index f4d2b36cbbf8..000000000000 --- a/test/Transforms/InstCombine/sdiv-shift.ll +++ /dev/null @@ -1,9 +0,0 @@ -; RUN: opt < %s -instcombine -S | not grep div - -define i32 @a(i16 zeroext %x, i32 %y) nounwind { -entry: - %conv = zext i16 %x to i32 - %s = shl i32 2, %y - %d = sdiv i32 %conv, %s - ret i32 %d -} diff --git a/test/Transforms/InstCombine/select-crash.ll b/test/Transforms/InstCombine/select-crash.ll index 18af1520c0e1..946ea2b8b70c 100644 --- a/test/Transforms/InstCombine/select-crash.ll +++ b/test/Transforms/InstCombine/select-crash.ll @@ -30,3 +30,20 @@ define <4 x float> @foo(i1 %b, <4 x float> %x, <4 x float> %y, <4 x float> %z) { %sel = select i1 %b, <4 x float> %a, <4 x float> %sub ret <4 x float> %sel } + +; CHECK: @test3 +define i32 @test3(i1 %bool, i32 %a) { +entry: + %cond = or i1 %bool, true + br i1 %cond, label %return, label %xpto + +; technically reachable, but this malformed IR may appear as a result of constant propagation +xpto: + %select = select i1 %bool, i32 %a, i32 %select + %select2 = select i1 %bool, i32 %select2, i32 %a + %sum = add i32 %select, %select2 + ret i32 %sum + +return: + ret i32 7 +} diff --git a/test/Transforms/InstCombine/select-load-call.ll b/test/Transforms/InstCombine/select-load-call.ll index bef0cf841bfa..b63468de53e1 100644 --- a/test/Transforms/InstCombine/select-load-call.ll +++ b/test/Transforms/InstCombine/select-load-call.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -instcombine -S | grep {ret i32 1} +; RUN: opt < %s -instcombine -S | grep "ret i32 1" declare void @test2() diff --git a/test/Transforms/InstCombine/setcc-strength-reduce.ll b/test/Transforms/InstCombine/setcc-strength-reduce.ll index 62ab116367fe..138712e5a9b6 100644 --- a/test/Transforms/InstCombine/setcc-strength-reduce.ll +++ b/test/Transforms/InstCombine/setcc-strength-reduce.ll @@ -3,7 +3,7 @@ ; into equivalent setne,eq instructions. ; ; RUN: opt < %s -instcombine -S | \ -; RUN: grep -v {icmp eq} | grep -v {icmp ne} | not grep icmp +; RUN: grep -v "icmp eq" | grep -v "icmp ne" | not grep icmp ; END. define i1 @test1(i32 %A) { diff --git a/test/Transforms/InstCombine/shift.ll b/test/Transforms/InstCombine/shift.ll index 52310e34e09d..25e708b7f51d 100644 --- a/test/Transforms/InstCombine/shift.ll +++ b/test/Transforms/InstCombine/shift.ll @@ -65,8 +65,17 @@ define i32 @test6(i32 %A) { ; CHECK: @test6 ; CHECK-NEXT: mul i32 %A, 6 ; CHECK-NEXT: ret i32 - %B = shl i32 %A, 1 ;; convert to an mul instruction - %C = mul i32 %B, 3 + %B = shl i32 %A, 1 ;; convert to an mul instruction + %C = mul i32 %B, 3 + ret i32 %C +} + +define i32 @test6a(i32 %A) { +; CHECK: @test6a +; CHECK-NEXT: mul i32 %A, 6 +; CHECK-NEXT: ret i32 + %B = mul i32 %A, 3 + %C = shl i32 %B, 1 ;; convert to an mul instruction ret i32 %C } @@ -97,7 +106,9 @@ define i8 @test9(i8 %A) { ret i8 %C } +;; This transformation is deferred to DAGCombine: ;; (A >> 7) << 7 === A & 128 +;; The shl may be valuable to scalar evolution. define i8 @test10(i8 %A) { ; CHECK: @test10 ; CHECK-NEXT: and i8 %A, -128 @@ -107,11 +118,21 @@ define i8 @test10(i8 %A) { ret i8 %C } +;; Allow the simplification when the lshr shift is exact. +define i8 @test10a(i8 %A) { +; CHECK: @test10a +; CHECK-NEXT: ret i8 %A + %B = lshr exact i8 %A, 7 + %C = shl i8 %B, 7 + ret i8 %C +} + +;; This transformation is deferred to DAGCombine: ;; (A >> 3) << 4 === (A & 0x1F) << 1 +;; The shl may be valuable to scalar evolution. define i8 @test11(i8 %A) { ; CHECK: @test11 -; CHECK-NEXT: mul i8 %A, 6 -; CHECK-NEXT: and i8 +; CHECK: shl i8 ; CHECK-NEXT: ret i8 %a = mul i8 %A, 3 ; <i8> [#uses=1] %B = lshr i8 %a, 3 ; <i8> [#uses=1] @@ -119,6 +140,18 @@ define i8 @test11(i8 %A) { ret i8 %C } +;; Allow the simplification in InstCombine when the lshr shift is exact. +define i8 @test11a(i8 %A) { +; CHECK: @test11a +; CHECK-NEXT: mul i8 %A, 6 +; CHECK-NEXT: ret i8 + %a = mul i8 %A, 3 + %B = lshr exact i8 %a, 3 + %C = shl i8 %B, 4 + ret i8 %C +} + +;; This is deferred to DAGCombine unless %B is single-use. ;; (A >> 8) << 8 === A & -256 define i32 @test12(i32 %A) { ; CHECK: @test12 @@ -129,11 +162,12 @@ define i32 @test12(i32 %A) { ret i32 %C } +;; This transformation is deferred to DAGCombine: ;; (A >> 3) << 4 === (A & -8) * 2 +;; The shl may be valuable to scalar evolution. define i8 @test13(i8 %A) { ; CHECK: @test13 -; CHECK-NEXT: mul i8 %A, 6 -; CHECK-NEXT: and i8 +; CHECK: shl i8 ; CHECK-NEXT: ret i8 %a = mul i8 %A, 3 ; <i8> [#uses=1] %B = ashr i8 %a, 3 ; <i8> [#uses=1] @@ -141,6 +175,16 @@ define i8 @test13(i8 %A) { ret i8 %C } +define i8 @test13a(i8 %A) { +; CHECK: @test13a +; CHECK-NEXT: mul i8 %A, 6 +; CHECK-NEXT: ret i8 + %a = mul i8 %A, 3 + %B = ashr exact i8 %a, 3 + %C = shl i8 %B, 4 + ret i8 %C +} + ;; D = ((B | 1234) << 4) === ((B << 4)|(1234 << 4) define i32 @test14(i32 %A) { ; CHECK: @test14 @@ -477,10 +521,11 @@ entry: %tmp49 = lshr i8 %tmp48, 5 %tmp50 = mul i8 %tmp49, 64 %tmp51 = xor i8 %tmp50, %tmp5 -; CHECK: and i8 %0, 16 %tmp52 = and i8 %tmp51, -128 %tmp53 = lshr i8 %tmp52, 7 +; CHECK: lshr i8 %tmp51, 7 %tmp54 = mul i8 %tmp53, 16 +; CHECK: shl nuw nsw i8 %tmp53, 4 %tmp55 = xor i8 %tmp54, %tmp51 ; CHECK: ret i8 %tmp551 ret i8 %tmp55 diff --git a/test/Transforms/InstCombine/shufflemask-undef.ll b/test/Transforms/InstCombine/shufflemask-undef.ll index cf87aef7df46..aa6baa989bfc 100644 --- a/test/Transforms/InstCombine/shufflemask-undef.ll +++ b/test/Transforms/InstCombine/shufflemask-undef.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -instcombine -S | not grep {shufflevector.\*i32 8} +; RUN: opt < %s -instcombine -S | not grep "shufflevector.*i32 8" 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:128:128" target triple = "i386-apple-darwin9" diff --git a/test/Transforms/InstCombine/shufflevec-constant.ll b/test/Transforms/InstCombine/shufflevec-constant.ll index 29ae5a79824a..a002b2a853f5 100644 --- a/test/Transforms/InstCombine/shufflevec-constant.ll +++ b/test/Transforms/InstCombine/shufflevec-constant.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -instcombine -S | grep {ret <4 x float> <float 0.000000e+00, float 0.000000e+00, float 0x7FF0000000000000, float 0x7FF0000000000000>} +; RUN: opt < %s -instcombine -S | grep "ret <4 x float> <float 0.000000e+00, float 0.000000e+00, float 0x7FF0000000000000, float 0x7FF0000000000000>" 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:128:128" target triple = "i386-apple-darwin9" diff --git a/test/Transforms/InstCombine/signed-comparison.ll b/test/Transforms/InstCombine/signed-comparison.ll index 9a08c6446c52..ab0e7e7ff9fe 100644 --- a/test/Transforms/InstCombine/signed-comparison.ll +++ b/test/Transforms/InstCombine/signed-comparison.ll @@ -1,7 +1,7 @@ ; RUN: opt < %s -instcombine -S > %t ; RUN: not grep zext %t ; RUN: not grep slt %t -; RUN: grep {icmp ult} %t +; RUN: grep "icmp ult" %t ; Instcombine should convert the zext+slt into a simple ult. diff --git a/test/Transforms/InstCombine/srem-simplify-bug.ll b/test/Transforms/InstCombine/srem-simplify-bug.ll index af824a445df0..3458714b8dae 100644 --- a/test/Transforms/InstCombine/srem-simplify-bug.ll +++ b/test/Transforms/InstCombine/srem-simplify-bug.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -instcombine -S | grep {ret i1 false} +; RUN: opt < %s -instcombine -S | grep "ret i1 false" ; PR2276 define i1 @f(i32 %x) { diff --git a/test/Transforms/InstCombine/stack-overalign.ll b/test/Transforms/InstCombine/stack-overalign.ll index 2fc84140b308..80c2ee88f340 100644 --- a/test/Transforms/InstCombine/stack-overalign.ll +++ b/test/Transforms/InstCombine/stack-overalign.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -instcombine -S | grep {align 32} | count 1 +; RUN: opt < %s -instcombine -S | grep "align 32" | count 1 ; It's tempting to have an instcombine in which the src pointer of a ; memcpy is aligned up to the alignment of the destination, however diff --git a/test/Transforms/InstCombine/stacksaverestore.ll b/test/Transforms/InstCombine/stacksaverestore.ll index 0fcaefac6224..f5c7a6f9f3f9 100644 --- a/test/Transforms/InstCombine/stacksaverestore.ll +++ b/test/Transforms/InstCombine/stacksaverestore.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -instcombine -S | grep {call.*stackrestore} | count 1 +; RUN: opt < %s -instcombine -S | grep "call.*stackrestore" | count 1 declare i8* @llvm.stacksave() declare void @llvm.stackrestore(i8*) diff --git a/test/Transforms/InstCombine/trunc.ll b/test/Transforms/InstCombine/trunc.ll index 6ec342a4f5c1..cbbad7f79777 100644 --- a/test/Transforms/InstCombine/trunc.ll +++ b/test/Transforms/InstCombine/trunc.ll @@ -12,8 +12,8 @@ define i64 @test1(i64 %a) { call void @use(i32 %b) ret i64 %d ; CHECK: @test1 -; CHECK: %d = and i64 %a, 15 -; CHECK: ret i64 %d +; CHECK-NOT: ext +; CHECK: ret } define i64 @test2(i64 %a) { %b = trunc i64 %a to i32 @@ -34,8 +34,8 @@ define i64 @test3(i64 %a) { call void @use(i32 %b) ret i64 %d ; CHECK: @test3 -; CHECK: %d = and i64 %a, 8 -; CHECK: ret i64 %d +; CHECK-NOT: ext +; CHECK: ret } define i64 @test4(i64 %a) { %b = trunc i64 %a to i32 @@ -46,8 +46,9 @@ define i64 @test4(i64 %a) { ret i64 %d ; CHECK: @test4 ; CHECK: = and i64 %a, 8 -; CHECK: %d = xor i64 {{.*}}, 8 -; CHECK: ret i64 %d +; CHECK: = xor i64 {{.*}}, 8 +; CHECK-NOT: ext +; CHECK: ret } define i32 @test5(i32 %A) { diff --git a/test/Transforms/InstCombine/udiv-simplify-bug-0.ll b/test/Transforms/InstCombine/udiv-simplify-bug-0.ll index bfdd98cddfaf..064e721768b3 100644 --- a/test/Transforms/InstCombine/udiv-simplify-bug-0.ll +++ b/test/Transforms/InstCombine/udiv-simplify-bug-0.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -instcombine -S | grep {ret i64 0} | count 2 +; RUN: opt < %s -instcombine -S | grep "ret i64 0" | count 2 define i64 @foo(i32 %x) nounwind { %y = lshr i32 %x, 1 diff --git a/test/Transforms/InstCombine/urem-simplify-bug.ll b/test/Transforms/InstCombine/urem-simplify-bug.ll index 229f1a85e860..3e94ab5b2c33 100644 --- a/test/Transforms/InstCombine/urem-simplify-bug.ll +++ b/test/Transforms/InstCombine/urem-simplify-bug.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -instcombine -S | grep {= or i32 %x, -5} +; RUN: opt < %s -instcombine -S | grep "= or i32 %x, -5" @.str = internal constant [5 x i8] c"foo\0A\00" ; <[5 x i8]*> [#uses=1] @.str1 = internal constant [5 x i8] c"bar\0A\00" ; <[5 x i8]*> [#uses=1] diff --git a/test/Transforms/InstCombine/vec_demanded_elts.ll b/test/Transforms/InstCombine/vec_demanded_elts.ll index cc63371eded6..0019a57627cb 100644 --- a/test/Transforms/InstCombine/vec_demanded_elts.ll +++ b/test/Transforms/InstCombine/vec_demanded_elts.ll @@ -162,4 +162,51 @@ entry: ret <4 x float> %shuffle9.i } +define <2 x float> @test_fptrunc(double %f) { +; CHECK: @test_fptrunc +; CHECK: insertelement +; CHECK: insertelement +; CHECK-NOT: insertelement + %tmp9 = insertelement <4 x double> undef, double %f, i32 0 + %tmp10 = insertelement <4 x double> %tmp9, double 0.000000e+00, i32 1 + %tmp11 = insertelement <4 x double> %tmp10, double 0.000000e+00, i32 2 + %tmp12 = insertelement <4 x double> %tmp11, double 0.000000e+00, i32 3 + %tmp5 = fptrunc <4 x double> %tmp12 to <4 x float> + %ret = shufflevector <4 x float> %tmp5, <4 x float> undef, <2 x i32> <i32 0, i32 1> + ret <2 x float> %ret +} + +define <2 x double> @test_fpext(float %f) { +; CHECK: @test_fpext +; CHECK: insertelement +; CHECK: insertelement +; CHECK-NOT: insertelement + %tmp9 = insertelement <4 x float> undef, float %f, i32 0 + %tmp10 = insertelement <4 x float> %tmp9, float 0.000000e+00, i32 1 + %tmp11 = insertelement <4 x float> %tmp10, float 0.000000e+00, i32 2 + %tmp12 = insertelement <4 x float> %tmp11, float 0.000000e+00, i32 3 + %tmp5 = fpext <4 x float> %tmp12 to <4 x double> + %ret = shufflevector <4 x double> %tmp5, <4 x double> undef, <2 x i32> <i32 0, i32 1> + ret <2 x double> %ret +} + +define <4 x float> @test_select(float %f, float %g) { +; CHECK: @test_select +; CHECK: %a0 = insertelement <4 x float> undef, float %f, i32 0 +; CHECK-NOT: insertelement +; CHECK: %a3 = insertelement <4 x float> %a0, float 3.000000e+00, i32 3 +; CHECK-NOT: insertelement +; CHECK: %ret = select <4 x i1> <i1 true, i1 false, i1 false, i1 true>, <4 x float> %a3, <4 x float> <float undef, float 4.000000e+00, float 5.000000e+00, float undef> + %a0 = insertelement <4 x float> undef, float %f, i32 0 + %a1 = insertelement <4 x float> %a0, float 1.000000e+00, i32 1 + %a2 = insertelement <4 x float> %a1, float 2.000000e+00, i32 2 + %a3 = insertelement <4 x float> %a2, float 3.000000e+00, i32 3 + %b0 = insertelement <4 x float> undef, float %g, i32 0 + %b1 = insertelement <4 x float> %b0, float 4.000000e+00, i32 1 + %b2 = insertelement <4 x float> %b1, float 5.000000e+00, i32 2 + %b3 = insertelement <4 x float> %b2, float 6.000000e+00, i32 3 + %ret = select <4 x i1> <i1 true, i1 false, i1 false, i1 true>, <4 x float> %a3, <4 x float> %b3 + ret <4 x float> %ret +} + diff --git a/test/Transforms/InstCombine/vec_insertelt.ll b/test/Transforms/InstCombine/vec_insertelt.ll index eedf882518bf..e35fa5e551fb 100644 --- a/test/Transforms/InstCombine/vec_insertelt.ll +++ b/test/Transforms/InstCombine/vec_insertelt.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -instcombine -S | grep {ret <4 x i32> %A} +; RUN: opt < %s -instcombine -S | grep "ret <4 x i32> %A" ; PR1286 define <4 x i32> @test1(<4 x i32> %A) { diff --git a/test/Transforms/InstCombine/vec_narrow.ll b/test/Transforms/InstCombine/vec_narrow.ll index 2be4359923ce..b4c41f6d297d 100644 --- a/test/Transforms/InstCombine/vec_narrow.ll +++ b/test/Transforms/InstCombine/vec_narrow.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -instcombine -S | grep {fadd float} +; RUN: opt < %s -instcombine -S | grep "fadd float" define float @test(<4 x float> %A, <4 x float> %B, float %f) { diff --git a/test/Transforms/InstCombine/vector-srem.ll b/test/Transforms/InstCombine/vector-srem.ll index acb11c52adb3..b1ed49eefa87 100644 --- a/test/Transforms/InstCombine/vector-srem.ll +++ b/test/Transforms/InstCombine/vector-srem.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -instcombine -S | grep {srem <4 x i32>} +; RUN: opt < %s -instcombine -S | grep "srem <4 x i32>" define <4 x i32> @foo(<4 x i32> %t, <4 x i32> %u) { diff --git a/test/Transforms/InstCombine/volatile_store.ll b/test/Transforms/InstCombine/volatile_store.ll index 22566781180d..7cab199a58f4 100644 --- a/test/Transforms/InstCombine/volatile_store.ll +++ b/test/Transforms/InstCombine/volatile_store.ll @@ -1,5 +1,5 @@ -; RUN: opt < %s -instcombine -S | grep {store volatile} -; RUN: opt < %s -instcombine -S | grep {load volatile} +; RUN: opt < %s -instcombine -S | grep "store volatile" +; RUN: opt < %s -instcombine -S | grep "load volatile" @x = weak global i32 0 ; <i32*> [#uses=2] diff --git a/test/Transforms/InstCombine/xor.ll b/test/Transforms/InstCombine/xor.ll index a7bcdac08bd8..3722697f9892 100644 --- a/test/Transforms/InstCombine/xor.ll +++ b/test/Transforms/InstCombine/xor.ll @@ -1,7 +1,7 @@ ; This test makes sure that these instructions are properly eliminated. ; ; RUN: opt < %s -instcombine -S | \ -; RUN: not grep {xor } +; RUN: not grep "xor " ; END. @G1 = global i32 0 ; <i32*> [#uses=1] @G2 = global i32 0 ; <i32*> [#uses=1] diff --git a/test/Transforms/InstCombine/zeroext-and-reduce.ll b/test/Transforms/InstCombine/zeroext-and-reduce.ll index 592b8a172f8e..315033dd8882 100644 --- a/test/Transforms/InstCombine/zeroext-and-reduce.ll +++ b/test/Transforms/InstCombine/zeroext-and-reduce.ll @@ -1,5 +1,5 @@ ; RUN: opt < %s -instcombine -S | \ -; RUN: grep {and i32 %Y, 8} +; RUN: grep "and i32 %Y, 8" define i32 @test1(i8 %X) { %Y = zext i8 %X to i32 ; <i32> [#uses=1] diff --git a/test/Transforms/InstCombine/zext-bool-add-sub.ll b/test/Transforms/InstCombine/zext-bool-add-sub.ll index 11642733acc0..78bcedbbc2e1 100644 --- a/test/Transforms/InstCombine/zext-bool-add-sub.ll +++ b/test/Transforms/InstCombine/zext-bool-add-sub.ll @@ -1,29 +1,16 @@ -; RUN: opt < %s -instcombine -S | not grep zext +; RUN: opt < %s -instcombine -S | FileCheck %s +; rdar://11748024 -define i32 @a(i1 %x) { +define i32 @a(i1 zeroext %x, i1 zeroext %y) { entry: - %y = zext i1 %x to i32 - %res = add i32 %y, 1 - ret i32 %res -} - -define i32 @b(i1 %x) { -entry: - %y = zext i1 %x to i32 - %res = add i32 %y, -1 - ret i32 %res -} - -define i32 @c(i1 %x) { -entry: - %y = zext i1 %x to i32 - %res = sub i32 0, %y - ret i32 %res -} - -define i32 @d(i1 %x) { -entry: - %y = zext i1 %x to i32 - %res = sub i32 3, %y - ret i32 %res +; CHECK: @a +; CHECK: [[TMP1:%.*]] = zext i1 %y to i32 +; CHECK: [[TMP2:%.*]] = select i1 %x, i32 2, i32 1 +; CHECK-NEXT: sub i32 [[TMP2]], [[TMP1]] + %conv = zext i1 %x to i32 + %conv3 = zext i1 %y to i32 + %conv3.neg = sub i32 0, %conv3 + %sub = add i32 %conv, 1 + %add = add i32 %sub, %conv3.neg + ret i32 %add } diff --git a/test/Transforms/InstCombine/zext-fold.ll b/test/Transforms/InstCombine/zext-fold.ll index 9521101e736a..e5f316b8111c 100644 --- a/test/Transforms/InstCombine/zext-fold.ll +++ b/test/Transforms/InstCombine/zext-fold.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -instcombine -S | grep {zext } | count 1 +; RUN: opt < %s -instcombine -S | grep "zext " | count 1 ; PR1570 define i32 @test2(float %X, float %Y) { diff --git a/test/Transforms/JumpThreading/2008-11-27-EntryMunge.ll b/test/Transforms/JumpThreading/2008-11-27-EntryMunge.ll index b5d1065e6793..6a50d4f1a32c 100644 --- a/test/Transforms/JumpThreading/2008-11-27-EntryMunge.ll +++ b/test/Transforms/JumpThreading/2008-11-27-EntryMunge.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -jump-threading -S | grep {ret i32 0} +; RUN: opt < %s -jump-threading -S | grep "ret i32 0" ; PR3138 define i32 @jt() { diff --git a/test/Transforms/JumpThreading/2012-07-19-NoSuccessorIndirectBr.ll b/test/Transforms/JumpThreading/2012-07-19-NoSuccessorIndirectBr.ll new file mode 100644 index 000000000000..1c2c0c75e36f --- /dev/null +++ b/test/Transforms/JumpThreading/2012-07-19-NoSuccessorIndirectBr.ll @@ -0,0 +1,8 @@ +; RUN: opt < %s -jump-threading +; PR 13405 +; Just check that it doesn't crash / assert + +define i32 @f() nounwind { +entry: + indirectbr i8* undef, [] +} diff --git a/test/Transforms/JumpThreading/compare.ll b/test/Transforms/JumpThreading/compare.ll index 581785c45f51..9b05b4496b0c 100644 --- a/test/Transforms/JumpThreading/compare.ll +++ b/test/Transforms/JumpThreading/compare.ll @@ -1,5 +1,5 @@ ; There should be no phi nodes left. -; RUN: opt < %s -jump-threading -S | not grep {phi i32} +; RUN: opt < %s -jump-threading -S | not grep "phi i32" declare i32 @f1() declare i32 @f2() diff --git a/test/Transforms/JumpThreading/no-irreducible-loops.ll b/test/Transforms/JumpThreading/no-irreducible-loops.ll index a4914f96348e..c6e9faa17116 100644 --- a/test/Transforms/JumpThreading/no-irreducible-loops.ll +++ b/test/Transforms/JumpThreading/no-irreducible-loops.ll @@ -1,6 +1,6 @@ ; RUN: opt < %s -jump-threading -loop-rotate -instcombine -indvars -loop-unroll -simplifycfg -S -verify-dom-info -verify-loop-info > %t -; RUN: grep {store volatile} %t | count 3 -; RUN: not grep {br label} %t +; RUN: grep "store volatile" %t | count 3 +; RUN: not grep "br label" %t ; Jump threading should not prevent this loop from being unrolled. diff --git a/test/Transforms/JumpThreading/phi-eq.ll b/test/Transforms/JumpThreading/phi-eq.ll new file mode 100644 index 000000000000..40d3c7edd05d --- /dev/null +++ b/test/Transforms/JumpThreading/phi-eq.ll @@ -0,0 +1,209 @@ +; RUN: llvm-as < %s | opt -jump-threading | llvm-dis | FileCheck %s +; Test whether two consecutive switches with identical structures assign the +; proper value to the proper variable. This is really testing +; Instruction::isIdenticalToWhenDefined, as previously that function was +; returning true if the value part of the operands of two phis were identical, +; even if the incoming blocks were not. +; NB: this function should be pruned down more. + +%struct._GList = type { i8*, %struct._GList*, %struct._GList* } +%struct.filter_def = type { i8*, i8* } + +@capture_filters = external hidden global %struct._GList*, align 8 +@display_filters = external hidden global %struct._GList*, align 8 +@.str2 = external hidden unnamed_addr constant [10 x i8], align 1 +@__PRETTY_FUNCTION__.copy_filter_list = external hidden unnamed_addr constant [62 x i8], align 1 +@.str12 = external hidden unnamed_addr constant [22 x i8], align 1 +@.str13 = external hidden unnamed_addr constant [31 x i8], align 1 +@capture_edited_filters = external hidden global %struct._GList*, align 8 +@display_edited_filters = external hidden global %struct._GList*, align 8 +@__PRETTY_FUNCTION__.get_filter_list = external hidden unnamed_addr constant [44 x i8], align 1 + +declare void @g_assertion_message(i8*, i8*, i32, i8*, i8*) noreturn + +declare void @g_free(i8*) + +declare %struct._GList* @g_list_first(%struct._GList*) + +declare noalias i8* @g_malloc(i64) + +define void @copy_filter_list(i32 %dest_type, i32 %src_type) nounwind uwtable ssp { +entry: + br label %do.body + +do.body: ; preds = %entry + %cmp = icmp ne i32 %dest_type, %src_type + br i1 %cmp, label %if.then, label %if.else + +if.then: ; preds = %do.body + br label %if.end + +if.else: ; preds = %do.body + call void @g_assertion_message_expr(i8* null, i8* getelementptr inbounds ([10 x i8]* @.str2, i32 0, i32 0), i32 581, i8* getelementptr inbounds ([62 x i8]* @__PRETTY_FUNCTION__.copy_filter_list, i32 0, i32 0), i8* getelementptr inbounds ([22 x i8]* @.str12, i32 0, i32 0)) noreturn + unreachable + +if.end: ; preds = %if.then + br label %do.end + +do.end: ; preds = %if.end + switch i32 %dest_type, label %sw.default.i [ + i32 0, label %sw.bb.i + i32 1, label %sw.bb1.i + i32 2, label %sw.bb2.i + i32 3, label %sw.bb3.i + ] + +sw.bb.i: ; preds = %do.end + br label %get_filter_list.exit + +sw.bb1.i: ; preds = %do.end + br label %get_filter_list.exit + +sw.bb2.i: ; preds = %do.end + br label %get_filter_list.exit + +sw.bb3.i: ; preds = %do.end + br label %get_filter_list.exit + +sw.default.i: ; preds = %do.end + call void @g_assertion_message(i8* null, i8* getelementptr inbounds ([10 x i8]* @.str2, i32 0, i32 0), i32 408, i8* getelementptr inbounds ([44 x i8]* @__PRETTY_FUNCTION__.get_filter_list, i32 0, i32 0), i8* null) noreturn nounwind + unreachable + +get_filter_list.exit: ; preds = %sw.bb3.i, %sw.bb2.i, %sw.bb1.i, %sw.bb.i + %0 = phi %struct._GList** [ @display_edited_filters, %sw.bb3.i ], [ @capture_edited_filters, %sw.bb2.i ], [ @display_filters, %sw.bb1.i ], [ @capture_filters, %sw.bb.i ] + switch i32 %src_type, label %sw.default.i5 [ + i32 0, label %sw.bb.i1 + i32 1, label %sw.bb1.i2 + i32 2, label %sw.bb2.i3 + i32 3, label %sw.bb3.i4 + ] + +sw.bb.i1: ; preds = %get_filter_list.exit + br label %get_filter_list.exit6 + +sw.bb1.i2: ; preds = %get_filter_list.exit + br label %get_filter_list.exit6 + +sw.bb2.i3: ; preds = %get_filter_list.exit + br label %get_filter_list.exit6 + +sw.bb3.i4: ; preds = %get_filter_list.exit + br label %get_filter_list.exit6 + +sw.default.i5: ; preds = %get_filter_list.exit + call void @g_assertion_message(i8* null, i8* getelementptr inbounds ([10 x i8]* @.str2, i32 0, i32 0), i32 408, i8* getelementptr inbounds ([44 x i8]* @__PRETTY_FUNCTION__.get_filter_list, i32 0, i32 0), i8* null) noreturn nounwind + unreachable + +; CHECK: get_filter_list.exit +get_filter_list.exit6: ; preds = %sw.bb3.i4, %sw.bb2.i3, %sw.bb1.i2, %sw.bb.i1 + %1 = phi %struct._GList** [ @display_edited_filters, %sw.bb3.i4 ], [ @capture_edited_filters, %sw.bb2.i3 ], [ @display_filters, %sw.bb1.i2 ], [ @capture_filters, %sw.bb.i1 ] +; CHECK: %2 = load + %2 = load %struct._GList** %1, align 8 +; We should have jump-threading insert an additional load here for the value +; coming out of the first switch, which is picked up by a subsequent phi +; CHECK: {{%\.pr = load %[^%]* %0}} +; CHECK-NEXT: br label %while.cond + br label %while.cond + +; CHECK: while.cond +while.cond: ; preds = %while.body, %get_filter_list.exit6 +; CHECK: {{= phi .*%.pr}} + %3 = load %struct._GList** %0, align 8 +; CHECK: tobool + %tobool = icmp ne %struct._GList* %3, null + br i1 %tobool, label %while.body, label %while.end + +while.body: ; preds = %while.cond + %4 = load %struct._GList** %0, align 8 + %5 = load %struct._GList** %0, align 8 + %call2 = call %struct._GList* @g_list_first(%struct._GList* %5) + %data.i = getelementptr inbounds %struct._GList* %call2, i32 0, i32 0 + %6 = load i8** %data.i, align 8 + %7 = bitcast i8* %6 to %struct.filter_def* + %name.i = getelementptr inbounds %struct.filter_def* %7, i32 0, i32 0 + %8 = load i8** %name.i, align 8 + call void @g_free(i8* %8) nounwind + %strval.i = getelementptr inbounds %struct.filter_def* %7, i32 0, i32 1 + %9 = load i8** %strval.i, align 8 + call void @g_free(i8* %9) nounwind + %10 = bitcast %struct.filter_def* %7 to i8* + call void @g_free(i8* %10) nounwind + %call.i = call %struct._GList* @g_list_remove_link(%struct._GList* %4, %struct._GList* %call2) nounwind + store %struct._GList* %call.i, %struct._GList** %0, align 8 + br label %while.cond + +while.end: ; preds = %while.cond + br label %do.body4 + +do.body4: ; preds = %while.end + %11 = load %struct._GList** %0, align 8 + %call5 = call i32 @g_list_length(%struct._GList* %11) + %cmp6 = icmp eq i32 %call5, 0 + br i1 %cmp6, label %if.then7, label %if.else8 + +if.then7: ; preds = %do.body4 + br label %if.end9 + +if.else8: ; preds = %do.body4 + call void @g_assertion_message_expr(i8* null, i8* getelementptr inbounds ([10 x i8]* @.str2, i32 0, i32 0), i32 600, i8* getelementptr inbounds ([62 x i8]* @__PRETTY_FUNCTION__.copy_filter_list, i32 0, i32 0), i8* getelementptr inbounds ([31 x i8]* @.str13, i32 0, i32 0)) noreturn + unreachable + +if.end9: ; preds = %if.then7 + br label %do.end10 + +do.end10: ; preds = %if.end9 + br label %while.cond11 + +while.cond11: ; preds = %cond.end, %do.end10 + %cond10 = phi %struct._GList* [ %cond, %cond.end ], [ %2, %do.end10 ] + %tobool12 = icmp ne %struct._GList* %cond10, null + br i1 %tobool12, label %while.body13, label %while.end16 + +while.body13: ; preds = %while.cond11 + %data = getelementptr inbounds %struct._GList* %cond10, i32 0, i32 0 + %12 = load i8** %data, align 8 + %13 = bitcast i8* %12 to %struct.filter_def* + %14 = load %struct._GList** %0, align 8 + %name = getelementptr inbounds %struct.filter_def* %13, i32 0, i32 0 + %15 = load i8** %name, align 8 + %strval = getelementptr inbounds %struct.filter_def* %13, i32 0, i32 1 + %16 = load i8** %strval, align 8 + %call.i7 = call noalias i8* @g_malloc(i64 16) nounwind + %17 = bitcast i8* %call.i7 to %struct.filter_def* + %call1.i = call noalias i8* @g_strdup(i8* %15) nounwind + %name.i8 = getelementptr inbounds %struct.filter_def* %17, i32 0, i32 0 + store i8* %call1.i, i8** %name.i8, align 8 + %call2.i = call noalias i8* @g_strdup(i8* %16) nounwind + %strval.i9 = getelementptr inbounds %struct.filter_def* %17, i32 0, i32 1 + store i8* %call2.i, i8** %strval.i9, align 8 + %18 = bitcast %struct.filter_def* %17 to i8* + %call3.i = call %struct._GList* @g_list_append(%struct._GList* %14, i8* %18) nounwind + store %struct._GList* %call3.i, %struct._GList** %0, align 8 + %tobool15 = icmp ne %struct._GList* %cond10, null + br i1 %tobool15, label %cond.true, label %cond.false + +cond.true: ; preds = %while.body13 + %next = getelementptr inbounds %struct._GList* %cond10, i32 0, i32 1 + %19 = load %struct._GList** %next, align 8 + br label %cond.end + +cond.false: ; preds = %while.body13 + br label %cond.end + +cond.end: ; preds = %cond.false, %cond.true + %cond = phi %struct._GList* [ %19, %cond.true ], [ null, %cond.false ] + br label %while.cond11 + +while.end16: ; preds = %while.cond11 + ret void +} + +declare void @g_assertion_message_expr(i8*, i8*, i32, i8*, i8*) noreturn + +declare i32 @g_list_length(%struct._GList*) + +declare noalias i8* @g_strdup(i8*) + +declare %struct._GList* @g_list_append(%struct._GList*, i8*) + +declare %struct._GList* @g_list_remove_link(%struct._GList*, %struct._GList*) diff --git a/test/Transforms/LCSSA/2006-06-03-IncorrectIDFPhis.ll b/test/Transforms/LCSSA/2006-06-03-IncorrectIDFPhis.ll index 153458579b89..dd43c8837901 100644 --- a/test/Transforms/LCSSA/2006-06-03-IncorrectIDFPhis.ll +++ b/test/Transforms/LCSSA/2006-06-03-IncorrectIDFPhis.ll @@ -1,5 +1,5 @@ ; RUN: opt < %s -loop-simplify -lcssa -S | \ -; RUN: grep {%%SJE.0.0.lcssa = phi .struct.SetJmpMapEntry} +; RUN: grep "%%SJE.0.0.lcssa = phi .struct.SetJmpMapEntry" %struct.SetJmpMapEntry = type { i8*, i32, %struct.SetJmpMapEntry* } diff --git a/test/Transforms/LCSSA/2006-06-12-MultipleExitsSameBlock.ll b/test/Transforms/LCSSA/2006-06-12-MultipleExitsSameBlock.ll index ad4f1447b292..575f8163c94b 100644 --- a/test/Transforms/LCSSA/2006-06-12-MultipleExitsSameBlock.ll +++ b/test/Transforms/LCSSA/2006-06-12-MultipleExitsSameBlock.ll @@ -1,7 +1,7 @@ ; RUN: opt < %s -lcssa -S | \ -; RUN: grep {%X.1.lcssa} +; RUN: grep "%X.1.lcssa" ; RUN: opt < %s -lcssa -S | \ -; RUN: not grep {%X.1.lcssa1} +; RUN: not grep "%X.1.lcssa1" declare i1 @c1() diff --git a/test/Transforms/LCSSA/basictest.ll b/test/Transforms/LCSSA/basictest.ll index 23ab2c0ce056..4b05ad995305 100644 --- a/test/Transforms/LCSSA/basictest.ll +++ b/test/Transforms/LCSSA/basictest.ll @@ -1,7 +1,7 @@ ; RUN: opt < %s -lcssa -S | \ -; RUN: grep {X3.lcssa = phi i32} +; RUN: grep "X3.lcssa = phi i32" ; RUN: opt < %s -lcssa -S | \ -; RUN: grep {X4 = add i32 3, %X3.lcssa} +; RUN: grep "X4 = add i32 3, %X3.lcssa" define void @lcssa(i1 %S2) { entry: diff --git a/test/Transforms/LCSSA/unreachable-use.ll b/test/Transforms/LCSSA/unreachable-use.ll index c389c9cfa878..71ae134e314c 100644 --- a/test/Transforms/LCSSA/unreachable-use.ll +++ b/test/Transforms/LCSSA/unreachable-use.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -lcssa -S -verify-loop-info | grep {\[%\]tmp33 = load i1\\*\\* \[%\]tmp} +; RUN: opt < %s -lcssa -S -verify-loop-info | grep "[%]tmp33 = load i1\*\* [%]tmp" ; PR6546 ; LCSSA doesn't need to transform uses in blocks not reachable diff --git a/test/Transforms/LCSSA/unused-phis.ll b/test/Transforms/LCSSA/unused-phis.ll index aa2ab963411d..01b214b8e36c 100644 --- a/test/Transforms/LCSSA/unused-phis.ll +++ b/test/Transforms/LCSSA/unused-phis.ll @@ -2,9 +2,9 @@ ; CHECK: exit1: ; CHECK: .lcssa = ; CHECK: exit2: -; CHECK: .lcssa2 = +; CHECK: .lcssa1 = ; CHECK: exit3: -; CHECK-NOT: .lcssa1 = +; CHECK-NOT: .lcssa ; Test to ensure that when there are multiple exit blocks, PHI nodes are ; only inserted by LCSSA when there is a use dominated by a given exit diff --git a/test/Transforms/LICM/2003-02-27-PreheaderProblem.ll b/test/Transforms/LICM/2003-02-27-PreheaderProblem.ll index 70a04c73b1d3..b54d520a91f7 100644 --- a/test/Transforms/LICM/2003-02-27-PreheaderProblem.ll +++ b/test/Transforms/LICM/2003-02-27-PreheaderProblem.ll @@ -4,7 +4,7 @@ ; case... bad. ; RUN: opt < %s -licm -loop-deletion -simplifycfg -S | \ -; RUN: not grep {br } +; RUN: not grep "br " define i32 @main(i32 %argc) { ; <label>:0 diff --git a/test/Transforms/LICM/2007-05-22-VolatileSink.ll b/test/Transforms/LICM/2007-05-22-VolatileSink.ll index 4df6ea758103..94511cc9c156 100644 --- a/test/Transforms/LICM/2007-05-22-VolatileSink.ll +++ b/test/Transforms/LICM/2007-05-22-VolatileSink.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -licm -S | grep {store volatile} +; RUN: opt < %s -licm -S | grep "store volatile" ; PR1435 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" target triple = "i686-apple-darwin8" diff --git a/test/Transforms/LICM/hoist-invariant-load.ll b/test/Transforms/LICM/hoist-invariant-load.ll index 4e100d3aee34..f9fc551df358 100644 --- a/test/Transforms/LICM/hoist-invariant-load.ll +++ b/test/Transforms/LICM/hoist-invariant-load.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -licm -stats -S |& grep "1 licm" +; RUN: opt < %s -licm -stats -S 2>&1 | grep "1 licm" @"\01L_OBJC_METH_VAR_NAME_" = internal global [4 x i8] c"foo\00", section "__TEXT,__objc_methname,cstring_literals", align 1 @"\01L_OBJC_SELECTOR_REFERENCES_" = internal global i8* getelementptr inbounds ([4 x i8]* @"\01L_OBJC_METH_VAR_NAME_", i32 0, i32 0), section "__DATA, __objc_selrefs, literal_pointers, no_dead_strip" diff --git a/test/Transforms/LICM/promote-order.ll b/test/Transforms/LICM/promote-order.ll new file mode 100644 index 000000000000..b016265bbb03 --- /dev/null +++ b/test/Transforms/LICM/promote-order.ll @@ -0,0 +1,41 @@ +; RUN: opt -tbaa -basicaa -licm -S < %s | FileCheck %s + +; LICM should keep the stores in their original order when it sinks/promotes them. +; rdar://12045203 + +target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128" +target triple = "x86_64-apple-macosx10.8.0" + +@p = external global i8* + +define i32* @_Z4doiti(i32 %n, float* %tmp1, i32* %tmp3) nounwind { +entry: + %cmp1 = icmp slt i32 0, %n + br i1 %cmp1, label %for.body.lr.ph, label %for.end + +for.body.lr.ph: ; preds = %entry + br label %for.body + +for.body: ; preds = %for.body, %for.body.lr.ph + %i.02 = phi i32 [ 0, %for.body.lr.ph ], [ %inc, %for.body ] + store float 1.000000e+00, float* %tmp1, align 4, !tbaa !1 + store i32 1, i32* %tmp3, align 4, !tbaa !2 + %inc = add nsw i32 %i.02, 1 + %cmp = icmp slt i32 %inc, %n + br i1 %cmp, label %for.body, label %for.cond.for.end_crit_edge + +; CHECK: for.cond.for.end_crit_edge: +; CHECK: store float 1.000000e+00, float* %tmp1 +; CHECK: store i32 1, i32* %tmp3 +for.cond.for.end_crit_edge: ; preds = %for.body + %split = phi i32* [ %tmp3, %for.body ] + br label %for.end + +for.end: ; preds = %for.cond.for.end_crit_edge, %entry + %r.0.lcssa = phi i32* [ %split, %for.cond.for.end_crit_edge ], [ undef, %entry ] + ret i32* %r.0.lcssa +} + +!0 = metadata !{metadata !"minimal TBAA"} +!1 = metadata !{metadata !"float", metadata !0} +!2 = metadata !{metadata !"int", metadata !0} diff --git a/test/Transforms/LICM/speculate.ll b/test/Transforms/LICM/speculate.ll index 507b193e6b1c..4c4d036b7dbf 100644 --- a/test/Transforms/LICM/speculate.ll +++ b/test/Transforms/LICM/speculate.ll @@ -165,3 +165,25 @@ for.inc: ; preds = %if.then, %for.body for.end: ; preds = %for.inc, %entry ret void } + +; SDiv is unsafe to speculate inside an infinite loop. + +define void @unsafe_sdiv_c(i64 %a, i64 %b, i64* %p) { +entry: +; CHECK: entry: +; CHECK-NOT: sdiv +; CHECK: br label %for.body + br label %for.body + +for.body: + %c = icmp eq i64 %b, 0 + br i1 %c, label %backedge, label %if.then + +if.then: + %d = sdiv i64 %a, %b + store i64 %d, i64* %p + br label %backedge + +backedge: + br label %for.body +} diff --git a/test/Transforms/LoopRotate/PhiRename-1.ll b/test/Transforms/LoopRotate/PhiRename-1.ll index 9cb55b411932..a2247775ea78 100644 --- a/test/Transforms/LoopRotate/PhiRename-1.ll +++ b/test/Transforms/LoopRotate/PhiRename-1.ll @@ -1,5 +1,6 @@ -; RUN: opt < %s -loop-rotate -verify-dom-info -verify-loop-info -S | not grep {\\\[ .tmp224} -; END. +; RUN: opt < %s -loop-rotate -verify-dom-info -verify-loop-info -S | FileCheck %s +; CHECK-NOT: [ {{.}}tmp224 + 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" %struct.FILE = type { i8*, i32, i32, i16, i16, %struct.__sbuf, i32, i8*, i32 (i8*)*, i32 (i8*, i8*, i32)*, i64 (i8*, i64, i32)*, i32 (i8*, i8*, i32)*, %struct.__sbuf, %struct.__sFILEX*, i32, [3 x i8], [1 x i8], %struct.__sbuf, i32, i64 } diff --git a/test/Transforms/LoopSimplify/indirectbr.ll b/test/Transforms/LoopSimplify/indirectbr.ll index 9814d4ad93f1..ca05f437e5cf 100644 --- a/test/Transforms/LoopSimplify/indirectbr.ll +++ b/test/Transforms/LoopSimplify/indirectbr.ll @@ -1,5 +1,5 @@ ; RUN: opt < %s -loop-simplify -lcssa -verify-loop-info -verify-dom-info -S \ -; RUN: | grep -F {indirectbr i8* %x, \[label %L0, label %L1\]} \ +; RUN: | grep -F "indirectbr i8* %x, [label %L0, label %L1]" \ ; RUN: | count 6 ; LoopSimplify should not try to transform loops when indirectbr is involved. diff --git a/test/Transforms/LoopSimplify/merge-exits.ll b/test/Transforms/LoopSimplify/merge-exits.ll index 40ad2f44e717..8de5938939dc 100644 --- a/test/Transforms/LoopSimplify/merge-exits.ll +++ b/test/Transforms/LoopSimplify/merge-exits.ll @@ -1,6 +1,6 @@ ; RUN: opt < %s -loop-simplify -loop-rotate -instcombine -indvars -S -verify-loop-info -verify-dom-info > %t ; RUN: not grep sext %t -; RUN: grep {phi i64} %t | count 1 +; RUN: grep "phi i64" %t | count 1 ; Loopsimplify should be able to merge the two loop exits ; into one, so that loop rotate can rotate the loop, so diff --git a/test/Transforms/LoopSimplify/preserve-scev.ll b/test/Transforms/LoopSimplify/preserve-scev.ll index 23ac7f257a38..854c612f02dd 100644 --- a/test/Transforms/LoopSimplify/preserve-scev.ll +++ b/test/Transforms/LoopSimplify/preserve-scev.ll @@ -1,4 +1,4 @@ -; RUN: opt -S < %s -indvars | opt -analyze -iv-users | grep {%cmp = icmp slt i32} | grep {= \{%\\.ph,+,1\}<%for.cond>} +; RUN: opt -S < %s -indvars | opt -analyze -iv-users | grep "%cmp = icmp slt i32" | grep "= {%\.ph,+,1}<%for.cond>" ; PR8079 ; LoopSimplify should invalidate indvars when splitting out the diff --git a/test/Transforms/LoopStrengthReduce/2012-07-13-ExpandUDiv.ll b/test/Transforms/LoopStrengthReduce/2012-07-13-ExpandUDiv.ll new file mode 100644 index 000000000000..a1222083abc9 --- /dev/null +++ b/test/Transforms/LoopStrengthReduce/2012-07-13-ExpandUDiv.ll @@ -0,0 +1,90 @@ +; RUN: opt -loop-reduce -S < %s | FileCheck %s +; +; PR11356: likely wrong code bug +target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128" +target triple = "x86_64-apple-darwin" + +@g_66 = global [1 x i32] zeroinitializer, align 4 +@g_775 = global i32 0, align 4 +@g_752 = global i32 0, align 4 +@g_3 = global i32 0, align 4 + +; Ensure that %div.i.i.us is not hoisted. +; CHECK: @main +; CHECK: for.body.i.i.us: +; CHECK: %div.i.i.i.us +; CHECK: %cmp5.i.i.us +define i32 @main() nounwind uwtable ssp { +entry: + %l_2 = alloca [1 x i32], align 4 + %arrayidx = getelementptr inbounds [1 x i32]* %l_2, i64 0, i64 0 + store i32 0, i32* %arrayidx, align 4, !tbaa !0 + %tmp = load i32* @g_3, align 4, !tbaa !0 + %idxprom = sext i32 %tmp to i64 + %arrayidx1 = getelementptr inbounds [1 x i32]* %l_2, i64 0, i64 %idxprom + %tmp1 = load i32* %arrayidx1, align 4, !tbaa !0 + %conv.i.i = and i32 %tmp1, 65535 + %tobool.i.i.i = icmp ne i32 %tmp, 0 + br label %codeRepl + +codeRepl.loopexit.us-lcssa: ; preds = %for.body.i.i, %codeRepl5 + br label %codeRepl.loopexit + +codeRepl.loopexit: ; preds = %codeRepl.loopexit.us-lcssa.us, %codeRepl.loopexit.us-lcssa + br label %codeRepl + +codeRepl: ; preds = %codeRepl.loopexit, %entry + br i1 %tobool.i.i.i, label %codeRepl.split.us, label %codeRepl.codeRepl.split_crit_edge + +codeRepl.codeRepl.split_crit_edge: ; preds = %codeRepl + br label %codeRepl.split + +codeRepl.split.us: ; preds = %codeRepl + br label %for.cond.i.i.us + +for.cond.i.i.us: ; preds = %for.inc.i.i.us, %codeRepl.split.us + %tmp2 = phi i32 [ 0, %codeRepl.split.us ], [ %add.i.i.us, %for.inc.i.i.us ] + br label %codeRepl5.us + +for.inc.i.i.us: ; preds = %for.body.i.i.us + %add.i.i.us = add nsw i32 %tmp2, 1 + store i32 %add.i.i.us, i32* @g_752, align 4, !tbaa !0 + br label %for.cond.i.i.us + +for.body.i.i.us: ; preds = %codeRepl5.us + %div.i.i.i.us = udiv i32 1, %conv.i.i + %cmp5.i.i.us = icmp eq i32 %div.i.i.i.us, %tmp2 + br i1 %cmp5.i.i.us, label %codeRepl.loopexit.us-lcssa.us, label %for.inc.i.i.us + +codeRepl5.us: ; preds = %for.cond.i.i.us + br i1 true, label %codeRepl.loopexit.us-lcssa.us, label %for.body.i.i.us + +codeRepl.loopexit.us-lcssa.us: ; preds = %codeRepl5.us, %for.body.i.i.us + br label %codeRepl.loopexit + +codeRepl.split: ; preds = %codeRepl.codeRepl.split_crit_edge + br label %for.cond.i.i + +for.cond.i.i: ; preds = %for.inc.i.i, %codeRepl.split + %tmp3 = phi i32 [ 0, %codeRepl.split ], [ %add.i.i, %for.inc.i.i ] + br label %codeRepl5 + +codeRepl5: ; preds = %for.cond.i.i + br i1 true, label %codeRepl.loopexit.us-lcssa, label %for.body.i.i + +for.body.i.i: ; preds = %codeRepl5 + %cmp5.i.i = icmp eq i32 0, %tmp3 + br i1 %cmp5.i.i, label %codeRepl.loopexit.us-lcssa, label %for.inc.i.i + +for.inc.i.i: ; preds = %for.body.i.i + %add.i.i = add nsw i32 %tmp3, 1 + store i32 %add.i.i, i32* @g_752, align 4, !tbaa !0 + br label %for.cond.i.i + +func_4.exit: ; No predecessors! + ret i32 0 +} + +!0 = metadata !{metadata !"int", metadata !1} +!1 = metadata !{metadata !"omnipotent char", metadata !2} +!2 = metadata !{metadata !"Simple C/C++ TBAA", null} diff --git a/test/Transforms/LoopStrengthReduce/2012-07-18-LimitReassociate.ll b/test/Transforms/LoopStrengthReduce/2012-07-18-LimitReassociate.ll new file mode 100644 index 000000000000..3793baccbbc1 --- /dev/null +++ b/test/Transforms/LoopStrengthReduce/2012-07-18-LimitReassociate.ll @@ -0,0 +1,517 @@ +; RUN: opt -loop-reduce -disable-output -debug-only=loop-reduce %s 2> %t +; RUN: FileCheck %s < %t +; REQUIRES: asserts +; +; PR13361: LSR + SCEV "hangs" on reasonably sized test with sequence of loops +; +; Without limits on CollectSubexpr, we have thousands of formulae for +; the use that crosses loops. With limits we have five. +; CHECK: LSR on loop %bb221: +; CHECK: After generating reuse formulae: +; CHECK: LSR is examining the following uses: +; CHECK: LSR Use: Kind=Special +; CHECK: {{.*reg\(\{\{\{\{\{\{\{\{\{}} +; CHECK: {{.*reg\(\{\{\{\{\{\{\{\{\{}} +; CHECK: {{.*reg\(\{\{\{\{\{\{\{\{\{}} +; CHECK: {{.*reg\(\{\{\{\{\{\{\{\{\{}} +; CHECK: {{.*reg\(\{\{\{\{\{\{\{\{\{}} +; CHECK-NOT:reg +; CHECK: Filtering for use +target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128" +target triple = "x86_64-unknown-freebsd9" + +%struct.snork = type { %struct.fuga, i32, i32, i32, i32, i32, i32 } +%struct.fuga = type { %struct.gork, i64 } +%struct.gork = type { i8*, i32, i32, %struct.noot* } +%struct.noot = type opaque +%struct.jim = type { [5120 x i8], i32, i32, [2048 x i8], i32, [256 x i8] } + +@global = external global %struct.snork, align 8 +@global1 = external hidden unnamed_addr constant [52 x i8], align 1 +@global2 = external hidden unnamed_addr constant [18 x i8], align 1 +@global3 = external hidden global %struct.jim, align 32 +@global4 = external hidden unnamed_addr constant [40 x i8], align 1 + +declare void @snork(...) nounwind + +declare fastcc void @blarg() nounwind uwtable readonly + +define hidden fastcc void @boogle() nounwind uwtable { +bb: + %tmp = trunc i64 0 to i32 + %tmp1 = icmp slt i32 %tmp, 2047 + %tmp2 = add i32 0, -1 + %tmp3 = icmp ult i32 %tmp2, 255 + %tmp4 = and i1 %tmp1, %tmp3 + br i1 %tmp4, label %bb6, label %bb5 + +bb5: ; preds = %bb + tail call void (...)* @snork(i8* getelementptr inbounds ([52 x i8]* @global1, i64 0, i64 0), i32 2021) nounwind + tail call void (...)* @snork(i8* getelementptr inbounds (%struct.jim* @global3, i64 0, i32 3, i64 1), i32 -2146631418) nounwind + unreachable + +bb6: ; preds = %bb + tail call void @zot(i8* getelementptr inbounds (%struct.jim* @global3, i64 0, i32 5, i64 0), i8* getelementptr inbounds (%struct.jim* @global3, i64 0, i32 3, i64 1), i64 undef, i32 1, i1 false) nounwind + %tmp7 = getelementptr inbounds %struct.jim* @global3, i64 0, i32 5, i64 undef + store i8 0, i8* %tmp7, align 1 + %tmp8 = add nsw i32 0, 1 + %tmp9 = sext i32 %tmp8 to i64 + %tmp10 = add i64 %tmp9, 1 + %tmp11 = getelementptr inbounds %struct.jim* @global3, i64 0, i32 3, i64 %tmp10 + %tmp12 = sub i64 2047, %tmp9 + %tmp13 = icmp eq i32 undef, 1 + br i1 %tmp13, label %bb14, label %bb15 + +bb14: ; preds = %bb6 + tail call fastcc void @blarg() + unreachable + +bb15: ; preds = %bb6 + %tmp16 = trunc i64 %tmp12 to i32 + br label %bb17 + +bb17: ; preds = %bb26, %bb15 + %tmp18 = phi i64 [ %tmp28, %bb26 ], [ 0, %bb15 ] + %tmp19 = phi i32 [ %tmp29, %bb26 ], [ 0, %bb15 ] + %tmp20 = trunc i64 %tmp18 to i32 + %tmp21 = icmp slt i32 %tmp20, %tmp16 + br i1 %tmp21, label %bb22, label %bb32 + +bb22: ; preds = %bb17 + %tmp23 = getelementptr inbounds %struct.jim* @global3, i64 0, i32 3, i64 0 + %tmp24 = load i8* %tmp23, align 1 + %tmp25 = icmp eq i8 %tmp24, 58 + br i1 %tmp25, label %bb30, label %bb26 + +bb26: ; preds = %bb22 + %tmp27 = icmp eq i8 %tmp24, 0 + %tmp28 = add i64 %tmp18, 1 + %tmp29 = add nsw i32 %tmp19, 1 + br i1 %tmp27, label %bb32, label %bb17 + +bb30: ; preds = %bb22 + %tmp31 = icmp ult i32 undef, 255 + br i1 %tmp31, label %bb33, label %bb32 + +bb32: ; preds = %bb30, %bb26, %bb17 + tail call void (...)* @snork(i8* getelementptr inbounds ([52 x i8]* @global1, i64 0, i64 0), i32 2038) nounwind + tail call void (...)* @snork(i8* %tmp11, i32 -2146631418) nounwind + unreachable + +bb33: ; preds = %bb30 + tail call void @zot(i8* getelementptr inbounds (%struct.jim* @global3, i64 0, i32 5, i64 0), i8* %tmp11, i64 undef, i32 1, i1 false) nounwind + %tmp34 = getelementptr inbounds %struct.jim* @global3, i64 0, i32 5, i64 undef + store i8 0, i8* %tmp34, align 1 + %tmp35 = add nsw i32 %tmp19, 1 + %tmp36 = sext i32 %tmp35 to i64 + %tmp37 = add i64 %tmp36, %tmp10 + %tmp38 = getelementptr inbounds %struct.jim* @global3, i64 0, i32 3, i64 %tmp37 + %tmp39 = sub i64 %tmp12, %tmp36 + br i1 false, label %bb40, label %bb41 + +bb40: ; preds = %bb33 + br label %bb41 + +bb41: ; preds = %bb40, %bb33 + %tmp42 = trunc i64 %tmp39 to i32 + br label %bb43 + +bb43: ; preds = %bb52, %bb41 + %tmp44 = phi i64 [ %tmp53, %bb52 ], [ 0, %bb41 ] + %tmp45 = phi i32 [ %tmp54, %bb52 ], [ 0, %bb41 ] + %tmp46 = trunc i64 %tmp44 to i32 + %tmp47 = icmp slt i32 %tmp46, %tmp42 + br i1 %tmp47, label %bb48, label %bb58 + +bb48: ; preds = %bb43 + %tmp49 = add i64 %tmp44, %tmp37 + %tmp50 = load i8* undef, align 1 + %tmp51 = icmp eq i8 %tmp50, 58 + br i1 %tmp51, label %bb55, label %bb52 + +bb52: ; preds = %bb48 + %tmp53 = add i64 %tmp44, 1 + %tmp54 = add nsw i32 %tmp45, 1 + br i1 undef, label %bb58, label %bb43 + +bb55: ; preds = %bb48 + %tmp56 = add i32 %tmp45, -1 + %tmp57 = icmp ult i32 %tmp56, 255 + br i1 %tmp57, label %bb59, label %bb58 + +bb58: ; preds = %bb55, %bb52, %bb43 + tail call void (...)* @snork(i8* getelementptr inbounds ([52 x i8]* @global1, i64 0, i64 0), i32 2055) nounwind + tail call void (...)* @snork(i8* %tmp38, i32 -2146631418) nounwind + br label %bb247 + +bb59: ; preds = %bb55 + %tmp60 = sext i32 %tmp45 to i64 + tail call void @zot(i8* getelementptr inbounds (%struct.jim* @global3, i64 0, i32 5, i64 0), i8* %tmp38, i64 %tmp60, i32 1, i1 false) nounwind + %tmp61 = getelementptr inbounds %struct.jim* @global3, i64 0, i32 5, i64 %tmp60 + store i8 0, i8* %tmp61, align 1 + %tmp62 = add nsw i32 %tmp45, 1 + %tmp63 = sext i32 %tmp62 to i64 + %tmp64 = add i64 %tmp63, %tmp37 + %tmp65 = sub i64 %tmp39, %tmp63 + %tmp66 = icmp eq i32 undef, 2 + br i1 %tmp66, label %bb67, label %bb68 + +bb67: ; preds = %bb59 + tail call fastcc void @blarg() + unreachable + +bb68: ; preds = %bb59 + switch i32 undef, label %bb71 [ + i32 0, label %bb74 + i32 -1, label %bb69 + ] + +bb69: ; preds = %bb68 + tail call void (...)* @snork(i8* getelementptr inbounds ([52 x i8]* @global1, i64 0, i64 0), i32 2071) nounwind + %tmp70 = load i32* getelementptr inbounds (%struct.snork* @global, i64 0, i32 2), align 4 + unreachable + +bb71: ; preds = %bb68 + %tmp72 = load i32* getelementptr inbounds (%struct.snork* @global, i64 0, i32 4), align 4 + %tmp73 = icmp eq i32 undef, 0 + br i1 %tmp73, label %bb247, label %bb74 + +bb74: ; preds = %bb71, %bb68 + %tmp75 = trunc i64 %tmp65 to i32 + br label %bb76 + +bb76: ; preds = %bb82, %bb74 + %tmp77 = phi i64 [ %tmp84, %bb82 ], [ 0, %bb74 ] + %tmp78 = phi i32 [ %tmp85, %bb82 ], [ 0, %bb74 ] + %tmp79 = trunc i64 %tmp77 to i32 + %tmp80 = icmp slt i32 %tmp79, %tmp75 + br i1 %tmp80, label %bb81, label %bb87 + +bb81: ; preds = %bb76 + br i1 false, label %bb86, label %bb82 + +bb82: ; preds = %bb81 + %tmp83 = icmp eq i8 0, 0 + %tmp84 = add i64 %tmp77, 1 + %tmp85 = add nsw i32 %tmp78, 1 + br i1 %tmp83, label %bb87, label %bb76 + +bb86: ; preds = %bb81 + br i1 undef, label %bb88, label %bb87 + +bb87: ; preds = %bb86, %bb82, %bb76 + unreachable + +bb88: ; preds = %bb86 + %tmp89 = add nsw i32 %tmp78, 1 + %tmp90 = sext i32 %tmp89 to i64 + %tmp91 = add i64 %tmp90, %tmp64 + %tmp92 = sub i64 %tmp65, %tmp90 + br i1 false, label %bb93, label %bb94 + +bb93: ; preds = %bb88 + unreachable + +bb94: ; preds = %bb88 + %tmp95 = trunc i64 %tmp92 to i32 + br label %bb96 + +bb96: ; preds = %bb102, %bb94 + %tmp97 = phi i64 [ %tmp103, %bb102 ], [ 0, %bb94 ] + %tmp98 = phi i32 [ %tmp104, %bb102 ], [ 0, %bb94 ] + %tmp99 = trunc i64 %tmp97 to i32 + %tmp100 = icmp slt i32 %tmp99, %tmp95 + br i1 %tmp100, label %bb101, label %bb106 + +bb101: ; preds = %bb96 + br i1 undef, label %bb105, label %bb102 + +bb102: ; preds = %bb101 + %tmp103 = add i64 %tmp97, 1 + %tmp104 = add nsw i32 %tmp98, 1 + br i1 false, label %bb106, label %bb96 + +bb105: ; preds = %bb101 + br i1 undef, label %bb107, label %bb106 + +bb106: ; preds = %bb105, %bb102, %bb96 + br label %bb247 + +bb107: ; preds = %bb105 + %tmp108 = add nsw i32 %tmp98, 1 + %tmp109 = sext i32 %tmp108 to i64 + %tmp110 = add i64 %tmp109, %tmp91 + %tmp111 = sub i64 %tmp92, %tmp109 + br i1 false, label %bb112, label %bb113 + +bb112: ; preds = %bb107 + unreachable + +bb113: ; preds = %bb107 + %tmp114 = trunc i64 %tmp111 to i32 + br label %bb115 + +bb115: ; preds = %bb121, %bb113 + %tmp116 = phi i64 [ %tmp122, %bb121 ], [ 0, %bb113 ] + %tmp117 = phi i32 [ %tmp123, %bb121 ], [ 0, %bb113 ] + %tmp118 = trunc i64 %tmp116 to i32 + %tmp119 = icmp slt i32 %tmp118, %tmp114 + br i1 %tmp119, label %bb120, label %bb125 + +bb120: ; preds = %bb115 + br i1 undef, label %bb124, label %bb121 + +bb121: ; preds = %bb120 + %tmp122 = add i64 %tmp116, 1 + %tmp123 = add nsw i32 %tmp117, 1 + br i1 false, label %bb125, label %bb115 + +bb124: ; preds = %bb120 + br i1 false, label %bb126, label %bb125 + +bb125: ; preds = %bb124, %bb121, %bb115 + unreachable + +bb126: ; preds = %bb124 + %tmp127 = add nsw i32 %tmp117, 1 + %tmp128 = sext i32 %tmp127 to i64 + %tmp129 = add i64 %tmp128, %tmp110 + %tmp130 = sub i64 %tmp111, %tmp128 + tail call fastcc void @blarg() + br i1 false, label %bb132, label %bb131 + +bb131: ; preds = %bb126 + unreachable + +bb132: ; preds = %bb126 + %tmp133 = trunc i64 %tmp130 to i32 + br label %bb134 + +bb134: ; preds = %bb140, %bb132 + %tmp135 = phi i64 [ %tmp141, %bb140 ], [ 0, %bb132 ] + %tmp136 = phi i32 [ %tmp142, %bb140 ], [ 0, %bb132 ] + %tmp137 = trunc i64 %tmp135 to i32 + %tmp138 = icmp slt i32 %tmp137, %tmp133 + br i1 %tmp138, label %bb139, label %bb144 + +bb139: ; preds = %bb134 + br i1 false, label %bb143, label %bb140 + +bb140: ; preds = %bb139 + %tmp141 = add i64 %tmp135, 1 + %tmp142 = add nsw i32 %tmp136, 1 + br i1 false, label %bb144, label %bb134 + +bb143: ; preds = %bb139 + br i1 false, label %bb145, label %bb144 + +bb144: ; preds = %bb143, %bb140, %bb134 + br label %bb247 + +bb145: ; preds = %bb143 + %tmp146 = add nsw i32 %tmp136, 1 + %tmp147 = sext i32 %tmp146 to i64 + %tmp148 = add i64 %tmp147, %tmp129 + %tmp149 = sub i64 %tmp130, %tmp147 + switch i32 0, label %bb152 [ + i32 0, label %bb150 + i32 16, label %bb150 + i32 32, label %bb150 + i32 48, label %bb150 + i32 64, label %bb150 + i32 256, label %bb150 + i32 4096, label %bb150 + ] + +bb150: ; preds = %bb145, %bb145, %bb145, %bb145, %bb145, %bb145, %bb145 + %tmp151 = trunc i64 %tmp149 to i32 + br label %bb153 + +bb152: ; preds = %bb145 + unreachable + +bb153: ; preds = %bb160, %bb150 + %tmp154 = phi i64 [ %tmp161, %bb160 ], [ 0, %bb150 ] + %tmp155 = phi i32 [ %tmp162, %bb160 ], [ 0, %bb150 ] + %tmp156 = trunc i64 %tmp154 to i32 + %tmp157 = icmp slt i32 %tmp156, %tmp151 + br i1 %tmp157, label %bb158, label %bb166 + +bb158: ; preds = %bb153 + %tmp159 = add i64 %tmp154, %tmp148 + br i1 false, label %bb163, label %bb160 + +bb160: ; preds = %bb158 + %tmp161 = add i64 %tmp154, 1 + %tmp162 = add nsw i32 %tmp155, 1 + br i1 false, label %bb166, label %bb153 + +bb163: ; preds = %bb158 + %tmp164 = add i32 %tmp155, -1 + %tmp165 = icmp ult i32 %tmp164, 255 + br i1 %tmp165, label %bb167, label %bb166 + +bb166: ; preds = %bb163, %bb160, %bb153 + unreachable + +bb167: ; preds = %bb163 + %tmp168 = add nsw i32 %tmp155, 1 + %tmp169 = sext i32 %tmp168 to i64 + %tmp170 = add i64 %tmp169, %tmp148 + %tmp171 = sub i64 %tmp149, %tmp169 + br i1 false, label %bb173, label %bb172 + +bb172: ; preds = %bb167 + unreachable + +bb173: ; preds = %bb167 + %tmp174 = trunc i64 %tmp171 to i32 + br label %bb175 + +bb175: ; preds = %bb181, %bb173 + %tmp176 = phi i64 [ %tmp183, %bb181 ], [ 0, %bb173 ] + %tmp177 = phi i32 [ %tmp184, %bb181 ], [ 0, %bb173 ] + %tmp178 = trunc i64 %tmp176 to i32 + %tmp179 = icmp slt i32 %tmp178, %tmp174 + br i1 %tmp179, label %bb180, label %bb186 + +bb180: ; preds = %bb175 + br i1 false, label %bb185, label %bb181 + +bb181: ; preds = %bb180 + %tmp182 = icmp eq i8 0, 0 + %tmp183 = add i64 %tmp176, 1 + %tmp184 = add nsw i32 %tmp177, 1 + br i1 %tmp182, label %bb186, label %bb175 + +bb185: ; preds = %bb180 + br i1 false, label %bb187, label %bb186 + +bb186: ; preds = %bb185, %bb181, %bb175 + unreachable + +bb187: ; preds = %bb185 + %tmp188 = add nsw i32 %tmp177, 1 + %tmp189 = sext i32 %tmp188 to i64 + %tmp190 = sub i64 %tmp171, %tmp189 + br i1 false, label %bb192, label %bb191 + +bb191: ; preds = %bb187 + unreachable + +bb192: ; preds = %bb187 + %tmp193 = trunc i64 %tmp190 to i32 + br label %bb194 + +bb194: ; preds = %bb200, %bb192 + %tmp195 = phi i64 [ %tmp201, %bb200 ], [ 0, %bb192 ] + %tmp196 = phi i32 [ %tmp202, %bb200 ], [ 0, %bb192 ] + %tmp197 = trunc i64 %tmp195 to i32 + %tmp198 = icmp slt i32 %tmp197, %tmp193 + br i1 %tmp198, label %bb199, label %bb204 + +bb199: ; preds = %bb194 + br i1 false, label %bb203, label %bb200 + +bb200: ; preds = %bb199 + %tmp201 = add i64 %tmp195, 1 + %tmp202 = add nsw i32 %tmp196, 1 + br i1 false, label %bb204, label %bb194 + +bb203: ; preds = %bb199 + br i1 undef, label %bb205, label %bb204 + +bb204: ; preds = %bb203, %bb200, %bb194 + unreachable + +bb205: ; preds = %bb203 + %tmp206 = add nsw i32 %tmp196, 1 + %tmp207 = sext i32 %tmp206 to i64 + %tmp208 = add i64 %tmp207, 0 + %tmp209 = sub i64 %tmp190, %tmp207 + br i1 %tmp13, label %bb210, label %bb211 + +bb210: ; preds = %bb205 + unreachable + +bb211: ; preds = %bb205 + %tmp212 = trunc i64 %tmp209 to i32 + %tmp213 = icmp slt i32 0, %tmp212 + br i1 false, label %bb215, label %bb214 + +bb214: ; preds = %bb211 + unreachable + +bb215: ; preds = %bb211 + %tmp216 = add i64 undef, %tmp208 + %tmp217 = sub i64 %tmp209, undef + br i1 false, label %bb218, label %bb219 + +bb218: ; preds = %bb215 + br label %bb219 + +bb219: ; preds = %bb218, %bb215 + %tmp220 = trunc i64 %tmp217 to i32 + br label %bb221 + +bb221: ; preds = %bb230, %bb219 + %tmp222 = phi i64 [ %tmp231, %bb230 ], [ 0, %bb219 ] + %tmp223 = phi i32 [ %tmp232, %bb230 ], [ 0, %bb219 ] + %tmp224 = trunc i64 %tmp222 to i32 + %tmp225 = icmp slt i32 %tmp224, %tmp220 + br i1 %tmp225, label %bb226, label %bb234 + +bb226: ; preds = %bb221 + %tmp227 = add i64 %tmp222, %tmp216 + %tmp228 = getelementptr inbounds %struct.jim* @global3, i64 0, i32 3, i64 %tmp227 + %tmp229 = load i8* %tmp228, align 1 + br i1 false, label %bb233, label %bb230 + +bb230: ; preds = %bb226 + %tmp231 = add i64 %tmp222, 1 + %tmp232 = add nsw i32 %tmp223, 1 + br i1 undef, label %bb234, label %bb221 + +bb233: ; preds = %bb226 + br i1 undef, label %bb235, label %bb234 + +bb234: ; preds = %bb233, %bb230, %bb221 + br label %bb247 + +bb235: ; preds = %bb233 + %tmp236 = add nsw i32 %tmp223, 1 + %tmp237 = sext i32 %tmp236 to i64 + %tmp238 = sub i64 %tmp217, %tmp237 + br i1 %tmp66, label %bb239, label %bb240 + +bb239: ; preds = %bb235 + unreachable + +bb240: ; preds = %bb235 + switch i32 0, label %bb244 [ + i32 0, label %bb241 + i32 1, label %bb241 + i32 4, label %bb241 + i32 6, label %bb241 + i32 9, label %bb241 + ] + +bb241: ; preds = %bb240, %bb240, %bb240, %bb240, %bb240 + %tmp242 = trunc i64 %tmp238 to i32 + %tmp243 = icmp slt i32 0, %tmp242 + br i1 false, label %bb246, label %bb245 + +bb244: ; preds = %bb240 + unreachable + +bb245: ; preds = %bb241 + unreachable + +bb246: ; preds = %bb241 + unreachable + +bb247: ; preds = %bb234, %bb144, %bb106, %bb71, %bb58 + ret void +} + +declare void @zot(i8* nocapture, i8* nocapture, i64, i32, i1) nounwind diff --git a/test/Transforms/LoopStrengthReduce/ARM/2012-06-15-lsr-noaddrmode.ll b/test/Transforms/LoopStrengthReduce/ARM/2012-06-15-lsr-noaddrmode.ll new file mode 100644 index 000000000000..b5124ea6f30d --- /dev/null +++ b/test/Transforms/LoopStrengthReduce/ARM/2012-06-15-lsr-noaddrmode.ll @@ -0,0 +1,102 @@ +; RUN: llc < %s -O3 -march=thumb -mcpu=cortex-a8 | FileCheck %s +; +; LSR should only check for valid address modes when the IV user is a +; memory address. +; svn r158536, rdar://11635990 +; +; Note that we still don't produce the best code here because we fail +; to coalesce the IV. See <rdar://problem/11680670> [coalescer] IVs +; need to be scheduled to expose coalescing. + +; LSR before the fix: +;The chosen solution requires 4 regs, with addrec cost 1, plus 3 base adds, plus 2 setup cost: +; LSR Use: Kind=Special, Offsets={0}, all-fixups-outside-loop, widest fixup type: i32 +; reg(%v3) + reg({0,+,-1}<%while.cond.i.i>) + imm(1) +; LSR Use: Kind=ICmpZero, Offsets={0}, widest fixup type: i32 +; reg(%v3) + reg({0,+,-1}<%while.cond.i.i>) +; LSR Use: Kind=Address of i32, Offsets={0}, widest fixup type: i32* +; reg((-4 + (4 * %v3) + %v1)) + 4*reg({0,+,-1}<%while.cond.i.i>) +; LSR Use: Kind=Address of i32, Offsets={0}, widest fixup type: i32* +; reg((-4 + (4 * %v3) + %v4)) + 4*reg({0,+,-1}<%while.cond.i.i>) +; LSR Use: Kind=Special, Offsets={0}, all-fixups-outside-loop, widest fixup type: i32 +; reg(%v3) +; +; LSR after the fix: +;The chosen solution requires 4 regs, with addrec cost 1, plus 1 base add, plus 2 setup cost: +; LSR Use: Kind=Special, Offsets={0}, all-fixups-outside-loop, widest fixup type: i32 +; reg({%v3,+,-1}<nsw><%while.cond.i.i>) + imm(1) +; LSR Use: Kind=ICmpZero, Offsets={0}, widest fixup type: i32 +; reg({%v3,+,-1}<nsw><%while.cond.i.i>) +; LSR Use: Kind=Address of i32, Offsets={0}, widest fixup type: i32* +; reg((-4 + %v1)) + 4*reg({%v3,+,-1}<nsw><%while.cond.i.i>) +; LSR Use: Kind=Address of i32, Offsets={0}, widest fixup type: i32* +; reg((-4 + %v4)) + 4*reg({%v3,+,-1}<nsw><%while.cond.i.i>) +; LSR Use: Kind=Special, Offsets={0}, all-fixups-outside-loop, widest fixup type: i32 +; reg(%v3) + + +%s = type { i32* } + +@ncol = external global i32, align 4 + +declare i32* @getptr() nounwind +declare %s* @getstruct() nounwind + +; CHECK: @main +; Check that the loop preheader contains no address computation. +; CHECK: %end_of_chain +; CHECK-NOT: add{{.*}}lsl +; CHECK: ldr{{.*}}lsl #2 +; CHECK: ldr{{.*}}lsl #2 +define i32 @main() nounwind ssp { +entry: + %v0 = load i32* @ncol, align 4, !tbaa !0 + %v1 = tail call i32* @getptr() nounwind + %cmp10.i = icmp eq i32 %v0, 0 + br label %while.cond.outer + +while.cond.outer: + %call18 = tail call %s* @getstruct() nounwind + br label %while.cond + +while.cond: + %cmp20 = icmp eq i32* %v1, null + br label %while.body + +while.body: + %v3 = load i32* @ncol, align 4, !tbaa !0 + br label %end_of_chain + +end_of_chain: + %state.i = getelementptr inbounds %s* %call18, i32 0, i32 0 + %v4 = load i32** %state.i, align 4, !tbaa !3 + br label %while.cond.i.i + +while.cond.i.i: + %counter.0.i.i = phi i32 [ %v3, %end_of_chain ], [ %dec.i.i, %land.rhs.i.i ] + %dec.i.i = add nsw i32 %counter.0.i.i, -1 + %tobool.i.i = icmp eq i32 %counter.0.i.i, 0 + br i1 %tobool.i.i, label %where.exit, label %land.rhs.i.i + +land.rhs.i.i: + %arrayidx.i.i = getelementptr inbounds i32* %v4, i32 %dec.i.i + %v5 = load i32* %arrayidx.i.i, align 4, !tbaa !0 + %arrayidx1.i.i = getelementptr inbounds i32* %v1, i32 %dec.i.i + %v6 = load i32* %arrayidx1.i.i, align 4, !tbaa !0 + %cmp.i.i = icmp eq i32 %v5, %v6 + br i1 %cmp.i.i, label %while.cond.i.i, label %equal_data.exit.i + +equal_data.exit.i: + ret i32 %counter.0.i.i + +where.exit: + br label %while.end.i + +while.end.i: + ret i32 %v3 +} + +!0 = metadata !{metadata !"int", metadata !1} +!1 = metadata !{metadata !"omnipotent char", metadata !2} +!2 = metadata !{metadata !"Simple C/C++ TBAA"} +!3 = metadata !{metadata !"any pointer", metadata !1} diff --git a/test/Transforms/LoopStrengthReduce/X86/2012-01-13-phielim.ll b/test/Transforms/LoopStrengthReduce/X86/2012-01-13-phielim.ll index ed32ca8659c8..c3b8b8910d5c 100644 --- a/test/Transforms/LoopStrengthReduce/X86/2012-01-13-phielim.ll +++ b/test/Transforms/LoopStrengthReduce/X86/2012-01-13-phielim.ll @@ -90,3 +90,59 @@ for.inc498: ; preds = %for.inc498, %for.bo while.end: ; preds = %entry ret void } + +; PR12898: SCEVExpander crash +; Test redundant phi elimination when the deleted phi's increment is +; itself a phi. +; +; CHECK: @test3 +; CHECK: %for.body3.lr.ph.us.i.loopexit +; CHECK-NEXT: in Loop: Header +; CHECK-NEXT: incq +; CHECK-NEXT: %for.body3.us.i +; CHECK-NEXT: Inner Loop +; CHECK: testb +; CHECK: jne +; CHECK: jmp +define fastcc void @test3(double* nocapture %u) nounwind uwtable ssp { +entry: + br i1 undef, label %meshBB1, label %meshBB5 + +for.inc8.us.i: ; preds = %for.body3.us.i + br i1 undef, label %meshBB1, label %meshBB + +for.body3.us.i: ; preds = %meshBB, %for.body3.lr.ph.us.i + %indvars.iv.i.SV.phi = phi i64 [ %indvars.iv.next.i, %meshBB ], [ 0, %for.body3.lr.ph.us.i ] + %storemerge13.us.i.SV.phi = phi i32 [ 0, %meshBB ], [ 0, %for.body3.lr.ph.us.i ] + %Opq.sa.calc12 = sub i32 undef, 227 + %0 = add nsw i64 %indvars.iv.i.SV.phi, %indvars.iv8.i.SV.phi26 + %1 = trunc i64 %0 to i32 + %mul.i.us.i = mul nsw i32 0, %1 + %arrayidx5.us.i = getelementptr inbounds double* %u, i64 %indvars.iv.i.SV.phi + %2 = load double* %arrayidx5.us.i, align 8 + %indvars.iv.next.i = add i64 %indvars.iv.i.SV.phi, 1 + br i1 undef, label %for.inc8.us.i, label %meshBB + +for.body3.lr.ph.us.i: ; preds = %meshBB1, %meshBB + %indvars.iv8.i.SV.phi26 = phi i64 [ undef, %meshBB1 ], [ %indvars.iv8.i.SV.phi24, %meshBB ] + %arrayidx.us.i = getelementptr inbounds double* undef, i64 %indvars.iv8.i.SV.phi26 + %3 = add i64 %indvars.iv8.i.SV.phi26, 1 + br label %for.body3.us.i + +for.inc8.us.i2: ; preds = %meshBB5 + unreachable + +eval_At_times_u.exit: ; preds = %meshBB5 + ret void + +meshBB: ; preds = %for.body3.us.i, %for.inc8.us.i + %indvars.iv8.i.SV.phi24 = phi i64 [ undef, %for.body3.us.i ], [ %3, %for.inc8.us.i ] + %meshStackVariable.phi = phi i32 [ %Opq.sa.calc12, %for.body3.us.i ], [ undef, %for.inc8.us.i ] + br i1 undef, label %for.body3.lr.ph.us.i, label %for.body3.us.i + +meshBB1: ; preds = %for.inc8.us.i, %entry + br label %for.body3.lr.ph.us.i + +meshBB5: ; preds = %entry + br i1 undef, label %eval_At_times_u.exit, label %for.inc8.us.i2 +} diff --git a/test/Transforms/LoopStrengthReduce/dont-hoist-simple-loop-constants.ll b/test/Transforms/LoopStrengthReduce/dont-hoist-simple-loop-constants.ll index 4136486fef45..f7a82f6616d2 100644 --- a/test/Transforms/LoopStrengthReduce/dont-hoist-simple-loop-constants.ll +++ b/test/Transforms/LoopStrengthReduce/dont-hoist-simple-loop-constants.ll @@ -1,5 +1,5 @@ ; RUN: opt < %s -loop-reduce -S | \ -; RUN: not grep {bitcast i32 1 to i32} +; RUN: not grep "bitcast i32 1 to i32" ; END. ; The setlt wants to use a value that is incremented one more than the dominant ; IV. Don't insert the 1 outside the loop, preventing folding it into the add. diff --git a/test/Transforms/LoopStrengthReduce/dont_reverse.ll b/test/Transforms/LoopStrengthReduce/dont_reverse.ll index 4c5db04b21d9..d65213d06af3 100644 --- a/test/Transforms/LoopStrengthReduce/dont_reverse.ll +++ b/test/Transforms/LoopStrengthReduce/dont_reverse.ll @@ -1,5 +1,5 @@ ; RUN: opt < %s -loop-reduce -S \ -; RUN: | grep {icmp eq i2 %lsr.iv.next, %xmp4344} +; RUN: | grep "icmp eq i2 %lsr.iv.next, %xmp4344" ; Don't reverse the iteration if the rhs of the compare is defined ; inside the loop. diff --git a/test/Transforms/LoopStrengthReduce/invariant_value_first.ll b/test/Transforms/LoopStrengthReduce/invariant_value_first.ll index 2ca678761fed..5c18809e59c2 100644 --- a/test/Transforms/LoopStrengthReduce/invariant_value_first.ll +++ b/test/Transforms/LoopStrengthReduce/invariant_value_first.ll @@ -1,6 +1,6 @@ ; Check that the index of 'P[outer]' is pulled out of the loop. ; RUN: opt < %s -loop-reduce -S | \ -; RUN: not grep {getelementptr.*%outer.*%INDVAR} +; RUN: not grep "getelementptr.*%outer.*%INDVAR" target datalayout = "e-p:32:32:32-n8:16:32" declare i1 @pred() diff --git a/test/Transforms/LoopStrengthReduce/invariant_value_first_arg.ll b/test/Transforms/LoopStrengthReduce/invariant_value_first_arg.ll index 86c4d915a00d..8eb8f05a8a1f 100644 --- a/test/Transforms/LoopStrengthReduce/invariant_value_first_arg.ll +++ b/test/Transforms/LoopStrengthReduce/invariant_value_first_arg.ll @@ -1,6 +1,6 @@ ; Check that the index of 'P[outer]' is pulled out of the loop. ; RUN: opt < %s -loop-reduce -S | \ -; RUN: not grep {getelementptr.*%outer.*%INDVAR} +; RUN: not grep "getelementptr.*%outer.*%INDVAR" target datalayout = "e-p:32:32:32-n32" declare i1 @pred() diff --git a/test/Transforms/LoopStrengthReduce/pr2570.ll b/test/Transforms/LoopStrengthReduce/pr2570.ll index 80efb9f87e53..7b569713a93d 100644 --- a/test/Transforms/LoopStrengthReduce/pr2570.ll +++ b/test/Transforms/LoopStrengthReduce/pr2570.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -loop-reduce -S | grep {phi\\>} | count 8 +; RUN: opt < %s -loop-reduce -S | grep "phi\>" | count 8 ; PR2570 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" diff --git a/test/Transforms/LoopStrengthReduce/quadradic-exit-value.ll b/test/Transforms/LoopStrengthReduce/quadradic-exit-value.ll index 59f14fcd1ce5..011824116b3a 100644 --- a/test/Transforms/LoopStrengthReduce/quadradic-exit-value.ll +++ b/test/Transforms/LoopStrengthReduce/quadradic-exit-value.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -analyze -iv-users | grep {\{1,+,3,+,2\}<%loop> (post-inc with loop %loop)} +; RUN: opt < %s -analyze -iv-users | grep "{1,+,3,+,2}<%loop> (post-inc with loop %loop)" ; The value of %r is dependent on a polynomial iteration expression. diff --git a/test/Transforms/LoopStrengthReduce/use_postinc_value_outside_loop.ll b/test/Transforms/LoopStrengthReduce/use_postinc_value_outside_loop.ll index 5ed37dd6a247..005e4c6b22c1 100644 --- a/test/Transforms/LoopStrengthReduce/use_postinc_value_outside_loop.ll +++ b/test/Transforms/LoopStrengthReduce/use_postinc_value_outside_loop.ll @@ -1,5 +1,5 @@ ; RUN: opt < %s -loop-reduce -S | \ -; RUN: grep {add i32 %indvar630.ui, 1} +; RUN: grep "add i32 %indvar630.ui, 1" ; ; Make sure that the use of the IV outside of the loop (the store) uses the ; post incremented value of the IV, not the preincremented value. This diff --git a/test/Transforms/LoopStrengthReduce/var_stride_used_by_compare.ll b/test/Transforms/LoopStrengthReduce/var_stride_used_by_compare.ll index 64ef4f951f2b..3405b26f1f38 100644 --- a/test/Transforms/LoopStrengthReduce/var_stride_used_by_compare.ll +++ b/test/Transforms/LoopStrengthReduce/var_stride_used_by_compare.ll @@ -1,10 +1,10 @@ ; Base should not be i*3, it should be i*2. ; RUN: opt < %s -loop-reduce -S | \ -; RUN: not grep {mul.*%i, 3} +; RUN: not grep "mul.*%i, 3" ; Indvar should not start at zero: ; RUN: opt < %s -loop-reduce -S | \ -; RUN: not grep {phi i32 .* 0} +; RUN: not grep "phi i32 .* 0" ; END. ; mul uint %i, 3 diff --git a/test/Transforms/LoopUnswitch/2008-11-03-Invariant.ll b/test/Transforms/LoopUnswitch/2008-11-03-Invariant.ll index 20f2c2bfd742..9d73d31d5044 100644 --- a/test/Transforms/LoopUnswitch/2008-11-03-Invariant.ll +++ b/test/Transforms/LoopUnswitch/2008-11-03-Invariant.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -loop-unswitch -stats -disable-output |& grep "1 loop-unswitch - Number of branches unswitched" | count 1 +; RUN: opt < %s -loop-unswitch -stats -disable-output 2>&1 | grep "1 loop-unswitch - Number of branches unswitched" | count 1 ; PR 3170 define i32 @a(i32 %x, i32 %y) nounwind { entry: diff --git a/test/Transforms/LoopUnswitch/2011-11-18-SimpleSwitch.ll b/test/Transforms/LoopUnswitch/2011-11-18-SimpleSwitch.ll index 8389fe46436f..c1fd58810660 100644 --- a/test/Transforms/LoopUnswitch/2011-11-18-SimpleSwitch.ll +++ b/test/Transforms/LoopUnswitch/2011-11-18-SimpleSwitch.ll @@ -35,11 +35,11 @@ ; CHECK: loop_begin.us1: ; preds = %loop_begin.backedge.us5, %.split.split.us ; CHECK-NEXT: %var_val.us2 = load i32* %var ; CHECK-NEXT: switch i32 2, label %default.us-lcssa.us-lcssa.us [ -; CHECK-NEXT: i32 1, label %inc.us3 -; CHECK-NEXT: i32 2, label %dec.us4 +; CHECK-NEXT: i32 1, label %inc.us4 +; CHECK-NEXT: i32 2, label %dec.us3 ; CHECK-NEXT: ] -; CHECK: dec.us4: ; preds = %loop_begin.us1 +; CHECK: dec.us3: ; preds = %loop_begin.us1 ; CHECK-NEXT: call void @decf() noreturn nounwind ; CHECK-NEXT: br label %loop_begin.backedge.us5 @@ -81,7 +81,7 @@ inc: dec: call void @decf() noreturn nounwind br label %loop_begin -default: +default: br label %loop_exit loop_exit: ret i32 0 diff --git a/test/Transforms/LoopUnswitch/2011-11-18-TwoSwitches-Threshold.ll b/test/Transforms/LoopUnswitch/2011-11-18-TwoSwitches-Threshold.ll index 05d98d513e0c..f3db47119958 100644 --- a/test/Transforms/LoopUnswitch/2011-11-18-TwoSwitches-Threshold.ll +++ b/test/Transforms/LoopUnswitch/2011-11-18-TwoSwitches-Threshold.ll @@ -19,15 +19,15 @@ ; CHECK: switch i32 1, label %second_switch.us [ ; CHECK-NEXT: i32 1, label %inc.us -; CHECK: inc.us: ; preds = %second_switch.us, %loop_begin.us -; CHECK-NEXT: call void @incf() noreturn nounwind -; CHECK-NEXT: br label %loop_begin.backedge.us - ; CHECK: second_switch.us: ; preds = %loop_begin.us ; CHECK-NEXT: switch i32 %d, label %default.us [ ; CHECK-NEXT: i32 1, label %inc.us ; CHECK-NEXT: ] +; CHECK: inc.us: ; preds = %second_switch.us, %loop_begin.us +; CHECK-NEXT: call void @incf() noreturn nounwind +; CHECK-NEXT: br label %loop_begin.backedge.us + ; CHECK: .split: ; preds = %..split_crit_edge ; CHECK-NEXT: br label %loop_begin @@ -73,7 +73,7 @@ inc: call void @incf() noreturn nounwind br label %loop_begin -default: +default: br label %loop_begin loop_exit: diff --git a/test/Transforms/LoopUnswitch/2011-11-18-TwoSwitches.ll b/test/Transforms/LoopUnswitch/2011-11-18-TwoSwitches.ll index 1b186d6becbb..270899642ffa 100644 --- a/test/Transforms/LoopUnswitch/2011-11-18-TwoSwitches.ll +++ b/test/Transforms/LoopUnswitch/2011-11-18-TwoSwitches.ll @@ -25,14 +25,14 @@ ; CHECK-NEXT: switch i32 1, label %second_switch.us.us [ ; CHECK-NEXT: i32 1, label %inc.us.us -; CHECK: inc.us.us: ; preds = %second_switch.us.us, %loop_begin.us.us -; CHECK-NEXT: call void @incf() noreturn nounwind -; CHECK-NEXT: br label %loop_begin.backedge.us.us - ; CHECK: second_switch.us.us: ; preds = %loop_begin.us.us ; CHECK-NEXT: switch i32 1, label %default.us.us [ ; CHECK-NEXT: i32 1, label %inc.us.us +; CHECK: inc.us.us: ; preds = %second_switch.us.us, %loop_begin.us.us +; CHECK-NEXT: call void @incf() noreturn nounwind +; CHECK-NEXT: br label %loop_begin.backedge.us.us + ; CHECK: .split.us.split: ; preds = %.split.us..split.us.split_crit_edge ; CHECK-NEXT: br label %loop_begin.us @@ -41,10 +41,6 @@ ; CHECK-NEXT: switch i32 1, label %second_switch.us [ ; CHECK-NEXT: i32 1, label %inc.us -; CHECK: inc.us: ; preds = %second_switch.us.inc.us_crit_edge, %loop_begin.us -; CHECK-NEXT: call void @incf() noreturn nounwind -; CHECK-NEXT: br label %loop_begin.backedge.us - ; CHECK: second_switch.us: ; preds = %loop_begin.us ; CHECK-NEXT: switch i32 %d, label %default.us [ ; CHECK-NEXT: i32 1, label %second_switch.us.inc.us_crit_edge @@ -53,6 +49,10 @@ ; CHECK: second_switch.us.inc.us_crit_edge: ; preds = %second_switch.us ; CHECK-NEXT: br i1 true, label %us-unreachable8, label %inc.us +; CHECK: inc.us: ; preds = %second_switch.us.inc.us_crit_edge, %loop_begin.us +; CHECK-NEXT: call void @incf() noreturn nounwind +; CHECK-NEXT: br label %loop_begin.backedge.us + ; CHECK: .split: ; preds = %..split_crit_edge ; CHECK-NEXT: %3 = icmp eq i32 %d, 1 ; CHECK-NEXT: br i1 %3, label %.split.split.us, label %.split..split.split_crit_edge @@ -65,21 +65,21 @@ ; CHECK: loop_begin.us1: ; preds = %loop_begin.backedge.us6, %.split.split.us ; CHECK-NEXT: %var_val.us2 = load i32* %var -; CHECK-NEXT: switch i32 %c, label %second_switch.us4 [ +; CHECK-NEXT: switch i32 %c, label %second_switch.us3 [ ; CHECK-NEXT: i32 1, label %loop_begin.inc_crit_edge.us ; CHECK-NEXT: ] -; CHECK: inc.us3: ; preds = %loop_begin.inc_crit_edge.us, %second_switch.us4 -; CHECK-NEXT: call void @incf() noreturn nounwind -; CHECK-NEXT: br label %loop_begin.backedge.us6 - -; CHECK: second_switch.us4: ; preds = %loop_begin.us1 +; CHECK: second_switch.us3: ; preds = %loop_begin.us1 ; CHECK-NEXT: switch i32 1, label %default.us5 [ -; CHECK-NEXT: i32 1, label %inc.us3 +; CHECK-NEXT: i32 1, label %inc.us4 ; CHECK-NEXT: ] +; CHECK: inc.us4: ; preds = %loop_begin.inc_crit_edge.us, %second_switch.us3 +; CHECK-NEXT: call void @incf() noreturn nounwind +; CHECK-NEXT: br label %loop_begin.backedge.us6 + ; CHECK: loop_begin.inc_crit_edge.us: ; preds = %loop_begin.us1 -; CHECK-NEXT: br i1 true, label %us-unreachable.us-lcssa.us, label %inc.us3 +; CHECK-NEXT: br i1 true, label %us-unreachable.us-lcssa.us, label %inc.us4 ; CHECK: .split.split: ; preds = %.split..split.split_crit_edge ; CHECK-NEXT: br label %loop_begin @@ -127,7 +127,7 @@ inc: call void @incf() noreturn nounwind br label %loop_begin -default: +default: br label %loop_begin loop_exit: diff --git a/test/Transforms/LoopUnswitch/2012-05-20-Phi.ll b/test/Transforms/LoopUnswitch/2012-05-20-Phi.ll new file mode 100644 index 000000000000..4c63a56bfdc5 --- /dev/null +++ b/test/Transforms/LoopUnswitch/2012-05-20-Phi.ll @@ -0,0 +1,25 @@ +; RUN: opt < %s -loop-unswitch -disable-output +; PR12887 +target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128" +target triple = "x86_64-unknown-linux-gnu" + +@a = common global i32 0, align 4 +@c = common global i32 0, align 4 +@b = common global i32 0, align 4 + +define void @func() noreturn nounwind uwtable { +entry: + %0 = load i32* @a, align 4 + %tobool = icmp eq i32 %0, 0 + %1 = load i32* @b, align 4 + br label %while.body + +while.body: ; preds = %while.body, %entry + %d.0 = phi i8 [ undef, %entry ], [ %conv2, %while.body ] + %conv = sext i8 %d.0 to i32 + %cond = select i1 %tobool, i32 0, i32 %conv + %conv11 = zext i8 %d.0 to i32 + %add = add i32 %1, %conv11 + %conv2 = trunc i32 %add to i8 + br label %while.body +} diff --git a/test/Transforms/LowerSwitch/feature.ll b/test/Transforms/LowerSwitch/feature.ll index cdfa0f371d66..cc77d3c44d56 100644 --- a/test/Transforms/LowerSwitch/feature.ll +++ b/test/Transforms/LowerSwitch/feature.ll @@ -1,10 +1,99 @@ -; RUN: opt < %s -lowerswitch -S > %t -; RUN: grep slt %t | count 10 -; RUN: grep ule %t | count 3 -; RUN: grep eq %t | count 9 +; RUN: opt < %s -lowerswitch -S | FileCheck %s + +; We have switch on input. +; On output we should got binary comparison tree. Check that all is fine. + +;CHECK: entry: +;CHECK-NEXT: br label %NodeBlock37 + +;CHECK: NodeBlock37: ; preds = %entry +;CHECK-NEXT: %Pivot38 = icmp ult i32 %tmp158, 11 +;CHECK-NEXT: br i1 %Pivot38, label %NodeBlock13, label %NodeBlock35 + +;CHECK: NodeBlock35: ; preds = %NodeBlock37 +;CHECK-NEXT: %Pivot36 = icmp ult i32 %tmp158, 14 +;CHECK-NEXT: br i1 %Pivot36, label %NodeBlock23, label %NodeBlock33 + +;CHECK: NodeBlock33: ; preds = %NodeBlock35 +;CHECK-NEXT: %Pivot34 = icmp ult i32 %tmp158, 15 +;CHECK-NEXT: br i1 %Pivot34, label %LeafBlock25, label %NodeBlock31 + +;CHECK: NodeBlock31: ; preds = %NodeBlock33 +;CHECK-NEXT: %Pivot32 = icmp ult i32 %tmp158, -6 +;CHECK-NEXT: br i1 %Pivot32, label %LeafBlock27, label %LeafBlock29 + +;CHECK: LeafBlock29: ; preds = %NodeBlock31 +;CHECK-NEXT: %tmp158.off = add i32 %tmp158, 6 +;CHECK-NEXT: %SwitchLeaf30 = icmp ule i32 %tmp158.off, 4 +;CHECK-NEXT: br i1 %SwitchLeaf30, label %bb338, label %NewDefault + +;CHECK: LeafBlock27: ; preds = %NodeBlock31 +;CHECK-NEXT: %SwitchLeaf28 = icmp eq i32 %tmp158, 15 +;CHECK-NEXT: br i1 %SwitchLeaf28, label %bb334, label %NewDefault + +;CHECK: LeafBlock25: ; preds = %NodeBlock33 +;CHECK-NEXT: %SwitchLeaf26 = icmp eq i32 %tmp158, 14 +;CHECK-NEXT: br i1 %SwitchLeaf26, label %bb332, label %NewDefault + +;CHECK: NodeBlock23: ; preds = %NodeBlock35 +;CHECK-NEXT: %Pivot24 = icmp ult i32 %tmp158, 12 +;CHECK-NEXT: br i1 %Pivot24, label %LeafBlock15, label %NodeBlock21 + +;CHECK: NodeBlock21: ; preds = %NodeBlock23 +;CHECK-NEXT: %Pivot22 = icmp ult i32 %tmp158, 13 +;CHECK-NEXT: br i1 %Pivot22, label %LeafBlock17, label %LeafBlock19 + +;CHECK: LeafBlock19: ; preds = %NodeBlock21 +;CHECK-NEXT: %SwitchLeaf20 = icmp eq i32 %tmp158, 13 +;CHECK-NEXT: br i1 %SwitchLeaf20, label %bb330, label %NewDefault + +;CHECK: LeafBlock17: ; preds = %NodeBlock21 +;CHECK-NEXT: %SwitchLeaf18 = icmp eq i32 %tmp158, 12 +;CHECK-NEXT: br i1 %SwitchLeaf18, label %bb328, label %NewDefault + +;CHECK: LeafBlock15: ; preds = %NodeBlock23 +;CHECK-NEXT: %SwitchLeaf16 = icmp eq i32 %tmp158, 11 +;CHECK-NEXT: br i1 %SwitchLeaf16, label %bb326, label %NewDefault + +;CHECK: NodeBlock13: ; preds = %NodeBlock37 +;CHECK-NEXT: %Pivot14 = icmp ult i32 %tmp158, 8 +;CHECK-NEXT: br i1 %Pivot14, label %NodeBlock, label %NodeBlock11 + +;CHECK: NodeBlock11: ; preds = %NodeBlock13 +;CHECK-NEXT: %Pivot12 = icmp ult i32 %tmp158, 9 +;CHECK-NEXT: br i1 %Pivot12, label %LeafBlock3, label %NodeBlock9 + +;CHECK: NodeBlock9: ; preds = %NodeBlock11 +;CHECK-NEXT: %Pivot10 = icmp ult i32 %tmp158, 10 +;CHECK-NEXT: br i1 %Pivot10, label %LeafBlock5, label %LeafBlock7 + +;CHECK: LeafBlock7: ; preds = %NodeBlock9 +;CHECK-NEXT: %SwitchLeaf8 = icmp eq i32 %tmp158, 10 +;CHECK-NEXT: br i1 %SwitchLeaf8, label %bb324, label %NewDefault + +;CHECK: LeafBlock5: ; preds = %NodeBlock9 +;CHECK-NEXT: %SwitchLeaf6 = icmp eq i32 %tmp158, 9 +;CHECK-NEXT: br i1 %SwitchLeaf6, label %bb322, label %NewDefault + +;CHECK: LeafBlock3: ; preds = %NodeBlock11 +;CHECK-NEXT: %SwitchLeaf4 = icmp eq i32 %tmp158, 8 +;CHECK-NEXT: br i1 %SwitchLeaf4, label %bb338, label %NewDefault + +;CHECK: NodeBlock: ; preds = %NodeBlock13 +;CHECK-NEXT: %Pivot = icmp ult i32 %tmp158, 7 +;CHECK-NEXT: br i1 %Pivot, label %LeafBlock, label %LeafBlock1 + +;CHECK: LeafBlock1: ; preds = %NodeBlock +;CHECK-NEXT: %SwitchLeaf2 = icmp eq i32 %tmp158, 7 +;CHECK-NEXT: br i1 %SwitchLeaf2, label %bb, label %NewDefault + +;CHECK: LeafBlock: ; preds = %NodeBlock +;CHECK-NEXT: %SwitchLeaf = icmp ule i32 %tmp158, 6 +;CHECK-NEXT: br i1 %SwitchLeaf, label %bb338, label %NewDefault define i32 @main(i32 %tmp158) { entry: + switch i32 %tmp158, label %bb336 [ i32 -2, label %bb338 i32 -3, label %bb338 diff --git a/test/Transforms/MemCpyOpt/2008-02-24-MultipleUseofSRet.ll b/test/Transforms/MemCpyOpt/2008-02-24-MultipleUseofSRet.ll index b95ad91a361a..d124be5f9029 100644 --- a/test/Transforms/MemCpyOpt/2008-02-24-MultipleUseofSRet.ll +++ b/test/Transforms/MemCpyOpt/2008-02-24-MultipleUseofSRet.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -basicaa -memcpyopt -dse -S | grep {call.*initialize} | not grep memtmp +; RUN: opt < %s -basicaa -memcpyopt -dse -S | grep "call.*initialize" | not grep memtmp ; PR2077 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" diff --git a/test/Transforms/MemCpyOpt/2008-03-13-ReturnSlotBitcast.ll b/test/Transforms/MemCpyOpt/2008-03-13-ReturnSlotBitcast.ll index 24cf576a08ba..61ba3c7e6cc5 100644 --- a/test/Transforms/MemCpyOpt/2008-03-13-ReturnSlotBitcast.ll +++ b/test/Transforms/MemCpyOpt/2008-03-13-ReturnSlotBitcast.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -basicaa -memcpyopt -S | not grep {call.*memcpy.} +; RUN: opt < %s -basicaa -memcpyopt -S | not grep "call.*memcpy." target datalayout = "E-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64" %a = type { i32 } diff --git a/test/Transforms/MemCpyOpt/memcpy.ll b/test/Transforms/MemCpyOpt/memcpy.ll index 63d0ebf5c137..3fa16288c219 100644 --- a/test/Transforms/MemCpyOpt/memcpy.ll +++ b/test/Transforms/MemCpyOpt/memcpy.ll @@ -148,3 +148,25 @@ define void @test8() { } declare noalias i8* @malloc(i32) + +; rdar://11341081 +%struct.big = type { [50 x i32] } + +define void @test9() nounwind uwtable ssp { +entry: +; CHECK: test9 +; CHECK: f1 +; CHECK-NOT: memcpy +; CHECK: f2 + %b = alloca %struct.big, align 4 + %tmp = alloca %struct.big, align 4 + call void @f1(%struct.big* sret %tmp) + %0 = bitcast %struct.big* %b to i8* + %1 = bitcast %struct.big* %tmp to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* %0, i8* %1, i64 200, i32 4, i1 false) + call void @f2(%struct.big* %b) + ret void +} + +declare void @f1(%struct.big* sret) +declare void @f2(%struct.big*) diff --git a/test/Transforms/MemCpyOpt/sret.ll b/test/Transforms/MemCpyOpt/sret.ll index 8eac7da7986b..1bbb5fe8651b 100644 --- a/test/Transforms/MemCpyOpt/sret.ll +++ b/test/Transforms/MemCpyOpt/sret.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -basicaa -memcpyopt -S | not grep {call.*memcpy} +; RUN: opt < %s -basicaa -memcpyopt -S | not grep "call.*memcpy" 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:128:128" target triple = "i686-apple-darwin9" diff --git a/test/Transforms/MergeFunc/fold-weak.ll b/test/Transforms/MergeFunc/fold-weak.ll index 23e4d33c3a9f..4df6e39c1256 100644 --- a/test/Transforms/MergeFunc/fold-weak.ll +++ b/test/Transforms/MergeFunc/fold-weak.ll @@ -1,6 +1,6 @@ ; RUN: opt < %s -mergefunc -S > %t -; RUN: grep {define weak} %t | count 2 -; RUN: grep {call} %t | count 2 +; RUN: grep "define weak" %t | count 2 +; RUN: grep "call" %t | count 2 ; XFAIL: * ; This test is off for a bit as we change this particular sort of folding to diff --git a/test/Transforms/MergeFunc/phi-speculation1.ll b/test/Transforms/MergeFunc/phi-speculation1.ll index 7b2a2fe5d52f..fd0baffb3108 100644 --- a/test/Transforms/MergeFunc/phi-speculation1.ll +++ b/test/Transforms/MergeFunc/phi-speculation1.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -mergefunc -stats -disable-output |& not grep {functions merged} +; RUN: opt < %s -mergefunc -stats -disable-output 2>&1 | not grep "functions merged" define i32 @foo1(i32 %x) { entry: diff --git a/test/Transforms/MergeFunc/phi-speculation2.ll b/test/Transforms/MergeFunc/phi-speculation2.ll index f080191ef860..eec8b5c5a90a 100644 --- a/test/Transforms/MergeFunc/phi-speculation2.ll +++ b/test/Transforms/MergeFunc/phi-speculation2.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -mergefunc -stats -disable-output |& grep {functions merged} +; RUN: opt < %s -mergefunc -stats -disable-output 2>&1 | grep "functions merged" define i32 @foo1(i32 %x) { entry: diff --git a/test/Transforms/MergeFunc/vector.ll b/test/Transforms/MergeFunc/vector.ll index 6954fcec3daf..4af079f8cdf7 100644 --- a/test/Transforms/MergeFunc/vector.ll +++ b/test/Transforms/MergeFunc/vector.ll @@ -1,4 +1,4 @@ -; RUN: opt -mergefunc -stats -disable-output < %s |& grep {functions merged} +; RUN: opt -mergefunc -stats -disable-output < %s 2>&1 | grep "functions merged" ; This test is checks whether we can merge ; vector<intptr_t>::push_back(0) diff --git a/test/Transforms/ObjCARC/basic.ll b/test/Transforms/ObjCARC/basic.ll index ba2f778a28ec..d9bb3f25bd79 100644 --- a/test/Transforms/ObjCARC/basic.ll +++ b/test/Transforms/ObjCARC/basic.ll @@ -1871,6 +1871,30 @@ return: ; preds = %if.then, %entry ret i8* %retval } +; An objc_retain can serve as a may-use for a different pointer. +; rdar://11931823 + +; CHECK: define void @test66( +; CHECK: %tmp7 = tail call i8* @objc_retain(i8* %cond) nounwind +; CHECK: tail call void @objc_release(i8* %cond) nounwind +; CHECK: } +define void @test66(i8* %tmp5, i8* %bar, i1 %tobool, i1 %tobool1, i8* %call) { +entry: + br i1 %tobool, label %cond.true, label %cond.end + +cond.true: + br label %cond.end + +cond.end: ; preds = %cond.true, %entry + %cond = phi i8* [ %tmp5, %cond.true ], [ %call, %entry ] + %tmp7 = tail call i8* @objc_retain(i8* %cond) nounwind + tail call void @objc_release(i8* %call) nounwind + %tmp8 = select i1 %tobool1, i8* %cond, i8* %bar + %tmp9 = tail call i8* @objc_retain(i8* %tmp8) nounwind + tail call void @objc_release(i8* %cond) nounwind + ret void +} + declare void @bar(i32 ()*) ; A few real-world testcases. diff --git a/test/Transforms/ObjCARC/contract-storestrong.ll b/test/Transforms/ObjCARC/contract-storestrong.ll index 4ff0596fbbc6..2922f816d589 100644 --- a/test/Transforms/ObjCARC/contract-storestrong.ll +++ b/test/Transforms/ObjCARC/contract-storestrong.ll @@ -4,6 +4,7 @@ target datalayout = "e-p:64:64:64" declare i8* @objc_retain(i8*) declare void @objc_release(i8*) +declare void @use_pointer(i8*) @x = external global i8* @@ -57,3 +58,112 @@ entry: tail call void @objc_release(i8* %tmp) nounwind ret void } + +; Don't do this if there's a use of the old pointer value between the store +; and the release. + +; CHECK: define void @test3(i8* %newValue) { +; CHECK-NEXT: entry: +; CHECK-NEXT: %x0 = tail call i8* @objc_retain(i8* %newValue) nounwind +; CHECK-NEXT: %x1 = load i8** @x, align 8 +; CHECK-NEXT: store i8* %x0, i8** @x, align 8 +; CHECK-NEXT: tail call void @use_pointer(i8* %x1), !clang.arc.no_objc_arc_exceptions !0 +; CHECK-NEXT: tail call void @objc_release(i8* %x1) nounwind, !clang.imprecise_release !0 +; CHECK-NEXT: ret void +; CHECK-NEXT: } +define void @test3(i8* %newValue) { +entry: + %x0 = tail call i8* @objc_retain(i8* %newValue) nounwind + %x1 = load i8** @x, align 8 + store i8* %newValue, i8** @x, align 8 + tail call void @use_pointer(i8* %x1), !clang.arc.no_objc_arc_exceptions !0 + tail call void @objc_release(i8* %x1) nounwind, !clang.imprecise_release !0 + ret void +} + +; Like test3, but with an icmp use instead of a call, for good measure. + +; CHECK: define i1 @test4(i8* %newValue, i8* %foo) { +; CHECK-NEXT: entry: +; CHECK-NEXT: %x0 = tail call i8* @objc_retain(i8* %newValue) nounwind +; CHECK-NEXT: %x1 = load i8** @x, align 8 +; CHECK-NEXT: store i8* %x0, i8** @x, align 8 +; CHECK-NEXT: %t = icmp eq i8* %x1, %foo +; CHECK-NEXT: tail call void @objc_release(i8* %x1) nounwind, !clang.imprecise_release !0 +; CHECK-NEXT: ret i1 %t +; CHECK-NEXT: } +define i1 @test4(i8* %newValue, i8* %foo) { +entry: + %x0 = tail call i8* @objc_retain(i8* %newValue) nounwind + %x1 = load i8** @x, align 8 + store i8* %newValue, i8** @x, align 8 + %t = icmp eq i8* %x1, %foo + tail call void @objc_release(i8* %x1) nounwind, !clang.imprecise_release !0 + ret i1 %t +} + +; Do form an objc_storeStrong here, because the use is before the store. + +; CHECK: define i1 @test5(i8* %newValue, i8* %foo) { +; CHECK: %t = icmp eq i8* %x1, %foo +; CHECK: tail call void @objc_storeStrong(i8** @x, i8* %newValue) nounwind +define i1 @test5(i8* %newValue, i8* %foo) { +entry: + %x0 = tail call i8* @objc_retain(i8* %newValue) nounwind + %x1 = load i8** @x, align 8 + %t = icmp eq i8* %x1, %foo + store i8* %newValue, i8** @x, align 8 + tail call void @objc_release(i8* %x1) nounwind, !clang.imprecise_release !0 + ret i1 %t +} + +; Like test5, but the release is before the store. + +; CHECK: define i1 @test6(i8* %newValue, i8* %foo) { +; CHECK: %t = icmp eq i8* %x1, %foo +; CHECK: tail call void @objc_storeStrong(i8** @x, i8* %newValue) nounwind +define i1 @test6(i8* %newValue, i8* %foo) { +entry: + %x0 = tail call i8* @objc_retain(i8* %newValue) nounwind + %x1 = load i8** @x, align 8 + tail call void @objc_release(i8* %x1) nounwind, !clang.imprecise_release !0 + %t = icmp eq i8* %x1, %foo + store i8* %newValue, i8** @x, align 8 + ret i1 %t +} + +; Like test0, but there's no store, so don't form an objc_storeStrong. + +; CHECK: define void @test7( +; CHECK-NEXT: entry: +; CHECK-NEXT: %0 = tail call i8* @objc_retain(i8* %p) nounwind +; CHECK-NEXT: %tmp = load i8** @x, align 8 +; CHECK-NEXT: tail call void @objc_release(i8* %tmp) nounwind +; CHECK-NEXT: ret void +; CHECK-NEXT: } +define void @test7(i8* %p) { +entry: + %0 = tail call i8* @objc_retain(i8* %p) nounwind + %tmp = load i8** @x, align 8 + tail call void @objc_release(i8* %tmp) nounwind + ret void +} + +; Like test0, but there's no retain, so don't form an objc_storeStrong. + +; CHECK: define void @test8( +; CHECK-NEXT: entry: +; CHECK-NEXT: %tmp = load i8** @x, align 8 +; CHECK-NEXT: store i8* %p, i8** @x, align 8 +; CHECK-NEXT: tail call void @objc_release(i8* %tmp) nounwind +; CHECK-NEXT: ret void +; CHECK-NEXT: } +define void @test8(i8* %p) { +entry: + %tmp = load i8** @x, align 8 + store i8* %p, i8** @x, align 8 + tail call void @objc_release(i8* %tmp) nounwind + ret void +} + +!0 = metadata !{} diff --git a/test/Transforms/ObjCARC/contract-testcases.ll b/test/Transforms/ObjCARC/contract-testcases.ll index 69fa8376757d..1510ed00e691 100644 --- a/test/Transforms/ObjCARC/contract-testcases.ll +++ b/test/Transforms/ObjCARC/contract-testcases.ll @@ -4,17 +4,17 @@ %0 = type opaque %1 = type opaque %2 = type { i64, i64 } -%3 = type { i8*, i8* } %4 = type opaque declare %0* @"\01-[NSAttributedString(Terminal) pathAtIndex:effectiveRange:]"(%1*, i8* nocapture, i64, %2*) optsize declare i8* @objc_retainAutoreleasedReturnValue(i8*) -declare i8* @objc_msgSend_fixup(i8*, %3*, ...) +declare i8* @objc_msgSend_fixup(i8*, i8*, ...) +declare i8* @objc_msgSend(i8*, i8*, ...) declare void @objc_release(i8*) declare %2 @NSUnionRange(i64, i64, i64, i64) optsize declare i8* @objc_autoreleaseReturnValue(i8*) declare i8* @objc_autorelease(i8*) -declare i8* @objc_msgSend() nonlazybind +declare i32 @__gxx_personality_sj0(...) ; Don't get in trouble on bugpointed code. @@ -52,7 +52,7 @@ bb6: ; preds = %bb5, %bb4, %bb4, %b ; CHECK: %tmp8 = phi %0* [ %0, %bb ], [ %0, %bb ] define void @test1() { bb: - %tmp = tail call %0* bitcast (i8* ()* @objc_msgSend to %0* ()*)() + %tmp = tail call %0* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to %0* ()*)() %tmp2 = bitcast %0* %tmp to i8* %tmp3 = tail call i8* @objc_retainAutoreleasedReturnValue(i8* %tmp2) nounwind br i1 undef, label %bb7, label %bb7 @@ -61,3 +61,30 @@ bb7: ; preds = %bb6, %bb6, %bb5 %tmp8 = phi %0* [ %tmp, %bb ], [ %tmp, %bb ] unreachable } + +; When looking for the defining instruction for an objc_retainAutoreleasedReturnValue +; call, handle the case where it's an invoke in a different basic block. +; rdar://11714057 + +; CHECK: define void @_Z6doTestP8NSString() { +; CHECK: invoke.cont: ; preds = %entry +; CHECK-NEXT: call void asm sideeffect "mov\09r7, r7\09\09@ marker for objc_retainAutoreleaseReturnValue", ""() +; CHECK-NEXT: %tmp = tail call i8* @objc_retainAutoreleasedReturnValue(i8* %call) nounwind +define void @_Z6doTestP8NSString() { +entry: + %call = invoke i8* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to i8* ()*)() + to label %invoke.cont unwind label %lpad + +invoke.cont: ; preds = %entry + %tmp = tail call i8* @objc_retainAutoreleasedReturnValue(i8* %call) nounwind + unreachable + +lpad: ; preds = %entry + %tmp1 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_sj0 to i8*) + cleanup + resume { i8*, i32 } undef +} + +!clang.arc.retainAutoreleasedReturnValueMarker = !{!0} + +!0 = metadata !{metadata !"mov\09r7, r7\09\09@ marker for objc_retainAutoreleaseReturnValue"} diff --git a/test/Transforms/ObjCARC/split-backedge.ll b/test/Transforms/ObjCARC/split-backedge.ll new file mode 100644 index 000000000000..08e2dce1f551 --- /dev/null +++ b/test/Transforms/ObjCARC/split-backedge.ll @@ -0,0 +1,48 @@ +; RUN: opt -S -objc-arc < %s | FileCheck %s + +; Handle a retain+release pair entirely contained within a split loop backedge. +; rdar://11256239 + +; CHECK: define void @test0 +; CHECK: call i8* @objc_retain(i8* %call) nounwind +; CHECK: call i8* @objc_retain(i8* %call) nounwind +; CHECK: call i8* @objc_retain(i8* %cond) nounwind +; CHECK: call void @objc_release(i8* %call) nounwind +; CHECK: call void @objc_release(i8* %call) nounwind +; CHECK: call void @objc_release(i8* %cond) nounwind +define void @test0() { +entry: + br label %while.body + +while.body: ; preds = %while.cond + %call = invoke i8* @returner() + to label %invoke.cont unwind label %lpad, !clang.arc.no_objc_arc_exceptions !0 + +invoke.cont: ; preds = %while.body + %t0 = call i8* @objc_retain(i8* %call) nounwind + %t1 = call i8* @objc_retain(i8* %call) nounwind + %call.i1 = invoke i8* @returner() + to label %invoke.cont1 unwind label %lpad + +invoke.cont1: ; preds = %invoke.cont + %cond = select i1 undef, i8* null, i8* %call + %t2 = call i8* @objc_retain(i8* %cond) nounwind + call void @objc_release(i8* %call) nounwind + call void @objc_release(i8* %call) nounwind + call void @use_pointer(i8* %cond) + call void @objc_release(i8* %cond) nounwind + br label %while.body + +lpad: ; preds = %invoke.cont, %while.body + %t4 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__objc_personality_v0 to i8*) + catch i8* null + ret void +} + +declare i8* @returner() +declare i32 @__objc_personality_v0(...) +declare void @objc_release(i8*) +declare i8* @objc_retain(i8*) +declare void @use_pointer(i8*) + +!0 = metadata !{} diff --git a/test/Transforms/ObjCARC/weak-dce.ll b/test/Transforms/ObjCARC/weak-dce.ll new file mode 100644 index 000000000000..f09467182b6f --- /dev/null +++ b/test/Transforms/ObjCARC/weak-dce.ll @@ -0,0 +1,46 @@ +; RUN: opt -S -basicaa -objc-arc < %s | FileCheck %s +; rdar://11434915 + +; Delete the weak calls and replace them with just the net retain. + +; CHECK: define void @test0(i8* %p) { +; CHECK-NEXT: call i8* @objc_retain(i8* %p) +; CHECK-NEXT: ret void + +define void @test0(i8* %p) { + %weakBlock = alloca i8*, align 8 + %tmp7 = call i8* @objc_initWeak(i8** %weakBlock, i8* %p) nounwind + %tmp26 = call i8* @objc_loadWeakRetained(i8** %weakBlock) nounwind + call void @objc_destroyWeak(i8** %weakBlock) nounwind + ret void +} + +; CHECK: define i8* @test1(i8* %p) { +; CHECK-NEXT: call i8* @objc_retain(i8* %p) +; CHECK-NEXT: ret i8* %p + +define i8* @test1(i8* %p) { + %weakBlock = alloca i8*, align 8 + %tmp7 = call i8* @objc_initWeak(i8** %weakBlock, i8* %p) nounwind + %tmp26 = call i8* @objc_loadWeakRetained(i8** %weakBlock) nounwind + call void @objc_destroyWeak(i8** %weakBlock) nounwind + ret i8* %tmp26 +} + +; CHECK: define i8* @test2(i8* %p, i8* %q) { +; CHECK-NEXT: call i8* @objc_retain(i8* %q) +; CHECK-NEXT: ret i8* %q + +define i8* @test2(i8* %p, i8* %q) { + %weakBlock = alloca i8*, align 8 + %tmp7 = call i8* @objc_initWeak(i8** %weakBlock, i8* %p) nounwind + %tmp19 = call i8* @objc_storeWeak(i8** %weakBlock, i8* %q) nounwind + %tmp26 = call i8* @objc_loadWeakRetained(i8** %weakBlock) nounwind + call void @objc_destroyWeak(i8** %weakBlock) nounwind + ret i8* %tmp26 +} + +declare i8* @objc_initWeak(i8**, i8*) +declare void @objc_destroyWeak(i8**) +declare i8* @objc_loadWeakRetained(i8**) +declare i8* @objc_storeWeak(i8** %weakBlock, i8* %q) diff --git a/test/Transforms/PhaseOrdering/PR6627.ll b/test/Transforms/PhaseOrdering/PR6627.ll new file mode 100644 index 000000000000..ef9947f103a8 --- /dev/null +++ b/test/Transforms/PhaseOrdering/PR6627.ll @@ -0,0 +1,93 @@ +; RUN: opt -O3 -S %s | FileCheck %s +; XFAIL: * + +declare i32 @doo(...) + +; PR6627 - This whole nasty sequence should be flattened down to a single +; 32-bit comparison. +define void @test2(i8* %arrayidx) nounwind ssp { +entry: + %xx = bitcast i8* %arrayidx to i32* + %x1 = load i32* %xx, align 4 + %tmp = trunc i32 %x1 to i8 + %conv = zext i8 %tmp to i32 + %cmp = icmp eq i32 %conv, 127 + br i1 %cmp, label %land.lhs.true, label %if.end + +land.lhs.true: ; preds = %entry + %arrayidx4 = getelementptr inbounds i8* %arrayidx, i64 1 + %tmp5 = load i8* %arrayidx4, align 1 + %conv6 = zext i8 %tmp5 to i32 + %cmp7 = icmp eq i32 %conv6, 69 + br i1 %cmp7, label %land.lhs.true9, label %if.end + +land.lhs.true9: ; preds = %land.lhs.true + %arrayidx12 = getelementptr inbounds i8* %arrayidx, i64 2 + %tmp13 = load i8* %arrayidx12, align 1 + %conv14 = zext i8 %tmp13 to i32 + %cmp15 = icmp eq i32 %conv14, 76 + br i1 %cmp15, label %land.lhs.true17, label %if.end + +land.lhs.true17: ; preds = %land.lhs.true9 + %arrayidx20 = getelementptr inbounds i8* %arrayidx, i64 3 + %tmp21 = load i8* %arrayidx20, align 1 + %conv22 = zext i8 %tmp21 to i32 + %cmp23 = icmp eq i32 %conv22, 70 + br i1 %cmp23, label %if.then, label %if.end + +if.then: ; preds = %land.lhs.true17 + %call25 = call i32 (...)* @doo() + br label %if.end + +if.end: + ret void + +; CHECK: @test2 +; CHECK: %x1 = load i32* %xx, align 4 +; CHECK-NEXT: icmp eq i32 %x1, 1179403647 +; CHECK-NEXT: br i1 {{.*}}, label %if.then, label %if.end +} + +; PR6627 - This should all be flattened down to one compare. This is the same +; as test2, except that the initial load is done as an i8 instead of i32, thus +; requiring widening. +define void @test2a(i8* %arrayidx) nounwind ssp { +entry: + %x1 = load i8* %arrayidx, align 4 + %conv = zext i8 %x1 to i32 + %cmp = icmp eq i32 %conv, 127 + br i1 %cmp, label %land.lhs.true, label %if.end + +land.lhs.true: ; preds = %entry + %arrayidx4 = getelementptr inbounds i8* %arrayidx, i64 1 + %tmp5 = load i8* %arrayidx4, align 1 + %conv6 = zext i8 %tmp5 to i32 + %cmp7 = icmp eq i32 %conv6, 69 + br i1 %cmp7, label %land.lhs.true9, label %if.end + +land.lhs.true9: ; preds = %land.lhs.true + %arrayidx12 = getelementptr inbounds i8* %arrayidx, i64 2 + %tmp13 = load i8* %arrayidx12, align 1 + %conv14 = zext i8 %tmp13 to i32 + %cmp15 = icmp eq i32 %conv14, 76 + br i1 %cmp15, label %land.lhs.true17, label %if.end + +land.lhs.true17: ; preds = %land.lhs.true9 + %arrayidx20 = getelementptr inbounds i8* %arrayidx, i64 3 + %tmp21 = load i8* %arrayidx20, align 1 + %conv22 = zext i8 %tmp21 to i32 + %cmp23 = icmp eq i32 %conv22, 70 + br i1 %cmp23, label %if.then, label %if.end + +if.then: ; preds = %land.lhs.true17 + %call25 = call i32 (...)* @doo() + br label %if.end + +if.end: + ret void + +; CHECK: @test2a +; CHECK: %x1 = load i32* {{.*}}, align 4 +; CHECK-NEXT: icmp eq i32 %x1, 1179403647 +; CHECK-NEXT: br i1 {{.*}}, label %if.then, label %if.end +} diff --git a/test/Transforms/PhaseOrdering/basic.ll b/test/Transforms/PhaseOrdering/basic.ll index e5b2ba4ab21c..88ebca0a9c3d 100644 --- a/test/Transforms/PhaseOrdering/basic.ll +++ b/test/Transforms/PhaseOrdering/basic.ll @@ -1,5 +1,4 @@ ; RUN: opt -O3 -S %s | FileCheck %s -; XFAIL: * target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64" target triple = "x86_64-apple-macosx10.6.7" @@ -24,95 +23,29 @@ define void @test1() nounwind ssp { ; CHECK-NEXT: ret void } - -; PR6627 - This whole nasty sequence should be flattened down to a single -; 32-bit comparison. -define void @test2(i8* %arrayidx) nounwind ssp { +; This function exposes a phase ordering problem when InstCombine is +; turning %add into a bitmask, making it difficult to spot a 0 return value. +; +; It it also important that %add is expressed as a multiple of %div so scalar +; evolution can recognize it. +define i32 @test2(i32 %a, i32* %p) nounwind uwtable ssp { entry: - %xx = bitcast i8* %arrayidx to i32* - %x1 = load i32* %xx, align 4 - %tmp = trunc i32 %x1 to i8 - %conv = zext i8 %tmp to i32 - %cmp = icmp eq i32 %conv, 127 - br i1 %cmp, label %land.lhs.true, label %if.end - -land.lhs.true: ; preds = %entry - %arrayidx4 = getelementptr inbounds i8* %arrayidx, i64 1 - %tmp5 = load i8* %arrayidx4, align 1 - %conv6 = zext i8 %tmp5 to i32 - %cmp7 = icmp eq i32 %conv6, 69 - br i1 %cmp7, label %land.lhs.true9, label %if.end - -land.lhs.true9: ; preds = %land.lhs.true - %arrayidx12 = getelementptr inbounds i8* %arrayidx, i64 2 - %tmp13 = load i8* %arrayidx12, align 1 - %conv14 = zext i8 %tmp13 to i32 - %cmp15 = icmp eq i32 %conv14, 76 - br i1 %cmp15, label %land.lhs.true17, label %if.end - -land.lhs.true17: ; preds = %land.lhs.true9 - %arrayidx20 = getelementptr inbounds i8* %arrayidx, i64 3 - %tmp21 = load i8* %arrayidx20, align 1 - %conv22 = zext i8 %tmp21 to i32 - %cmp23 = icmp eq i32 %conv22, 70 - br i1 %cmp23, label %if.then, label %if.end - -if.then: ; preds = %land.lhs.true17 - %call25 = call i32 (...)* @doo() - br label %if.end - -if.end: - ret void + %div = udiv i32 %a, 4 + %arrayidx = getelementptr inbounds i32* %p, i64 0 + store i32 %div, i32* %arrayidx, align 4 + %add = add i32 %div, %div + %arrayidx1 = getelementptr inbounds i32* %p, i64 1 + store i32 %add, i32* %arrayidx1, align 4 + %arrayidx2 = getelementptr inbounds i32* %p, i64 1 + %0 = load i32* %arrayidx2, align 4 + %arrayidx3 = getelementptr inbounds i32* %p, i64 0 + %1 = load i32* %arrayidx3, align 4 + %mul = mul i32 2, %1 + %sub = sub i32 %0, %mul + ret i32 %sub ; CHECK: @test2 -; CHECK: %x1 = load i32* %xx, align 4 -; CHECK-NEXT: icmp eq i32 %x1, 1179403647 -; CHECK-NEXT: br i1 {{.*}}, label %if.then, label %if.end +; CHECK: %div = lshr i32 %a, 2 +; CHECK: %add = shl nuw nsw i32 %div, 1 +; CHECK: ret i32 0 } - -declare i32 @doo(...) - -; PR6627 - This should all be flattened down to one compare. This is the same -; as test2, except that the initial load is done as an i8 instead of i32, thus -; requiring widening. -define void @test2a(i8* %arrayidx) nounwind ssp { -entry: - %x1 = load i8* %arrayidx, align 4 - %conv = zext i8 %x1 to i32 - %cmp = icmp eq i32 %conv, 127 - br i1 %cmp, label %land.lhs.true, label %if.end - -land.lhs.true: ; preds = %entry - %arrayidx4 = getelementptr inbounds i8* %arrayidx, i64 1 - %tmp5 = load i8* %arrayidx4, align 1 - %conv6 = zext i8 %tmp5 to i32 - %cmp7 = icmp eq i32 %conv6, 69 - br i1 %cmp7, label %land.lhs.true9, label %if.end - -land.lhs.true9: ; preds = %land.lhs.true - %arrayidx12 = getelementptr inbounds i8* %arrayidx, i64 2 - %tmp13 = load i8* %arrayidx12, align 1 - %conv14 = zext i8 %tmp13 to i32 - %cmp15 = icmp eq i32 %conv14, 76 - br i1 %cmp15, label %land.lhs.true17, label %if.end - -land.lhs.true17: ; preds = %land.lhs.true9 - %arrayidx20 = getelementptr inbounds i8* %arrayidx, i64 3 - %tmp21 = load i8* %arrayidx20, align 1 - %conv22 = zext i8 %tmp21 to i32 - %cmp23 = icmp eq i32 %conv22, 70 - br i1 %cmp23, label %if.then, label %if.end - -if.then: ; preds = %land.lhs.true17 - %call25 = call i32 (...)* @doo() - br label %if.end - -if.end: - ret void - -; CHECK: @test2a -; CHECK: %x1 = load i32* {{.*}}, align 4 -; CHECK-NEXT: icmp eq i32 %x1, 1179403647 -; CHECK-NEXT: br i1 {{.*}}, label %if.then, label %if.end -} - diff --git a/test/Transforms/PhaseOrdering/scev.ll b/test/Transforms/PhaseOrdering/scev.ll new file mode 100644 index 000000000000..c73128082216 --- /dev/null +++ b/test/Transforms/PhaseOrdering/scev.ll @@ -0,0 +1,64 @@ +; RUN: opt -O3 -S -analyze -scalar-evolution %s | FileCheck %s +; +; This file contains phase ordering tests for scalar evolution. +; Test that the standard passes don't obfuscate the IR so scalar evolution can't +; recognize expressions. + +; CHECK: test1 +; The loop body contains two increments by %div. +; Make sure that 2*%div is recognizable, and not expressed as a bit mask of %d. +; CHECK: --> {%p,+,(2 * (%d /u 4) * sizeof(i32))} +define void @test1(i64 %d, i32* %p) nounwind uwtable ssp { +entry: + %div = udiv i64 %d, 4 + br label %for.cond + +for.cond: ; preds = %for.inc, %entry + %p.addr.0 = phi i32* [ %p, %entry ], [ %add.ptr1, %for.inc ] + %i.0 = phi i32 [ 0, %entry ], [ %inc, %for.inc ] + %cmp = icmp ne i32 %i.0, 64 + br i1 %cmp, label %for.body, label %for.end + +for.body: ; preds = %for.cond + store i32 0, i32* %p.addr.0, align 4 + %add.ptr = getelementptr inbounds i32* %p.addr.0, i64 %div + store i32 1, i32* %add.ptr, align 4 + %add.ptr1 = getelementptr inbounds i32* %add.ptr, i64 %div + br label %for.inc + +for.inc: ; preds = %for.body + %inc = add i32 %i.0, 1 + br label %for.cond + +for.end: ; preds = %for.cond + ret void +} + +; CHECK: test1a +; Same thing as test1, but it is even more tempting to fold 2 * (%d /u 2) +; CHECK: --> {%p,+,(2 * (%d /u 2) * sizeof(i32))} +define void @test1a(i64 %d, i32* %p) nounwind uwtable ssp { +entry: + %div = udiv i64 %d, 2 + br label %for.cond + +for.cond: ; preds = %for.inc, %entry + %p.addr.0 = phi i32* [ %p, %entry ], [ %add.ptr1, %for.inc ] + %i.0 = phi i32 [ 0, %entry ], [ %inc, %for.inc ] + %cmp = icmp ne i32 %i.0, 64 + br i1 %cmp, label %for.body, label %for.end + +for.body: ; preds = %for.cond + store i32 0, i32* %p.addr.0, align 4 + %add.ptr = getelementptr inbounds i32* %p.addr.0, i64 %div + store i32 1, i32* %add.ptr, align 4 + %add.ptr1 = getelementptr inbounds i32* %add.ptr, i64 %div + br label %for.inc + +for.inc: ; preds = %for.body + %inc = add i32 %i.0, 1 + br label %for.cond + +for.end: ; preds = %for.cond + ret void +} diff --git a/test/Transforms/PruneEH/2003-09-14-ExternalCall.ll b/test/Transforms/PruneEH/2003-09-14-ExternalCall.ll deleted file mode 100644 index 64aba4610167..000000000000 --- a/test/Transforms/PruneEH/2003-09-14-ExternalCall.ll +++ /dev/null @@ -1,14 +0,0 @@ -; RUN: opt < %s -prune-eh -S | grep invoke - -declare void @External() - -define void @foo() { - invoke void @External( ) - to label %Cont unwind label %Cont -Cont: ; preds = %0, %0 - %exn = landingpad {i8*, i32} personality i32 (...)* @__gxx_personality_v0 - cleanup - ret void -} - -declare i32 @__gxx_personality_v0(...) diff --git a/test/Transforms/PruneEH/simplenoreturntest.ll b/test/Transforms/PruneEH/simplenoreturntest.ll index 61e2f15c0d0a..ec5d100d7513 100644 --- a/test/Transforms/PruneEH/simplenoreturntest.ll +++ b/test/Transforms/PruneEH/simplenoreturntest.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -prune-eh -S | not grep {ret i32} +; RUN: opt < %s -prune-eh -S | not grep "ret i32" declare void @noreturn() noreturn diff --git a/test/Transforms/Reassociate/2005-08-24-Crash.ll b/test/Transforms/Reassociate/2005-08-24-Crash.ll deleted file mode 100644 index 9864de45f88e..000000000000 --- a/test/Transforms/Reassociate/2005-08-24-Crash.ll +++ /dev/null @@ -1,13 +0,0 @@ -; RUN: opt < %s -reassociate -disable-output - -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 -} - diff --git a/test/Transforms/Reassociate/2005-09-01-ArrayOutOfBounds.ll b/test/Transforms/Reassociate/2005-09-01-ArrayOutOfBounds.ll index 33e44d4ba753..f66148bb4abc 100644 --- a/test/Transforms/Reassociate/2005-09-01-ArrayOutOfBounds.ll +++ b/test/Transforms/Reassociate/2005-09-01-ArrayOutOfBounds.ll @@ -1,5 +1,5 @@ ; RUN: opt < %s -reassociate -instcombine -S |\ -; RUN: grep {ret i32 0} +; RUN: grep "ret i32 0" define i32 @f(i32 %a0, i32 %a1, i32 %a2, i32 %a3, i32 %a4) { %tmp.2 = add i32 %a4, %a3 ; <i32> [#uses=1] diff --git a/test/Transforms/Reassociate/2012-05-08-UndefLeak.ll b/test/Transforms/Reassociate/2012-05-08-UndefLeak.ll new file mode 100644 index 000000000000..2f5a53e0ce46 --- /dev/null +++ b/test/Transforms/Reassociate/2012-05-08-UndefLeak.ll @@ -0,0 +1,85 @@ +; RUN: opt < %s -reassociate -S | FileCheck %s +; PR12169 +; PR12764 +; XFAIL: * +; Transform disabled until PR13021 is fixed. + +define i64 @f(i64 %x0) { +; CHECK: @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 +} diff --git a/test/Transforms/Reassociate/2012-06-08-InfiniteLoop.ll b/test/Transforms/Reassociate/2012-06-08-InfiniteLoop.ll new file mode 100644 index 000000000000..6e62a287e022 --- /dev/null +++ b/test/Transforms/Reassociate/2012-06-08-InfiniteLoop.ll @@ -0,0 +1,21 @@ +; 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 +} diff --git a/test/Transforms/Reassociate/absorption.ll b/test/Transforms/Reassociate/absorption.ll new file mode 100644 index 000000000000..2ccc2b579496 --- /dev/null +++ b/test/Transforms/Reassociate/absorption.ll @@ -0,0 +1,11 @@ +; 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: @foo +; CHECK: ret i8 -1 +} diff --git a/test/Transforms/Reassociate/crash.ll b/test/Transforms/Reassociate/crash.ll index 7a819422eab8..ce586e15fbcf 100644 --- a/test/Transforms/Reassociate/crash.ll +++ b/test/Transforms/Reassociate/crash.ll @@ -67,3 +67,80 @@ _33: ; preds = %_33, %_ %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* @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 +} diff --git a/test/Transforms/Reassociate/fp-commute.ll b/test/Transforms/Reassociate/fp-commute.ll new file mode 100644 index 000000000000..025689bb0c10 --- /dev/null +++ b/test/Transforms/Reassociate/fp-commute.ll @@ -0,0 +1,18 @@ +; RUN: opt -reassociate -S < %s | FileCheck %s + +target triple = "armv7-apple-ios" + +declare void @use(float) + +; CHECK: test +define void @test(float %x, float %y) { +entry: +; CHECK: fmul float %x, %y +; CHECK: fmul float %x, %y + %0 = fmul float %x, %y + %1 = fmul float %y, %x + %2 = fsub float %0, %1 + call void @use(float %0) + call void @use(float %2) + ret void +} diff --git a/test/Transforms/Reassociate/mightymul.ll b/test/Transforms/Reassociate/mightymul.ll new file mode 100644 index 000000000000..cfbc485ffa03 --- /dev/null +++ b/test/Transforms/Reassociate/mightymul.ll @@ -0,0 +1,35 @@ +; RUN: opt < %s -reassociate +; PR13021 + +define i32 @foo(i32 %x) { + %t0 = mul i32 %x, %x + %t1 = mul i32 %t0, %t0 + %t2 = mul i32 %t1, %t1 + %t3 = mul i32 %t2, %t2 + %t4 = mul i32 %t3, %t3 + %t5 = mul i32 %t4, %t4 + %t6 = mul i32 %t5, %t5 + %t7 = mul i32 %t6, %t6 + %t8 = mul i32 %t7, %t7 + %t9 = mul i32 %t8, %t8 + %t10 = mul i32 %t9, %t9 + %t11 = mul i32 %t10, %t10 + %t12 = mul i32 %t11, %t11 + %t13 = mul i32 %t12, %t12 + %t14 = mul i32 %t13, %t13 + %t15 = mul i32 %t14, %t14 + %t16 = mul i32 %t15, %t15 + %t17 = mul i32 %t16, %t16 + %t18 = mul i32 %t17, %t17 + %t19 = mul i32 %t18, %t18 + %t20 = mul i32 %t19, %t19 + %t21 = mul i32 %t20, %t20 + %t22 = mul i32 %t21, %t21 + %t23 = mul i32 %t22, %t22 + %t24 = mul i32 %t23, %t23 + %t25 = mul i32 %t24, %t24 + %t26 = mul i32 %t25, %t25 + %t27 = mul i32 %t26, %t26 + %t28 = mul i32 %t27, %t27 + ret i32 %t28 +} diff --git a/test/Transforms/Reassociate/mulfactor.ll b/test/Transforms/Reassociate/mulfactor.ll index f279727c9930..6c099b43b363 100644 --- a/test/Transforms/Reassociate/mulfactor.ll +++ b/test/Transforms/Reassociate/mulfactor.ll @@ -1,14 +1,134 @@ -; RUN: opt < %s -reassociate -instcombine -S | grep mul | count 2 +; RUN: opt < %s -reassociate -S | FileCheck %s -; This should have exactly 2 multiplies when we're done. +define i32 @test1(i32 %a, i32 %b) { +; CHECK: @test1 +; CHECK: mul i32 %a, %a +; CHECK-NEXT: mul i32 %a, 2 +; CHECK-NEXT: add +; CHECK-NEXT: mul +; CHECK-NEXT: add +; CHECK-NEXT: ret -define i32 @f(i32 %a, i32 %b) { - %tmp.2 = mul i32 %a, %a ; <i32> [#uses=1] - %tmp.5 = shl i32 %a, 1 ; <i32> [#uses=1] - %tmp.6 = mul i32 %tmp.5, %b ; <i32> [#uses=1] - %tmp.10 = mul i32 %b, %b ; <i32> [#uses=1] - %tmp.7 = add i32 %tmp.6, %tmp.2 ; <i32> [#uses=1] - %tmp.11 = add i32 %tmp.7, %tmp.10 ; <i32> [#uses=1] +entry: + %tmp.2 = mul i32 %a, %a + %tmp.5 = shl i32 %a, 1 + %tmp.6 = mul i32 %tmp.5, %b + %tmp.10 = mul i32 %b, %b + %tmp.7 = add i32 %tmp.6, %tmp.2 + %tmp.11 = add i32 %tmp.7, %tmp.10 ret i32 %tmp.11 } +define i32 @test2(i32 %t) { +; CHECK: @test2 +; CHECK: mul +; CHECK-NEXT: add +; CHECK-NEXT: ret + +entry: + %a = mul i32 %t, 6 + %b = mul i32 %t, 36 + %c = add i32 %b, 15 + %d = add i32 %c, %a + ret i32 %d +} + +define i32 @test3(i32 %x) { +; (x^8) +; CHECK: @test3 +; CHECK: mul +; CHECK-NEXT: mul +; CHECK-NEXT: mul +; CHECK-NEXT: ret + +entry: + %a = mul i32 %x, %x + %b = mul i32 %a, %x + %c = mul i32 %b, %x + %d = mul i32 %c, %x + %e = mul i32 %d, %x + %f = mul i32 %e, %x + %g = mul i32 %f, %x + ret i32 %g +} + +define i32 @test4(i32 %x) { +; (x^7) +; CHECK: @test4 +; CHECK: mul +; CHECK-NEXT: mul +; CHECK-NEXT: mul +; CHECK-NEXT: mul +; CHECK-NEXT: ret + +entry: + %a = mul i32 %x, %x + %b = mul i32 %a, %x + %c = mul i32 %b, %x + %d = mul i32 %c, %x + %e = mul i32 %d, %x + %f = mul i32 %e, %x + ret i32 %f +} + +define i32 @test5(i32 %x, i32 %y) { +; (x^4) * (y^2) +; CHECK: @test5 +; CHECK: mul +; CHECK-NEXT: mul +; CHECK-NEXT: mul +; CHECK-NEXT: ret + +entry: + %a = mul i32 %x, %y + %b = mul i32 %a, %y + %c = mul i32 %b, %x + %d = mul i32 %c, %x + %e = mul i32 %d, %x + ret i32 %e +} + +define i32 @test6(i32 %x, i32 %y, i32 %z) { +; (x^5) * (y^3) * z +; CHECK: @test6 +; CHECK: mul +; CHECK-NEXT: mul +; CHECK-NEXT: mul +; CHECK-NEXT: mul +; CHECK-NEXT: mul +; CHECK-NEXT: mul +; CHECK-NEXT: ret + +entry: + %a = mul i32 %x, %y + %b = mul i32 %a, %x + %c = mul i32 %b, %y + %d = mul i32 %c, %x + %e = mul i32 %d, %y + %f = mul i32 %e, %x + %g = mul i32 %f, %z + %h = mul i32 %g, %x + ret i32 %h +} + +define i32 @test7(i32 %x, i32 %y, i32 %z) { +; (x^4) * (y^3) * (z^2) +; CHECK: @test7 +; CHECK: mul +; CHECK-NEXT: mul +; CHECK-NEXT: mul +; CHECK-NEXT: mul +; CHECK-NEXT: mul +; CHECK-NEXT: ret + +entry: + %a = mul i32 %y, %x + %b = mul i32 %a, %z + %c = mul i32 %b, %z + %d = mul i32 %c, %x + %e = mul i32 %d, %y + %f = mul i32 %e, %y + %g = mul i32 %f, %x + %h = mul i32 %g, %x + ret i32 %h +} diff --git a/test/Transforms/Reassociate/mulfactor2.ll b/test/Transforms/Reassociate/mulfactor2.ll deleted file mode 100644 index 8116554196fb..000000000000 --- a/test/Transforms/Reassociate/mulfactor2.ll +++ /dev/null @@ -1,15 +0,0 @@ -; This should turn into one multiply and one add. - -; RUN: opt < %s -instcombine -reassociate -instcombine -S > %t -; RUN: grep mul %t | count 1 -; RUN: grep add %t | count 1 - -define i32 @main(i32 %t) { - %tmp.3 = mul i32 %t, 12 ; <i32> [#uses=1] - %tmp.4 = add i32 %tmp.3, 5 ; <i32> [#uses=1] - %tmp.6 = mul i32 %t, 6 ; <i32> [#uses=1] - %tmp.8 = mul i32 %tmp.4, 3 ; <i32> [#uses=1] - %tmp.9 = add i32 %tmp.8, %tmp.6 ; <i32> [#uses=1] - ret i32 %tmp.9 -} - diff --git a/test/Transforms/Reassociate/multistep.ll b/test/Transforms/Reassociate/multistep.ll new file mode 100644 index 000000000000..7466d2e99d89 --- /dev/null +++ b/test/Transforms/Reassociate/multistep.ll @@ -0,0 +1,31 @@ +; RUN: opt < %s -reassociate -S | FileCheck %s + +define i64 @multistep1(i64 %a, i64 %b, i64 %c) { +; Check that a*a*b+a*a*c is turned into a*(a*(b+c)). +; CHECK: @multistep1 + %t0 = mul i64 %a, %b + %t1 = mul i64 %a, %t0 ; a*(a*b) + %t2 = mul i64 %a, %c + %t3 = mul i64 %a, %t2 ; a*(a*c) + %t4 = add i64 %t1, %t3 +; CHECK-NEXT: add i64 %c, %b +; CHECK-NEXT: mul i64 %tmp{{.*}}, %a +; CHECK-NEXT: mul i64 %tmp{{.*}}, %a +; CHECK-NEXT: ret + ret i64 %t4 +} + +define i64 @multistep2(i64 %a, i64 %b, i64 %c, i64 %d) { +; Check that a*b+a*c+d is turned into a*(b+c)+d. +; CHECK: @multistep2 + %t0 = mul i64 %a, %b + %t1 = mul i64 %a, %c + %t2 = add i64 %t1, %d ; a*c+d + %t3 = add i64 %t0, %t2 ; a*b+(a*c+d) +; CHECK-NEXT: add i64 %c, %b +; CHECK-NEXT: mul i64 %tmp{{.*}}, %a +; CHECK-NEXT: add i64 %tmp{{.*}}, %d +; CHECK-NEXT: ret + ret i64 %t3 +} + diff --git a/test/Transforms/Reassociate/no-op.ll b/test/Transforms/Reassociate/no-op.ll new file mode 100644 index 000000000000..0444cf082d0d --- /dev/null +++ b/test/Transforms/Reassociate/no-op.ll @@ -0,0 +1,38 @@ +; RUN: opt < %s -reassociate -S | FileCheck %s + +; When there is nothing to do, or not much to do, check that reassociate leaves +; things alone. + +declare void @use(i32) + +define void @test1(i32 %a, i32 %b) { +; Shouldn't change or move any of the add instructions. Should commute but +; otherwise not change or move any of the mul instructions. +; CHECK: @test1 + %a0 = add nsw i32 %a, 1 +; CHECK-NEXT: %a0 = add nsw i32 %a, 1 + %m0 = mul nsw i32 3, %a +; CHECK-NEXT: %m0 = mul nsw i32 %a, 3 + %a1 = add nsw i32 %a0, %b +; CHECK-NEXT: %a1 = add nsw i32 %a0, %b + %m1 = mul nsw i32 %b, %m0 +; CHECK-NEXT: %m1 = mul nsw i32 %m0, %b + call void @use(i32 %a1) +; CHECK-NEXT: call void @use + call void @use(i32 %m1) + ret void +} + +define void @test2(i32 %a, i32 %b, i32 %c, i32 %d) { +; The initial add doesn't change so should not lose the nsw flag. +; CHECK: @test2 + %a0 = add nsw i32 %b, %a +; CHECK-NEXT: %a0 = add nsw i32 %b, %a + %a1 = add nsw i32 %a0, %d +; CHECK-NEXT: %a1 = add i32 %a0, %c + %a2 = add nsw i32 %a1, %c +; CHECK-NEXT: %a2 = add i32 %a1, %d + call void @use(i32 %a2) +; CHECK-NEXT: call void @use + ret void +} diff --git a/test/Transforms/Reassociate/repeats.ll b/test/Transforms/Reassociate/repeats.ll new file mode 100644 index 000000000000..6a020470f379 --- /dev/null +++ b/test/Transforms/Reassociate/repeats.ll @@ -0,0 +1,252 @@ +; RUN: opt < %s -reassociate -S | FileCheck %s + +; Tests involving repeated operations on the same value. + +define i8 @nilpotent(i8 %x) { +; CHECK: @nilpotent + %tmp = xor i8 %x, %x + ret i8 %tmp +; CHECK: ret i8 0 +} + +define i2 @idempotent(i2 %x) { +; CHECK: @idempotent + %tmp1 = and i2 %x, %x + %tmp2 = and i2 %tmp1, %x + %tmp3 = and i2 %tmp2, %x + ret i2 %tmp3 +; CHECK: ret i2 %x +} + +define i2 @add(i2 %x) { +; CHECK: @add + %tmp1 = add i2 %x, %x + %tmp2 = add i2 %tmp1, %x + %tmp3 = add i2 %tmp2, %x + ret i2 %tmp3 +; CHECK: ret i2 0 +} + +define i2 @cst_add() { +; CHECK: @cst_add + %tmp1 = add i2 1, 1 + %tmp2 = add i2 %tmp1, 1 + ret i2 %tmp2 +; CHECK: ret i2 -1 +} + +define i8 @cst_mul() { +; CHECK: @cst_mul + %tmp1 = mul i8 3, 3 + %tmp2 = mul i8 %tmp1, 3 + %tmp3 = mul i8 %tmp2, 3 + %tmp4 = mul i8 %tmp3, 3 + ret i8 %tmp4 +; CHECK: ret i8 -13 +} + +define i3 @foo3x5(i3 %x) { +; Can be done with two multiplies. +; CHECK: @foo3x5 +; CHECK-NEXT: mul +; CHECK-NEXT: mul +; CHECK-NEXT: ret + %tmp1 = mul i3 %x, %x + %tmp2 = mul i3 %tmp1, %x + %tmp3 = mul i3 %tmp2, %x + %tmp4 = mul i3 %tmp3, %x + ret i3 %tmp4 +} + +define i3 @foo3x6(i3 %x) { +; Can be done with two multiplies. +; CHECK: @foo3x6 +; CHECK-NEXT: mul +; CHECK-NEXT: mul +; CHECK-NEXT: ret + %tmp1 = mul i3 %x, %x + %tmp2 = mul i3 %tmp1, %x + %tmp3 = mul i3 %tmp2, %x + %tmp4 = mul i3 %tmp3, %x + %tmp5 = mul i3 %tmp4, %x + ret i3 %tmp5 +} + +define i3 @foo3x7(i3 %x) { +; Can be done with two multiplies. +; CHECK: @foo3x7 +; CHECK-NEXT: mul +; CHECK-NEXT: mul +; CHECK-NEXT: ret + %tmp1 = mul i3 %x, %x + %tmp2 = mul i3 %tmp1, %x + %tmp3 = mul i3 %tmp2, %x + %tmp4 = mul i3 %tmp3, %x + %tmp5 = mul i3 %tmp4, %x + %tmp6 = mul i3 %tmp5, %x + ret i3 %tmp6 +} + +define i4 @foo4x8(i4 %x) { +; Can be done with two multiplies. +; CHECK: @foo4x8 +; CHECK-NEXT: mul +; CHECK-NEXT: mul +; CHECK-NEXT: ret + %tmp1 = mul i4 %x, %x + %tmp2 = mul i4 %tmp1, %x + %tmp3 = mul i4 %tmp2, %x + %tmp4 = mul i4 %tmp3, %x + %tmp5 = mul i4 %tmp4, %x + %tmp6 = mul i4 %tmp5, %x + %tmp7 = mul i4 %tmp6, %x + ret i4 %tmp7 +} + +define i4 @foo4x9(i4 %x) { +; Can be done with three multiplies. +; CHECK: @foo4x9 +; CHECK-NEXT: mul +; CHECK-NEXT: mul +; CHECK-NEXT: mul +; CHECK-NEXT: ret + %tmp1 = mul i4 %x, %x + %tmp2 = mul i4 %tmp1, %x + %tmp3 = mul i4 %tmp2, %x + %tmp4 = mul i4 %tmp3, %x + %tmp5 = mul i4 %tmp4, %x + %tmp6 = mul i4 %tmp5, %x + %tmp7 = mul i4 %tmp6, %x + %tmp8 = mul i4 %tmp7, %x + ret i4 %tmp8 +} + +define i4 @foo4x10(i4 %x) { +; Can be done with three multiplies. +; CHECK: @foo4x10 +; CHECK-NEXT: mul +; CHECK-NEXT: mul +; CHECK-NEXT: mul +; CHECK-NEXT: ret + %tmp1 = mul i4 %x, %x + %tmp2 = mul i4 %tmp1, %x + %tmp3 = mul i4 %tmp2, %x + %tmp4 = mul i4 %tmp3, %x + %tmp5 = mul i4 %tmp4, %x + %tmp6 = mul i4 %tmp5, %x + %tmp7 = mul i4 %tmp6, %x + %tmp8 = mul i4 %tmp7, %x + %tmp9 = mul i4 %tmp8, %x + ret i4 %tmp9 +} + +define i4 @foo4x11(i4 %x) { +; Can be done with four multiplies. +; CHECK: @foo4x11 +; CHECK-NEXT: mul +; CHECK-NEXT: mul +; CHECK-NEXT: mul +; CHECK-NEXT: mul +; CHECK-NEXT: ret + %tmp1 = mul i4 %x, %x + %tmp2 = mul i4 %tmp1, %x + %tmp3 = mul i4 %tmp2, %x + %tmp4 = mul i4 %tmp3, %x + %tmp5 = mul i4 %tmp4, %x + %tmp6 = mul i4 %tmp5, %x + %tmp7 = mul i4 %tmp6, %x + %tmp8 = mul i4 %tmp7, %x + %tmp9 = mul i4 %tmp8, %x + %tmp10 = mul i4 %tmp9, %x + ret i4 %tmp10 +} + +define i4 @foo4x12(i4 %x) { +; Can be done with two multiplies. +; CHECK: @foo4x12 +; CHECK-NEXT: mul +; CHECK-NEXT: mul +; CHECK-NEXT: ret + %tmp1 = mul i4 %x, %x + %tmp2 = mul i4 %tmp1, %x + %tmp3 = mul i4 %tmp2, %x + %tmp4 = mul i4 %tmp3, %x + %tmp5 = mul i4 %tmp4, %x + %tmp6 = mul i4 %tmp5, %x + %tmp7 = mul i4 %tmp6, %x + %tmp8 = mul i4 %tmp7, %x + %tmp9 = mul i4 %tmp8, %x + %tmp10 = mul i4 %tmp9, %x + %tmp11 = mul i4 %tmp10, %x + ret i4 %tmp11 +} + +define i4 @foo4x13(i4 %x) { +; Can be done with three multiplies. +; CHECK: @foo4x13 +; CHECK-NEXT: mul +; CHECK-NEXT: mul +; CHECK-NEXT: mul +; CHECK-NEXT: ret + %tmp1 = mul i4 %x, %x + %tmp2 = mul i4 %tmp1, %x + %tmp3 = mul i4 %tmp2, %x + %tmp4 = mul i4 %tmp3, %x + %tmp5 = mul i4 %tmp4, %x + %tmp6 = mul i4 %tmp5, %x + %tmp7 = mul i4 %tmp6, %x + %tmp8 = mul i4 %tmp7, %x + %tmp9 = mul i4 %tmp8, %x + %tmp10 = mul i4 %tmp9, %x + %tmp11 = mul i4 %tmp10, %x + %tmp12 = mul i4 %tmp11, %x + ret i4 %tmp12 +} + +define i4 @foo4x14(i4 %x) { +; Can be done with three multiplies. +; CHECK: @foo4x14 +; CHECK-NEXT: mul +; CHECK-NEXT: mul +; CHECK-NEXT: mul +; CHECK-NEXT: ret + %tmp1 = mul i4 %x, %x + %tmp2 = mul i4 %tmp1, %x + %tmp3 = mul i4 %tmp2, %x + %tmp4 = mul i4 %tmp3, %x + %tmp5 = mul i4 %tmp4, %x + %tmp6 = mul i4 %tmp5, %x + %tmp7 = mul i4 %tmp6, %x + %tmp8 = mul i4 %tmp7, %x + %tmp9 = mul i4 %tmp8, %x + %tmp10 = mul i4 %tmp9, %x + %tmp11 = mul i4 %tmp10, %x + %tmp12 = mul i4 %tmp11, %x + %tmp13 = mul i4 %tmp12, %x + ret i4 %tmp13 +} + +define i4 @foo4x15(i4 %x) { +; Can be done with four multiplies. +; CHECK: @foo4x15 +; CHECK-NEXT: mul +; CHECK-NEXT: mul +; CHECK-NEXT: mul +; CHECK-NEXT: mul +; CHECK-NEXT: ret + %tmp1 = mul i4 %x, %x + %tmp2 = mul i4 %tmp1, %x + %tmp3 = mul i4 %tmp2, %x + %tmp4 = mul i4 %tmp3, %x + %tmp5 = mul i4 %tmp4, %x + %tmp6 = mul i4 %tmp5, %x + %tmp7 = mul i4 %tmp6, %x + %tmp8 = mul i4 %tmp7, %x + %tmp9 = mul i4 %tmp8, %x + %tmp10 = mul i4 %tmp9, %x + %tmp11 = mul i4 %tmp10, %x + %tmp12 = mul i4 %tmp11, %x + %tmp13 = mul i4 %tmp12, %x + %tmp14 = mul i4 %tmp13, %x + ret i4 %tmp14 +} diff --git a/test/Transforms/Reassociate/shifttest.ll b/test/Transforms/Reassociate/shifttest.ll index 8b2cbc98c47a..d9a5336fbfb4 100644 --- a/test/Transforms/Reassociate/shifttest.ll +++ b/test/Transforms/Reassociate/shifttest.ll @@ -1,7 +1,7 @@ ; With shl->mul reassociation, we can see that this is (shl A, 9) * A ; ; RUN: opt < %s -reassociate -instcombine -S |\ -; RUN: grep {shl .*, 9} +; RUN: grep "shl .*, 9" define i32 @test(i32 %A, i32 %B) { %X = shl i32 %A, 5 ; <i32> [#uses=1] diff --git a/test/Transforms/SCCP/2004-12-10-UndefBranchBug.ll b/test/Transforms/SCCP/2004-12-10-UndefBranchBug.ll index 4adfde3bfe9c..c847b4eaca3d 100644 --- a/test/Transforms/SCCP/2004-12-10-UndefBranchBug.ll +++ b/test/Transforms/SCCP/2004-12-10-UndefBranchBug.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -sccp -S | grep {ret i32 1} +; RUN: opt < %s -sccp -S | grep "ret i32 1" ; This function definitely returns 1, even if we don't know the direction ; of the branch. diff --git a/test/Transforms/SCCP/2006-12-19-UndefBug.ll b/test/Transforms/SCCP/2006-12-19-UndefBug.ll index ec69ce05fe94..ede1a32c5f7a 100644 --- a/test/Transforms/SCCP/2006-12-19-UndefBug.ll +++ b/test/Transforms/SCCP/2006-12-19-UndefBug.ll @@ -1,5 +1,5 @@ ; RUN: opt < %s -sccp -S | \ -; RUN: grep {ret i1 false} +; RUN: grep "ret i1 false" define i1 @foo() { %X = and i1 false, undef ; <i1> [#uses=1] diff --git a/test/Transforms/SCCP/2008-04-22-multiple-ret-sccp.ll b/test/Transforms/SCCP/2008-04-22-multiple-ret-sccp.ll index a40455cf5d00..e7168dda0891 100644 --- a/test/Transforms/SCCP/2008-04-22-multiple-ret-sccp.ll +++ b/test/Transforms/SCCP/2008-04-22-multiple-ret-sccp.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -sccp -S | grep {ret i32 %Z} +; RUN: opt < %s -sccp -S | grep "ret i32 %Z" ; rdar://5778210 declare {i32, i32} @bar(i32 %A) diff --git a/test/Transforms/SCCP/2008-05-23-UndefCallFold.ll b/test/Transforms/SCCP/2008-05-23-UndefCallFold.ll index 63f41dbc0240..4688643ebd54 100644 --- a/test/Transforms/SCCP/2008-05-23-UndefCallFold.ll +++ b/test/Transforms/SCCP/2008-05-23-UndefCallFold.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -sccp -S | not grep {ret i32 undef} +; RUN: opt < %s -sccp -S | not grep "ret i32 undef" ; PR2358 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:128:128" diff --git a/test/Transforms/SCCP/2009-01-14-IPSCCP-Invoke.ll b/test/Transforms/SCCP/2009-01-14-IPSCCP-Invoke.ll index f62ed7048e05..c05f897f1a37 100644 --- a/test/Transforms/SCCP/2009-01-14-IPSCCP-Invoke.ll +++ b/test/Transforms/SCCP/2009-01-14-IPSCCP-Invoke.ll @@ -1,5 +1,5 @@ -; RUN: opt < %s -ipsccp -S | grep {ret i32 42} -; RUN: opt < %s -ipsccp -S | grep {ret i32 undef} +; RUN: opt < %s -ipsccp -S | grep "ret i32 42" +; RUN: opt < %s -ipsccp -S | grep "ret i32 undef" ; PR3325 define i32 @main() { diff --git a/test/Transforms/SCCP/apint-array.ll b/test/Transforms/SCCP/apint-array.ll index 1e75878f3aeb..888b9e1d22d5 100644 --- a/test/Transforms/SCCP/apint-array.ll +++ b/test/Transforms/SCCP/apint-array.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -sccp -S | grep {ret i101 12} +; RUN: opt < %s -sccp -S | grep "ret i101 12" @Y = constant [6 x i101] [ i101 12, i101 123456789000000, i101 -12,i101 -123456789000000, i101 0,i101 9123456789000000] diff --git a/test/Transforms/SCCP/apint-basictest4.ll b/test/Transforms/SCCP/apint-basictest4.ll index 862426020e4f..572f97c572ee 100644 --- a/test/Transforms/SCCP/apint-basictest4.ll +++ b/test/Transforms/SCCP/apint-basictest4.ll @@ -4,7 +4,7 @@ ; RUN: opt < %s -sccp -S | not grep and ; RUN: opt < %s -sccp -S | not grep trunc -; RUN: opt < %s -sccp -S | grep {ret i100 -1} +; RUN: opt < %s -sccp -S | grep "ret i100 -1" define i100 @test(i133 %A) { %B = and i133 0, %A diff --git a/test/Transforms/SCCP/apint-ipsccp1.ll b/test/Transforms/SCCP/apint-ipsccp1.ll index fda40f53fe1f..f6f18fe66f89 100644 --- a/test/Transforms/SCCP/apint-ipsccp1.ll +++ b/test/Transforms/SCCP/apint-ipsccp1.ll @@ -1,5 +1,5 @@ -; RUN: opt < %s -ipsccp -S | grep -v {ret i512 undef} | \ -; RUN: grep {ret i8 2} +; RUN: opt < %s -ipsccp -S | grep -v "ret i512 undef" | \ +; RUN: grep "ret i8 2" define internal i512 @test(i1 %B) { br i1 %B, label %BB1, label %BB2 diff --git a/test/Transforms/SCCP/apint-ipsccp2.ll b/test/Transforms/SCCP/apint-ipsccp2.ll index 3c02e05548db..834cca488484 100644 --- a/test/Transforms/SCCP/apint-ipsccp2.ll +++ b/test/Transforms/SCCP/apint-ipsccp2.ll @@ -1,5 +1,5 @@ -; RUN: opt < %s -ipsccp -S | grep -v {ret i101 0} | \ -; RUN: grep -v {ret i101 undef} | not grep ret +; RUN: opt < %s -ipsccp -S | grep -v "ret i101 0" | \ +; RUN: grep -v "ret i101 undef" | not grep ret define internal i101 @bar(i101 %A) { diff --git a/test/Transforms/SCCP/logical-nuke.ll b/test/Transforms/SCCP/logical-nuke.ll index b3d845c7eec5..45f6f44a0eb2 100644 --- a/test/Transforms/SCCP/logical-nuke.ll +++ b/test/Transforms/SCCP/logical-nuke.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -sccp -S | grep {ret i32 0} +; RUN: opt < %s -sccp -S | grep "ret i32 0" ; Test that SCCP has basic knowledge of when and/or nuke overdefined values. diff --git a/test/Transforms/SCCP/vector-bitcast.ll b/test/Transforms/SCCP/vector-bitcast.ll new file mode 100644 index 000000000000..b032085083c6 --- /dev/null +++ b/test/Transforms/SCCP/vector-bitcast.ll @@ -0,0 +1,20 @@ +; RUN: opt -sccp -S < %s | FileCheck %s + +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:128:128-n8:16:32-S128" + +; CHECK: store volatile <2 x i64> zeroinitializer, <2 x i64>* %p +; rdar://11324230 + +define void @foo(<2 x i64>* %p) nounwind { +entry: + br label %while.body.i + +while.body.i: ; preds = %while.body.i, %entry + %vWorkExponent.i.033 = phi <4 x i32> [ %sub.i.i, %while.body.i ], [ <i32 939524096, i32 939524096, i32 939524096, i32 939524096>, %entry ] + %sub.i.i = add <4 x i32> %vWorkExponent.i.033, <i32 -8388608, i32 -8388608, i32 -8388608, i32 -8388608> + %0 = bitcast <4 x i32> %sub.i.i to <2 x i64> + %and.i119.i = and <2 x i64> %0, zeroinitializer + store volatile <2 x i64> %and.i119.i, <2 x i64>* %p + br label %while.body.i +} + diff --git a/test/Transforms/ScalarRepl/2003-09-12-IncorrectPromote.ll b/test/Transforms/ScalarRepl/2003-09-12-IncorrectPromote.ll index eb1c945e34eb..0b5e4152c423 100644 --- a/test/Transforms/ScalarRepl/2003-09-12-IncorrectPromote.ll +++ b/test/Transforms/ScalarRepl/2003-09-12-IncorrectPromote.ll @@ -1,7 +1,7 @@ ; Scalar replacement was incorrectly promoting this alloca!! ; ; RUN: opt < %s -scalarrepl -S | \ -; RUN: sed {s/;.*//g} | grep {\\\[} +; RUN: sed "s/;.*//g" | grep "\[" define i8* @test() { %A = alloca [30 x i8] ; <[30 x i8]*> [#uses=1] diff --git a/test/Transforms/ScalarRepl/2003-10-29-ArrayProblem.ll b/test/Transforms/ScalarRepl/2003-10-29-ArrayProblem.ll index 00e43a79043d..77c7b54b63ff 100644 --- a/test/Transforms/ScalarRepl/2003-10-29-ArrayProblem.ll +++ b/test/Transforms/ScalarRepl/2003-10-29-ArrayProblem.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -scalarrepl -S | grep {alloca %%T} +; RUN: opt < %s -scalarrepl -S | grep "alloca %%T" %T = type { [80 x i8], i32, i32 } declare i32 @.callback_1(i8*) diff --git a/test/Transforms/ScalarRepl/2008-01-29-PromoteBug.ll b/test/Transforms/ScalarRepl/2008-01-29-PromoteBug.ll index 8bc4ff0b3ffc..a53f3deadc72 100644 --- a/test/Transforms/ScalarRepl/2008-01-29-PromoteBug.ll +++ b/test/Transforms/ScalarRepl/2008-01-29-PromoteBug.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -scalarrepl -instcombine -S | grep {ret i8 17} +; RUN: opt < %s -scalarrepl -instcombine -S | grep "ret i8 17" ; rdar://5707076 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:128:128-n8:16:32" target triple = "i386-apple-darwin9.1.0" diff --git a/test/Transforms/ScalarRepl/2008-06-22-LargeArray.ll b/test/Transforms/ScalarRepl/2008-06-22-LargeArray.ll index 71ba601833d0..f597613ef2b7 100644 --- a/test/Transforms/ScalarRepl/2008-06-22-LargeArray.ll +++ b/test/Transforms/ScalarRepl/2008-06-22-LargeArray.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -scalarrepl -S | grep {call.*mem} +; RUN: opt < %s -scalarrepl -S | grep "call.*mem" ; PR2369 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:128:128" diff --git a/test/Transforms/ScalarRepl/2008-08-22-out-of-range-array-promote.ll b/test/Transforms/ScalarRepl/2008-08-22-out-of-range-array-promote.ll index 7cccb19714a8..b2a9d43b2277 100644 --- a/test/Transforms/ScalarRepl/2008-08-22-out-of-range-array-promote.ll +++ b/test/Transforms/ScalarRepl/2008-08-22-out-of-range-array-promote.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -scalarrepl -S | grep {s = alloca .struct.x} +; RUN: opt < %s -scalarrepl -S | grep "s = alloca .struct.x" ; PR2423 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:128:128" target triple = "i386-apple-darwin8" diff --git a/test/Transforms/ScalarRepl/2009-02-02-ScalarPromoteOutOfRange.ll b/test/Transforms/ScalarRepl/2009-02-02-ScalarPromoteOutOfRange.ll index 9c0f2030c0e4..3c8a364edcdc 100644 --- a/test/Transforms/ScalarRepl/2009-02-02-ScalarPromoteOutOfRange.ll +++ b/test/Transforms/ScalarRepl/2009-02-02-ScalarPromoteOutOfRange.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -scalarrepl -instcombine -S | grep {ret i32 %x} +; RUN: opt < %s -scalarrepl -instcombine -S | grep "ret i32 %x" 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" target triple = "i386-pc-linux-gnu" diff --git a/test/Transforms/ScalarRepl/2009-02-05-LoadFCA.ll b/test/Transforms/ScalarRepl/2009-02-05-LoadFCA.ll index f8ab875bac4b..67228a7a3cec 100644 --- a/test/Transforms/ScalarRepl/2009-02-05-LoadFCA.ll +++ b/test/Transforms/ScalarRepl/2009-02-05-LoadFCA.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -scalarrepl -instcombine -inline -instcombine -S | grep {ret i32 42} +; RUN: opt < %s -scalarrepl -instcombine -inline -instcombine -S | grep "ret i32 42" ; PR3489 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128" target triple = "x86_64-apple-darwin10.0" diff --git a/test/Transforms/ScalarRepl/2009-03-04-MemCpyAlign.ll b/test/Transforms/ScalarRepl/2009-03-04-MemCpyAlign.ll index 3218d599d1c1..a4182d4c1d7c 100644 --- a/test/Transforms/ScalarRepl/2009-03-04-MemCpyAlign.ll +++ b/test/Transforms/ScalarRepl/2009-03-04-MemCpyAlign.ll @@ -1,6 +1,6 @@ ; The store into %p should end up with a known alignment of 1, since the memcpy ; is only known to access it with 1-byte alignment. -; RUN: opt < %s -scalarrepl -S | grep {store i16 1, .*, align 1} +; RUN: opt < %s -scalarrepl -S | grep "store i16 1, .*, align 1" ; PR3720 target datalayout = "E-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64" diff --git a/test/Transforms/ScalarRepl/2011-06-08-VectorExtractValue.ll b/test/Transforms/ScalarRepl/2011-06-08-VectorExtractValue.ll index 98fa1c684ce1..459688547fb4 100644 --- a/test/Transforms/ScalarRepl/2011-06-08-VectorExtractValue.ll +++ b/test/Transforms/ScalarRepl/2011-06-08-VectorExtractValue.ll @@ -10,8 +10,7 @@ target triple = "x86_64-apple-macosx10.7.0" ; CHECK: main ; CHECK-NOT: alloca -; CHECK: %[[A:[a-z0-9]*]] = and i128 -; CHECK: %[[B:[a-z0-9]*]] = trunc i128 %[[A]] to i32 +; CHECK: extractelement <2 x float> zeroinitializer, i32 0 define void @main() uwtable ssp { entry: @@ -28,8 +27,7 @@ entry: ; CHECK: test1 ; CHECK-NOT: alloca -; CHECK: %[[A:[a-z0-9]*]] = and i128 -; CHECK: %[[B:[a-z0-9]*]] = trunc i128 %[[A]] to i32 +; CHECK: extractelement <2 x float> zeroinitializer, i32 0 define void @test1() uwtable ssp { entry: @@ -43,9 +41,8 @@ entry: ; CHECK: test2 ; CHECK-NOT: alloca -; CHECK: and i128 -; CHECK: or i128 -; CHECK: trunc i128 +; CHECK: %[[A:[a-z0-9]*]] = extractelement <2 x float> zeroinitializer, i32 0 +; CHECK: fadd float %[[A]], 1.000000e+00 ; CHECK-NOT: insertelement ; CHECK-NOT: extractelement @@ -62,3 +59,17 @@ entry: %r = fadd float %r1, %r2 ret float %r } + +; CHECK: test3 +; CHECK: %[[A:[a-z0-9]*]] = extractelement <2 x float> <float 2.000000e+00, float 3.000000e+00>, i32 1 +; CHECK: ret float %[[A]] + +define float @test3() { +entry: + %ai = alloca { <2 x float>, <2 x float> }, align 8 + store { <2 x float>, <2 x float> } {<2 x float> <float 0.0, float 1.0>, <2 x float> <float 2.0, float 3.0>}, { <2 x float>, <2 x float> }* %ai, align 8 + %tmpcast = bitcast { <2 x float>, <2 x float> }* %ai to [4 x float]* + %arrayidx = getelementptr inbounds [4 x float]* %tmpcast, i64 0, i64 3 + %f = load float* %arrayidx, align 4 + ret float %f +} diff --git a/test/Transforms/ScalarRepl/crash.ll b/test/Transforms/ScalarRepl/crash.ll index cd4dc328e69a..58c5a3a0527d 100644 --- a/test/Transforms/ScalarRepl/crash.ll +++ b/test/Transforms/ScalarRepl/crash.ll @@ -260,5 +260,27 @@ entry: ret void } +; rdar://11861001 - The dynamic GEP here was incorrectly making all accesses +; to the alloca think they were also dynamic. Inserts and extracts created to +; access the vector were all being based from the dynamic access, even in BBs +; not dominated by the GEP. +define fastcc void @test() optsize inlinehint ssp align 2 { +entry: + %alloc.0.0 = alloca <4 x float>, align 16 + %bitcast = bitcast <4 x float>* %alloc.0.0 to [4 x float]* + %idx3 = getelementptr inbounds [4 x float]* %bitcast, i32 0, i32 3 + store float 0.000000e+00, float* %idx3, align 4 + br label %for.body10 + +for.body10: ; preds = %for.body10, %entry + %loopidx = phi i32 [ 0, %entry ], [ undef, %for.body10 ] + %unusedidx = getelementptr inbounds <4 x float>* %alloc.0.0, i32 0, i32 %loopidx + br i1 undef, label %for.end, label %for.body10 + +for.end: ; preds = %for.body10 + store <4 x float> <float -1.000000e+00, float -1.000000e+00, float -1.000000e+00, float 0.000000e+00>, <4 x float>* %alloc.0.0, align 16 + ret void +} + declare void @llvm.memcpy.p0i8.p0i8.i32(i8* nocapture, i8* nocapture, i32, i32, i1) nounwind declare void @llvm.memset.p0i8.i64(i8* nocapture, i8, i64, i32, i1) nounwind diff --git a/test/Transforms/ScalarRepl/dynamic-vector-gep.ll b/test/Transforms/ScalarRepl/dynamic-vector-gep.ll new file mode 100644 index 000000000000..565cd7616422 --- /dev/null +++ b/test/Transforms/ScalarRepl/dynamic-vector-gep.ll @@ -0,0 +1,167 @@ +; RUN: opt < %s -scalarrepl -S | FileCheck %s + +target datalayout = "E-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64" +target triple = "x86_64-apple-darwin10.0.0" + +; CHECK: @test1 +; CHECK: %[[alloc:[\.a-z0-9]*]] = alloca <4 x float> +; CHECK: store <4 x float> zeroinitializer, <4 x float>* %[[alloc]] +; CHECK: memset +; CHECK: extractelement <4 x float> zeroinitializer, i32 %idx2 + +; Split the array but don't replace the memset with an insert +; element as its not a constant offset. +; The load, however, can be replaced with an extract element. +define float @test1(i32 %idx1, i32 %idx2) { +entry: + %0 = alloca [4 x <4 x float>] + store [4 x <4 x float>] zeroinitializer, [4 x <4 x float>]* %0 + %ptr1 = getelementptr [4 x <4 x float>]* %0, i32 0, i32 0, i32 %idx1 + %cast = bitcast float* %ptr1 to i8* + call void @llvm.memset.p0i8.i32(i8* %cast, i8 0, i32 4, i32 4, i1 false) + %ptr2 = getelementptr [4 x <4 x float>]* %0, i32 0, i32 1, i32 %idx2 + %ret = load float* %ptr2 + ret float %ret +} + +; CHECK: @test2 +; CHECK: %[[ins:[\.a-z0-9]*]] = insertelement <4 x float> zeroinitializer, float 1.000000e+00, i32 %idx1 +; CHECK: extractelement <4 x float> %[[ins]], i32 %idx2 + +; Do SROA on the array when it has dynamic vector reads and writes. +define float @test2(i32 %idx1, i32 %idx2) { +entry: + %0 = alloca [4 x <4 x float>] + store [4 x <4 x float>] zeroinitializer, [4 x <4 x float>]* %0 + %ptr1 = getelementptr [4 x <4 x float>]* %0, i32 0, i32 0, i32 %idx1 + store float 1.0, float* %ptr1 + %ptr2 = getelementptr [4 x <4 x float>]* %0, i32 0, i32 0, i32 %idx2 + %ret = load float* %ptr2 + ret float %ret +} + +; CHECK: test3 +; CHECK: %0 = alloca [4 x <4 x float>] +; CHECK-NOT: alloca + +; Don't do SROA on a dynamically indexed vector when it spans +; more than one array element of the alloca array it is within. +define float @test3(i32 %idx1, i32 %idx2) { +entry: + %0 = alloca [4 x <4 x float>] + store [4 x <4 x float>] zeroinitializer, [4 x <4 x float>]* %0 + %bigvec = bitcast [4 x <4 x float>]* %0 to <16 x float>* + %ptr1 = getelementptr <16 x float>* %bigvec, i32 0, i32 %idx1 + store float 1.0, float* %ptr1 + %ptr2 = getelementptr <16 x float>* %bigvec, i32 0, i32 %idx2 + %ret = load float* %ptr2 + ret float %ret +} + +; CHECK: test4 +; CHECK: insertelement <16 x float> zeroinitializer, float 1.000000e+00, i32 %idx1 +; CHECK: extractelement <16 x float> %0, i32 %idx2 + +; Don't do SROA on a dynamically indexed vector when it spans +; more than one array element of the alloca array it is within. +; However, unlike test3, the store is on the vector type +; so SROA will convert the large alloca into the large vector +; type and do all accesses with insert/extract element +define float @test4(i32 %idx1, i32 %idx2) { +entry: + %0 = alloca [4 x <4 x float>] + %bigvec = bitcast [4 x <4 x float>]* %0 to <16 x float>* + store <16 x float> zeroinitializer, <16 x float>* %bigvec + %ptr1 = getelementptr <16 x float>* %bigvec, i32 0, i32 %idx1 + store float 1.0, float* %ptr1 + %ptr2 = getelementptr <16 x float>* %bigvec, i32 0, i32 %idx2 + %ret = load float* %ptr2 + ret float %ret +} + +; CHECK: @test5 +; CHECK: %0 = alloca [4 x <4 x float>] +; CHECK-NOT: alloca + +; Don't do SROA as the is a second dynamically indexed array +; which may span multiple elements of the alloca. +define float @test5(i32 %idx1, i32 %idx2) { +entry: + %0 = alloca [4 x <4 x float>] + store [4 x <4 x float>] zeroinitializer, [4 x <4 x float>]* %0 + %ptr1 = getelementptr [4 x <4 x float>]* %0, i32 0, i32 0, i32 %idx1 + %ptr2 = bitcast float* %ptr1 to [1 x <2 x float>]* + %ptr3 = getelementptr [1 x <2 x float>]* %ptr2, i32 0, i32 0, i32 %idx1 + store float 1.0, float* %ptr1 + %ptr4 = getelementptr [4 x <4 x float>]* %0, i32 0, i32 0, i32 %idx2 + %ret = load float* %ptr4 + ret float %ret +} + +; CHECK: test6 +; CHECK: insertelement <4 x float> zeroinitializer, float 1.000000e+00, i32 %idx1 +; CHECK: extractelement <4 x float> zeroinitializer, i32 %idx2 + +%vector.pair = type { %vector.anon, %vector.anon } +%vector.anon = type { %vector } +%vector = type { <4 x float> } + +; Dynamic GEPs on vectors were crashing when the vector was inside a struct +; as the new GEP for the new alloca might not include all the indices from +; the original GEP, just the indices it needs to get to the correct offset of +; some type, not necessarily the dynamic vector. +; This test makes sure we don't have this crash. +define float @test6(i32 %idx1, i32 %idx2) { +entry: + %0 = alloca %vector.pair + store %vector.pair zeroinitializer, %vector.pair* %0 + %ptr1 = getelementptr %vector.pair* %0, i32 0, i32 0, i32 0, i32 0, i32 %idx1 + store float 1.0, float* %ptr1 + %ptr2 = getelementptr %vector.pair* %0, i32 0, i32 1, i32 0, i32 0, i32 %idx2 + %ret = load float* %ptr2 + ret float %ret +} + +; CHECK: test7 +; CHECK: insertelement <4 x float> zeroinitializer, float 1.000000e+00, i32 %idx1 +; CHECK: extractelement <4 x float> zeroinitializer, i32 %idx2 + +%array.pair = type { [2 x %array.anon], %array.anon } +%array.anon = type { [2 x %vector] } + +; This is the same as test6 and tests the same crash, but on arrays. +define float @test7(i32 %idx1, i32 %idx2) { +entry: + %0 = alloca %array.pair + store %array.pair zeroinitializer, %array.pair* %0 + %ptr1 = getelementptr %array.pair* %0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 %idx1 + store float 1.0, float* %ptr1 + %ptr2 = getelementptr %array.pair* %0, i32 0, i32 1, i32 0, i32 0, i32 0, i32 %idx2 + %ret = load float* %ptr2 + ret float %ret +} + +; CHECK: test8 +; CHECK: %[[offset1:[\.a-z0-9]*]] = add i32 %idx1, 1 +; CHECK: %[[ins:[\.a-z0-9]*]] = insertelement <4 x float> zeroinitializer, float 1.000000e+00, i32 %[[offset1]] +; CHECK: %[[offset2:[\.a-z0-9]*]] = add i32 %idx2, 2 +; CHECK: extractelement <4 x float> %[[ins]], i32 %[[offset2]] + +; Do SROA on the vector when it has dynamic vector reads and writes +; from a non-zero offset. +define float @test8(i32 %idx1, i32 %idx2) { +entry: + %0 = alloca <4 x float> + store <4 x float> zeroinitializer, <4 x float>* %0 + %ptr1 = getelementptr <4 x float>* %0, i32 0, i32 1 + %ptr2 = bitcast float* %ptr1 to <3 x float>* + %ptr3 = getelementptr <3 x float>* %ptr2, i32 0, i32 %idx1 + store float 1.0, float* %ptr3 + %ptr4 = getelementptr <4 x float>* %0, i32 0, i32 2 + %ptr5 = bitcast float* %ptr4 to <2 x float>* + %ptr6 = getelementptr <2 x float>* %ptr5, i32 0, i32 %idx2 + %ret = load float* %ptr6 + ret float %ret +} + +declare void @llvm.memset.p0i8.i32(i8*, i8, i32, i32, i1) diff --git a/test/Transforms/ScalarRepl/memcpy-from-global.ll b/test/Transforms/ScalarRepl/memcpy-from-global.ll index 59475adc77f0..5557a8fd8754 100644 --- a/test/Transforms/ScalarRepl/memcpy-from-global.ll +++ b/test/Transforms/ScalarRepl/memcpy-from-global.ll @@ -45,8 +45,10 @@ declare void @llvm.memcpy.i32(i8*, i8*, i32, i32) declare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture, i8* nocapture, i64, i32, i1) nounwind %T = type { i8, [123 x i8] } +%U = type { i32, i32, i32, i32, i32 } @G = constant %T {i8 1, [123 x i8] zeroinitializer } +@H = constant [2 x %U] zeroinitializer, align 16 define void @test2() { %A = alloca %T @@ -108,3 +110,37 @@ define void @test5() { declare void @baz(i8* byval) + + +define void @test6() { + %A = alloca %U, align 16 + %a = bitcast %U* %A to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* %a, i8* bitcast ([2 x %U]* @H to i8*), i64 20, i32 16, i1 false) + call void @bar(i8* %a) readonly +; CHECK: @test6 +; CHECK-NEXT: %a = bitcast +; CHECK-NEXT: call void @bar(i8* %a) + ret void +} + +define void @test7() { + %A = alloca %U, align 16 + %a = bitcast %U* %A to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* %a, i8* bitcast (%U* getelementptr ([2 x %U]* @H, i64 0, i32 0) to i8*), i64 20, i32 4, i1 false) + call void @bar(i8* %a) readonly +; CHECK: @test7 +; CHECK-NEXT: %a = bitcast +; CHECK-NEXT: call void @bar(i8* %a) + ret void +} + +define void @test8() { + %A = alloca %U, align 16 + %a = bitcast %U* %A to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* %a, i8* bitcast (%U* getelementptr ([2 x %U]* @H, i64 0, i32 1) to i8*), i64 20, i32 4, i1 false) + call void @bar(i8* %a) readonly +; CHECK: @test8 +; CHECK: llvm.memcpy +; CHECK: bar + ret void +} diff --git a/test/Transforms/ScalarRepl/memset-aggregate-byte-leader.ll b/test/Transforms/ScalarRepl/memset-aggregate-byte-leader.ll index 0d61e5aab6c7..3510dfc24d9a 100644 --- a/test/Transforms/ScalarRepl/memset-aggregate-byte-leader.ll +++ b/test/Transforms/ScalarRepl/memset-aggregate-byte-leader.ll @@ -1,6 +1,6 @@ ; PR1226 ; RUN: opt < %s -scalarrepl -S | \ -; RUN: not grep {call void @llvm.memcpy.i32} +; RUN: not grep "call void @llvm.memcpy.i32" ; RUN: opt < %s -scalarrepl -S | grep getelementptr ; END. diff --git a/test/Transforms/ScalarRepl/memset-aggregate.ll b/test/Transforms/ScalarRepl/memset-aggregate.ll index 42e7a0ffdc6a..95ecf175eed2 100644 --- a/test/Transforms/ScalarRepl/memset-aggregate.ll +++ b/test/Transforms/ScalarRepl/memset-aggregate.ll @@ -1,7 +1,7 @@ ; PR1226 -; RUN: opt < %s -scalarrepl -S | grep {ret i32 16843009} +; RUN: opt < %s -scalarrepl -S | grep "ret i32 16843009" ; RUN: opt < %s -scalarrepl -S | not grep alloca -; RUN: opt < %s -scalarrepl -instcombine -S | grep {ret i16 514} +; RUN: opt < %s -scalarrepl -instcombine -S | grep "ret i16 514" 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" target triple = "i686-apple-darwin8" diff --git a/test/Transforms/ScalarRepl/not-a-vector.ll b/test/Transforms/ScalarRepl/not-a-vector.ll index f873456b3c7c..67fefb4841b3 100644 --- a/test/Transforms/ScalarRepl/not-a-vector.ll +++ b/test/Transforms/ScalarRepl/not-a-vector.ll @@ -1,6 +1,6 @@ ; RUN: opt < %s -scalarrepl -S | not grep alloca -; RUN: opt < %s -scalarrepl -S | not grep {7 x double} -; RUN: opt < %s -scalarrepl -instcombine -S | grep {ret double %B} +; RUN: opt < %s -scalarrepl -S | not grep "7 x double" +; RUN: opt < %s -scalarrepl -instcombine -S | grep "ret double %B" target datalayout = "E-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64" define double @test(double %A, double %B) { diff --git a/test/Transforms/ScalarRepl/union-fp-int.ll b/test/Transforms/ScalarRepl/union-fp-int.ll index 8b7e50df31bb..6a4991887186 100644 --- a/test/Transforms/ScalarRepl/union-fp-int.ll +++ b/test/Transforms/ScalarRepl/union-fp-int.ll @@ -1,7 +1,7 @@ ; RUN: opt < %s -scalarrepl -S | \ ; RUN: not grep alloca ; RUN: opt < %s -scalarrepl -S | \ -; RUN: grep {bitcast.*float.*i32} +; RUN: grep "bitcast.*float.*i32" target datalayout = "E-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64" define i32 @test(float %X) { diff --git a/test/Transforms/ScalarRepl/union-pointer.ll b/test/Transforms/ScalarRepl/union-pointer.ll index ea4ec14e5621..03d25ac7085e 100644 --- a/test/Transforms/ScalarRepl/union-pointer.ll +++ b/test/Transforms/ScalarRepl/union-pointer.ll @@ -1,7 +1,7 @@ ; PR892 ; RUN: opt < %s -scalarrepl -S | \ ; RUN: not grep alloca -; RUN: opt < %s -scalarrepl -S | grep {ret i8} +; RUN: opt < %s -scalarrepl -S | grep "ret i8" target datalayout = "e-p:32:32-n8:16:32" target triple = "i686-apple-darwin8.7.2" diff --git a/test/Transforms/ScalarRepl/vector_memcpy.ll b/test/Transforms/ScalarRepl/vector_memcpy.ll index decbd301b8df..33e8034f5734 100644 --- a/test/Transforms/ScalarRepl/vector_memcpy.ll +++ b/test/Transforms/ScalarRepl/vector_memcpy.ll @@ -1,6 +1,6 @@ ; RUN: opt < %s -scalarrepl -S > %t -; RUN: grep {ret <16 x float> %A} %t -; RUN: grep {ret <16 x float> zeroinitializer} %t +; RUN: grep "ret <16 x float> %A" %t +; RUN: grep "ret <16 x float> zeroinitializer" %t target datalayout = "E-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64" define <16 x float> @foo(<16 x float> %A) nounwind { diff --git a/test/Transforms/ScalarRepl/volatile.ll b/test/Transforms/ScalarRepl/volatile.ll index fadf1aa276c8..056526cbd92b 100644 --- a/test/Transforms/ScalarRepl/volatile.ll +++ b/test/Transforms/ScalarRepl/volatile.ll @@ -1,5 +1,5 @@ -; RUN: opt < %s -scalarrepl -S | grep {load volatile} -; RUN: opt < %s -scalarrepl -S | grep {store volatile} +; RUN: opt < %s -scalarrepl -S | grep "load volatile" +; RUN: opt < %s -scalarrepl -S | grep "store volatile" define i32 @voltest(i32 %T) { %A = alloca {i32, i32} diff --git a/test/Transforms/SimplifyCFG/2002-05-05-EmptyBlockMerge.ll b/test/Transforms/SimplifyCFG/2002-05-05-EmptyBlockMerge.ll index 414235ba7cde..feffb4e4c812 100644 --- a/test/Transforms/SimplifyCFG/2002-05-05-EmptyBlockMerge.ll +++ b/test/Transforms/SimplifyCFG/2002-05-05-EmptyBlockMerge.ll @@ -1,7 +1,7 @@ ; Basic block #2 should not be merged into BB #3! ; ; RUN: opt < %s -simplifycfg -S | \ -; RUN: grep {br label} +; RUN: grep "br label" ; declare void @foo() diff --git a/test/Transforms/SimplifyCFG/2003-08-05-MishandleInvoke.ll b/test/Transforms/SimplifyCFG/2003-08-05-MishandleInvoke.ll deleted file mode 100644 index bc61a75561d3..000000000000 --- a/test/Transforms/SimplifyCFG/2003-08-05-MishandleInvoke.ll +++ /dev/null @@ -1,15 +0,0 @@ -; Do not remove the invoke! -; -; RUN: opt < %s -simplifycfg -S | grep invoke - -define i32 @test() { - invoke i32 @test( ) - to label %Ret unwind label %Ret ; <i32>:1 [#uses=0] -Ret: ; preds = %0, %0 - %val = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) - catch i8* null - %A = add i32 0, 1 ; <i32> [#uses=1] - ret i32 %A -} - -declare i32 @__gxx_personality_v0(...) diff --git a/test/Transforms/SimplifyCFG/2003-08-17-BranchFold.ll b/test/Transforms/SimplifyCFG/2003-08-17-BranchFold.ll index 8ac9ae443728..fc89b165f85b 100644 --- a/test/Transforms/SimplifyCFG/2003-08-17-BranchFold.ll +++ b/test/Transforms/SimplifyCFG/2003-08-17-BranchFold.ll @@ -2,7 +2,7 @@ ; 'br Dest' ; RUN: opt < %s -simplifycfg -S | \ -; RUN: not grep {br i1 %c2} +; RUN: not grep "br i1 %c2" declare void @noop() diff --git a/test/Transforms/SimplifyCFG/2003-08-17-BranchFoldOrdering.ll b/test/Transforms/SimplifyCFG/2003-08-17-BranchFoldOrdering.ll index 888e187b6b4d..c1b032fb8b39 100644 --- a/test/Transforms/SimplifyCFG/2003-08-17-BranchFoldOrdering.ll +++ b/test/Transforms/SimplifyCFG/2003-08-17-BranchFoldOrdering.ll @@ -4,7 +4,7 @@ ; the ConstantFoldTerminator function. ; RUN: opt < %s -simplifycfg -S | \ -; RUN: not grep {br i1 %c2} +; RUN: not grep "br i1 %c2" declare void @noop() diff --git a/test/Transforms/SimplifyCFG/2006-10-29-InvokeCrash.ll b/test/Transforms/SimplifyCFG/2006-10-29-InvokeCrash.ll deleted file mode 100644 index 27d9d8f67418..000000000000 --- a/test/Transforms/SimplifyCFG/2006-10-29-InvokeCrash.ll +++ /dev/null @@ -1,567 +0,0 @@ -; RUN: opt < %s -simplifycfg -disable-output -; END. - %struct..4._102 = type { %struct.QVectorData* } - %struct..5._125 = type { %struct.QMapData* } - %struct.QAbstractTextDocumentLayout = type { %struct.QObject } - %struct.QBasicAtomic = type { i32 } - %struct.QFont = type { %struct.QFontPrivate*, i32 } - %struct.QFontMetrics = type { %struct.QFontPrivate* } - %struct.QFontPrivate = type opaque - %"struct.QFragmentMap<QTextBlockData>" = type { %struct.QFragmentMapData } - %struct.QFragmentMapData = type { %"struct.QFragmentMapData::._154", i32 } - %"struct.QFragmentMapData::._154" = type { %"struct.QFragmentMapData::Header"* } - %"struct.QFragmentMapData::Header" = type { i32, i32, i32, i32, i32, i32, i32, i32 } - %"struct.QHash<uint,QHashDummyValue>" = type { %"struct.QHash<uint,QHashDummyValue>::._152" } - %"struct.QHash<uint,QHashDummyValue>::._152" = type { %struct.QHashData* } - %struct.QHashData = type { %"struct.QHashData::Node"*, %"struct.QHashData::Node"**, %struct.QBasicAtomic, i32, i32, i16, i16, i32, i8 } - %"struct.QHashData::Node" = type { %"struct.QHashData::Node"*, i32 } - %"struct.QList<QObject*>::._92" = type { %struct.QListData } - %"struct.QList<QPointer<QObject> >" = type { %"struct.QList<QObject*>::._92" } - %struct.QListData = type { %"struct.QListData::Data"* } - %"struct.QListData::Data" = type { %struct.QBasicAtomic, i32, i32, i32, i8, [1 x i8*] } - %"struct.QMap<QUrl,QVariant>" = type { %struct..5._125 } - %struct.QMapData = type { %"struct.QMapData::Node"*, [12 x %"struct.QMapData::Node"*], %struct.QBasicAtomic, i32, i32, i32, i8 } - %"struct.QMapData::Node" = type { %"struct.QMapData::Node"*, [1 x %"struct.QMapData::Node"*] } - %struct.QObject = type { i32 (...)**, %struct.QObjectData* } - %struct.QObjectData = type { i32 (...)**, %struct.QObject*, %struct.QObject*, %"struct.QList<QPointer<QObject> >", i8, [3 x i8], i32, i32 } - %struct.QObjectPrivate = type { %struct.QObjectData, i32, %struct.QObject*, %"struct.QList<QPointer<QObject> >", %"struct.QVector<QAbstractTextDocumentLayout::Selection>", %struct.QString } - %struct.QPaintDevice = type { i32 (...)**, i16 } - %struct.QPainter = type { %struct.QPainterPrivate* } - %struct.QPainterPrivate = type opaque - %struct.QPointF = type { double, double } - %struct.QPrinter = type { %struct.QPaintDevice, %struct.QPrinterPrivate* } - %struct.QPrinterPrivate = type opaque - %struct.QRectF = type { double, double, double, double } - %"struct.QSet<uint>" = type { %"struct.QHash<uint,QHashDummyValue>" } - %"struct.QSharedDataPointer<QTextFormatPrivate>" = type { %struct.QTextFormatPrivate* } - %struct.QString = type { %"struct.QString::Data"* } - %"struct.QString::Data" = type { %struct.QBasicAtomic, i32, i32, i16*, i8, i8, [1 x i16] } - %struct.QTextBlockFormat = type { %struct.QTextFormat } - %struct.QTextBlockGroup = type { %struct.QAbstractTextDocumentLayout } - %struct.QTextDocumentConfig = type { %struct.QString } - %struct.QTextDocumentPrivate = type { %struct.QObjectPrivate, %struct.QString, %"struct.QVector<QAbstractTextDocumentLayout::Selection>", i1, i32, i32, i1, i32, i32, i32, i32, i1, %struct.QTextFormatCollection, %struct.QTextBlockGroup*, %struct.QAbstractTextDocumentLayout*, %"struct.QFragmentMap<QTextBlockData>", %"struct.QFragmentMap<QTextBlockData>", i32, %"struct.QList<QPointer<QObject> >", %"struct.QList<QPointer<QObject> >", %"struct.QMap<QUrl,QVariant>", %"struct.QMap<QUrl,QVariant>", %"struct.QMap<QUrl,QVariant>", %struct.QTextDocumentConfig, i1, i1, %struct.QPointF } - %struct.QTextFormat = type { %"struct.QSharedDataPointer<QTextFormatPrivate>", i32 } - %struct.QTextFormatCollection = type { %"struct.QVector<QAbstractTextDocumentLayout::Selection>", %"struct.QVector<QAbstractTextDocumentLayout::Selection>", %"struct.QSet<uint>", %struct.QFont } - %struct.QTextFormatPrivate = type opaque - %"struct.QVector<QAbstractTextDocumentLayout::Selection>" = type { %struct..4._102 } - %struct.QVectorData = type { %struct.QBasicAtomic, i32, i32, i8 } - -define void @_ZNK13QTextDocument5printEP8QPrinter(%struct.QAbstractTextDocumentLayout* %this, %struct.QPrinter* %printer) { -entry: - %tmp = alloca %struct.QPointF, align 16 ; <%struct.QPointF*> [#uses=2] - %tmp.upgrd.1 = alloca %struct.QRectF, align 16 ; <%struct.QRectF*> [#uses=5] - %tmp2 = alloca %struct.QPointF, align 16 ; <%struct.QPointF*> [#uses=3] - %tmp.upgrd.2 = alloca %struct.QFontMetrics, align 16 ; <%struct.QFontMetrics*> [#uses=4] - %tmp.upgrd.3 = alloca %struct.QFont, align 16 ; <%struct.QFont*> [#uses=4] - %tmp3 = alloca %struct.QPointF, align 16 ; <%struct.QPointF*> [#uses=2] - %p = alloca %struct.QPainter, align 16 ; <%struct.QPainter*> [#uses=14] - %body = alloca %struct.QRectF, align 16 ; <%struct.QRectF*> [#uses=9] - %pageNumberPos = alloca %struct.QPointF, align 16 ; <%struct.QPointF*> [#uses=4] - %scaledPageSize = alloca %struct.QPointF, align 16 ; <%struct.QPointF*> [#uses=6] - %printerPageSize = alloca %struct.QPointF, align 16 ; <%struct.QPointF*> [#uses=3] - %fmt = alloca %struct.QTextBlockFormat, align 16 ; <%struct.QTextBlockFormat*> [#uses=5] - %font = alloca %struct.QFont, align 16 ; <%struct.QFont*> [#uses=5] - %tmp.upgrd.4 = call %struct.QTextDocumentPrivate* @_ZNK13QTextDocument6d_funcEv( %struct.QAbstractTextDocumentLayout* %this ) ; <%struct.QTextDocumentPrivate*> [#uses=5] - %tmp.upgrd.5 = getelementptr %struct.QPrinter* %printer, i32 0, i32 0 ; <%struct.QPaintDevice*> [#uses=1] - call void @_ZN8QPainterC1EP12QPaintDevice( %struct.QPainter* %p, %struct.QPaintDevice* %tmp.upgrd.5 ) - %tmp.upgrd.6 = invoke i1 @_ZNK8QPainter8isActiveEv( %struct.QPainter* %p ) - to label %invcont unwind label %cleanup329 ; <i1> [#uses=1] -invcont: ; preds = %entry - br i1 %tmp.upgrd.6, label %cond_next, label %cleanup328 -cond_next: ; preds = %invcont - %tmp8 = invoke %struct.QAbstractTextDocumentLayout* @_ZNK13QTextDocument14documentLayoutEv( %struct.QAbstractTextDocumentLayout* %this ) - to label %invcont7 unwind label %cleanup329 ; <%struct.QAbstractTextDocumentLayout*> [#uses=0] -invcont7: ; preds = %cond_next - %tmp10 = getelementptr %struct.QTextDocumentPrivate* %tmp.upgrd.4, i32 0, i32 26 ; <%struct.QPointF*> [#uses=1] - call void @_ZN7QPointFC1Edd( %struct.QPointF* %tmp, double 0.000000e+00, double 0.000000e+00 ) - call void @_ZN6QRectFC1ERK7QPointFRK6QSizeF( %struct.QRectF* %body, %struct.QPointF* %tmp, %struct.QPointF* %tmp10 ) - call void @_ZN7QPointFC1Ev( %struct.QPointF* %pageNumberPos ) - %tmp12 = getelementptr %struct.QTextDocumentPrivate* %tmp.upgrd.4, i32 0, i32 26 ; <%struct.QPointF*> [#uses=1] - %tmp13 = call i1 @_ZNK6QSizeF7isValidEv( %struct.QPointF* %tmp12 ) ; <i1> [#uses=1] - br i1 %tmp13, label %cond_next15, label %bb -cond_next15: ; preds = %invcont7 - %tmp17 = getelementptr %struct.QTextDocumentPrivate* %tmp.upgrd.4, i32 0, i32 26 ; <%struct.QPointF*> [#uses=1] - %tmp.upgrd.7 = call double @_ZNK6QSizeF6heightEv( %struct.QPointF* %tmp17 ) ; <double> [#uses=1] - %tmp18 = fcmp oeq double %tmp.upgrd.7, 0x41DFFFFFFFC00000 ; <i1> [#uses=1] - br i1 %tmp18, label %bb, label %cond_next20 -cond_next20: ; preds = %cond_next15 - br label %bb21 -bb: ; preds = %cond_next15, %invcont7 - br label %bb21 -bb21: ; preds = %bb, %cond_next20 - %iftmp.406.0 = phi i1 [ false, %bb ], [ true, %cond_next20 ] ; <i1> [#uses=1] - br i1 %iftmp.406.0, label %cond_true24, label %cond_false -cond_true24: ; preds = %bb21 - %tmp.upgrd.8 = invoke i32 @_Z13qt_defaultDpiv( ) - to label %invcont25 unwind label %cleanup329 ; <i32> [#uses=1] -invcont25: ; preds = %cond_true24 - %tmp26 = sitofp i32 %tmp.upgrd.8 to double ; <double> [#uses=2] - %tmp30 = invoke %struct.QAbstractTextDocumentLayout* @_ZNK13QTextDocument14documentLayoutEv( %struct.QAbstractTextDocumentLayout* %this ) - to label %invcont29 unwind label %cleanup329 ; <%struct.QAbstractTextDocumentLayout*> [#uses=1] -invcont29: ; preds = %invcont25 - %tmp32 = invoke %struct.QPaintDevice* @_ZNK27QAbstractTextDocumentLayout11paintDeviceEv( %struct.QAbstractTextDocumentLayout* %tmp30 ) - to label %invcont31 unwind label %cleanup329 ; <%struct.QPaintDevice*> [#uses=3] -invcont31: ; preds = %invcont29 - %tmp34 = icmp eq %struct.QPaintDevice* %tmp32, null ; <i1> [#uses=1] - br i1 %tmp34, label %cond_next42, label %cond_true35 -cond_true35: ; preds = %invcont31 - %tmp38 = invoke i32 @_ZNK12QPaintDevice11logicalDpiXEv( %struct.QPaintDevice* %tmp32 ) - to label %invcont37 unwind label %cleanup329 ; <i32> [#uses=1] -invcont37: ; preds = %cond_true35 - %tmp38.upgrd.9 = sitofp i32 %tmp38 to double ; <double> [#uses=1] - %tmp41 = invoke i32 @_ZNK12QPaintDevice11logicalDpiYEv( %struct.QPaintDevice* %tmp32 ) - to label %invcont40 unwind label %cleanup329 ; <i32> [#uses=1] -invcont40: ; preds = %invcont37 - %tmp41.upgrd.10 = sitofp i32 %tmp41 to double ; <double> [#uses=1] - br label %cond_next42 -cond_next42: ; preds = %invcont40, %invcont31 - %sourceDpiY.2 = phi double [ %tmp41.upgrd.10, %invcont40 ], [ %tmp26, %invcont31 ] ; <double> [#uses=1] - %sourceDpiX.2 = phi double [ %tmp38.upgrd.9, %invcont40 ], [ %tmp26, %invcont31 ] ; <double> [#uses=1] - %tmp44 = getelementptr %struct.QPrinter* %printer, i32 0, i32 0 ; <%struct.QPaintDevice*> [#uses=1] - %tmp46 = invoke i32 @_ZNK12QPaintDevice11logicalDpiXEv( %struct.QPaintDevice* %tmp44 ) - to label %invcont45 unwind label %cleanup329 ; <i32> [#uses=1] -invcont45: ; preds = %cond_next42 - %tmp46.upgrd.11 = sitofp i32 %tmp46 to double ; <double> [#uses=1] - %tmp48 = fdiv double %tmp46.upgrd.11, %sourceDpiX.2 ; <double> [#uses=2] - %tmp50 = getelementptr %struct.QPrinter* %printer, i32 0, i32 0 ; <%struct.QPaintDevice*> [#uses=1] - %tmp52 = invoke i32 @_ZNK12QPaintDevice11logicalDpiYEv( %struct.QPaintDevice* %tmp50 ) - to label %invcont51 unwind label %cleanup329 ; <i32> [#uses=1] -invcont51: ; preds = %invcont45 - %tmp52.upgrd.12 = sitofp i32 %tmp52 to double ; <double> [#uses=1] - %tmp54 = fdiv double %tmp52.upgrd.12, %sourceDpiY.2 ; <double> [#uses=2] - invoke void @_ZN8QPainter5scaleEdd( %struct.QPainter* %p, double %tmp48, double %tmp54 ) - to label %invcont57 unwind label %cleanup329 -invcont57: ; preds = %invcont51 - %tmp.upgrd.13 = getelementptr %struct.QPointF* %scaledPageSize, i32 0, i32 0 ; <double*> [#uses=1] - %tmp60 = getelementptr %struct.QTextDocumentPrivate* %tmp.upgrd.4, i32 0, i32 26, i32 0 ; <double*> [#uses=1] - %tmp61 = load double* %tmp60 ; <double> [#uses=1] - store double %tmp61, double* %tmp.upgrd.13 - %tmp62 = getelementptr %struct.QPointF* %scaledPageSize, i32 0, i32 1 ; <double*> [#uses=1] - %tmp63 = getelementptr %struct.QTextDocumentPrivate* %tmp.upgrd.4, i32 0, i32 26, i32 1 ; <double*> [#uses=1] - %tmp64 = load double* %tmp63 ; <double> [#uses=1] - store double %tmp64, double* %tmp62 - %tmp65 = call double* @_ZN6QSizeF6rwidthEv( %struct.QPointF* %scaledPageSize ) ; <double*> [#uses=2] - %tmp67 = load double* %tmp65 ; <double> [#uses=1] - %tmp69 = fmul double %tmp67, %tmp48 ; <double> [#uses=1] - store double %tmp69, double* %tmp65 - %tmp71 = call double* @_ZN6QSizeF7rheightEv( %struct.QPointF* %scaledPageSize ) ; <double*> [#uses=2] - %tmp73 = load double* %tmp71 ; <double> [#uses=1] - %tmp75 = fmul double %tmp73, %tmp54 ; <double> [#uses=1] - store double %tmp75, double* %tmp71 - %tmp78 = getelementptr %struct.QPrinter* %printer, i32 0, i32 0 ; <%struct.QPaintDevice*> [#uses=1] - %tmp80 = invoke i32 @_ZNK12QPaintDevice6heightEv( %struct.QPaintDevice* %tmp78 ) - to label %invcont79 unwind label %cleanup329 ; <i32> [#uses=1] -invcont79: ; preds = %invcont57 - %tmp82 = getelementptr %struct.QPrinter* %printer, i32 0, i32 0 ; <%struct.QPaintDevice*> [#uses=1] - %tmp84 = invoke i32 @_ZNK12QPaintDevice5widthEv( %struct.QPaintDevice* %tmp82 ) - to label %invcont83 unwind label %cleanup329 ; <i32> [#uses=1] -invcont83: ; preds = %invcont79 - %tmp80.upgrd.14 = sitofp i32 %tmp80 to double ; <double> [#uses=1] - %tmp84.upgrd.15 = sitofp i32 %tmp84 to double ; <double> [#uses=1] - call void @_ZN6QSizeFC1Edd( %struct.QPointF* %printerPageSize, double %tmp84.upgrd.15, double %tmp80.upgrd.14 ) - %tmp85 = call double @_ZNK6QSizeF6heightEv( %struct.QPointF* %printerPageSize ) ; <double> [#uses=1] - %tmp86 = call double @_ZNK6QSizeF6heightEv( %struct.QPointF* %scaledPageSize ) ; <double> [#uses=1] - %tmp87 = fdiv double %tmp85, %tmp86 ; <double> [#uses=1] - %tmp88 = call double @_ZNK6QSizeF5widthEv( %struct.QPointF* %printerPageSize ) ; <double> [#uses=1] - %tmp89 = call double @_ZNK6QSizeF5widthEv( %struct.QPointF* %scaledPageSize ) ; <double> [#uses=1] - %tmp90 = fdiv double %tmp88, %tmp89 ; <double> [#uses=1] - invoke void @_ZN8QPainter5scaleEdd( %struct.QPainter* %p, double %tmp90, double %tmp87 ) - to label %cond_next194 unwind label %cleanup329 -cond_false: ; preds = %bb21 - %tmp.upgrd.16 = getelementptr %struct.QAbstractTextDocumentLayout* %this, i32 0, i32 0 ; <%struct.QObject*> [#uses=1] - %tmp95 = invoke %struct.QAbstractTextDocumentLayout* @_ZNK13QTextDocument5cloneEP7QObject( %struct.QAbstractTextDocumentLayout* %this, %struct.QObject* %tmp.upgrd.16 ) - to label %invcont94 unwind label %cleanup329 ; <%struct.QAbstractTextDocumentLayout*> [#uses=9] -invcont94: ; preds = %cond_false - %tmp99 = invoke %struct.QAbstractTextDocumentLayout* @_ZNK13QTextDocument14documentLayoutEv( %struct.QAbstractTextDocumentLayout* %tmp95 ) - to label %invcont98 unwind label %cleanup329 ; <%struct.QAbstractTextDocumentLayout*> [#uses=1] -invcont98: ; preds = %invcont94 - %tmp101 = invoke %struct.QPaintDevice* @_ZNK8QPainter6deviceEv( %struct.QPainter* %p ) - to label %invcont100 unwind label %cleanup329 ; <%struct.QPaintDevice*> [#uses=1] -invcont100: ; preds = %invcont98 - invoke void @_ZN27QAbstractTextDocumentLayout14setPaintDeviceEP12QPaintDevice( %struct.QAbstractTextDocumentLayout* %tmp99, %struct.QPaintDevice* %tmp101 ) - to label %invcont103 unwind label %cleanup329 -invcont103: ; preds = %invcont100 - %tmp105 = invoke %struct.QPaintDevice* @_ZNK8QPainter6deviceEv( %struct.QPainter* %p ) - to label %invcont104 unwind label %cleanup329 ; <%struct.QPaintDevice*> [#uses=1] -invcont104: ; preds = %invcont103 - %tmp107 = invoke i32 @_ZNK12QPaintDevice11logicalDpiYEv( %struct.QPaintDevice* %tmp105 ) - to label %invcont106 unwind label %cleanup329 ; <i32> [#uses=1] -invcont106: ; preds = %invcont104 - %tmp108 = sitofp i32 %tmp107 to double ; <double> [#uses=1] - %tmp109 = fmul double %tmp108, 0x3FE93264C993264C ; <double> [#uses=1] - %tmp109.upgrd.17 = fptosi double %tmp109 to i32 ; <i32> [#uses=3] - %tmp.upgrd.18 = call %struct.QTextBlockGroup* @_ZNK13QTextDocument9rootFrameEv( %struct.QAbstractTextDocumentLayout* %tmp95 ) ; <%struct.QTextBlockGroup*> [#uses=1] - invoke void @_ZNK10QTextFrame11frameFormatEv( %struct.QTextBlockFormat* sret %fmt, %struct.QTextBlockGroup* %tmp.upgrd.18 ) - to label %invcont111 unwind label %cleanup329 -invcont111: ; preds = %invcont106 - %tmp112 = sitofp i32 %tmp109.upgrd.17 to double ; <double> [#uses=1] - invoke void @_ZN16QTextFrameFormat9setMarginEd( %struct.QTextBlockFormat* %fmt, double %tmp112 ) - to label %invcont114 unwind label %cleanup192 -invcont114: ; preds = %invcont111 - %tmp116 = call %struct.QTextBlockGroup* @_ZNK13QTextDocument9rootFrameEv( %struct.QAbstractTextDocumentLayout* %tmp95 ) ; <%struct.QTextBlockGroup*> [#uses=1] - invoke void @_ZN10QTextFrame14setFrameFormatERK16QTextFrameFormat( %struct.QTextBlockGroup* %tmp116, %struct.QTextBlockFormat* %fmt ) - to label %invcont117 unwind label %cleanup192 -invcont117: ; preds = %invcont114 - %tmp119 = invoke %struct.QPaintDevice* @_ZNK8QPainter6deviceEv( %struct.QPainter* %p ) - to label %invcont118 unwind label %cleanup192 ; <%struct.QPaintDevice*> [#uses=1] -invcont118: ; preds = %invcont117 - %tmp121 = invoke i32 @_ZNK12QPaintDevice6heightEv( %struct.QPaintDevice* %tmp119 ) - to label %invcont120 unwind label %cleanup192 ; <i32> [#uses=1] -invcont120: ; preds = %invcont118 - %tmp121.upgrd.19 = sitofp i32 %tmp121 to double ; <double> [#uses=1] - %tmp123 = invoke %struct.QPaintDevice* @_ZNK8QPainter6deviceEv( %struct.QPainter* %p ) - to label %invcont122 unwind label %cleanup192 ; <%struct.QPaintDevice*> [#uses=1] -invcont122: ; preds = %invcont120 - %tmp125 = invoke i32 @_ZNK12QPaintDevice5widthEv( %struct.QPaintDevice* %tmp123 ) - to label %invcont124 unwind label %cleanup192 ; <i32> [#uses=1] -invcont124: ; preds = %invcont122 - %tmp125.upgrd.20 = sitofp i32 %tmp125 to double ; <double> [#uses=1] - call void @_ZN6QRectFC1Edddd( %struct.QRectF* %tmp.upgrd.1, double 0.000000e+00, double 0.000000e+00, double %tmp125.upgrd.20, double %tmp121.upgrd.19 ) - %tmp126 = getelementptr %struct.QRectF* %body, i32 0, i32 0 ; <double*> [#uses=1] - %tmp127 = getelementptr %struct.QRectF* %tmp.upgrd.1, i32 0, i32 0 ; <double*> [#uses=1] - %tmp128 = load double* %tmp127 ; <double> [#uses=1] - store double %tmp128, double* %tmp126 - %tmp129 = getelementptr %struct.QRectF* %body, i32 0, i32 1 ; <double*> [#uses=1] - %tmp130 = getelementptr %struct.QRectF* %tmp.upgrd.1, i32 0, i32 1 ; <double*> [#uses=1] - %tmp131 = load double* %tmp130 ; <double> [#uses=1] - store double %tmp131, double* %tmp129 - %tmp132 = getelementptr %struct.QRectF* %body, i32 0, i32 2 ; <double*> [#uses=1] - %tmp133 = getelementptr %struct.QRectF* %tmp.upgrd.1, i32 0, i32 2 ; <double*> [#uses=1] - %tmp134 = load double* %tmp133 ; <double> [#uses=1] - store double %tmp134, double* %tmp132 - %tmp135 = getelementptr %struct.QRectF* %body, i32 0, i32 3 ; <double*> [#uses=1] - %tmp136 = getelementptr %struct.QRectF* %tmp.upgrd.1, i32 0, i32 3 ; <double*> [#uses=1] - %tmp137 = load double* %tmp136 ; <double> [#uses=1] - store double %tmp137, double* %tmp135 - %tmp138 = call double @_ZNK6QRectF6heightEv( %struct.QRectF* %body ) ; <double> [#uses=1] - %tmp139 = sitofp i32 %tmp109.upgrd.17 to double ; <double> [#uses=1] - %tmp140 = fsub double %tmp138, %tmp139 ; <double> [#uses=1] - %tmp142 = invoke %struct.QPaintDevice* @_ZNK8QPainter6deviceEv( %struct.QPainter* %p ) - to label %invcont141 unwind label %cleanup192 ; <%struct.QPaintDevice*> [#uses=1] -invcont141: ; preds = %invcont124 - invoke void @_ZNK13QTextDocument11defaultFontEv( %struct.QFont* sret %tmp.upgrd.3, %struct.QAbstractTextDocumentLayout* %tmp95 ) - to label %invcont144 unwind label %cleanup192 -invcont144: ; preds = %invcont141 - invoke void @_ZN12QFontMetricsC1ERK5QFontP12QPaintDevice( %struct.QFontMetrics* %tmp.upgrd.2, %struct.QFont* %tmp.upgrd.3, %struct.QPaintDevice* %tmp142 ) - to label %invcont146 unwind label %cleanup173 -invcont146: ; preds = %invcont144 - %tmp149 = invoke i32 @_ZNK12QFontMetrics6ascentEv( %struct.QFontMetrics* %tmp.upgrd.2 ) - to label %invcont148 unwind label %cleanup168 ; <i32> [#uses=1] -invcont148: ; preds = %invcont146 - %tmp149.upgrd.21 = sitofp i32 %tmp149 to double ; <double> [#uses=1] - %tmp150 = fadd double %tmp140, %tmp149.upgrd.21 ; <double> [#uses=1] - %tmp152 = invoke %struct.QPaintDevice* @_ZNK8QPainter6deviceEv( %struct.QPainter* %p ) - to label %invcont151 unwind label %cleanup168 ; <%struct.QPaintDevice*> [#uses=1] -invcont151: ; preds = %invcont148 - %tmp154 = invoke i32 @_ZNK12QPaintDevice11logicalDpiYEv( %struct.QPaintDevice* %tmp152 ) - to label %invcont153 unwind label %cleanup168 ; <i32> [#uses=1] -invcont153: ; preds = %invcont151 - %tmp155 = mul i32 %tmp154, 5 ; <i32> [#uses=1] - %tmp156 = sdiv i32 %tmp155, 72 ; <i32> [#uses=1] - %tmp156.upgrd.22 = sitofp i32 %tmp156 to double ; <double> [#uses=1] - %tmp157 = fadd double %tmp150, %tmp156.upgrd.22 ; <double> [#uses=1] - %tmp158 = call double @_ZNK6QRectF5widthEv( %struct.QRectF* %body ) ; <double> [#uses=1] - %tmp159 = sitofp i32 %tmp109.upgrd.17 to double ; <double> [#uses=1] - %tmp160 = fsub double %tmp158, %tmp159 ; <double> [#uses=1] - call void @_ZN7QPointFC1Edd( %struct.QPointF* %tmp2, double %tmp160, double %tmp157 ) - %tmp161 = getelementptr %struct.QPointF* %pageNumberPos, i32 0, i32 0 ; <double*> [#uses=1] - %tmp162 = getelementptr %struct.QPointF* %tmp2, i32 0, i32 0 ; <double*> [#uses=1] - %tmp163 = load double* %tmp162 ; <double> [#uses=1] - store double %tmp163, double* %tmp161 - %tmp164 = getelementptr %struct.QPointF* %pageNumberPos, i32 0, i32 1 ; <double*> [#uses=1] - %tmp165 = getelementptr %struct.QPointF* %tmp2, i32 0, i32 1 ; <double*> [#uses=1] - %tmp166 = load double* %tmp165 ; <double> [#uses=1] - store double %tmp166, double* %tmp164 - invoke void @_ZN12QFontMetricsD1Ev( %struct.QFontMetrics* %tmp.upgrd.2 ) - to label %cleanup171 unwind label %cleanup173 -cleanup168: ; preds = %invcont151, %invcont148, %invcont146 - %val168 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) - cleanup - invoke void @_ZN12QFontMetricsD1Ev( %struct.QFontMetrics* %tmp.upgrd.2 ) - to label %cleanup173 unwind label %cleanup173 -cleanup171: ; preds = %invcont153 - invoke void @_ZN5QFontD1Ev( %struct.QFont* %tmp.upgrd.3 ) - to label %finally170 unwind label %cleanup192 -cleanup173: ; preds = %cleanup168, %cleanup168, %invcont153, %invcont144 - %val173 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) - cleanup - invoke void @_ZN5QFontD1Ev( %struct.QFont* %tmp.upgrd.3 ) - to label %cleanup192 unwind label %cleanup192 -finally170: ; preds = %cleanup171 - invoke void @_ZNK13QTextDocument11defaultFontEv( %struct.QFont* sret %font, %struct.QAbstractTextDocumentLayout* %tmp95 ) - to label %invcont177 unwind label %cleanup192 -invcont177: ; preds = %finally170 - invoke void @_ZN5QFont12setPointSizeEi( %struct.QFont* %font, i32 10 ) - to label %invcont179 unwind label %cleanup187 -invcont179: ; preds = %invcont177 - invoke void @_ZN13QTextDocument14setDefaultFontERK5QFont( %struct.QAbstractTextDocumentLayout* %tmp95, %struct.QFont* %font ) - to label %invcont181 unwind label %cleanup187 -invcont181: ; preds = %invcont179 - call void @_ZNK6QRectF4sizeEv( %struct.QPointF* sret %tmp3, %struct.QRectF* %body ) - invoke void @_ZN13QTextDocument11setPageSizeERK6QSizeF( %struct.QAbstractTextDocumentLayout* %tmp95, %struct.QPointF* %tmp3 ) - to label %cleanup185 unwind label %cleanup187 -cleanup185: ; preds = %invcont181 - invoke void @_ZN5QFontD1Ev( %struct.QFont* %font ) - to label %cleanup190 unwind label %cleanup192 -cleanup187: ; preds = %invcont181, %invcont179, %invcont177 - %val187 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) - cleanup - invoke void @_ZN5QFontD1Ev( %struct.QFont* %font ) - to label %cleanup192 unwind label %cleanup192 -cleanup190: ; preds = %cleanup185 - invoke void @_ZN16QTextFrameFormatD1Ev( %struct.QTextBlockFormat* %fmt ) - to label %cond_next194 unwind label %cleanup329 -cleanup192: ; preds = %cleanup187, %cleanup187, %cleanup185, %finally170, %cleanup173, %cleanup173, %cleanup171, %invcont141, %invcont124, %invcont122, %invcont120, %invcont118, %invcont117, %invcont114, %invcont111 - %val192 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) - cleanup - invoke void @_ZN16QTextFrameFormatD1Ev( %struct.QTextBlockFormat* %fmt ) - to label %cleanup329 unwind label %cleanup329 -cond_next194: ; preds = %cleanup190, %invcont83 - %clonedDoc.1 = phi %struct.QAbstractTextDocumentLayout* [ null, %invcont83 ], [ %tmp95, %cleanup190 ] ; <%struct.QAbstractTextDocumentLayout*> [#uses=3] - %doc.1 = phi %struct.QAbstractTextDocumentLayout* [ %this, %invcont83 ], [ %tmp95, %cleanup190 ] ; <%struct.QAbstractTextDocumentLayout*> [#uses=2] - %tmp197 = invoke i1 @_ZNK8QPrinter13collateCopiesEv( %struct.QPrinter* %printer ) - to label %invcont196 unwind label %cleanup329 ; <i1> [#uses=1] -invcont196: ; preds = %cond_next194 - br i1 %tmp197, label %cond_true200, label %cond_false204 -cond_true200: ; preds = %invcont196 - %tmp203 = invoke i32 @_ZNK8QPrinter9numCopiesEv( %struct.QPrinter* %printer ) - to label %invcont202 unwind label %cleanup329 ; <i32> [#uses=1] -invcont202: ; preds = %cond_true200 - br label %cond_next208 -cond_false204: ; preds = %invcont196 - %tmp207 = invoke i32 @_ZNK8QPrinter9numCopiesEv( %struct.QPrinter* %printer ) - to label %invcont206 unwind label %cleanup329 ; <i32> [#uses=1] -invcont206: ; preds = %cond_false204 - br label %cond_next208 -cond_next208: ; preds = %invcont206, %invcont202 - %pageCopies.0 = phi i32 [ %tmp203, %invcont202 ], [ 1, %invcont206 ] ; <i32> [#uses=2] - %docCopies.0 = phi i32 [ 1, %invcont202 ], [ %tmp207, %invcont206 ] ; <i32> [#uses=2] - %tmp211 = invoke i32 @_ZNK8QPrinter8fromPageEv( %struct.QPrinter* %printer ) - to label %invcont210 unwind label %cleanup329 ; <i32> [#uses=3] -invcont210: ; preds = %cond_next208 - %tmp214 = invoke i32 @_ZNK8QPrinter6toPageEv( %struct.QPrinter* %printer ) - to label %invcont213 unwind label %cleanup329 ; <i32> [#uses=3] -invcont213: ; preds = %invcont210 - %tmp216 = icmp eq i32 %tmp211, 0 ; <i1> [#uses=1] - br i1 %tmp216, label %cond_true217, label %cond_next225 -cond_true217: ; preds = %invcont213 - %tmp219 = icmp eq i32 %tmp214, 0 ; <i1> [#uses=1] - br i1 %tmp219, label %cond_true220, label %cond_next225 -cond_true220: ; preds = %cond_true217 - %tmp223 = invoke i32 @_ZNK13QTextDocument9pageCountEv( %struct.QAbstractTextDocumentLayout* %doc.1 ) - to label %invcont222 unwind label %cleanup329 ; <i32> [#uses=1] -invcont222: ; preds = %cond_true220 - br label %cond_next225 -cond_next225: ; preds = %invcont222, %cond_true217, %invcont213 - %toPage.1 = phi i32 [ %tmp223, %invcont222 ], [ %tmp214, %cond_true217 ], [ %tmp214, %invcont213 ] ; <i32> [#uses=2] - %fromPage.1 = phi i32 [ 1, %invcont222 ], [ %tmp211, %cond_true217 ], [ %tmp211, %invcont213 ] ; <i32> [#uses=2] - %tmp.page = invoke i32 @_ZNK8QPrinter9pageOrderEv( %struct.QPrinter* %printer ) - to label %invcont227 unwind label %cleanup329 ; <i32> [#uses=1] -invcont227: ; preds = %cond_next225 - %tmp228 = icmp eq i32 %tmp.page, 1 ; <i1> [#uses=1] - br i1 %tmp228, label %cond_true230, label %cond_next234 -cond_true230: ; preds = %invcont227 - br label %cond_next234 -cond_next234: ; preds = %cond_true230, %invcont227 - %ascending.1 = phi i1 [ false, %cond_true230 ], [ true, %invcont227 ] ; <i1> [#uses=1] - %toPage.2 = phi i32 [ %fromPage.1, %cond_true230 ], [ %toPage.1, %invcont227 ] ; <i32> [#uses=1] - %fromPage.2 = phi i32 [ %toPage.1, %cond_true230 ], [ %fromPage.1, %invcont227 ] ; <i32> [#uses=1] - br label %bb309 -bb237: ; preds = %cond_true313, %cond_next293 - %iftmp.410.4 = phi i1 [ %iftmp.410.5, %cond_true313 ], [ %iftmp.410.1, %cond_next293 ] ; <i1> [#uses=1] - %page.4 = phi i32 [ %fromPage.2, %cond_true313 ], [ %page.3, %cond_next293 ] ; <i32> [#uses=4] - br label %bb273 -invcont240: ; preds = %cond_true277 - %tmp242 = icmp eq i32 %tmp241, 2 ; <i1> [#uses=1] - br i1 %tmp242, label %bb252, label %cond_next244 -cond_next244: ; preds = %invcont240 - %tmp247 = invoke i32 @_ZNK8QPrinter12printerStateEv( %struct.QPrinter* %printer ) - to label %invcont246 unwind label %cleanup329 ; <i32> [#uses=1] -invcont246: ; preds = %cond_next244 - %tmp248 = icmp eq i32 %tmp247, 3 ; <i1> [#uses=1] - br i1 %tmp248, label %bb252, label %bb253 -bb252: ; preds = %invcont246, %invcont240 - br label %bb254 -bb253: ; preds = %invcont246 - br label %bb254 -bb254: ; preds = %bb253, %bb252 - %iftmp.410.0 = phi i1 [ true, %bb252 ], [ false, %bb253 ] ; <i1> [#uses=2] - br i1 %iftmp.410.0, label %UserCanceled, label %cond_next258 -cond_next258: ; preds = %bb254 - invoke fastcc void @_Z9printPageiP8QPainterPK13QTextDocumentRK6QRectFRK7QPointF( i32 %page.4, %struct.QPainter* %p, %struct.QAbstractTextDocumentLayout* %doc.1, %struct.QRectF* %body, %struct.QPointF* %pageNumberPos ) - to label %invcont261 unwind label %cleanup329 -invcont261: ; preds = %cond_next258 - %tmp263 = add i32 %pageCopies.0, -1 ; <i32> [#uses=1] - %tmp265 = icmp sgt i32 %tmp263, %j.4 ; <i1> [#uses=1] - br i1 %tmp265, label %cond_true266, label %cond_next270 -cond_true266: ; preds = %invcont261 - %tmp269 = invoke i1 @_ZN8QPrinter7newPageEv( %struct.QPrinter* %printer ) - to label %cond_next270 unwind label %cleanup329 ; <i1> [#uses=0] -cond_next270: ; preds = %cond_true266, %invcont261 - %tmp272 = add i32 %j.4, 1 ; <i32> [#uses=1] - br label %bb273 -bb273: ; preds = %cond_next270, %bb237 - %iftmp.410.1 = phi i1 [ %iftmp.410.4, %bb237 ], [ %iftmp.410.0, %cond_next270 ] ; <i1> [#uses=2] - %j.4 = phi i32 [ 0, %bb237 ], [ %tmp272, %cond_next270 ] ; <i32> [#uses=3] - %tmp276 = icmp slt i32 %j.4, %pageCopies.0 ; <i1> [#uses=1] - br i1 %tmp276, label %cond_true277, label %bb280 -cond_true277: ; preds = %bb273 - %tmp241 = invoke i32 @_ZNK8QPrinter12printerStateEv( %struct.QPrinter* %printer ) - to label %invcont240 unwind label %cleanup329 ; <i32> [#uses=1] -bb280: ; preds = %bb273 - %tmp283 = icmp eq i32 %page.4, %toPage.2 ; <i1> [#uses=1] - br i1 %tmp283, label %bb297, label %cond_next285 -cond_next285: ; preds = %bb280 - br i1 %ascending.1, label %cond_true287, label %cond_false290 -cond_true287: ; preds = %cond_next285 - %tmp289 = add i32 %page.4, 1 ; <i32> [#uses=1] - br label %cond_next293 -cond_false290: ; preds = %cond_next285 - %tmp292 = add i32 %page.4, -1 ; <i32> [#uses=1] - br label %cond_next293 -cond_next293: ; preds = %cond_false290, %cond_true287 - %page.3 = phi i32 [ %tmp289, %cond_true287 ], [ %tmp292, %cond_false290 ] ; <i32> [#uses=1] - %tmp296 = invoke i1 @_ZN8QPrinter7newPageEv( %struct.QPrinter* %printer ) - to label %bb237 unwind label %cleanup329 ; <i1> [#uses=0] -bb297: ; preds = %bb280 - %tmp299 = add i32 %docCopies.0, -1 ; <i32> [#uses=1] - %tmp301 = icmp sgt i32 %tmp299, %i.1 ; <i1> [#uses=1] - br i1 %tmp301, label %cond_true302, label %cond_next306 -cond_true302: ; preds = %bb297 - %tmp305 = invoke i1 @_ZN8QPrinter7newPageEv( %struct.QPrinter* %printer ) - to label %cond_next306 unwind label %cleanup329 ; <i1> [#uses=0] -cond_next306: ; preds = %cond_true302, %bb297 - %tmp308 = add i32 %i.1, 1 ; <i32> [#uses=1] - br label %bb309 -bb309: ; preds = %cond_next306, %cond_next234 - %iftmp.410.5 = phi i1 [ undef, %cond_next234 ], [ %iftmp.410.1, %cond_next306 ] ; <i1> [#uses=1] - %i.1 = phi i32 [ 0, %cond_next234 ], [ %tmp308, %cond_next306 ] ; <i32> [#uses=3] - %tmp312 = icmp slt i32 %i.1, %docCopies.0 ; <i1> [#uses=1] - br i1 %tmp312, label %cond_true313, label %UserCanceled -cond_true313: ; preds = %bb309 - br label %bb237 -UserCanceled: ; preds = %bb309, %bb254 - %tmp318 = icmp eq %struct.QAbstractTextDocumentLayout* %clonedDoc.1, null ; <i1> [#uses=1] - br i1 %tmp318, label %cleanup327, label %cond_true319 -cond_true319: ; preds = %UserCanceled - %tmp.upgrd.23 = getelementptr %struct.QAbstractTextDocumentLayout* %clonedDoc.1, i32 0, i32 0, i32 0 ; <i32 (...)***> [#uses=1] - %tmp.upgrd.24 = load i32 (...)*** %tmp.upgrd.23 ; <i32 (...)**> [#uses=1] - %tmp322 = getelementptr i32 (...)** %tmp.upgrd.24, i32 4 ; <i32 (...)**> [#uses=1] - %tmp.upgrd.25 = load i32 (...)** %tmp322 ; <i32 (...)*> [#uses=1] - %tmp.upgrd.26 = bitcast i32 (...)* %tmp.upgrd.25 to void (%struct.QAbstractTextDocumentLayout*)* ; <void (%struct.QAbstractTextDocumentLayout*)*> [#uses=1] - invoke void %tmp.upgrd.26( %struct.QAbstractTextDocumentLayout* %clonedDoc.1 ) - to label %cleanup327 unwind label %cleanup329 -cleanup327: ; preds = %cond_true319, %UserCanceled - call void @_ZN8QPainterD1Ev( %struct.QPainter* %p ) - ret void -cleanup328: ; preds = %invcont - call void @_ZN8QPainterD1Ev( %struct.QPainter* %p ) - ret void -cleanup329: ; preds = %cond_true319, %cond_true302, %cond_next293, %cond_true277, %cond_true266, %cond_next258, %cond_next244, %cond_next225, %cond_true220, %invcont210, %cond_next208, %cond_false204, %cond_true200, %cond_next194, %cleanup192, %cleanup192, %cleanup190, %invcont106, %invcont104, %invcont103, %invcont100, %invcont98, %invcont94, %cond_false, %invcont83, %invcont79, %invcont57, %invcont51, %invcont45, %cond_next42, %invcont37, %cond_true35, %invcont29, %invcont25, %cond_true24, %cond_next, %entry - %val = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) - cleanup - call void @_ZN8QPainterD1Ev( %struct.QPainter* %p ) - resume { i8*, i32 } %val -} - -declare void @_ZN6QSizeFC1Edd(%struct.QPointF*, double, double) - -declare i1 @_ZNK6QSizeF7isValidEv(%struct.QPointF*) - -declare double @_ZNK6QSizeF5widthEv(%struct.QPointF*) - -declare double @_ZNK6QSizeF6heightEv(%struct.QPointF*) - -declare double* @_ZN6QSizeF6rwidthEv(%struct.QPointF*) - -declare double* @_ZN6QSizeF7rheightEv(%struct.QPointF*) - -declare %struct.QTextDocumentPrivate* @_ZNK13QTextDocument6d_funcEv(%struct.QAbstractTextDocumentLayout*) - -declare void @_ZN7QPointFC1Ev(%struct.QPointF*) - -declare void @_ZN7QPointFC1Edd(%struct.QPointF*, double, double) - -declare void @_ZN16QTextFrameFormat9setMarginEd(%struct.QTextBlockFormat*, double) - -declare void @_ZN6QRectFC1Edddd(%struct.QRectF*, double, double, double, double) - -declare void @_ZN6QRectFC1ERK7QPointFRK6QSizeF(%struct.QRectF*, %struct.QPointF*, %struct.QPointF*) - -declare double @_ZNK6QRectF5widthEv(%struct.QRectF*) - -declare double @_ZNK6QRectF6heightEv(%struct.QRectF*) - -declare void @_ZNK6QRectF4sizeEv(%struct.QPointF*, %struct.QRectF*) - -declare void @_ZN16QTextFrameFormatD1Ev(%struct.QTextBlockFormat*) - -declare void @_ZNK10QTextFrame11frameFormatEv(%struct.QTextBlockFormat*, %struct.QTextBlockGroup*) - -declare void @_ZN10QTextFrame14setFrameFormatERK16QTextFrameFormat(%struct.QTextBlockGroup*, %struct.QTextBlockFormat*) - -declare i32 @_ZNK12QPaintDevice5widthEv(%struct.QPaintDevice*) - -declare i32 @_ZNK12QPaintDevice6heightEv(%struct.QPaintDevice*) - -declare i32 @_ZNK12QPaintDevice11logicalDpiXEv(%struct.QPaintDevice*) - -declare i32 @_ZNK12QPaintDevice11logicalDpiYEv(%struct.QPaintDevice*) - -declare %struct.QAbstractTextDocumentLayout* @_ZNK13QTextDocument5cloneEP7QObject(%struct.QAbstractTextDocumentLayout*, %struct.QObject*) - -declare void @_ZN5QFontD1Ev(%struct.QFont*) - -declare %struct.QAbstractTextDocumentLayout* @_ZNK13QTextDocument14documentLayoutEv(%struct.QAbstractTextDocumentLayout*) - -declare %struct.QTextBlockGroup* @_ZNK13QTextDocument9rootFrameEv(%struct.QAbstractTextDocumentLayout*) - -declare i32 @_ZNK13QTextDocument9pageCountEv(%struct.QAbstractTextDocumentLayout*) - -declare void @_ZNK13QTextDocument11defaultFontEv(%struct.QFont*, %struct.QAbstractTextDocumentLayout*) - -declare void @_ZN13QTextDocument14setDefaultFontERK5QFont(%struct.QAbstractTextDocumentLayout*, %struct.QFont*) - -declare void @_ZN13QTextDocument11setPageSizeERK6QSizeF(%struct.QAbstractTextDocumentLayout*, %struct.QPointF*) - -declare void @_Z9printPageiP8QPainterPK13QTextDocumentRK6QRectFRK7QPointF(i32, %struct.QPainter*, %struct.QAbstractTextDocumentLayout*, %struct.QRectF*, %struct.QPointF*) - -declare void @_ZN12QFontMetricsD1Ev(%struct.QFontMetrics*) - -declare void @_ZN8QPainterC1EP12QPaintDevice(%struct.QPainter*, %struct.QPaintDevice*) - -declare i1 @_ZNK8QPainter8isActiveEv(%struct.QPainter*) - -declare i32 @_Z13qt_defaultDpiv() - -declare %struct.QPaintDevice* @_ZNK27QAbstractTextDocumentLayout11paintDeviceEv(%struct.QAbstractTextDocumentLayout*) - -declare void @_ZN8QPainter5scaleEdd(%struct.QPainter*, double, double) - -declare %struct.QPaintDevice* @_ZNK8QPainter6deviceEv(%struct.QPainter*) - -declare void @_ZN27QAbstractTextDocumentLayout14setPaintDeviceEP12QPaintDevice(%struct.QAbstractTextDocumentLayout*, %struct.QPaintDevice*) - -declare void @_ZN12QFontMetricsC1ERK5QFontP12QPaintDevice(%struct.QFontMetrics*, %struct.QFont*, %struct.QPaintDevice*) - -declare i32 @_ZNK12QFontMetrics6ascentEv(%struct.QFontMetrics*) - -declare void @_ZN5QFont12setPointSizeEi(%struct.QFont*, i32) - -declare i1 @_ZNK8QPrinter13collateCopiesEv(%struct.QPrinter*) - -declare i32 @_ZNK8QPrinter9numCopiesEv(%struct.QPrinter*) - -declare i32 @_ZNK8QPrinter8fromPageEv(%struct.QPrinter*) - -declare i32 @_ZNK8QPrinter6toPageEv(%struct.QPrinter*) - -declare i32 @_ZNK8QPrinter9pageOrderEv(%struct.QPrinter*) - -declare i32 @_ZNK8QPrinter12printerStateEv(%struct.QPrinter*) - -declare i1 @_ZN8QPrinter7newPageEv(%struct.QPrinter*) - -declare void @_ZN8QPainterD1Ev(%struct.QPainter*) - -declare i32 @__gxx_personality_v0(...) diff --git a/test/Transforms/SimplifyCFG/2008-01-02-hoist-fp-add.ll b/test/Transforms/SimplifyCFG/2008-01-02-hoist-fp-add.ll index 00f2d5bcf135..14baeea4b0b9 100644 --- a/test/Transforms/SimplifyCFG/2008-01-02-hoist-fp-add.ll +++ b/test/Transforms/SimplifyCFG/2008-01-02-hoist-fp-add.ll @@ -1,5 +1,5 @@ ; The phi should not be eliminated in this case, because the fp op could trap. -; RUN: opt < %s -simplifycfg -S | grep {= phi double} +; RUN: opt < %s -simplifycfg -S | grep "= phi double" 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:128:128" target triple = "i686-apple-darwin8" diff --git a/test/Transforms/SimplifyCFG/2008-05-16-PHIBlockMerge.ll b/test/Transforms/SimplifyCFG/2008-05-16-PHIBlockMerge.ll index 56f43b64f74e..13ccad6a1eeb 100644 --- a/test/Transforms/SimplifyCFG/2008-05-16-PHIBlockMerge.ll +++ b/test/Transforms/SimplifyCFG/2008-05-16-PHIBlockMerge.ll @@ -1,6 +1,6 @@ ; RUN: opt < %s -simplifycfg -S > %t -; RUN: not grep {^BB.tomerge} %t -; RUN: grep {^BB.nomerge} %t | count 2 +; RUN: not grep "^BB.tomerge" %t +; RUN: grep "^BB.nomerge" %t | count 2 ; ModuleID = '<stdin>' declare i1 @foo() diff --git a/test/Transforms/SimplifyCFG/2008-07-13-InfLoopMiscompile.ll b/test/Transforms/SimplifyCFG/2008-07-13-InfLoopMiscompile.ll index d025dee85f2d..9b6084f0e1af 100644 --- a/test/Transforms/SimplifyCFG/2008-07-13-InfLoopMiscompile.ll +++ b/test/Transforms/SimplifyCFG/2008-07-13-InfLoopMiscompile.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -simplifycfg -S | grep {%outval = phi i32 .*mux} +; RUN: opt < %s -simplifycfg -S | grep "%outval = phi i32 .*mux" ; PR2540 ; Outval should end up with a select from 0/2, not all constants. diff --git a/test/Transforms/SimplifyCFG/2009-06-15-InvokeCrash.ll b/test/Transforms/SimplifyCFG/2009-06-15-InvokeCrash.ll deleted file mode 100644 index abf4455d780b..000000000000 --- a/test/Transforms/SimplifyCFG/2009-06-15-InvokeCrash.ll +++ /dev/null @@ -1,569 +0,0 @@ -; RUN: opt < %s -simplifycfg -disable-output -; END. - %struct..4._102 = type { %struct.QVectorData* } - %struct..5._125 = type { %struct.QMapData* } - %struct.QAbstractTextDocumentLayout = type { %struct.QObject } - %struct.QBasicAtomic = type { i32 } - %struct.QFont = type { %struct.QFontPrivate*, i32 } - %struct.QFontMetrics = type { %struct.QFontPrivate* } - %struct.QFontPrivate = type opaque - %"struct.QFragmentMap<QTextBlockData>" = type { %struct.QFragmentMapData } - %struct.QFragmentMapData = type { %"struct.QFragmentMapData::._154", i32 } - %"struct.QFragmentMapData::._154" = type { %"struct.QFragmentMapData::Header"* } - %"struct.QFragmentMapData::Header" = type { i32, i32, i32, i32, i32, i32, i32, i32 } - %"struct.QHash<uint,QHashDummyValue>" = type { %"struct.QHash<uint,QHashDummyValue>::._152" } - %"struct.QHash<uint,QHashDummyValue>::._152" = type { %struct.QHashData* } - %struct.QHashData = type { %"struct.QHashData::Node"*, %"struct.QHashData::Node"**, %struct.QBasicAtomic, i32, i32, i16, i16, i32, i8 } - %"struct.QHashData::Node" = type { %"struct.QHashData::Node"*, i32 } - %"struct.QList<QObject*>::._92" = type { %struct.QListData } - %"struct.QList<QPointer<QObject> >" = type { %"struct.QList<QObject*>::._92" } - %struct.QListData = type { %"struct.QListData::Data"* } - %"struct.QListData::Data" = type { %struct.QBasicAtomic, i32, i32, i32, i8, [1 x i8*] } - %"struct.QMap<QUrl,QVariant>" = type { %struct..5._125 } - %struct.QMapData = type { %"struct.QMapData::Node"*, [12 x %"struct.QMapData::Node"*], %struct.QBasicAtomic, i32, i32, i32, i8 } - %"struct.QMapData::Node" = type { %"struct.QMapData::Node"*, [1 x %"struct.QMapData::Node"*] } - %struct.QObject = type { i32 (...)**, %struct.QObjectData* } - %struct.QObjectData = type { i32 (...)**, %struct.QObject*, %struct.QObject*, %"struct.QList<QPointer<QObject> >", i8, [3 x i8], i32, i32 } - %struct.QObjectPrivate = type { %struct.QObjectData, i32, %struct.QObject*, %"struct.QList<QPointer<QObject> >", %"struct.QVector<QAbstractTextDocumentLayout::Selection>", %struct.QString } - %struct.QPaintDevice = type { i32 (...)**, i16 } - %struct.QPainter = type { %struct.QPainterPrivate* } - %struct.QPainterPrivate = type opaque - %struct.QPointF = type { double, double } - %struct.QPrinter = type { %struct.QPaintDevice, %struct.QPrinterPrivate* } - %struct.QPrinterPrivate = type opaque - %struct.QRectF = type { double, double, double, double } - %"struct.QSet<uint>" = type { %"struct.QHash<uint,QHashDummyValue>" } - %"struct.QSharedDataPointer<QTextFormatPrivate>" = type { %struct.QTextFormatPrivate* } - %struct.QString = type { %"struct.QString::Data"* } - %"struct.QString::Data" = type { %struct.QBasicAtomic, i32, i32, i16*, i8, i8, [1 x i16] } - %struct.QTextBlockFormat = type { %struct.QTextFormat } - %struct.QTextBlockGroup = type { %struct.QAbstractTextDocumentLayout } - %struct.QTextDocumentConfig = type { %struct.QString } - %struct.QTextDocumentPrivate = type { %struct.QObjectPrivate, %struct.QString, %"struct.QVector<QAbstractTextDocumentLayout::Selection>", i1, i32, i32, i1, i32, i32, i32, i32, i1, %struct.QTextFormatCollection, %struct.QTextBlockGroup*, %struct.QAbstractTextDocumentLayout*, %"struct.QFragmentMap<QTextBlockData>", %"struct.QFragmentMap<QTextBlockData>", i32, %"struct.QList<QPointer<QObject> >", %"struct.QList<QPointer<QObject> >", %"struct.QMap<QUrl,QVariant>", %"struct.QMap<QUrl,QVariant>", %"struct.QMap<QUrl,QVariant>", %struct.QTextDocumentConfig, i1, i1, %struct.QPointF } - %struct.QTextFormat = type { %"struct.QSharedDataPointer<QTextFormatPrivate>", i32 } - %struct.QTextFormatCollection = type { %"struct.QVector<QAbstractTextDocumentLayout::Selection>", %"struct.QVector<QAbstractTextDocumentLayout::Selection>", %"struct.QSet<uint>", %struct.QFont } - %struct.QTextFormatPrivate = type opaque - %"struct.QVector<QAbstractTextDocumentLayout::Selection>" = type { %struct..4._102 } - %struct.QVectorData = type { %struct.QBasicAtomic, i32, i32, i8 } - -define void @_ZNK13QTextDocument5printEP8QPrinter(%struct.QAbstractTextDocumentLayout* %this, %struct.QPrinter* %printer) { -entry: - %tmp = alloca %struct.QPointF, align 16 ; <%struct.QPointF*> [#uses=2] - %tmp.upgrd.1 = alloca %struct.QRectF, align 16 ; <%struct.QRectF*> [#uses=5] - %tmp2 = alloca %struct.QPointF, align 16 ; <%struct.QPointF*> [#uses=3] - %tmp.upgrd.2 = alloca %struct.QFontMetrics, align 16 ; <%struct.QFontMetrics*> [#uses=4] - %tmp.upgrd.3 = alloca %struct.QFont, align 16 ; <%struct.QFont*> [#uses=4] - %tmp3 = alloca %struct.QPointF, align 16 ; <%struct.QPointF*> [#uses=2] - %p = alloca %struct.QPainter, align 16 ; <%struct.QPainter*> [#uses=14] - %body = alloca %struct.QRectF, align 16 ; <%struct.QRectF*> [#uses=9] - %foo = alloca double, align 8 - %bar = alloca double, align 8 - %pageNumberPos = alloca %struct.QPointF, align 16 ; <%struct.QPointF*> [#uses=4] - %scaledPageSize = alloca %struct.QPointF, align 16 ; <%struct.QPointF*> [#uses=6] - %printerPageSize = alloca %struct.QPointF, align 16 ; <%struct.QPointF*> [#uses=3] - %fmt = alloca %struct.QTextBlockFormat, align 16 ; <%struct.QTextBlockFormat*> [#uses=5] - %font = alloca %struct.QFont, align 16 ; <%struct.QFont*> [#uses=5] - %tmp.upgrd.4 = call %struct.QTextDocumentPrivate* @_ZNK13QTextDocument6d_funcEv( %struct.QAbstractTextDocumentLayout* %this ) ; <%struct.QTextDocumentPrivate*> [#uses=5] - %tmp.upgrd.5 = getelementptr %struct.QPrinter* %printer, i32 0, i32 0 ; <%struct.QPaintDevice*> [#uses=1] - call void @_ZN8QPainterC1EP12QPaintDevice( %struct.QPainter* %p, %struct.QPaintDevice* %tmp.upgrd.5 ) - %tmp.upgrd.6 = invoke i1 @_ZNK8QPainter8isActiveEv( %struct.QPainter* %p ) - to label %invcont unwind label %cleanup329 ; <i1> [#uses=1] -invcont: ; preds = %entry - br i1 %tmp.upgrd.6, label %cond_next, label %cleanup328 -cond_next: ; preds = %invcont - %tmp8 = invoke %struct.QAbstractTextDocumentLayout* @_ZNK13QTextDocument14documentLayoutEv( %struct.QAbstractTextDocumentLayout* %this ) - to label %invcont7 unwind label %cleanup329 ; <%struct.QAbstractTextDocumentLayout*> [#uses=0] -invcont7: ; preds = %cond_next - %tmp10 = getelementptr %struct.QTextDocumentPrivate* %tmp.upgrd.4, i32 0, i32 26 ; <%struct.QPointF*> [#uses=1] - call void @_ZN7QPointFC1Edd( %struct.QPointF* %tmp, double 0.000000e+00, double 0.000000e+00 ) - call void @_ZN6QRectFC1ERK7QPointFRK6QSizeF( %struct.QRectF* %body, %struct.QPointF* %tmp, %struct.QPointF* %tmp10 ) - call void @_ZN7QPointFC1Ev( %struct.QPointF* %pageNumberPos ) - %tmp12 = getelementptr %struct.QTextDocumentPrivate* %tmp.upgrd.4, i32 0, i32 26 ; <%struct.QPointF*> [#uses=1] - %tmp13 = call i1 @_ZNK6QSizeF7isValidEv( %struct.QPointF* %tmp12 ) ; <i1> [#uses=1] - br i1 %tmp13, label %cond_next15, label %bb -cond_next15: ; preds = %invcont7 - %tmp17 = getelementptr %struct.QTextDocumentPrivate* %tmp.upgrd.4, i32 0, i32 26 ; <%struct.QPointF*> [#uses=1] - %tmp.upgrd.7 = call double @_ZNK6QSizeF6heightEv( %struct.QPointF* %tmp17 ) ; <double> [#uses=1] - %tmp18 = fcmp oeq double %tmp.upgrd.7, 0x41DFFFFFFFC00000 ; <i1> [#uses=1] - br i1 %tmp18, label %bb, label %cond_next20 -cond_next20: ; preds = %cond_next15 - br label %bb21 -bb: ; preds = %cond_next15, %invcont7 - br label %bb21 -bb21: ; preds = %bb, %cond_next20 - %iftmp.406.0 = phi i1 [ false, %bb ], [ true, %cond_next20 ] ; <i1> [#uses=1] - br i1 %iftmp.406.0, label %cond_true24, label %cond_false -cond_true24: ; preds = %bb21 - %tmp.upgrd.8 = invoke i32 @_Z13qt_defaultDpiv( ) - to label %invcont25 unwind label %cleanup329 ; <i32> [#uses=1] -invcont25: ; preds = %cond_true24 - %tmp26 = sitofp i32 %tmp.upgrd.8 to double ; <double> [#uses=2] - %tmp30 = invoke %struct.QAbstractTextDocumentLayout* @_ZNK13QTextDocument14documentLayoutEv( %struct.QAbstractTextDocumentLayout* %this ) - to label %invcont29 unwind label %cleanup329 ; <%struct.QAbstractTextDocumentLayout*> [#uses=1] -invcont29: ; preds = %invcont25 - %tmp32 = invoke %struct.QPaintDevice* @_ZNK27QAbstractTextDocumentLayout11paintDeviceEv( %struct.QAbstractTextDocumentLayout* %tmp30 ) - to label %invcont31 unwind label %cleanup329 ; <%struct.QPaintDevice*> [#uses=3] -invcont31: ; preds = %invcont29 - %tmp34 = icmp eq %struct.QPaintDevice* %tmp32, null ; <i1> [#uses=1] - br i1 %tmp34, label %cond_next42, label %cond_true35 -cond_true35: ; preds = %invcont31 - %tmp38 = invoke i32 @_ZNK12QPaintDevice11logicalDpiXEv( %struct.QPaintDevice* %tmp32 ) - to label %invcont37 unwind label %cleanup329 ; <i32> [#uses=1] -invcont37: ; preds = %cond_true35 - %tmp38.upgrd.9 = sitofp i32 %tmp38 to double ; <double> [#uses=1] - %tmp41 = invoke i32 @_ZNK12QPaintDevice11logicalDpiYEv( %struct.QPaintDevice* %tmp32 ) - to label %invcont40 unwind label %cleanup329 ; <i32> [#uses=1] -invcont40: ; preds = %invcont37 - %tmp41.upgrd.10 = sitofp i32 %tmp41 to double ; <double> [#uses=1] - br label %cond_next42 -cond_next42: ; preds = %invcont40, %invcont31 - %sourceDpiY.2 = phi double [ %tmp41.upgrd.10, %invcont40 ], [ %tmp26, %invcont31 ] ; <double> [#uses=1] - %sourceDpiX.2 = phi double [ %tmp38.upgrd.9, %invcont40 ], [ %tmp26, %invcont31 ] ; <double> [#uses=1] - %tmp44 = getelementptr %struct.QPrinter* %printer, i32 0, i32 0 ; <%struct.QPaintDevice*> [#uses=1] - %tmp46 = invoke i32 @_ZNK12QPaintDevice11logicalDpiXEv( %struct.QPaintDevice* %tmp44 ) - to label %invcont45 unwind label %cleanup329 ; <i32> [#uses=1] -invcont45: ; preds = %cond_next42 - %tmp46.upgrd.11 = sitofp i32 %tmp46 to double ; <double> [#uses=1] - %tmp48 = fdiv double %tmp46.upgrd.11, %sourceDpiX.2 ; <double> [#uses=2] - %tmp50 = getelementptr %struct.QPrinter* %printer, i32 0, i32 0 ; <%struct.QPaintDevice*> [#uses=1] - %tmp52 = invoke i32 @_ZNK12QPaintDevice11logicalDpiYEv( %struct.QPaintDevice* %tmp50 ) - to label %invcont51 unwind label %cleanup329 ; <i32> [#uses=1] -invcont51: ; preds = %invcont45 - %tmp52.upgrd.12 = sitofp i32 %tmp52 to double ; <double> [#uses=1] - %tmp54 = fdiv double %tmp52.upgrd.12, %sourceDpiY.2 ; <double> [#uses=2] - invoke void @_ZN8QPainter5scaleEdd( %struct.QPainter* %p, double %tmp48, double %tmp54 ) - to label %invcont57 unwind label %cleanup329 -invcont57: ; preds = %invcont51 - %tmp.upgrd.13 = getelementptr %struct.QPointF* %scaledPageSize, i32 0, i32 0 ; <double*> [#uses=1] - %tmp60 = getelementptr %struct.QTextDocumentPrivate* %tmp.upgrd.4, i32 0, i32 26, i32 0 ; <double*> [#uses=1] - %tmp61 = load double* %tmp60 ; <double> [#uses=1] - store double %tmp61, double* %tmp.upgrd.13 - %tmp62 = getelementptr %struct.QPointF* %scaledPageSize, i32 0, i32 1 ; <double*> [#uses=1] - %tmp63 = getelementptr %struct.QTextDocumentPrivate* %tmp.upgrd.4, i32 0, i32 26, i32 1 ; <double*> [#uses=1] - %tmp64 = load double* %tmp63 ; <double> [#uses=1] - store double %tmp64, double* %tmp62 - %tmp65 = call double* @_ZN6QSizeF6rwidthEv( %struct.QPointF* %scaledPageSize ) ; <double*> [#uses=2] - %tmp67 = load double* %tmp65 ; <double> [#uses=1] - %tmp69 = fmul double %tmp67, %tmp48 ; <double> [#uses=1] - store double %tmp69, double* %tmp65 - %tmp71 = call double* @_ZN6QSizeF7rheightEv( %struct.QPointF* %scaledPageSize ) ; <double*> [#uses=2] - %tmp73 = load double* %tmp71 ; <double> [#uses=1] - %tmp75 = fmul double %tmp73, %tmp54 ; <double> [#uses=1] - store double %tmp75, double* %tmp71 - %tmp78 = getelementptr %struct.QPrinter* %printer, i32 0, i32 0 ; <%struct.QPaintDevice*> [#uses=1] - %tmp80 = invoke i32 @_ZNK12QPaintDevice6heightEv( %struct.QPaintDevice* %tmp78 ) - to label %invcont79 unwind label %cleanup329 ; <i32> [#uses=1] -invcont79: ; preds = %invcont57 - %tmp82 = getelementptr %struct.QPrinter* %printer, i32 0, i32 0 ; <%struct.QPaintDevice*> [#uses=1] - %tmp84 = invoke i32 @_ZNK12QPaintDevice5widthEv( %struct.QPaintDevice* %tmp82 ) - to label %invcont83 unwind label %cleanup329 ; <i32> [#uses=1] -invcont83: ; preds = %invcont79 - %tmp80.upgrd.14 = sitofp i32 %tmp80 to double ; <double> [#uses=1] - %tmp84.upgrd.15 = sitofp i32 %tmp84 to double ; <double> [#uses=1] - call void @_ZN6QSizeFC1Edd( %struct.QPointF* %printerPageSize, double %tmp84.upgrd.15, double %tmp80.upgrd.14 ) - %tmp85 = call double @_ZNK6QSizeF6heightEv( %struct.QPointF* %printerPageSize ) ; <double> [#uses=1] - %tmp86 = call double @_ZNK6QSizeF6heightEv( %struct.QPointF* %scaledPageSize ) ; <double> [#uses=1] - %tmp87 = fdiv double %tmp85, %tmp86 ; <double> [#uses=1] - %tmp88 = call double @_ZNK6QSizeF5widthEv( %struct.QPointF* %printerPageSize ) ; <double> [#uses=1] - %tmp89 = call double @_ZNK6QSizeF5widthEv( %struct.QPointF* %scaledPageSize ) ; <double> [#uses=1] - %tmp90 = fdiv double %tmp88, %tmp89 ; <double> [#uses=1] - invoke void @_ZN8QPainter5scaleEdd( %struct.QPainter* %p, double %tmp90, double %tmp87 ) - to label %cond_next194 unwind label %cleanup329 -cond_false: ; preds = %bb21 - %tmp.upgrd.16 = getelementptr %struct.QAbstractTextDocumentLayout* %this, i32 0, i32 0 ; <%struct.QObject*> [#uses=1] - %tmp95 = invoke %struct.QAbstractTextDocumentLayout* @_ZNK13QTextDocument5cloneEP7QObject( %struct.QAbstractTextDocumentLayout* %this, %struct.QObject* %tmp.upgrd.16 ) - to label %invcont94 unwind label %cleanup329 ; <%struct.QAbstractTextDocumentLayout*> [#uses=9] -invcont94: ; preds = %cond_false - %tmp99 = invoke %struct.QAbstractTextDocumentLayout* @_ZNK13QTextDocument14documentLayoutEv( %struct.QAbstractTextDocumentLayout* %tmp95 ) - to label %invcont98 unwind label %cleanup329 ; <%struct.QAbstractTextDocumentLayout*> [#uses=1] -invcont98: ; preds = %invcont94 - %tmp101 = invoke %struct.QPaintDevice* @_ZNK8QPainter6deviceEv( %struct.QPainter* %p ) - to label %invcont100 unwind label %cleanup329 ; <%struct.QPaintDevice*> [#uses=1] -invcont100: ; preds = %invcont98 - invoke void @_ZN27QAbstractTextDocumentLayout14setPaintDeviceEP12QPaintDevice( %struct.QAbstractTextDocumentLayout* %tmp99, %struct.QPaintDevice* %tmp101 ) - to label %invcont103 unwind label %cleanup329 -invcont103: ; preds = %invcont100 - %tmp105 = invoke %struct.QPaintDevice* @_ZNK8QPainter6deviceEv( %struct.QPainter* %p ) - to label %invcont104 unwind label %cleanup329 ; <%struct.QPaintDevice*> [#uses=1] -invcont104: ; preds = %invcont103 - %tmp107 = invoke i32 @_ZNK12QPaintDevice11logicalDpiYEv( %struct.QPaintDevice* %tmp105 ) - to label %invcont106 unwind label %cleanup329 ; <i32> [#uses=1] -invcont106: ; preds = %invcont104 - %tmp108 = sitofp i32 %tmp107 to double ; <double> [#uses=1] - %tmp109 = fmul double %tmp108, 0x3FE93264C993264C ; <double> [#uses=1] - %tmp109.upgrd.17 = fptosi double %tmp109 to i32 ; <i32> [#uses=3] - %tmp.upgrd.18 = call %struct.QTextBlockGroup* @_ZNK13QTextDocument9rootFrameEv( %struct.QAbstractTextDocumentLayout* %tmp95 ) ; <%struct.QTextBlockGroup*> [#uses=1] - invoke void @_ZNK10QTextFrame11frameFormatEv( %struct.QTextBlockFormat* sret %fmt, %struct.QTextBlockGroup* %tmp.upgrd.18 ) - to label %invcont111 unwind label %cleanup329 -invcont111: ; preds = %invcont106 - %tmp112 = sitofp i32 %tmp109.upgrd.17 to double ; <double> [#uses=1] - invoke void @_ZN16QTextFrameFormat9setMarginEd( %struct.QTextBlockFormat* %fmt, double %tmp112 ) - to label %invcont114 unwind label %cleanup192 -invcont114: ; preds = %invcont111 - %tmp116 = call %struct.QTextBlockGroup* @_ZNK13QTextDocument9rootFrameEv( %struct.QAbstractTextDocumentLayout* %tmp95 ) ; <%struct.QTextBlockGroup*> [#uses=1] - invoke void @_ZN10QTextFrame14setFrameFormatERK16QTextFrameFormat( %struct.QTextBlockGroup* %tmp116, %struct.QTextBlockFormat* %fmt ) - to label %invcont117 unwind label %cleanup192 -invcont117: ; preds = %invcont114 - %tmp119 = invoke %struct.QPaintDevice* @_ZNK8QPainter6deviceEv( %struct.QPainter* %p ) - to label %invcont118 unwind label %cleanup192 ; <%struct.QPaintDevice*> [#uses=1] -invcont118: ; preds = %invcont117 - %tmp121 = invoke i32 @_ZNK12QPaintDevice6heightEv( %struct.QPaintDevice* %tmp119 ) - to label %invcont120 unwind label %cleanup192 ; <i32> [#uses=1] -invcont120: ; preds = %invcont118 - %tmp121.upgrd.19 = sitofp i32 %tmp121 to double ; <double> [#uses=1] - %tmp123 = invoke %struct.QPaintDevice* @_ZNK8QPainter6deviceEv( %struct.QPainter* %p ) - to label %invcont122 unwind label %cleanup192 ; <%struct.QPaintDevice*> [#uses=1] -invcont122: ; preds = %invcont120 - %tmp125 = invoke i32 @_ZNK12QPaintDevice5widthEv( %struct.QPaintDevice* %tmp123 ) - to label %invcont124 unwind label %cleanup192 ; <i32> [#uses=1] -invcont124: ; preds = %invcont122 - %tmp125.upgrd.20 = sitofp i32 %tmp125 to double ; <double> [#uses=1] - call void @_ZN6QRectFC1Edddd( %struct.QRectF* %tmp.upgrd.1, double 0.000000e+00, double 0.000000e+00, double %tmp125.upgrd.20, double %tmp121.upgrd.19 ) - %tmp126 = getelementptr %struct.QRectF* %body, i32 0, i32 0 ; <double*> [#uses=1] - %tmp127 = getelementptr %struct.QRectF* %tmp.upgrd.1, i32 0, i32 0 ; <double*> [#uses=1] - %tmp128 = load double* %tmp127 ; <double> [#uses=1] - store double %tmp128, double* %tmp126 - %tmp129 = getelementptr %struct.QRectF* %body, i32 0, i32 1 ; <double*> [#uses=1] - %tmp130 = getelementptr %struct.QRectF* %tmp.upgrd.1, i32 0, i32 1 ; <double*> [#uses=1] - %tmp131 = load double* %tmp130 ; <double> [#uses=1] - store double %tmp131, double* %tmp129 - %tmp132 = getelementptr %struct.QRectF* %body, i32 0, i32 2 ; <double*> [#uses=1] - %tmp133 = getelementptr %struct.QRectF* %tmp.upgrd.1, i32 0, i32 2 ; <double*> [#uses=1] - %tmp134 = load double* %tmp133 ; <double> [#uses=1] - store double %tmp134, double* %tmp132 - %tmp135 = getelementptr %struct.QRectF* %body, i32 0, i32 3 ; <double*> [#uses=1] - %tmp136 = getelementptr %struct.QRectF* %tmp.upgrd.1, i32 0, i32 3 ; <double*> [#uses=1] - %tmp137 = load double* %tmp136 ; <double> [#uses=1] - store double %tmp137, double* %tmp135 - %tmp138 = call double @_ZNK6QRectF6heightEv( %struct.QRectF* %body ) ; <double> [#uses=1] - %tmp139 = sitofp i32 %tmp109.upgrd.17 to double ; <double> [#uses=1] - %tmp140 = fsub double %tmp138, %tmp139 ; <double> [#uses=1] - %tmp142 = invoke %struct.QPaintDevice* @_ZNK8QPainter6deviceEv( %struct.QPainter* %p ) - to label %invcont141 unwind label %cleanup192 ; <%struct.QPaintDevice*> [#uses=1] -invcont141: ; preds = %invcont124 - invoke void @_ZNK13QTextDocument11defaultFontEv( %struct.QFont* sret %tmp.upgrd.3, %struct.QAbstractTextDocumentLayout* %tmp95 ) - to label %invcont144 unwind label %cleanup192 -invcont144: ; preds = %invcont141 - invoke void @_ZN12QFontMetricsC1ERK5QFontP12QPaintDevice( %struct.QFontMetrics* %tmp.upgrd.2, %struct.QFont* %tmp.upgrd.3, %struct.QPaintDevice* %tmp142 ) - to label %invcont146 unwind label %cleanup173 -invcont146: ; preds = %invcont144 - %tmp149 = invoke i32 @_ZNK12QFontMetrics6ascentEv( %struct.QFontMetrics* %tmp.upgrd.2 ) - to label %invcont148 unwind label %cleanup168 ; <i32> [#uses=1] -invcont148: ; preds = %invcont146 - %tmp149.upgrd.21 = sitofp i32 %tmp149 to double ; <double> [#uses=1] - %tmp150 = fadd double %tmp140, %tmp149.upgrd.21 ; <double> [#uses=1] - %tmp152 = invoke %struct.QPaintDevice* @_ZNK8QPainter6deviceEv( %struct.QPainter* %p ) - to label %invcont151 unwind label %cleanup168 ; <%struct.QPaintDevice*> [#uses=1] -invcont151: ; preds = %invcont148 - %tmp154 = invoke i32 @_ZNK12QPaintDevice11logicalDpiYEv( %struct.QPaintDevice* %tmp152 ) - to label %invcont153 unwind label %cleanup168 ; <i32> [#uses=1] -invcont153: ; preds = %invcont151 - %tmp155 = mul i32 %tmp154, 5 ; <i32> [#uses=1] - %tmp156 = sdiv i32 %tmp155, 72 ; <i32> [#uses=1] - %tmp156.upgrd.22 = sitofp i32 %tmp156 to double ; <double> [#uses=1] - %tmp157 = fadd double %tmp150, %tmp156.upgrd.22 ; <double> [#uses=1] - %tmp158 = call double @_ZNK6QRectF5widthEv( %struct.QRectF* %body ) ; <double> [#uses=1] - %tmp159 = sitofp i32 %tmp109.upgrd.17 to double ; <double> [#uses=1] - %tmp160 = fsub double %tmp158, %tmp159 ; <double> [#uses=1] - call void @_ZN7QPointFC1Edd( %struct.QPointF* %tmp2, double %tmp160, double %tmp157 ) - %tmp161 = getelementptr %struct.QPointF* %pageNumberPos, i32 0, i32 0 ; <double*> [#uses=1] - %tmp162 = getelementptr %struct.QPointF* %tmp2, i32 0, i32 0 ; <double*> [#uses=1] - %tmp163 = load double* %tmp162 ; <double> [#uses=1] - store double %tmp163, double* %tmp161 - %tmp164 = getelementptr %struct.QPointF* %pageNumberPos, i32 0, i32 1 ; <double*> [#uses=1] - %tmp165 = getelementptr %struct.QPointF* %tmp2, i32 0, i32 1 ; <double*> [#uses=1] - %tmp166 = load double* %tmp165 ; <double> [#uses=1] - store double %tmp166, double* %tmp164 - invoke void @_ZN12QFontMetricsD1Ev( %struct.QFontMetrics* %tmp.upgrd.2 ) - to label %cleanup171 unwind label %cleanup173 -cleanup168: ; preds = %invcont151, %invcont148, %invcont146 - %val168 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) - cleanup - invoke void @_ZN12QFontMetricsD1Ev( %struct.QFontMetrics* %tmp.upgrd.2 ) - to label %cleanup173 unwind label %cleanup173 -cleanup171: ; preds = %invcont153 - invoke void @_ZN5QFontD1Ev( %struct.QFont* %tmp.upgrd.3 ) - to label %finally170 unwind label %cleanup192 -cleanup173: ; preds = %cleanup168, %cleanup168, %invcont153, %invcont144 - %val173 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) - cleanup - invoke void @_ZN5QFontD1Ev( %struct.QFont* %tmp.upgrd.3 ) - to label %cleanup192 unwind label %cleanup192 -finally170: ; preds = %cleanup171 - invoke void @_ZNK13QTextDocument11defaultFontEv( %struct.QFont* sret %font, %struct.QAbstractTextDocumentLayout* %tmp95 ) - to label %invcont177 unwind label %cleanup192 -invcont177: ; preds = %finally170 - invoke void @_ZN5QFont12setPointSizeEi( %struct.QFont* %font, i32 10 ) - to label %invcont179 unwind label %cleanup187 -invcont179: ; preds = %invcont177 - invoke void @_ZN13QTextDocument14setDefaultFontERK5QFont( %struct.QAbstractTextDocumentLayout* %tmp95, %struct.QFont* %font ) - to label %invcont181 unwind label %cleanup187 -invcont181: ; preds = %invcont179 - call void @_ZNK6QRectF4sizeEv( %struct.QPointF* sret %tmp3, %struct.QRectF* %body ) - invoke void @_ZN13QTextDocument11setPageSizeERK6QSizeF( %struct.QAbstractTextDocumentLayout* %tmp95, %struct.QPointF* %tmp3 ) - to label %cleanup185 unwind label %cleanup187 -cleanup185: ; preds = %invcont181 - invoke void @_ZN5QFontD1Ev( %struct.QFont* %font ) - to label %cleanup190 unwind label %cleanup192 -cleanup187: ; preds = %invcont181, %invcont179, %invcont177 - %val187 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) - cleanup - invoke void @_ZN5QFontD1Ev( %struct.QFont* %font ) - to label %cleanup192 unwind label %cleanup192 -cleanup190: ; preds = %cleanup185 - invoke void @_ZN16QTextFrameFormatD1Ev( %struct.QTextBlockFormat* %fmt ) - to label %cond_next194 unwind label %cleanup329 -cleanup192: ; preds = %cleanup187, %cleanup187, %cleanup185, %finally170, %cleanup173, %cleanup173, %cleanup171, %invcont141, %invcont124, %invcont122, %invcont120, %invcont118, %invcont117, %invcont114, %invcont111 - %val192 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) - cleanup - invoke void @_ZN16QTextFrameFormatD1Ev( %struct.QTextBlockFormat* %fmt ) - to label %cleanup329 unwind label %cleanup329 -cond_next194: ; preds = %cleanup190, %invcont83 - %clonedDoc.1 = phi %struct.QAbstractTextDocumentLayout* [ null, %invcont83 ], [ %tmp95, %cleanup190 ] ; <%struct.QAbstractTextDocumentLayout*> [#uses=3] - %doc.1 = phi %struct.QAbstractTextDocumentLayout* [ %this, %invcont83 ], [ %tmp95, %cleanup190 ] ; <%struct.QAbstractTextDocumentLayout*> [#uses=2] - %tmp197 = invoke i1 @_ZNK8QPrinter13collateCopiesEv( %struct.QPrinter* %printer ) - to label %invcont196 unwind label %cleanup329 ; <i1> [#uses=1] -invcont196: ; preds = %cond_next194 - br i1 %tmp197, label %cond_true200, label %cond_false204 -cond_true200: ; preds = %invcont196 - %tmp2000 = load double* %foo - store double %tmp2000, double* %bar - %tmp203 = invoke i32 @_ZNK8QPrinter9numCopiesEv( %struct.QPrinter* %printer ) - to label %cond_next208 unwind label %cleanup329 ; <i32> [#uses=1] -cond_false204: ; preds = %invcont196 - %tmp2001 = load double* %foo - store double %tmp2001, double* %bar - %tmp207 = invoke i32 @_ZNK8QPrinter9numCopiesEv( %struct.QPrinter* %printer ) - to label %cond_next208 unwind label %cleanup329 ; <i32> [#uses=1] -cond_next208: ; preds = %invcont206, %invcont202 - %pageCopies.0 = phi i32 [ %tmp203, %cond_true200 ], [ 1, %cond_false204 ] ; <i32> [#uses=2] - %docCopies.0 = phi i32 [ 1, %cond_true200 ], [ %tmp207, %cond_false204 ] ; <i32> [#uses=2] - %tmp211 = invoke i32 @_ZNK8QPrinter8fromPageEv( %struct.QPrinter* %printer ) - to label %invcont210 unwind label %cleanup329 ; <i32> [#uses=3] -invcont210: ; preds = %cond_next208 - %tmp214 = invoke i32 @_ZNK8QPrinter6toPageEv( %struct.QPrinter* %printer ) - to label %invcont213 unwind label %cleanup329 ; <i32> [#uses=3] -invcont213: ; preds = %invcont210 - %tmp216 = icmp eq i32 %tmp211, 0 ; <i1> [#uses=1] - br i1 %tmp216, label %cond_true217, label %cond_next225 -cond_true217: ; preds = %invcont213 - %tmp219 = icmp eq i32 %tmp214, 0 ; <i1> [#uses=1] - br i1 %tmp219, label %cond_true220, label %cond_next225 -cond_true220: ; preds = %cond_true217 - %tmp223 = invoke i32 @_ZNK13QTextDocument9pageCountEv( %struct.QAbstractTextDocumentLayout* %doc.1 ) - to label %invcont222 unwind label %cleanup329 ; <i32> [#uses=1] -invcont222: ; preds = %cond_true220 - br label %cond_next225 -cond_next225: ; preds = %invcont222, %cond_true217, %invcont213 - %toPage.1 = phi i32 [ %tmp223, %invcont222 ], [ %tmp214, %cond_true217 ], [ %tmp214, %invcont213 ] ; <i32> [#uses=2] - %fromPage.1 = phi i32 [ 1, %invcont222 ], [ %tmp211, %cond_true217 ], [ %tmp211, %invcont213 ] ; <i32> [#uses=2] - %tmp.page = invoke i32 @_ZNK8QPrinter9pageOrderEv( %struct.QPrinter* %printer ) - to label %invcont227 unwind label %cleanup329 ; <i32> [#uses=1] -invcont227: ; preds = %cond_next225 - %tmp228 = icmp eq i32 %tmp.page, 1 ; <i1> [#uses=1] - br i1 %tmp228, label %cond_true230, label %cond_next234 -cond_true230: ; preds = %invcont227 - br label %cond_next234 -cond_next234: ; preds = %cond_true230, %invcont227 - %ascending.1 = phi i1 [ false, %cond_true230 ], [ true, %invcont227 ] ; <i1> [#uses=1] - %toPage.2 = phi i32 [ %fromPage.1, %cond_true230 ], [ %toPage.1, %invcont227 ] ; <i32> [#uses=1] - %fromPage.2 = phi i32 [ %toPage.1, %cond_true230 ], [ %fromPage.1, %invcont227 ] ; <i32> [#uses=1] - br label %bb309 -bb237: ; preds = %cond_true313, %cond_next293 - %iftmp.410.4 = phi i1 [ %iftmp.410.5, %cond_true313 ], [ %iftmp.410.1, %cond_next293 ] ; <i1> [#uses=1] - %page.4 = phi i32 [ %fromPage.2, %cond_true313 ], [ %page.3, %cond_next293 ] ; <i32> [#uses=4] - br label %bb273 -invcont240: ; preds = %cond_true277 - %tmp242 = icmp eq i32 %tmp241, 2 ; <i1> [#uses=1] - br i1 %tmp242, label %bb252, label %cond_next244 -cond_next244: ; preds = %invcont240 - %tmp247 = invoke i32 @_ZNK8QPrinter12printerStateEv( %struct.QPrinter* %printer ) - to label %invcont246 unwind label %cleanup329 ; <i32> [#uses=1] -invcont246: ; preds = %cond_next244 - %tmp248 = icmp eq i32 %tmp247, 3 ; <i1> [#uses=1] - br i1 %tmp248, label %bb252, label %bb253 -bb252: ; preds = %invcont246, %invcont240 - br label %bb254 -bb253: ; preds = %invcont246 - br label %bb254 -bb254: ; preds = %bb253, %bb252 - %iftmp.410.0 = phi i1 [ true, %bb252 ], [ false, %bb253 ] ; <i1> [#uses=2] - br i1 %iftmp.410.0, label %UserCanceled, label %cond_next258 -cond_next258: ; preds = %bb254 - invoke fastcc void @_Z9printPageiP8QPainterPK13QTextDocumentRK6QRectFRK7QPointF( i32 %page.4, %struct.QPainter* %p, %struct.QAbstractTextDocumentLayout* %doc.1, %struct.QRectF* %body, %struct.QPointF* %pageNumberPos ) - to label %invcont261 unwind label %cleanup329 -invcont261: ; preds = %cond_next258 - %tmp263 = add i32 %pageCopies.0, -1 ; <i32> [#uses=1] - %tmp265 = icmp sgt i32 %tmp263, %j.4 ; <i1> [#uses=1] - br i1 %tmp265, label %cond_true266, label %cond_next270 -cond_true266: ; preds = %invcont261 - %tmp269 = invoke i1 @_ZN8QPrinter7newPageEv( %struct.QPrinter* %printer ) - to label %cond_next270 unwind label %cleanup329 ; <i1> [#uses=0] -cond_next270: ; preds = %cond_true266, %invcont261 - %tmp272 = add i32 %j.4, 1 ; <i32> [#uses=1] - br label %bb273 -bb273: ; preds = %cond_next270, %bb237 - %iftmp.410.1 = phi i1 [ %iftmp.410.4, %bb237 ], [ %iftmp.410.0, %cond_next270 ] ; <i1> [#uses=2] - %j.4 = phi i32 [ 0, %bb237 ], [ %tmp272, %cond_next270 ] ; <i32> [#uses=3] - %tmp276 = icmp slt i32 %j.4, %pageCopies.0 ; <i1> [#uses=1] - br i1 %tmp276, label %cond_true277, label %bb280 -cond_true277: ; preds = %bb273 - %tmp241 = invoke i32 @_ZNK8QPrinter12printerStateEv( %struct.QPrinter* %printer ) - to label %invcont240 unwind label %cleanup329 ; <i32> [#uses=1] -bb280: ; preds = %bb273 - %tmp283 = icmp eq i32 %page.4, %toPage.2 ; <i1> [#uses=1] - br i1 %tmp283, label %bb297, label %cond_next285 -cond_next285: ; preds = %bb280 - br i1 %ascending.1, label %cond_true287, label %cond_false290 -cond_true287: ; preds = %cond_next285 - %tmp289 = add i32 %page.4, 1 ; <i32> [#uses=1] - br label %cond_next293 -cond_false290: ; preds = %cond_next285 - %tmp292 = add i32 %page.4, -1 ; <i32> [#uses=1] - br label %cond_next293 -cond_next293: ; preds = %cond_false290, %cond_true287 - %page.3 = phi i32 [ %tmp289, %cond_true287 ], [ %tmp292, %cond_false290 ] ; <i32> [#uses=1] - %tmp296 = invoke i1 @_ZN8QPrinter7newPageEv( %struct.QPrinter* %printer ) - to label %bb237 unwind label %cleanup329 ; <i1> [#uses=0] -bb297: ; preds = %bb280 - %tmp299 = add i32 %docCopies.0, -1 ; <i32> [#uses=1] - %tmp301 = icmp sgt i32 %tmp299, %i.1 ; <i1> [#uses=1] - br i1 %tmp301, label %cond_true302, label %cond_next306 -cond_true302: ; preds = %bb297 - %tmp305 = invoke i1 @_ZN8QPrinter7newPageEv( %struct.QPrinter* %printer ) - to label %cond_next306 unwind label %cleanup329 ; <i1> [#uses=0] -cond_next306: ; preds = %cond_true302, %bb297 - %tmp308 = add i32 %i.1, 1 ; <i32> [#uses=1] - br label %bb309 -bb309: ; preds = %cond_next306, %cond_next234 - %iftmp.410.5 = phi i1 [ undef, %cond_next234 ], [ %iftmp.410.1, %cond_next306 ] ; <i1> [#uses=1] - %i.1 = phi i32 [ 0, %cond_next234 ], [ %tmp308, %cond_next306 ] ; <i32> [#uses=3] - %tmp312 = icmp slt i32 %i.1, %docCopies.0 ; <i1> [#uses=1] - br i1 %tmp312, label %cond_true313, label %UserCanceled -cond_true313: ; preds = %bb309 - br label %bb237 -UserCanceled: ; preds = %bb309, %bb254 - %tmp318 = icmp eq %struct.QAbstractTextDocumentLayout* %clonedDoc.1, null ; <i1> [#uses=1] - br i1 %tmp318, label %cleanup327, label %cond_true319 -cond_true319: ; preds = %UserCanceled - %tmp.upgrd.23 = getelementptr %struct.QAbstractTextDocumentLayout* %clonedDoc.1, i32 0, i32 0, i32 0 ; <i32 (...)***> [#uses=1] - %tmp.upgrd.24 = load i32 (...)*** %tmp.upgrd.23 ; <i32 (...)**> [#uses=1] - %tmp322 = getelementptr i32 (...)** %tmp.upgrd.24, i32 4 ; <i32 (...)**> [#uses=1] - %tmp.upgrd.25 = load i32 (...)** %tmp322 ; <i32 (...)*> [#uses=1] - %tmp.upgrd.26 = bitcast i32 (...)* %tmp.upgrd.25 to void (%struct.QAbstractTextDocumentLayout*)* ; <void (%struct.QAbstractTextDocumentLayout*)*> [#uses=1] - invoke void %tmp.upgrd.26( %struct.QAbstractTextDocumentLayout* %clonedDoc.1 ) - to label %cleanup327 unwind label %cleanup329 -cleanup327: ; preds = %cond_true319, %UserCanceled - call void @_ZN8QPainterD1Ev( %struct.QPainter* %p ) - ret void -cleanup328: ; preds = %invcont - call void @_ZN8QPainterD1Ev( %struct.QPainter* %p ) - ret void -cleanup329: ; preds = %cond_true319, %cond_true302, %cond_next293, %cond_true277, %cond_true266, %cond_next258, %cond_next244, %cond_next225, %cond_true220, %invcont210, %cond_next208, %cond_false204, %cond_true200, %cond_next194, %cleanup192, %cleanup192, %cleanup190, %invcont106, %invcont104, %invcont103, %invcont100, %invcont98, %invcont94, %cond_false, %invcont83, %invcont79, %invcont57, %invcont51, %invcont45, %cond_next42, %invcont37, %cond_true35, %invcont29, %invcont25, %cond_true24, %cond_next, %entry - %val329 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) - cleanup - call void @_ZN8QPainterD1Ev( %struct.QPainter* %p ) - resume { i8*, i32 } %val329 -} - -declare void @_ZN6QSizeFC1Edd(%struct.QPointF*, double, double) - -declare i1 @_ZNK6QSizeF7isValidEv(%struct.QPointF*) - -declare double @_ZNK6QSizeF5widthEv(%struct.QPointF*) - -declare double @_ZNK6QSizeF6heightEv(%struct.QPointF*) - -declare double* @_ZN6QSizeF6rwidthEv(%struct.QPointF*) - -declare double* @_ZN6QSizeF7rheightEv(%struct.QPointF*) - -declare %struct.QTextDocumentPrivate* @_ZNK13QTextDocument6d_funcEv(%struct.QAbstractTextDocumentLayout*) - -declare void @_ZN7QPointFC1Ev(%struct.QPointF*) - -declare void @_ZN7QPointFC1Edd(%struct.QPointF*, double, double) - -declare void @_ZN16QTextFrameFormat9setMarginEd(%struct.QTextBlockFormat*, double) - -declare void @_ZN6QRectFC1Edddd(%struct.QRectF*, double, double, double, double) - -declare void @_ZN6QRectFC1ERK7QPointFRK6QSizeF(%struct.QRectF*, %struct.QPointF*, %struct.QPointF*) - -declare double @_ZNK6QRectF5widthEv(%struct.QRectF*) - -declare double @_ZNK6QRectF6heightEv(%struct.QRectF*) - -declare void @_ZNK6QRectF4sizeEv(%struct.QPointF*, %struct.QRectF*) - -declare void @_ZN16QTextFrameFormatD1Ev(%struct.QTextBlockFormat*) - -declare void @_ZNK10QTextFrame11frameFormatEv(%struct.QTextBlockFormat*, %struct.QTextBlockGroup*) - -declare void @_ZN10QTextFrame14setFrameFormatERK16QTextFrameFormat(%struct.QTextBlockGroup*, %struct.QTextBlockFormat*) - -declare i32 @_ZNK12QPaintDevice5widthEv(%struct.QPaintDevice*) - -declare i32 @_ZNK12QPaintDevice6heightEv(%struct.QPaintDevice*) - -declare i32 @_ZNK12QPaintDevice11logicalDpiXEv(%struct.QPaintDevice*) - -declare i32 @_ZNK12QPaintDevice11logicalDpiYEv(%struct.QPaintDevice*) - -declare %struct.QAbstractTextDocumentLayout* @_ZNK13QTextDocument5cloneEP7QObject(%struct.QAbstractTextDocumentLayout*, %struct.QObject*) - -declare void @_ZN5QFontD1Ev(%struct.QFont*) - -declare %struct.QAbstractTextDocumentLayout* @_ZNK13QTextDocument14documentLayoutEv(%struct.QAbstractTextDocumentLayout*) - -declare %struct.QTextBlockGroup* @_ZNK13QTextDocument9rootFrameEv(%struct.QAbstractTextDocumentLayout*) - -declare i32 @_ZNK13QTextDocument9pageCountEv(%struct.QAbstractTextDocumentLayout*) - -declare void @_ZNK13QTextDocument11defaultFontEv(%struct.QFont*, %struct.QAbstractTextDocumentLayout*) - -declare void @_ZN13QTextDocument14setDefaultFontERK5QFont(%struct.QAbstractTextDocumentLayout*, %struct.QFont*) - -declare void @_ZN13QTextDocument11setPageSizeERK6QSizeF(%struct.QAbstractTextDocumentLayout*, %struct.QPointF*) - -declare void @_Z9printPageiP8QPainterPK13QTextDocumentRK6QRectFRK7QPointF(i32, %struct.QPainter*, %struct.QAbstractTextDocumentLayout*, %struct.QRectF*, %struct.QPointF*) - -declare void @_ZN12QFontMetricsD1Ev(%struct.QFontMetrics*) - -declare void @_ZN8QPainterC1EP12QPaintDevice(%struct.QPainter*, %struct.QPaintDevice*) - -declare i1 @_ZNK8QPainter8isActiveEv(%struct.QPainter*) - -declare i32 @_Z13qt_defaultDpiv() - -declare %struct.QPaintDevice* @_ZNK27QAbstractTextDocumentLayout11paintDeviceEv(%struct.QAbstractTextDocumentLayout*) - -declare void @_ZN8QPainter5scaleEdd(%struct.QPainter*, double, double) - -declare %struct.QPaintDevice* @_ZNK8QPainter6deviceEv(%struct.QPainter*) - -declare void @_ZN27QAbstractTextDocumentLayout14setPaintDeviceEP12QPaintDevice(%struct.QAbstractTextDocumentLayout*, %struct.QPaintDevice*) - -declare void @_ZN12QFontMetricsC1ERK5QFontP12QPaintDevice(%struct.QFontMetrics*, %struct.QFont*, %struct.QPaintDevice*) - -declare i32 @_ZNK12QFontMetrics6ascentEv(%struct.QFontMetrics*) - -declare void @_ZN5QFont12setPointSizeEi(%struct.QFont*, i32) - -declare i1 @_ZNK8QPrinter13collateCopiesEv(%struct.QPrinter*) - -declare i32 @_ZNK8QPrinter9numCopiesEv(%struct.QPrinter*) - -declare i32 @_ZNK8QPrinter8fromPageEv(%struct.QPrinter*) - -declare i32 @_ZNK8QPrinter6toPageEv(%struct.QPrinter*) - -declare i32 @_ZNK8QPrinter9pageOrderEv(%struct.QPrinter*) - -declare i32 @_ZNK8QPrinter12printerStateEv(%struct.QPrinter*) - -declare i1 @_ZN8QPrinter7newPageEv(%struct.QPrinter*) - -declare void @_ZN8QPainterD1Ev(%struct.QPainter*) - -declare i32 @__gxx_personality_v0(...) diff --git a/test/Transforms/SimplifyCFG/BrUnwind.ll b/test/Transforms/SimplifyCFG/BrUnwind.ll index 7ab8faa2cea9..14853642c09a 100644 --- a/test/Transforms/SimplifyCFG/BrUnwind.ll +++ b/test/Transforms/SimplifyCFG/BrUnwind.ll @@ -1,5 +1,5 @@ ; RUN: opt < %s -simplifycfg -S | \ -; RUN: not grep {br label} +; RUN: not grep "br label" define void @test(i1 %C) { br i1 %C, label %A, label %B diff --git a/test/Transforms/SimplifyCFG/DeadSetCC.ll b/test/Transforms/SimplifyCFG/DeadSetCC.ll index 83394628cc44..c62560000cae 100644 --- a/test/Transforms/SimplifyCFG/DeadSetCC.ll +++ b/test/Transforms/SimplifyCFG/DeadSetCC.ll @@ -1,5 +1,5 @@ ; RUN: opt < %s -simplifycfg -S | \ -; RUN: not grep {icmp eq} +; RUN: not grep "icmp eq" ; Check that simplifycfg deletes a dead 'seteq' instruction when it ; folds a conditional branch into a switch instruction. diff --git a/test/Transforms/SimplifyCFG/UncondBranchToReturn.ll b/test/Transforms/SimplifyCFG/UncondBranchToReturn.ll index bf9d9535d636..b6d54d32566b 100644 --- a/test/Transforms/SimplifyCFG/UncondBranchToReturn.ll +++ b/test/Transforms/SimplifyCFG/UncondBranchToReturn.ll @@ -3,7 +3,7 @@ ; important case. This is basically the most trivial form of tail-duplication. ; RUN: opt < %s -simplifycfg -S | \ -; RUN: not grep {br label} +; RUN: not grep "br label" define i32 @test(i1 %B, i32 %A, i32 %B.upgrd.1) { br i1 %B, label %T, label %F diff --git a/test/Transforms/SimplifyCFG/branch-fold.ll b/test/Transforms/SimplifyCFG/branch-fold.ll index 2b2968119188..7097dea424e1 100644 --- a/test/Transforms/SimplifyCFG/branch-fold.ll +++ b/test/Transforms/SimplifyCFG/branch-fold.ll @@ -17,3 +17,54 @@ b: c: ret void } + +; rdar://10554090 +define zeroext i1 @test2(i64 %i0, i64 %i1) nounwind uwtable readonly ssp { +entry: +; CHECK: test2 +; CHECK: br i1 + %and.i.i = and i64 %i0, 281474976710655 + %and.i11.i = and i64 %i1, 281474976710655 + %or.cond = icmp eq i64 %and.i.i, %and.i11.i + br i1 %or.cond, label %c, label %a + +a: +; CHECK: br + %shr.i4.i = lshr i64 %i0, 48 + %and.i5.i = and i64 %shr.i4.i, 32767 + %shr.i.i = lshr i64 %i1, 48 + %and.i2.i = and i64 %shr.i.i, 32767 + %cmp9.i = icmp ult i64 %and.i5.i, %and.i2.i + br i1 %cmp9.i, label %c, label %b + +b: +; CHECK-NOT: br + %shr.i13.i9 = lshr i64 %i1, 48 + %and.i14.i10 = and i64 %shr.i13.i9, 32767 + %shr.i.i11 = lshr i64 %i0, 48 + %and.i11.i12 = and i64 %shr.i.i11, 32767 + %phitmp = icmp uge i64 %and.i14.i10, %and.i11.i12 + br label %c + +c: + %o2 = phi i1 [ false, %a ], [ %phitmp, %b ], [ false, %entry ] + ret i1 %o2 +} + +; PR13180 +define void @pr13180(i8 %p) { +entry: + %tobool = icmp eq i8 %p, 0 + br i1 %tobool, label %cond.false, label %cond.true + +cond.true: ; preds = %entry + br label %cond.end + +cond.false: ; preds = %entry + %phitmp = icmp eq i8 %p, 0 + br label %cond.end + +cond.end: ; preds = %cond.false, %cond.true + %cond = phi i1 [ undef, %cond.true ], [ %phitmp, %cond.false ] + unreachable +} diff --git a/test/Transforms/SimplifyCFG/branch-phi-thread.ll b/test/Transforms/SimplifyCFG/branch-phi-thread.ll index f52d979ecd39..c19ba69866b4 100644 --- a/test/Transforms/SimplifyCFG/branch-phi-thread.ll +++ b/test/Transforms/SimplifyCFG/branch-phi-thread.ll @@ -1,5 +1,5 @@ ; RUN: opt < %s -simplifycfg -adce -S | \ -; RUN: not grep {call void @f1} +; RUN: not grep "call void @f1" ; END. declare void @f1() diff --git a/test/Transforms/SimplifyCFG/duplicate-phis.ll b/test/Transforms/SimplifyCFG/duplicate-phis.ll index 5129f9fb6d2f..4788406fc0f3 100644 --- a/test/Transforms/SimplifyCFG/duplicate-phis.ll +++ b/test/Transforms/SimplifyCFG/duplicate-phis.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -instcombine -simplifycfg -S | grep { = phi } | count 1 +; RUN: opt < %s -instcombine -simplifycfg -S | grep " = phi " | count 1 ; instcombine should sort the PHI operands so that simplifycfg can see the ; duplicate and remove it. diff --git a/test/Transforms/SimplifyCFG/invoke.ll b/test/Transforms/SimplifyCFG/invoke.ll new file mode 100644 index 000000000000..10dc41b44bc7 --- /dev/null +++ b/test/Transforms/SimplifyCFG/invoke.ll @@ -0,0 +1,139 @@ +; RUN: opt < %s -simplifycfg -S | FileCheck %s +target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128" + +declare i32 @__gxx_personality_v0(...) +declare void @__cxa_call_unexpected(i8*) +declare void @purefn() nounwind readnone +declare i32 @read_only() nounwind readonly +declare i32 @nounwind_fn() nounwind +declare i32 @fn() + + +; CHECK: @f1 +define i8* @f1() nounwind uwtable ssp { +entry: +; CHECK: call void @llvm.trap() +; CHECK: unreachable + %call = invoke noalias i8* undef() + to label %invoke.cont unwind label %lpad + +invoke.cont: + ret i8* %call + +lpad: + %0 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) + filter [0 x i8*] zeroinitializer + %1 = extractvalue { i8*, i32 } %0, 0 + tail call void @__cxa_call_unexpected(i8* %1) noreturn nounwind + unreachable +} + +; CHECK: @f2 +define i8* @f2() nounwind uwtable ssp { +entry: +; CHECK: call void @llvm.trap() +; CHECK: unreachable + %call = invoke noalias i8* null() + to label %invoke.cont unwind label %lpad + +invoke.cont: + ret i8* %call + +lpad: + %0 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) + filter [0 x i8*] zeroinitializer + %1 = extractvalue { i8*, i32 } %0, 0 + tail call void @__cxa_call_unexpected(i8* %1) noreturn nounwind + unreachable +} + +; CHECK: @f3 +define i32 @f3() nounwind uwtable ssp { +; CHECK-NEXT: entry +entry: +; CHECK-NEXT: ret i32 3 + %call = invoke i32 @read_only() + to label %invoke.cont unwind label %lpad + +invoke.cont: + ret i32 3 + +lpad: + %0 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) + filter [0 x i8*] zeroinitializer + %1 = extractvalue { i8*, i32 } %0, 0 + tail call void @__cxa_call_unexpected(i8* %1) noreturn nounwind + unreachable +} + +; CHECK: @f4 +define i32 @f4() nounwind uwtable ssp { +; CHECK-NEXT: entry +entry: +; CHECK-NEXT: call i32 @read_only() + %call = invoke i32 @read_only() + to label %invoke.cont unwind label %lpad + +invoke.cont: +; CHECK-NEXT: ret i32 %call + ret i32 %call + +lpad: + %0 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) + filter [0 x i8*] zeroinitializer + %1 = extractvalue { i8*, i32 } %0, 0 + tail call void @__cxa_call_unexpected(i8* %1) noreturn nounwind + unreachable +} + +; CHECK: @f5 +define i32 @f5(i1 %cond, i8* %a, i8* %b) { +entry: + br i1 %cond, label %x, label %y + +x: +; CHECK: invoke i32 @fn() + %call = invoke i32 @fn() + to label %cont unwind label %lpad + +y: +; CHECK: call i32 @nounwind_fn() + %call2 = invoke i32 @nounwind_fn() + to label %cont unwind label %lpad + +cont: +; CHECK: phi i32 +; CHECK: ret i32 %phi + %phi = phi i32 [%call, %x], [%call2, %y] + ret i32 %phi + +lpad: +; CHECK-NOT: phi + %phi2 = phi i8* [%a, %x], [%b, %y] + %0 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) + filter [0 x i8*] zeroinitializer +; CHECK: __cxa_call_unexpected(i8* %a) + tail call void @__cxa_call_unexpected(i8* %phi2) noreturn nounwind + unreachable +} + +; CHECK: @f6 +define void @f6() { +entry: + invoke void @purefn() + to label %invoke.cont1 unwind label %lpad + +invoke.cont1: + %foo = invoke i32 @fn() + to label %invoke.cont2 unwind label %lpad + +invoke.cont2: + ret void + +lpad: +; CHECK-NOT: phi + %tmp = phi i8* [ null, %invoke.cont1 ], [ null, %entry ] + landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) + cleanup + ret void +} diff --git a/test/Transforms/SimplifyCFG/switch_thread.ll b/test/Transforms/SimplifyCFG/switch_thread.ll index bd85fccd5273..93966841a425 100644 --- a/test/Transforms/SimplifyCFG/switch_thread.ll +++ b/test/Transforms/SimplifyCFG/switch_thread.ll @@ -1,5 +1,5 @@ ; RUN: opt < %s -simplifycfg -S | \ -; RUN: not grep {call void @DEAD} +; RUN: not grep "call void @DEAD" ; Test that we can thread a simple known condition through switch statements. diff --git a/test/Transforms/SimplifyLibCalls/2007-04-06-strchr-miscompile.ll b/test/Transforms/SimplifyLibCalls/2007-04-06-strchr-miscompile.ll index 8e9f2062cded..ae917f70f4f1 100644 --- a/test/Transforms/SimplifyLibCalls/2007-04-06-strchr-miscompile.ll +++ b/test/Transforms/SimplifyLibCalls/2007-04-06-strchr-miscompile.ll @@ -1,8 +1,8 @@ ; PR1307 ; RUN: opt < %s -simplify-libcalls -instcombine -S > %t -; RUN: grep {@str,.*i64 3} %t -; RUN: grep {@str1,.*i64 7} %t -; RUN: grep {ret i8.*null} %t +; RUN: grep "@str,.*i64 3" %t +; RUN: grep "@str1,.*i64 7" %t +; RUN: grep "ret i8.*null" %t ; END. @str = internal constant [5 x i8] c"foog\00" diff --git a/test/Transforms/SimplifyLibCalls/2009-02-12-StrTo.ll b/test/Transforms/SimplifyLibCalls/2009-02-12-StrTo.ll index f8a0c88d2f89..2717228f7ee1 100644 --- a/test/Transforms/SimplifyLibCalls/2009-02-12-StrTo.ll +++ b/test/Transforms/SimplifyLibCalls/2009-02-12-StrTo.ll @@ -1,14 +1,14 @@ -; RUN: opt < %s -simplify-libcalls -S > %t -; RUN: grep nocapture %t | count 2 -; RUN: grep null %t | grep nocapture | count 1 -; RUN: grep null %t | grep call | not grep readonly +; RUN: opt < %s -simplify-libcalls -S | FileCheck %s ; Test that we add nocapture to the declaration, and to the second call only. +; CHECK: declare float @strtol(i8*, i8** nocapture, i32) nounwind declare float @strtol(i8* %s, i8** %endptr, i32 %base) define void @foo(i8* %x, i8** %endptr) { +; CHECK: call float @strtol(i8* %x, i8** %endptr, i32 10) call float @strtol(i8* %x, i8** %endptr, i32 10) +; CHECK: %2 = call float @strtol(i8* nocapture %x, i8** null, i32 10) call float @strtol(i8* %x, i8** null, i32 10) ret void } diff --git a/test/Transforms/SimplifyLibCalls/2009-05-30-memcmp-byte.ll b/test/Transforms/SimplifyLibCalls/2009-05-30-memcmp-byte.ll index 9056499b4c55..f4c80ed13271 100644 --- a/test/Transforms/SimplifyLibCalls/2009-05-30-memcmp-byte.ll +++ b/test/Transforms/SimplifyLibCalls/2009-05-30-memcmp-byte.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -simplify-libcalls -instcombine -S | grep {ret i32 -65} +; RUN: opt < %s -simplify-libcalls -instcombine -S | grep "ret i32 -65" ; PR4284 define i32 @test() nounwind { diff --git a/test/Transforms/SimplifyLibCalls/FFS.ll b/test/Transforms/SimplifyLibCalls/FFS.ll index ab45f1819b29..e38d78349d43 100644 --- a/test/Transforms/SimplifyLibCalls/FFS.ll +++ b/test/Transforms/SimplifyLibCalls/FFS.ll @@ -1,6 +1,6 @@ ; Test that the ToAsciiOptimizer works correctly ; RUN: opt < %s -simplify-libcalls -S | \ -; RUN: not grep {call.*@ffs} +; RUN: not grep "call.*@ffs" @non_const = external global i32 ; <i32*> [#uses=1] diff --git a/test/Transforms/SimplifyLibCalls/FPrintF.ll b/test/Transforms/SimplifyLibCalls/FPrintF.ll index 4a0d232dac3b..51733e4a1ef6 100644 --- a/test/Transforms/SimplifyLibCalls/FPrintF.ll +++ b/test/Transforms/SimplifyLibCalls/FPrintF.ll @@ -1,6 +1,6 @@ ; Test that the FPrintFOptimizer works correctly ; RUN: opt < %s -simplify-libcalls -S | \ -; RUN: not grep {call.*fprintf} +; RUN: not grep "call.*fprintf" ; This transformation requires the pointer size, as it assumes that size_t is ; the size of a pointer. diff --git a/test/Transforms/SimplifyLibCalls/FPuts.ll b/test/Transforms/SimplifyLibCalls/FPuts.ll index 1f72ede79614..aa01aba2656c 100644 --- a/test/Transforms/SimplifyLibCalls/FPuts.ll +++ b/test/Transforms/SimplifyLibCalls/FPuts.ll @@ -1,6 +1,6 @@ ; Test that the FPutsOptimizer works correctly ; RUN: opt < %s -simplify-libcalls -S | \ -; RUN: not grep {call.*fputs} +; RUN: not grep "call.*fputs" ; This transformation requires the pointer size, as it assumes that size_t is ; the size of a pointer. diff --git a/test/Transforms/SimplifyLibCalls/MemCpy.ll b/test/Transforms/SimplifyLibCalls/MemCpy.ll index c711178fa1b7..1faad036a865 100644 --- a/test/Transforms/SimplifyLibCalls/MemCpy.ll +++ b/test/Transforms/SimplifyLibCalls/MemCpy.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -constprop -instcombine -S | not grep {call.*llvm.memcpy.i32} +; RUN: opt < %s -constprop -instcombine -S | not grep "call.*llvm.memcpy.i32" @h = constant [2 x i8] c"h\00" ; <[2 x i8]*> [#uses=1] @hel = constant [4 x i8] c"hel\00" ; <[4 x i8]*> [#uses=1] diff --git a/test/Transforms/SimplifyLibCalls/SPrintF.ll b/test/Transforms/SimplifyLibCalls/SPrintF.ll index 847e363f52c1..514a7d9f6eee 100644 --- a/test/Transforms/SimplifyLibCalls/SPrintF.ll +++ b/test/Transforms/SimplifyLibCalls/SPrintF.ll @@ -1,6 +1,6 @@ ; Test that the SPrintFOptimizer works correctly ; RUN: opt < %s -simplify-libcalls -S | \ -; RUN: not grep {call.*sprintf} +; RUN: not grep "call.*sprintf" ; This transformation requires the pointer size, as it assumes that size_t is ; the size of a pointer. diff --git a/test/Transforms/SimplifyLibCalls/StpCpy.ll b/test/Transforms/SimplifyLibCalls/StpCpy.ll new file mode 100644 index 000000000000..914b0955bc90 --- /dev/null +++ b/test/Transforms/SimplifyLibCalls/StpCpy.ll @@ -0,0 +1,43 @@ +; Test that the StpCpyOptimizer works correctly +; RUN: opt < %s -simplify-libcalls -S | FileCheck %s + +; This transformation requires the pointer size, as it assumes that size_t is +; the size of a pointer. +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:128:128-n8:16:32" + +@hello = constant [6 x i8] c"hello\00" + +declare i8* @stpcpy(i8*, i8*) + +declare i8* @__stpcpy_chk(i8*, i8*, i32) nounwind + +declare i32 @llvm.objectsize.i32(i8*, i1) nounwind readonly + +define i32 @t1() { +; CHECK: @t1 + %target = alloca [1024 x i8] + %arg1 = getelementptr [1024 x i8]* %target, i32 0, i32 0 + %arg2 = getelementptr [6 x i8]* @hello, i32 0, i32 0 + %rslt1 = call i8* @stpcpy( i8* %arg1, i8* %arg2 ) +; CHECK: @llvm.memcpy.p0i8.p0i8.i32 + ret i32 0 +} + +define i32 @t2() { +; CHECK: @t2 + %target = alloca [1024 x i8] + %arg1 = getelementptr [1024 x i8]* %target, i32 0, i32 0 + %arg2 = getelementptr [6 x i8]* @hello, i32 0, i32 0 + %tmp1 = call i32 @llvm.objectsize.i32(i8* %arg1, i1 false) + %rslt1 = call i8* @__stpcpy_chk(i8* %arg1, i8* %arg2, i32 %tmp1) +; CHECK: @__memcpy_chk + ret i32 0 +} + +define i8* @t3(i8* %arg) { +; CHECK: @t3 + %stpcpy = tail call i8* @stpcpy(i8* %arg, i8* %arg) +; CHECK: [[LEN:%[a-z]+]] = call i32 @strlen(i8* %arg) +; CHECK-NEXT: getelementptr inbounds i8* %arg, i32 [[LEN]] + ret i8* %stpcpy +} diff --git a/test/Transforms/SimplifyLibCalls/StrCat.ll b/test/Transforms/SimplifyLibCalls/StrCat.ll index 4e3d0ab7f40f..3ea691a3cfbe 100644 --- a/test/Transforms/SimplifyLibCalls/StrCat.ll +++ b/test/Transforms/SimplifyLibCalls/StrCat.ll @@ -1,9 +1,9 @@ ; Test that the StrCatOptimizer works correctly ; PR3661 ; RUN: opt < %s -simplify-libcalls -S | \ -; RUN: not grep {call.*strcat} +; RUN: not grep "call.*strcat" ; RUN: opt < %s -simplify-libcalls -S | \ -; RUN: grep {puts.*%arg1} +; RUN: grep "puts.*%arg1" ; This transformation requires the pointer size, as it assumes that size_t is ; the size of a pointer. diff --git a/test/Transforms/SimplifyLibCalls/StrLen.ll b/test/Transforms/SimplifyLibCalls/StrLen.ll index acd8aaf6e543..4a20bbd2ce81 100644 --- a/test/Transforms/SimplifyLibCalls/StrLen.ll +++ b/test/Transforms/SimplifyLibCalls/StrLen.ll @@ -1,6 +1,6 @@ ; Test that the StrCatOptimizer works correctly ; RUN: opt < %s -simplify-libcalls -S | \ -; RUN: not grep {call.*strlen} +; RUN: not grep "call.*strlen" target datalayout = "e-p:32:32" @hello = constant [6 x i8] c"hello\00" ; <[6 x i8]*> [#uses=3] diff --git a/test/Transforms/SimplifyLibCalls/StrNCat.ll b/test/Transforms/SimplifyLibCalls/StrNCat.ll index d09c022fd4cd..073792b96a1b 100644 --- a/test/Transforms/SimplifyLibCalls/StrNCat.ll +++ b/test/Transforms/SimplifyLibCalls/StrNCat.ll @@ -1,8 +1,8 @@ ; Test that the StrNCatOptimizer works correctly ; RUN: opt < %s -simplify-libcalls -S | \ -; RUN: not grep {call.*strncat} +; RUN: not grep "call.*strncat" ; RUN: opt < %s -simplify-libcalls -S | \ -; RUN: grep {puts.*%arg1} +; RUN: grep "puts.*%arg1" ; This transformation requires the pointer size, as it assumes that size_t is ; the size of a pointer. diff --git a/test/Transforms/SimplifyLibCalls/StrNCpy.ll b/test/Transforms/SimplifyLibCalls/StrNCpy.ll index c8af3ca8c3e2..4e47b31a6afa 100644 --- a/test/Transforms/SimplifyLibCalls/StrNCpy.ll +++ b/test/Transforms/SimplifyLibCalls/StrNCpy.ll @@ -1,6 +1,6 @@ ; Test that the StrNCpyOptimizer works correctly ; RUN: opt < %s -simplify-libcalls -S | \ -; RUN: not grep {call.*strncpy} +; RUN: not grep "call.*strncpy" ; This transformation requires the pointer size, as it assumes that size_t is ; the size of a pointer. diff --git a/test/Transforms/SimplifyLibCalls/ToAscii.ll b/test/Transforms/SimplifyLibCalls/ToAscii.ll index e2b5683d9d73..aef47333b3c3 100644 --- a/test/Transforms/SimplifyLibCalls/ToAscii.ll +++ b/test/Transforms/SimplifyLibCalls/ToAscii.ll @@ -1,6 +1,6 @@ ; Test that the ToAsciiOptimizer works correctly ; RUN: opt < %s -simplify-libcalls -S | \ -; RUN: not grep {call.*toascii} +; RUN: not grep "call.*toascii" declare i32 @toascii(i32) diff --git a/test/Transforms/SimplifyLibCalls/abs.ll b/test/Transforms/SimplifyLibCalls/abs.ll index 6fbe0b9de44e..3934a5b98f74 100644 --- a/test/Transforms/SimplifyLibCalls/abs.ll +++ b/test/Transforms/SimplifyLibCalls/abs.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -simplify-libcalls -S | grep {select i1 %ispos} +; RUN: opt < %s -simplify-libcalls -S | grep "select i1 %ispos" ; PR2337 define i32 @test(i32 %x) { diff --git a/test/Transforms/SimplifyLibCalls/exp2.ll b/test/Transforms/SimplifyLibCalls/exp2.ll index 2f5d910558f5..a5927757cf93 100644 --- a/test/Transforms/SimplifyLibCalls/exp2.ll +++ b/test/Transforms/SimplifyLibCalls/exp2.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -simplify-libcalls -S | grep {call.*ldexp} | count 4 +; RUN: opt < %s -simplify-libcalls -S | grep "call.*ldexp" | count 4 ; rdar://5852514 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:128:128" diff --git a/test/Transforms/SimplifyLibCalls/memmove.ll b/test/Transforms/SimplifyLibCalls/memmove.ll index c0c00506cdd3..5aaeeeb024f7 100644 --- a/test/Transforms/SimplifyLibCalls/memmove.ll +++ b/test/Transforms/SimplifyLibCalls/memmove.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -simplify-libcalls -S | grep {llvm.memmove} +; RUN: opt < %s -simplify-libcalls -S | grep "llvm.memmove" 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" target triple = "i686-pc-linux-gnu" diff --git a/test/Transforms/SimplifyLibCalls/memset-64.ll b/test/Transforms/SimplifyLibCalls/memset-64.ll index fb752c4083af..92412dee71ad 100644 --- a/test/Transforms/SimplifyLibCalls/memset-64.ll +++ b/test/Transforms/SimplifyLibCalls/memset-64.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -simplify-libcalls -S | grep {llvm.memset} +; RUN: opt < %s -simplify-libcalls -S | grep "llvm.memset" target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128" target triple = "x86_64-pc-linux-gnu" diff --git a/test/Transforms/SimplifyLibCalls/memset.ll b/test/Transforms/SimplifyLibCalls/memset.ll index 0aede064cac1..853215a4d24c 100644 --- a/test/Transforms/SimplifyLibCalls/memset.ll +++ b/test/Transforms/SimplifyLibCalls/memset.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -simplify-libcalls -S | grep {llvm.memset} +; RUN: opt < %s -simplify-libcalls -S | grep "llvm.memset" 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" target triple = "i686-pc-linux-gnu" diff --git a/test/Transforms/SimplifyLibCalls/pow2.ll b/test/Transforms/SimplifyLibCalls/pow2.ll index f8364f740b22..f0964e7d6daa 100644 --- a/test/Transforms/SimplifyLibCalls/pow2.ll +++ b/test/Transforms/SimplifyLibCalls/pow2.ll @@ -1,6 +1,6 @@ ; Testcase for calls to the standard C "pow" function ; -; RUN: opt < %s -simplify-libcalls -S | not grep {call .pow} +; RUN: opt < %s -simplify-libcalls -S | not grep "call .pow" declare double @pow(double, double) diff --git a/test/Transforms/Sink/basic.ll b/test/Transforms/Sink/basic.ll index 4c531d82e6ee..1d0b6b529d56 100644 --- a/test/Transforms/Sink/basic.ll +++ b/test/Transforms/Sink/basic.ll @@ -36,3 +36,29 @@ true: false: ret i32 0 } + +; Sink to the nearest post-dominator + +; CHECK: @diamond +; CHECK: X: +; CHECK-NEXT: phi +; CHECK-NEXT: mul nsw +; CHECK-NEXT: sub + +define i32 @diamond(i32 %a, i32 %b, i32 %c) { + %1 = mul nsw i32 %c, %b + %2 = icmp sgt i32 %a, 0 + br i1 %2, label %B0, label %B1 + +B0: ; preds = %0 + br label %X + +B1: ; preds = %0 + br label %X + +X: ; preds = %5, %3 + %.01 = phi i32 [ %c, %B0 ], [ %a, %B1 ] + %R = sub i32 %1, %.01 + ret i32 %R +} + diff --git a/test/Transforms/TailCallElim/ackermann.ll b/test/Transforms/TailCallElim/ackermann.ll index 0c140ad681d5..5b5dbcc225c1 100644 --- a/test/Transforms/TailCallElim/ackermann.ll +++ b/test/Transforms/TailCallElim/ackermann.ll @@ -1,5 +1,5 @@ ; This function contains two tail calls, which should be eliminated -; RUN: opt < %s -tailcallelim -stats -disable-output |& grep {2 tailcallelim} +; RUN: opt < %s -tailcallelim -stats -disable-output 2>&1 | grep "2 tailcallelim" define i32 @Ack(i32 %M.1, i32 %N.1) { entry: diff --git a/test/Transforms/TailCallElim/dont-tce-tail-marked-call.ll b/test/Transforms/TailCallElim/dont-tce-tail-marked-call.ll index 5cc92e1b1730..e4f8b483c3c0 100644 --- a/test/Transforms/TailCallElim/dont-tce-tail-marked-call.ll +++ b/test/Transforms/TailCallElim/dont-tce-tail-marked-call.ll @@ -1,5 +1,5 @@ ; RUN: opt < %s -tailcallelim -S | \ -; RUN: grep {call i32 @foo} +; RUN: grep "call i32 @foo" declare void @bar(i32*) diff --git a/test/Transforms/TailCallElim/dup_tail.ll b/test/Transforms/TailCallElim/dup_tail.ll index 93638804f92e..42ac2f9dc4b9 100644 --- a/test/Transforms/TailCallElim/dup_tail.ll +++ b/test/Transforms/TailCallElim/dup_tail.ll @@ -1,5 +1,5 @@ ; Duplicate the return into if.end to enable TCE. -; RUN: opt %s -tailcallelim -stats -disable-output |& grep {Number of return duplicated} +; RUN: opt %s -tailcallelim -stats -disable-output 2>&1 | grep "Number of return duplicated" define i32 @fib(i32 %n) nounwind ssp { entry: diff --git a/test/Transforms/TailCallElim/trivial_codegen_tailcall.ll b/test/Transforms/TailCallElim/trivial_codegen_tailcall.ll index 3dddb013f7ce..3d01d1709952 100644 --- a/test/Transforms/TailCallElim/trivial_codegen_tailcall.ll +++ b/test/Transforms/TailCallElim/trivial_codegen_tailcall.ll @@ -1,5 +1,5 @@ ; RUN: opt < %s -tailcallelim -S | \ -; RUN: grep {tail call void @foo} +; RUN: grep "tail call void @foo" declare void @foo() diff --git a/test/Transforms/TailDup/2008-06-11-AvoidDupLoopHeader.ll b/test/Transforms/TailDup/2008-06-11-AvoidDupLoopHeader.ll index 03e99bc9bf6a..7853d7ba06fb 100644 --- a/test/Transforms/TailDup/2008-06-11-AvoidDupLoopHeader.ll +++ b/test/Transforms/TailDup/2008-06-11-AvoidDupLoopHeader.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -tailduplicate -taildup-threshold=3 -stats -disable-output |& not grep tailduplicate +; RUN: opt < %s -tailduplicate -taildup-threshold=3 -stats -disable-output 2>&1 | not grep tailduplicate ; XFAIL: * define i32 @foo(i32 %l) nounwind { |