[PATCH] D146268: [tests] precommit tests for D145846
Allen zhong via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Mar 19 21:42:22 PDT 2023
Allen updated this revision to Diff 506462.
Allen added a comment.
Add more tests according comment
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D146268/new/
https://reviews.llvm.org/D146268
Files:
llvm/test/Transforms/InstCombine/icmp-sub.ll
Index: llvm/test/Transforms/InstCombine/icmp-sub.ll
===================================================================
--- llvm/test/Transforms/InstCombine/icmp-sub.ll
+++ llvm/test/Transforms/InstCombine/icmp-sub.ll
@@ -561,3 +561,85 @@
bb_exit:
ret void
}
+
+; https://alive2.llvm.org/ce/z/D2Aph4
+define i1 @PR60818_ne(i32 %a) {
+; CHECK-LABEL: @PR60818_ne(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[SUB:%.*]] = sub i32 0, [[A:%.*]]
+; CHECK-NEXT: [[CMP:%.*]] = icmp ne i32 [[SUB]], [[A]]
+; CHECK-NEXT: ret i1 [[CMP]]
+;
+entry:
+ %sub = sub i32 0, %a
+ %cmp = icmp ne i32 %sub, %a
+ ret i1 %cmp
+}
+
+define i1 @PR60818_eq(i32 %a) {
+; CHECK-LABEL: @PR60818_eq(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[SUB:%.*]] = sub i32 0, [[A:%.*]]
+; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[SUB]], [[A]]
+; CHECK-NEXT: ret i1 [[CMP]]
+;
+entry:
+ %sub = sub i32 0, %a
+ %cmp = icmp eq i32 %sub, %a
+ ret i1 %cmp
+}
+
+define i1 @PR60818_eq_commuted(i32 %a) {
+; CHECK-LABEL: @PR60818_eq(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[SUB:%.*]] = sub i32 0, [[A:%.*]]
+; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[SUB]], [[A]]
+; CHECK-NEXT: ret i1 [[CMP]]
+;
+entry:
+ %sub = sub i32 0, %a
+ %cmp = icmp eq i32 %a, %sub ; negation on RHS
+ ret i1 %cmp
+}
+
+define <2 x i1> @PR60818_ne_vecotr(<2 x i32> %a) {
+; CHECK-LABEL: @PR60818_eq(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[SUB:%.*]] = sub i32 0, [[A:%.*]]
+; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[SUB]], [[A]]
+; CHECK-NEXT: ret i1 [[CMP]]
+;
+entry:
+ %sub = sub <2 x i32> zeroinitializer, %a
+ %cmp = icmp ne <2 x i32> %a, %sub
+ ret <2 x i1> %cmp
+}
+
+; Negative as multi-use
+define i1 @PR60818_eq_multi_use(i32 %a) {
+; CHECK-LABEL: @PR60818_eq(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[SUB:%.*]] = sub i32 0, [[A:%.*]]
+; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[SUB]], [[A]]
+; CHECK-NEXT: ret i1 [[CMP]]
+;
+entry:
+ %sub = sub i32 0, %a
+ call void @use(i32 %sub) ; add new user
+ %cmp = icmp eq i32 %sub, %a
+ ret i1 %cmp
+}
+
+; Negative as non-equality predicate
+define i1 @PR60818_sgt(i32 %a) {
+; CHECK-LABEL: @PR60818_eq(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[SUB:%.*]] = sub i32 0, [[A:%.*]]
+; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[SUB]], [[A]]
+; CHECK-NEXT: ret i1 [[CMP]]
+;
+entry:
+ %sub = sub i32 0, %a
+ %cmp = icmp sgt i32 %sub, %a
+ ret i1 %cmp
+}
\ No newline at end of file
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D146268.506462.patch
Type: text/x-patch
Size: 2424 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230320/708d2886/attachment.bin>
More information about the llvm-commits
mailing list