[llvm] 759bab0 - [InstCombine] Add tests for folding `(icmp eq/ne (add nuw x, y), 0)`; NFC
Noah Goldstein via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 9 11:56:44 PDT 2024
Author: Noah Goldstein
Date: 2024-04-09T13:56:28-05:00
New Revision: 759bab068157d93a71ef20dc28a2eaed4fec6d40
URL: https://github.com/llvm/llvm-project/commit/759bab068157d93a71ef20dc28a2eaed4fec6d40
DIFF: https://github.com/llvm/llvm-project/commit/759bab068157d93a71ef20dc28a2eaed4fec6d40.diff
LOG: [InstCombine] Add tests for folding `(icmp eq/ne (add nuw x, y), 0)`; NFC
Added:
Modified:
llvm/test/Transforms/InstCombine/icmp-add.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/InstCombine/icmp-add.ll b/llvm/test/Transforms/InstCombine/icmp-add.ll
index b99ed20d7d431c..6f990890dbb2cf 100644
--- a/llvm/test/Transforms/InstCombine/icmp-add.ll
+++ b/llvm/test/Transforms/InstCombine/icmp-add.ll
@@ -3003,4 +3003,28 @@ define i1 @icmp_dec_notnonzero(i8 %x) {
ret i1 %c
}
+define i1 @icmp_addnuw_nonzero(i8 %x, i8 %y) {
+; CHECK-LABEL: @icmp_addnuw_nonzero(
+; CHECK-NEXT: [[I:%.*]] = sub i8 0, [[Y:%.*]]
+; CHECK-NEXT: [[C:%.*]] = icmp eq i8 [[I]], [[X:%.*]]
+; CHECK-NEXT: ret i1 [[C]]
+;
+ %i = add nuw i8 %x, %y
+ %c = icmp eq i8 %i, 0
+ ret i1 %c
+}
+
+define i1 @icmp_addnuw_nonzero_fail_multiuse(i32 %x, i32 %y) {
+; CHECK-LABEL: @icmp_addnuw_nonzero_fail_multiuse(
+; CHECK-NEXT: [[I:%.*]] = add nuw i32 [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT: [[C:%.*]] = icmp eq i32 [[I]], 0
+; CHECK-NEXT: call void @use(i32 [[I]])
+; CHECK-NEXT: ret i1 [[C]]
+;
+ %i = add nuw i32 %x, %y
+ %c = icmp eq i32 %i, 0
+ call void @use(i32 %i)
+ ret i1 %c
+}
+
declare void @llvm.assume(i1)
More information about the llvm-commits
mailing list