[llvm] fd73e4d - [CVP] Add more tests for select with overdefined operand (NFC)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Sun Apr 4 04:54:19 PDT 2021
Author: Nikita Popov
Date: 2021-04-04T13:54:06+02:00
New Revision: fd73e4d4b29961d3b7dd8e746cdca9f7a15e1efa
URL: https://github.com/llvm/llvm-project/commit/fd73e4d4b29961d3b7dd8e746cdca9f7a15e1efa
DIFF: https://github.com/llvm/llvm-project/commit/fd73e4d4b29961d3b7dd8e746cdca9f7a15e1efa.diff
LOG: [CVP] Add more tests for select with overdefined operand (NFC)
Also check the case where one operand isn't constant, which isn't
handled right now, because the SPF code requires both operands
to be ranges.
Move the tests to directly check ranges rather than go through an
and, to make it more obvious that this has no relation to bitmasks.
Added:
Modified:
llvm/test/Transforms/CorrelatedValuePropagation/and.ll
llvm/test/Transforms/CorrelatedValuePropagation/basic.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/CorrelatedValuePropagation/and.ll b/llvm/test/Transforms/CorrelatedValuePropagation/and.ll
index 195dd8b9b4d6..66d73f0da2c6 100644
--- a/llvm/test/Transforms/CorrelatedValuePropagation/and.ll
+++ b/llvm/test/Transforms/CorrelatedValuePropagation/and.ll
@@ -124,27 +124,3 @@ continue:
exit:
ret i32 -1
}
-
-define i32 @min_and(i32 %a) {
-; CHECK-LABEL: @min_and(
-; CHECK-NEXT: [[CMP:%.*]] = icmp ult i32 [[A:%.*]], 127
-; CHECK-NEXT: [[SEL:%.*]] = select i1 [[CMP]], i32 [[A]], i32 127
-; CHECK-NEXT: ret i32 [[SEL]]
-;
- %cmp = icmp ult i32 %a, 127
- %sel = select i1 %cmp, i32 %a, i32 127
- %and = and i32 %sel, 127
- ret i32 %and
-}
-
-define i32 @min_and_comm(i32 %a) {
-; CHECK-LABEL: @min_and_comm(
-; CHECK-NEXT: [[CMP:%.*]] = icmp uge i32 [[A:%.*]], 127
-; CHECK-NEXT: [[SEL:%.*]] = select i1 [[CMP]], i32 127, i32 [[A]]
-; CHECK-NEXT: ret i32 [[SEL]]
-;
- %cmp = icmp uge i32 %a, 127
- %sel = select i1 %cmp, i32 127, i32 %a
- %and = and i32 %sel, 127
- ret i32 %and
-}
diff --git a/llvm/test/Transforms/CorrelatedValuePropagation/basic.ll b/llvm/test/Transforms/CorrelatedValuePropagation/basic.ll
index 9748037e8af7..49c6f648ccfc 100644
--- a/llvm/test/Transforms/CorrelatedValuePropagation/basic.ll
+++ b/llvm/test/Transforms/CorrelatedValuePropagation/basic.ll
@@ -524,6 +524,64 @@ out:
ret i1 false
}
+define i1 @umin_lhs_overdefined_rhs_const(i32 %a) {
+; CHECK-LABEL: @umin_lhs_overdefined_rhs_const(
+; CHECK-NEXT: [[CMP:%.*]] = icmp ult i32 [[A:%.*]], 42
+; CHECK-NEXT: [[SEL:%.*]] = select i1 [[CMP]], i32 [[A]], i32 42
+; CHECK-NEXT: ret i1 true
+;
+ %cmp = icmp ult i32 %a, 42
+ %sel = select i1 %cmp, i32 %a, i32 42
+ %cmp2 = icmp ule i32 %sel, 42
+ ret i1 %cmp2
+}
+
+define i1 @umin_rhs_overdefined_lhs_const(i32 %a) {
+; CHECK-LABEL: @umin_rhs_overdefined_lhs_const(
+; CHECK-NEXT: [[CMP:%.*]] = icmp uge i32 [[A:%.*]], 42
+; CHECK-NEXT: [[SEL:%.*]] = select i1 [[CMP]], i32 42, i32 [[A]]
+; CHECK-NEXT: ret i1 true
+;
+ %cmp = icmp uge i32 %a, 42
+ %sel = select i1 %cmp, i32 42, i32 %a
+ %cmp2 = icmp ule i32 %sel, 42
+ ret i1 %cmp2
+}
+
+define i1 @umin_lhs_overdefined_rhs_range(i32 %a, i32 %b) {
+; CHECK-LABEL: @umin_lhs_overdefined_rhs_range(
+; CHECK-NEXT: [[ASSUME:%.*]] = icmp ult i32 [[B:%.*]], 42
+; CHECK-NEXT: call void @llvm.assume(i1 [[ASSUME]])
+; CHECK-NEXT: [[CMP:%.*]] = icmp ult i32 [[A:%.*]], [[B]]
+; CHECK-NEXT: [[SEL:%.*]] = select i1 [[CMP]], i32 [[A]], i32 [[B]]
+; CHECK-NEXT: [[CMP2:%.*]] = icmp ult i32 [[SEL]], 42
+; CHECK-NEXT: ret i1 [[CMP2]]
+;
+ %assume = icmp ult i32 %b, 42
+ call void @llvm.assume(i1 %assume)
+ %cmp = icmp ult i32 %a, %b
+ %sel = select i1 %cmp, i32 %a, i32 %b
+ %cmp2 = icmp ult i32 %sel, 42
+ ret i1 %cmp2
+}
+
+define i1 @umin_rhs_overdefined_lhs_range(i32 %a, i32 %b) {
+; CHECK-LABEL: @umin_rhs_overdefined_lhs_range(
+; CHECK-NEXT: [[ASSUME:%.*]] = icmp ult i32 [[B:%.*]], 42
+; CHECK-NEXT: call void @llvm.assume(i1 [[ASSUME]])
+; CHECK-NEXT: [[CMP:%.*]] = icmp uge i32 [[A:%.*]], [[B]]
+; CHECK-NEXT: [[SEL:%.*]] = select i1 [[CMP]], i32 [[B]], i32 [[A]]
+; CHECK-NEXT: [[CMP2:%.*]] = icmp ult i32 [[SEL]], 42
+; CHECK-NEXT: ret i1 [[CMP2]]
+;
+ %assume = icmp ult i32 %b, 42
+ call void @llvm.assume(i1 %assume)
+ %cmp = icmp uge i32 %a, %b
+ %sel = select i1 %cmp, i32 %b, i32 %a
+ %cmp2 = icmp ult i32 %sel, 42
+ ret i1 %cmp2
+}
+
define i1 @clamp_low1(i32 %a) {
; CHECK-LABEL: @clamp_low1(
; CHECK-NEXT: entry:
More information about the llvm-commits
mailing list