[llvm] r354750 - [InstCombine] add test for icmp+add fold; NFC
Sanjay Patel via llvm-commits
llvm-commits at lists.llvm.org
Sun Feb 24 09:31:16 PST 2019
Author: spatel
Date: Sun Feb 24 09:31:15 2019
New Revision: 354750
URL: http://llvm.org/viewvc/llvm-project?rev=354750&view=rev
Log:
[InstCombine] add test for icmp+add fold; NFC
Modified:
llvm/trunk/test/Transforms/InstCombine/uaddo.ll
Modified: llvm/trunk/test/Transforms/InstCombine/uaddo.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/uaddo.ll?rev=354750&r1=354749&r2=354750&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/uaddo.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/uaddo.ll Sun Feb 24 09:31:15 2019
@@ -151,3 +151,32 @@ define i32 @uaddo_wrong_pred2(i32 %x, i3
ret i32 %r
}
+; icmp canonicalization should be consistent for these cases.
+; Either the compare depends on the sum or not.
+
+define i1 @uaddo_1(i8 %x, i8* %p) {
+; CHECK-LABEL: @uaddo_1(
+; CHECK-NEXT: [[A:%.*]] = add i8 [[X:%.*]], 1
+; CHECK-NEXT: store i8 [[A]], i8* [[P:%.*]], align 1
+; CHECK-NEXT: [[C:%.*]] = icmp eq i8 [[A]], 0
+; CHECK-NEXT: ret i1 [[C]]
+;
+ %a = add i8 %x, 1
+ store i8 %a, i8* %p
+ %c = icmp ult i8 %a, 1
+ ret i1 %c
+}
+
+define i1 @uaddo_neg1(i8 %x, i8* %p) {
+; CHECK-LABEL: @uaddo_neg1(
+; CHECK-NEXT: [[A:%.*]] = add i8 [[X:%.*]], -1
+; CHECK-NEXT: store i8 [[A]], i8* [[P:%.*]], align 1
+; CHECK-NEXT: [[C:%.*]] = icmp ne i8 [[X]], 0
+; CHECK-NEXT: ret i1 [[C]]
+;
+ %a = add i8 %x, -1
+ store i8 %a, i8* %p
+ %c = icmp ne i8 %a, -1
+ ret i1 %c
+}
+
More information about the llvm-commits
mailing list