[llvm] f204886 - [CVP] Add test with nested cycle (NFC)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 18 07:57:44 PST 2024


Author: Nikita Popov
Date: 2024-01-18T16:57:29+01:00
New Revision: f20488687e54a7202b0c90a9d3bee540c5e40f9a

URL: https://github.com/llvm/llvm-project/commit/f20488687e54a7202b0c90a9d3bee540c5e40f9a
DIFF: https://github.com/llvm/llvm-project/commit/f20488687e54a7202b0c90a9d3bee540c5e40f9a.diff

LOG: [CVP] Add test with nested cycle (NFC)

This is a regression test for a miscompile that would have been
introduced by an upcoming patch.

Added: 
    llvm/test/Transforms/CorrelatedValuePropagation/nested-cycle.ll

Modified: 
    

Removed: 
    


################################################################################
diff  --git a/llvm/test/Transforms/CorrelatedValuePropagation/nested-cycle.ll b/llvm/test/Transforms/CorrelatedValuePropagation/nested-cycle.ll
new file mode 100644
index 00000000000000..7e5ce71f129a4c
--- /dev/null
+++ b/llvm/test/Transforms/CorrelatedValuePropagation/nested-cycle.ll
@@ -0,0 +1,55 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 4
+; RUN: opt -S -passes=jump-threading,correlated-propagation < %s | FileCheck %s
+
+; This runs both jump threading and CVP to query values in the right order.
+; The comparison should not fold.
+
+define void @test(i32 %n, i1 %c, i1 %c2) {
+; CHECK-LABEL: define void @test(
+; CHECK-SAME: i32 [[N:%.*]], i1 [[C:%.*]], i1 [[C2:%.*]]) {
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:    br label [[LOOP:%.*]]
+; CHECK:       loop:
+; CHECK-NEXT:    [[IV:%.*]] = phi i32 [ [[IV_NEXT:%.*]], [[LOOP_LATCH:%.*]] ], [ 0, [[ENTRY:%.*]] ]
+; CHECK-NEXT:    [[CMP:%.*]] = icmp eq i32 [[IV]], 0
+; CHECK-NEXT:    call void @use(i1 [[CMP]])
+; CHECK-NEXT:    [[IV_NEXT]] = add nuw nsw i32 [[IV]], 1
+; CHECK-NEXT:    br label [[LOOP2:%.*]]
+; CHECK:       loop2:
+; CHECK-NEXT:    br i1 [[C]], label [[LOOP2_LATCH:%.*]], label [[LOOP2_LATCH]]
+; CHECK:       loop2.latch:
+; CHECK-NEXT:    br i1 [[C2]], label [[LOOP_LATCH]], label [[LOOP2]]
+; CHECK:       loop.latch:
+; CHECK-NEXT:    [[EXIT_COND:%.*]] = icmp eq i32 [[IV_NEXT]], [[N]]
+; CHECK-NEXT:    br i1 [[EXIT_COND]], label [[EXIT:%.*]], label [[LOOP]]
+; CHECK:       exit:
+; CHECK-NEXT:    ret void
+;
+entry:
+  br label %loop
+
+loop:
+  %iv = phi i32 [ %iv.next, %loop.latch ], [ 0, %entry ]
+  %cmp = icmp eq i32 %iv, 0
+  call void @use(i1 %cmp)
+  %iv.next = add nuw nsw i32 %iv, 1
+  br label %loop2
+
+loop2:
+  br i1 %c, label %loop2.latch, label %loop2.split
+
+loop2.split:
+  br label %loop2.latch
+
+loop2.latch:
+  br i1 %c2, label %loop.latch, label %loop2
+
+loop.latch:
+  %exit.cond = icmp eq i32 %iv.next, %n
+  br i1 %exit.cond, label %exit, label %loop
+
+exit:
+  ret void
+}
+
+declare void @use(i1)


        


More information about the llvm-commits mailing list