From 4cd6cc64edb3833327601fb9eb2b5a9b6fb2bb7f Mon Sep 17 00:00:00 2001 From: Florian Hahn Date: Wed, 13 Oct 2021 16:47:42 +0100 Subject: [PATCH] [SCEV] Add test for propagating poison through select condition. Precommit a test for D111643. --- llvm/test/Analysis/ScalarEvolution/nsw.ll | 36 +++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/llvm/test/Analysis/ScalarEvolution/nsw.ll b/llvm/test/Analysis/ScalarEvolution/nsw.ll index 99bd34a2a9ea..f1b2c8e9c714 100644 --- a/llvm/test/Analysis/ScalarEvolution/nsw.ll +++ b/llvm/test/Analysis/ScalarEvolution/nsw.ll @@ -393,3 +393,39 @@ loop: leave: ret void } + +define void @select_cond_poison_propagation(double* %p, i32 %x) nounwind { +; CHECK-LABEL: 'select_cond_poison_propagation' +; CHECK-NEXT: Classifying expressions for: @select_cond_poison_propagation +; CHECK-NEXT: %iv = phi i32 [ %iv.next, %loop ], [ 0, %entry ] +; CHECK-NEXT: --> {0,+,1}<%loop> U: [0,-2147483648) S: [0,-2147483648) Exits: <> LoopDispositions: { %loop: Computable } +; CHECK-NEXT: %iv.next = add nsw i32 %iv, 1 +; CHECK-NEXT: --> {1,+,1}<%loop> U: [1,0) S: [1,0) Exits: <> LoopDispositions: { %loop: Computable } +; CHECK-NEXT: %sel = select i1 %cmp, i32 10, i32 20 +; CHECK-NEXT: --> %sel U: [0,31) S: [0,31) Exits: <> LoopDispositions: { %loop: Variant } +; CHECK-NEXT: %cond = call i1 @cond() +; CHECK-NEXT: --> %cond U: full-set S: full-set Exits: <> LoopDispositions: { %loop: Variant } +; CHECK-NEXT: Determining loop execution counts for: @select_cond_poison_propagation +; CHECK-NEXT: Loop %loop: Unpredictable backedge-taken count. +; CHECK-NEXT: Loop %loop: Unpredictable max backedge-taken count. +; CHECK-NEXT: Loop %loop: Unpredictable predicated backedge-taken count. +; +entry: + br label %loop + +loop: + %iv = phi i32 [ %iv.next, %loop ], [ 0, %entry ] + %iv.next = add nsw i32 %iv, 1 + %cmp = icmp ult i32 %iv.next, %x + %sel = select i1 %cmp, i32 10, i32 20 + call void @foo(i32 noundef %sel) + %cond = call i1 @cond() + br i1 %cond, label %loop, label %return + +return: + ret void +} + +declare void @foo(i32) + +declare i1 @cond()