[PATCH] D157590: [SCCP] Do not attempt to create constexpr for a scalable vector GEP
Rahul Anand Radhakrishnan via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 10 02:36:19 PDT 2023
rahulana-quic updated this revision to Diff 548939.
rahulana-quic added a comment.
Update the check to see if the GEP is constant-foldable.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D157590/new/
https://reviews.llvm.org/D157590
Files:
llvm/lib/Transforms/Utils/SCCPSolver.cpp
llvm/test/Transforms/SCCP/vscale-gep.ll
Index: llvm/test/Transforms/SCCP/vscale-gep.ll
===================================================================
--- /dev/null
+++ llvm/test/Transforms/SCCP/vscale-gep.ll
@@ -0,0 +1,11 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt < %s -passes=sccp -S | FileCheck %s
+
+define ptr @scalable_vector_getelementptr(i64 %x) {
+; CHECK-LABEL: @scalable_vector_getelementptr(
+; CHECK-NEXT: [[PTR:%.*]] = getelementptr <vscale x 4 x i32>, ptr null, i64 1
+; CHECK-NEXT: ret ptr [[PTR]]
+;
+ %ptr = getelementptr <vscale x 4 x i32>, ptr null, i64 1
+ ret ptr %ptr
+}
Index: llvm/lib/Transforms/Utils/SCCPSolver.cpp
===================================================================
--- llvm/lib/Transforms/Utils/SCCPSolver.cpp
+++ llvm/lib/Transforms/Utils/SCCPSolver.cpp
@@ -1539,11 +1539,8 @@
return (void)markOverdefined(&I);
}
- Constant *Ptr = Operands[0];
- auto Indices = ArrayRef(Operands.begin() + 1, Operands.end());
- Constant *C =
- ConstantExpr::getGetElementPtr(I.getSourceElementType(), Ptr, Indices);
- markConstant(&I, C);
+ if (Constant *C = ConstantFoldInstOperands(&I, Operands, DL))
+ markConstant(&I, C);
}
void SCCPInstVisitor::visitStoreInst(StoreInst &SI) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D157590.548939.patch
Type: text/x-patch
Size: 1258 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230810/81be8d5b/attachment.bin>
More information about the llvm-commits
mailing list