[llvm-branch-commits] [llvm] efa9728 - [ConstraintElimination] Decompose GEP %ptr, SHL().
Florian Hahn via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Tue Dec 1 03:03:23 PST 2020
Author: Florian Hahn
Date: 2020-12-01T10:58:36Z
New Revision: efa9728a50012c9ead2b0110620e8865b36bef73
URL: https://github.com/llvm/llvm-project/commit/efa9728a50012c9ead2b0110620e8865b36bef73
DIFF: https://github.com/llvm/llvm-project/commit/efa9728a50012c9ead2b0110620e8865b36bef73.diff
LOG: [ConstraintElimination] Decompose GEP %ptr, SHL().
Add support the decompose a GEP with an SHL operand.
Added:
Modified:
llvm/lib/Transforms/Scalar/ConstraintElimination.cpp
llvm/test/Transforms/ConstraintElimination/geps.ll
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp b/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp
index 608ef5337842..5c806b6e5486 100644
--- a/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp
+++ b/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp
@@ -57,6 +57,14 @@ static SmallVector<std::pair<int64_t, Value *>, 4> decompose(Value *V) {
nullptr},
{1, GEP->getPointerOperand()}};
}
+ Value *Op0;
+ ConstantInt *CI;
+ if (match(GEP->getOperand(GEP->getNumOperands() - 1),
+ m_NUWShl(m_Value(Op0), m_ConstantInt(CI))))
+ return {{0, nullptr},
+ {1, GEP->getPointerOperand()},
+ {pow(2, CI->getSExtValue()), Op0}};
+
return {{0, nullptr},
{1, GEP->getPointerOperand()},
{1, GEP->getOperand(GEP->getNumOperands() - 1)}};
diff --git a/llvm/test/Transforms/ConstraintElimination/geps.ll b/llvm/test/Transforms/ConstraintElimination/geps.ll
index ed013ed2c961..52aea974294b 100644
--- a/llvm/test/Transforms/ConstraintElimination/geps.ll
+++ b/llvm/test/Transforms/ConstraintElimination/geps.ll
@@ -387,7 +387,7 @@ define void @test.ult.gep.shl(i32* readonly %src, i32* readnone %max, i32 %idx,
; CHECK-NEXT: [[IDX_SHL_1:%.*]] = shl nuw i32 [[IDX]], 1
; CHECK-NEXT: [[ADD_PTR_SHL_1:%.*]] = getelementptr inbounds i32, i32* [[SRC]], i32 [[IDX_SHL_1]]
; CHECK-NEXT: [[C_MAX_0:%.*]] = icmp ult i32* [[ADD_PTR_SHL_1]], [[MAX]]
-; CHECK-NEXT: call void @use(i1 [[C_MAX_0]])
+; CHECK-NEXT: call void @use(i1 true)
; CHECK-NEXT: [[IDX_SHL_2:%.*]] = shl nuw i32 [[IDX]], 2
; CHECK-NEXT: [[ADD_PTR_SHL_2:%.*]] = getelementptr inbounds i32, i32* [[SRC]], i32 [[IDX_SHL_2]]
; CHECK-NEXT: [[C_MAX_1:%.*]] = icmp ult i32* [[ADD_PTR_SHL_2]], [[MAX]]
More information about the llvm-branch-commits
mailing list