[llvm] 0b302be - [Transforms] Pre-commit test cases for CorrelatedValuePropagation to handle both values of select
Dmitry Vassiliev via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 22 12:12:11 PST 2022
Author: Dmitry Vassiliev
Date: 2022-02-23T00:10:05+04:00
New Revision: 0b302be023388e7cec2daf680a3ea6718c6af53f
URL: https://github.com/llvm/llvm-project/commit/0b302be023388e7cec2daf680a3ea6718c6af53f
DIFF: https://github.com/llvm/llvm-project/commit/0b302be023388e7cec2daf680a3ea6718c6af53f.diff
LOG: [Transforms] Pre-commit test cases for CorrelatedValuePropagation to handle both values of select
This is a pre-commit of test cases relevant for D119643.
CorrelatedValuePropagation should handle inverted select condition, but it does not yet.
Added:
Modified:
llvm/test/Transforms/CorrelatedValuePropagation/basic.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/CorrelatedValuePropagation/basic.ll b/llvm/test/Transforms/CorrelatedValuePropagation/basic.ll
index aa1d305f63bb6..024ff29d363ec 100644
--- a/llvm/test/Transforms/CorrelatedValuePropagation/basic.ll
+++ b/llvm/test/Transforms/CorrelatedValuePropagation/basic.ll
@@ -143,6 +143,67 @@ return:
ret void
}
+; "false" case for CorrelatedValuePropagation
+define void @loop1(i32* %x, i32* %y) {
+; CHECK-LABEL: @loop1(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: br label [[LOOP:%.*]]
+; CHECK: loop:
+; CHECK-NEXT: [[PHI:%.*]] = phi i32* [ [[F:%.*]], [[LOOP]] ], [ [[X:%.*]], [[ENTRY:%.*]] ]
+; CHECK-NEXT: [[F]] = tail call i32* @f(i32* [[PHI]])
+; CHECK-NEXT: [[CMP1:%.*]] = icmp ne i32* [[F]], [[Y:%.*]]
+; CHECK-NEXT: [[SEL:%.*]] = select i1 [[CMP1]], i32* [[F]], i32* null
+; CHECK-NEXT: [[CMP2:%.*]] = icmp eq i32* [[SEL]], null
+; CHECK-NEXT: br i1 [[CMP2]], label [[RETURN:%.*]], label [[LOOP]]
+; CHECK: return:
+; CHECK-NEXT: ret void
+;
+entry:
+ br label %loop
+
+loop:
+ %phi = phi i32* [ %sel, %loop ], [ %x, %entry ]
+ %f = tail call i32* @f(i32* %phi)
+ %cmp1 = icmp ne i32* %f, %y
+ %sel = select i1 %cmp1, i32* %f, i32* null
+ %cmp2 = icmp eq i32* %sel, null
+ br i1 %cmp2, label %return, label %loop
+
+return:
+ ret void
+}
+
+; "true" case for CorrelatedValuePropagation
+define void @loop2(i32* %x, i32* %y) {
+; CHECK-LABEL: @loop2(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: br label [[LOOP:%.*]]
+; CHECK: loop:
+;; CorrelatedValuePropagation should handle inverted select condition, but it does not yet.
+;; CHECK-NEXT: [[PHI:%.*]] = phi i32* [ [[F:%.*]], [[LOOP]] ], [ [[X:%.*]], [[ENTRY:%.*]] ]
+; CHECK-NEXT: [[F:%.*]] = tail call i32* @f(i32* [[PHI]])
+; CHECK-NEXT: [[CMP1:%.*]] = icmp eq i32* [[F]], [[Y:%.*]]
+; CHECK-NEXT: [[SEL:%.*]] = select i1 [[CMP1]], i32* null, i32* [[F]]
+; CHECK-NEXT: [[CMP2:%.*]] = icmp eq i32* [[SEL]], null
+; CHECK-NEXT: br i1 [[CMP2]], label [[RETURN:%.*]], label [[LOOP]]
+; CHECK: return:
+; CHECK-NEXT: ret void
+;
+entry:
+ br label %loop
+
+loop:
+ %phi = phi i32* [ %sel, %loop ], [ %x, %entry ]
+ %f = tail call i32* @f(i32* %phi)
+ %cmp1 = icmp eq i32* %f, %y
+ %sel = select i1 %cmp1, i32* null, i32* %f
+ %cmp2 = icmp eq i32* %sel, null
+ br i1 %cmp2, label %return, label %loop
+
+return:
+ ret void
+}
+
define i32 @switch1(i32 %s) {
; CHECK-LABEL: @switch1(
; CHECK-NEXT: entry:
More information about the llvm-commits
mailing list