[llvm] cfb4c1a - [IndVars] Add test for PR56242 (NFC)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 27 05:54:32 PDT 2022


Author: Nikita Popov
Date: 2022-06-27T14:54:20+02:00
New Revision: cfb4c1a735e9648ead5bf60a1fab4f09b5ee6453

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

LOG: [IndVars] Add test for PR56242 (NFC)

Added: 
    llvm/test/Transforms/IndVarSimplify/pr56242.ll

Modified: 
    

Removed: 
    


################################################################################
diff  --git a/llvm/test/Transforms/IndVarSimplify/pr56242.ll b/llvm/test/Transforms/IndVarSimplify/pr56242.ll
new file mode 100644
index 0000000000000..82e1d2252e760
--- /dev/null
+++ b/llvm/test/Transforms/IndVarSimplify/pr56242.ll
@@ -0,0 +1,49 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt -S -indvars < %s | FileCheck %s
+
+declare void @use(i1)
+
+define void @test(ptr %arr) {
+; CHECK-LABEL: @test(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:    br label [[LOOP_HEADER:%.*]]
+; CHECK:       loop.header:
+; CHECK-NEXT:    [[IV:%.*]] = phi i64 [ [[IV_INC:%.*]], [[LOOP_LATCH:%.*]] ], [ 0, [[ENTRY:%.*]] ]
+; CHECK-NEXT:    [[PTR:%.*]] = getelementptr inbounds i32, ptr [[ARR:%.*]], i64 [[IV]]
+; CHECK-NEXT:    [[V:%.*]] = load i32, ptr [[PTR]], align 4
+; CHECK-NEXT:    [[CMP1:%.*]] = icmp sgt i32 [[V]], 0
+; CHECK-NEXT:    br i1 [[CMP1]], label [[IF:%.*]], label [[LOOP_LATCH]]
+; CHECK:       if:
+; CHECK-NEXT:    call void @use(i1 false)
+; CHECK-NEXT:    br label [[LOOP_LATCH]]
+; CHECK:       loop.latch:
+; CHECK-NEXT:    [[IV_INC]] = add nuw nsw i64 [[IV]], 1
+; CHECK-NEXT:    [[CMP:%.*]] = icmp ult i64 [[IV_INC]], 16
+; CHECK-NEXT:    br i1 [[CMP]], label [[LOOP_HEADER]], label [[EXIT:%.*]]
+; CHECK:       exit:
+; CHECK-NEXT:    ret void
+;
+entry:
+  br label %loop.header
+
+loop.header:
+  %iv = phi i64 [ %iv.inc, %loop.latch ], [ 0, %entry ]
+  %prev = phi i32 [ %v, %loop.latch ], [ 0, %entry ]
+  %ptr = getelementptr inbounds i32, ptr %arr, i64 %iv
+  %v = load i32, ptr %ptr
+  %cmp1 = icmp sgt i32 %v, 0
+  br i1 %cmp1, label %if, label %loop.latch
+
+if:
+  %cmp2 = icmp slt i32 %prev, 0
+  call void @use(i1 %cmp2)
+  br label %loop.latch
+
+loop.latch:
+  %iv.inc = add nuw nsw i64 %iv, 1
+  %cmp = icmp ult i64 %iv.inc, 16
+  br i1 %cmp, label %loop.header, label %exit
+
+exit:
+  ret void
+}


        


More information about the llvm-commits mailing list