[PATCH] D139289: [SCCP] Propagate equality of a not-constant
luxufan via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 5 03:25:08 PST 2022
StephenFan updated this revision to Diff 480038.
StephenFan retitled this revision from "[SCCP] Propagate equality or inequality state of a not-constant" to "[SCCP] Propagate equality of a not-constant".
StephenFan edited the summary of this revision.
StephenFan added a comment.
Update title.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D139289/new/
https://reviews.llvm.org/D139289
Files:
llvm/lib/Transforms/Utils/SCCPSolver.cpp
llvm/test/Transforms/SCCP/conditions-ranges.ll
Index: llvm/test/Transforms/SCCP/conditions-ranges.ll
===================================================================
--- llvm/test/Transforms/SCCP/conditions-ranges.ll
+++ llvm/test/Transforms/SCCP/conditions-ranges.ll
@@ -1370,6 +1370,37 @@
ret void
}
+define i32 @equal_not_constant(ptr noundef %p, ptr noundef %q) {
+; CHECK-LABEL: @equal_not_constant(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[CMP:%.*]] = icmp ne ptr [[P:%.*]], null
+; CHECK-NEXT: br i1 [[CMP]], label [[IF_THEN:%.*]], label [[IF_END:%.*]]
+; CHECK: if.then:
+; CHECK-NEXT: [[CMP_THEN:%.*]] = icmp eq ptr [[P]], [[Q:%.*]]
+; CHECK-NEXT: br i1 [[CMP_THEN]], label [[IF_THEN1:%.*]], label [[IF_END]]
+; CHECK: if.then1:
+; CHECK-NEXT: call void @use(i1 true)
+; CHECK-NEXT: br label [[IF_END]]
+; CHECK: if.end:
+; CHECK-NEXT: ret i32 0
+;
+entry:
+ %cmp = icmp ne ptr %p, null
+ br i1 %cmp, label %if.then, label %if.end
+
+if.then: ; preds = %entry
+ %cmp.then = icmp eq ptr %p, %q
+ br i1 %cmp.then, label %if.then1, label %if.end
+
+if.then1: ; preds = %if.then
+ %cmp.then1 = icmp ne ptr %q, null
+ call void @use(i1 %cmp.then1)
+ br label %if.end
+
+if.end:
+ ret i32 0
+}
+
define i1 @ptr_icmp_data_layout() {
; CHECK-LABEL: @ptr_icmp_data_layout(
; CHECK-NEXT: ret i1 false
Index: llvm/lib/Transforms/Utils/SCCPSolver.cpp
===================================================================
--- llvm/lib/Transforms/Utils/SCCPSolver.cpp
+++ llvm/lib/Transforms/Utils/SCCPSolver.cpp
@@ -1313,9 +1313,10 @@
IV, &CB,
ValueLatticeElement::getRange(NewCR, /*MayIncludeUndef*/ false));
return;
- } else if (Pred == CmpInst::ICMP_EQ && CondVal.isConstant()) {
+ } else if (Pred == CmpInst::ICMP_EQ &&
+ (CondVal.isConstant() || CondVal.isNotConstant())) {
// For non-integer values or integer constant expressions, only
- // propagate equal constants.
+ // propagate equal constants or not-constants.
addAdditionalUser(OtherOp, &CB);
mergeInValue(IV, &CB, CondVal);
return;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D139289.480038.patch
Type: text/x-patch
Size: 2197 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221205/949a984d/attachment.bin>
More information about the llvm-commits
mailing list