diff options
| author | Hongbin Zheng <etherzhhb@gmail.com> | 2017-09-29 16:32:12 +0000 |
|---|---|---|
| committer | Hongbin Zheng <etherzhhb@gmail.com> | 2017-09-29 16:32:12 +0000 |
| commit | c8abdf5f2509067052e5845d3d8a0e21020f628a (patch) | |
| tree | b3d7372733104c0e88404b5d0904d49f9c939e30 /llvm/test/Transforms/IndVarSimplify | |
| parent | c2e79c2dfc07e1aba27946f22ea370cd5c130b04 (diff) | |
| download | bcm5719-llvm-c8abdf5f2509067052e5845d3d8a0e21020f628a.tar.gz bcm5719-llvm-c8abdf5f2509067052e5845d3d8a0e21020f628a.zip | |
[SimplifyIndVar] Do not fail when we constant fold an IV user to ConstantPointerNull
The type of a SCEVConstant may not match the corresponding LLVM Value.
In this case, we skip the constant folding for now.
TODO: Replace ConstantInt Zero by ConstantPointerNull
llvm-svn: 314531
Diffstat (limited to 'llvm/test/Transforms/IndVarSimplify')
| -rw-r--r-- | llvm/test/Transforms/IndVarSimplify/constant-fold-1.ll | 39 | ||||
| -rw-r--r-- | llvm/test/Transforms/IndVarSimplify/constant-fold.ll | 2 |
2 files changed, 40 insertions, 1 deletions
diff --git a/llvm/test/Transforms/IndVarSimplify/constant-fold-1.ll b/llvm/test/Transforms/IndVarSimplify/constant-fold-1.ll new file mode 100644 index 00000000000..a1ab41d0130 --- /dev/null +++ b/llvm/test/Transforms/IndVarSimplify/constant-fold-1.ll @@ -0,0 +1,39 @@ +; RUN: opt < %s -indvars -S | FileCheck %s + +target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-unknown-linux-gnu" + +define void @test(i64* %arg) unnamed_addr align 2 { +bb: + switch i64 undef, label %bb1 [ + ] + +bb1: ; preds = %bb + br label %bb2 + +bb2: ; preds = %bb6, %bb1 + %tmp = phi i64* [%arg, %bb1 ], [ %tmp7, %bb6 ] + switch i2 undef, label %bb6 [ + i2 1, label %bb5 + i2 -2, label %bb3 + i2 -1, label %bb3 + ] + +bb3: ; preds = %bb2, %bb2 + %tmp4 = call fastcc i32* @wobble(i64* nonnull %tmp, i32* null) + %tmp5 = load i32, i32* %tmp4 , align 8 + br label %bb6 + +bb5: ; preds = %bb2 + unreachable + +bb6: ; preds = %bb3, %bb2 + %tmp7 = load i64*, i64** undef, align 8 + br label %bb2 +} + +declare i32* @wobble(i64*, i32* returned) + +; Should not fail when SCEV is fold to ConstantPointerNull +; CHECK-LABEL: void @test +; CHECK: load i32, i32* %{{[a-zA-Z$._0-9]+}} diff --git a/llvm/test/Transforms/IndVarSimplify/constant-fold.ll b/llvm/test/Transforms/IndVarSimplify/constant-fold.ll index a35349aa1f5..ef42ac7dc78 100644 --- a/llvm/test/Transforms/IndVarSimplify/constant-fold.ll +++ b/llvm/test/Transforms/IndVarSimplify/constant-fold.ll @@ -19,7 +19,7 @@ for.end: ; preds = %for.inc } ; Should fold the condition of the select into constant -; CHECK-LABEL: void @test +; CHECK-LABEL: void @test0( ; CHECK: icmp eq i32 0, 0 define void @test1(i32* %a) { |

