[llvm] 1ad5898 - [ConstraintElimination] Add test that crash in earlier var handling.
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 7 01:33:36 PDT 2022
Author: Florian Hahn
Date: 2022-10-07T09:31:45+01:00
New Revision: 1ad58989ee75842e260eb9ecf0e3e758156548c9
URL: https://github.com/llvm/llvm-project/commit/1ad58989ee75842e260eb9ecf0e3e758156548c9
DIFF: https://github.com/llvm/llvm-project/commit/1ad58989ee75842e260eb9ecf0e3e758156548c9.diff
LOG: [ConstraintElimination] Add test that crash in earlier var handling.
Add a test that caused a crash in the new variable handling code in
earlier versions.
Added:
Modified:
llvm/test/Transforms/ConstraintElimination/loops-header-tested-pointer-cmps.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/ConstraintElimination/loops-header-tested-pointer-cmps.ll b/llvm/test/Transforms/ConstraintElimination/loops-header-tested-pointer-cmps.ll
index 1c4ff692e200e..b5daafc16ffc3 100644
--- a/llvm/test/Transforms/ConstraintElimination/loops-header-tested-pointer-cmps.ll
+++ b/llvm/test/Transforms/ConstraintElimination/loops-header-tested-pointer-cmps.ll
@@ -760,3 +760,48 @@ loop.latch.2:
exit:
ret void
}
+
+; Test case that exposed a crash in the earlier NewVariables handling code.
+define void @test_only_some_new_variables_may_be_0(ptr %A, ptr %start) {
+; CHECK-LABEL: @test_only_some_new_variables_may_be_0(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[A_10:%.*]] = getelementptr inbounds i32, ptr [[A:%.*]], i64 10
+; CHECK-NEXT: br label [[HEADER:%.*]]
+; CHECK: header:
+; CHECK-NEXT: [[IV:%.*]] = phi i64 [ 0, [[ENTRY:%.*]] ], [ [[IV_NEXT:%.*]], [[LATCH:%.*]] ]
+; CHECK-NEXT: [[A_IV:%.*]] = getelementptr i32, ptr [[A]], i64 [[IV]]
+; CHECK-NEXT: [[C_1:%.*]] = icmp ult ptr [[A_IV]], [[A_10]]
+; CHECK-NEXT: [[C_2:%.*]] = icmp uge ptr [[A_IV]], [[START:%.*]]
+; CHECK-NEXT: [[AND:%.*]] = and i1 [[C_1]], [[C_2]]
+; CHECK-NEXT: br i1 [[AND]], label [[LATCH]], label [[EXIT:%.*]]
+; CHECK: latch:
+; CHECK-NEXT: call void @clobber()
+; CHECK-NEXT: [[IV_NEXT]] = add nsw i64 [[IV]], -1
+; CHECK-NEXT: [[CMP_NOT_I:%.*]] = icmp eq i64 [[IV]], 0
+; CHECK-NEXT: br i1 [[CMP_NOT_I]], label [[HEADER]], label [[EXIT]]
+; CHECK: exit:
+; CHECK-NEXT: ret void
+;
+entry:
+ %A.10 = getelementptr inbounds i32, ptr %A, i64 10
+ br label %header
+
+header:
+ %iv = phi i64 [ 0, %entry ], [ %iv.next, %latch ]
+ %A.iv = getelementptr i32, ptr %A, i64 %iv
+ %c.1 = icmp ult ptr %A.iv, %A.10
+ %c.2 = icmp uge ptr %A.iv, %start
+ %and = and i1 %c.1, %c.2
+ br i1 %and, label %latch, label %exit
+
+latch:
+ call void @clobber()
+ %iv.next = add nsw i64 %iv, -1
+ %cmp.not.i = icmp eq i64 %iv, 0
+ br i1 %cmp.not.i, label %header, label %exit
+
+exit:
+ ret void
+}
+
+declare void @clobber()
More information about the llvm-commits
mailing list