diff options
| author | Johannes Doerfert <johannes@jdoerfert.de> | 2019-10-31 13:46:43 -0500 |
|---|---|---|
| committer | Johannes Doerfert <johannes@jdoerfert.de> | 2019-10-31 13:49:16 -0500 |
| commit | e15ab8f277c71c6843537ffdca7ca9f5eea0b9ea (patch) | |
| tree | d3d62e852afd8e775ba9ee2eaabf74dd442e54c6 /llvm/test | |
| parent | 4de09e0f44605aa98ff1a9c103fc95c34d222bf8 (diff) | |
| download | bcm5719-llvm-e15ab8f277c71c6843537ffdca7ca9f5eea0b9ea.tar.gz bcm5719-llvm-e15ab8f277c71c6843537ffdca7ca9f5eea0b9ea.zip | |
[InstCombine] Add the test that triggered the D60846 revert
This is in preparation of D69571.
Diffstat (limited to 'llvm/test')
| -rw-r--r-- | llvm/test/Transforms/InstCombine/known-non-zero.ll | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/llvm/test/Transforms/InstCombine/known-non-zero.ll b/llvm/test/Transforms/InstCombine/known-non-zero.ll index 0329fbaf990..57980e0890c 100644 --- a/llvm/test/Transforms/InstCombine/known-non-zero.ll +++ b/llvm/test/Transforms/InstCombine/known-non-zero.ll @@ -91,3 +91,45 @@ exit: %res = phi <8 x i64> [ %ctz, %non_zero ], [ zeroinitializer, %start ] ret <8 x i64> %res } + +; Test that exposed a bug in the PHI handling after D60846. No folding should happen here! +define void @D60846_misompile(i1* %p) { +; CHECK-LABEL: @D60846_misompile( +; CHECK-NEXT: entry: +; CHECK-NEXT: br label [[LOOP:%.*]] +; CHECK: loop: +; CHECK-NEXT: [[I:%.*]] = phi i16 [ 0, [[ENTRY:%.*]] ], [ [[I_INC:%.*]], [[COMMON:%.*]] ] +; CHECK-NEXT: [[IS_ZERO:%.*]] = icmp eq i16 [[I]], 0 +; CHECK-NEXT: br i1 [[IS_ZERO]], label [[COMMON]], label [[NON_ZERO:%.*]] +; CHECK: non_zero: +; CHECK-NEXT: [[IS_ONE:%.*]] = icmp eq i16 [[I]], 1 +; CHECK-NEXT: store i1 [[IS_ONE]], i1* [[P:%.*]], align 1 +; CHECK-NEXT: br label [[COMMON]] +; CHECK: common: +; CHECK-NEXT: [[I_INC]] = add i16 [[I]], 1 +; CHECK-NEXT: [[LOOP_COND:%.*]] = icmp ult i16 [[I_INC]], 2 +; CHECK-NEXT: br i1 [[LOOP_COND]], label [[LOOP]], label [[EXIT:%.*]] +; CHECK: exit: +; CHECK-NEXT: ret void +; +entry: + br label %loop + +loop: ; preds = %common, %entry + %i = phi i16 [ 0, %entry ], [ %i.inc, %common ] + %is_zero = icmp eq i16 %i, 0 + br i1 %is_zero, label %common, label %non_zero + +non_zero: ; preds = %loop + %is_one = icmp eq i16 %i, 1 + store i1 %is_one, i1* %p + br label %common + +common: ; preds = %non_zero, %loop + %i.inc = add i16 %i, 1 + %loop_cond = icmp ult i16 %i.inc, 2 + br i1 %loop_cond, label %loop, label %exit + +exit: ; preds = %common + ret void +} |

