[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:04:04 PDT 2023


rahulana-quic updated this revision to Diff 548929.
rahulana-quic added a comment.

Added test


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,verify -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,13 @@
     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 (!I.getSourceElementType()->isScalableTy()) {
+    Constant *Ptr = Operands[0];
+    auto Indices = ArrayRef(Operands.begin() + 1, Operands.end());
+    Constant *C =
+        ConstantExpr::getGetElementPtr(I.getSourceElementType(), Ptr, Indices);
+    markConstant(&I, C);
+  }
 }
 
 void SCCPInstVisitor::visitStoreInst(StoreInst &SI) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D157590.548929.patch
Type: text/x-patch
Size: 1460 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230810/716bf379/attachment.bin>


More information about the llvm-commits mailing list