[llvm] aaeae84 - [InstSimplify] add tests for icmp with no-wrap add operand; NFC
Sanjay Patel via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 28 06:52:02 PST 2021
Author: Sanjay Patel
Date: 2021-12-28T09:45:37-05:00
New Revision: aaeae842ef821063c5c6ce5fada4e62967c14b96
URL: https://github.com/llvm/llvm-project/commit/aaeae842ef821063c5c6ce5fada4e62967c14b96
DIFF: https://github.com/llvm/llvm-project/commit/aaeae842ef821063c5c6ce5fada4e62967c14b96.diff
LOG: [InstSimplify] add tests for icmp with no-wrap add operand; NFC
Added:
Modified:
llvm/test/Transforms/InstSimplify/icmp-constant.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/InstSimplify/icmp-constant.ll b/llvm/test/Transforms/InstSimplify/icmp-constant.ll
index 77d4a388c055..0784510a7ae4 100644
--- a/llvm/test/Transforms/InstSimplify/icmp-constant.ll
+++ b/llvm/test/Transforms/InstSimplify/icmp-constant.ll
@@ -623,6 +623,72 @@ define i1 @add_nsw_neg_const1(i32 %x) {
ret i1 %cmp
}
+define i1 @add_nsw_sgt(i8 %x) {
+; CHECK-LABEL: @add_nsw_sgt(
+; CHECK-NEXT: ret i1 true
+;
+ %add = add nsw i8 %x, 5
+ %cmp = icmp sgt i8 %add, -124
+ ret i1 %cmp
+}
+
+define i1 @add_nsw_nuw_sgt(i8 %x) {
+; CHECK-LABEL: @add_nsw_nuw_sgt(
+; CHECK-NEXT: [[ADD:%.*]] = add nuw nsw i8 [[X:%.*]], 5
+; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i8 [[ADD]], -124
+; CHECK-NEXT: ret i1 [[CMP]]
+;
+ %add = add nsw nuw i8 %x, 5
+ %cmp = icmp sgt i8 %add, -124
+ ret i1 %cmp
+}
+
+; minimum x is -128, so add could be -124.
+
+define i1 @add_nsw_sgt_limit(i8 %x) {
+; CHECK-LABEL: @add_nsw_sgt_limit(
+; CHECK-NEXT: [[ADD:%.*]] = add nsw i8 [[X:%.*]], 4
+; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i8 [[ADD]], -124
+; CHECK-NEXT: ret i1 [[CMP]]
+;
+ %add = add nsw i8 %x, 4
+ %cmp = icmp sgt i8 %add, -124
+ ret i1 %cmp
+}
+
+define i1 @add_nsw_slt(i8 %x) {
+; CHECK-LABEL: @add_nsw_slt(
+; CHECK-NEXT: ret i1 false
+;
+ %add = add nsw i8 %x, 5
+ %cmp = icmp slt i8 %add, -123
+ ret i1 %cmp
+}
+
+define i1 @add_nsw_nuw_slt(i8 %x) {
+; CHECK-LABEL: @add_nsw_nuw_slt(
+; CHECK-NEXT: [[ADD:%.*]] = add nuw nsw i8 [[X:%.*]], 5
+; CHECK-NEXT: [[CMP:%.*]] = icmp slt i8 [[ADD]], -123
+; CHECK-NEXT: ret i1 [[CMP]]
+;
+ %add = add nsw nuw i8 %x, 5
+ %cmp = icmp slt i8 %add, -123
+ ret i1 %cmp
+}
+
+; minimum x is -128, so add could be -123.
+
+define i1 @add_nsw_slt_limit(i8 %x) {
+; CHECK-LABEL: @add_nsw_slt_limit(
+; CHECK-NEXT: [[ADD:%.*]] = add nsw i8 [[X:%.*]], 5
+; CHECK-NEXT: [[CMP:%.*]] = icmp slt i8 [[ADD]], -122
+; CHECK-NEXT: ret i1 [[CMP]]
+;
+ %add = add nsw i8 %x, 5
+ %cmp = icmp slt i8 %add, -122
+ ret i1 %cmp
+}
+
; InstCombine can fold this, but not InstSimplify.
define i1 @add_nsw_neg_const2(i32 %x) {
More information about the llvm-commits
mailing list