[PATCH] D137185: [ConstraintElimination] Do not crash on vector GEP in decomposeGEP

Bjorn Pettersson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 2 02:05:02 PDT 2022


This revision was not accepted when it landed; it landed in state "Needs Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rG44bb4099cd75: [ConstraintElimination] Do not crash on vector GEP in decomposeGEP (authored by bjope).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137185/new/

https://reviews.llvm.org/D137185

Files:
  llvm/lib/Transforms/Scalar/ConstraintElimination.cpp
  llvm/test/Transforms/ConstraintElimination/geps-ptrvector.ll


Index: llvm/test/Transforms/ConstraintElimination/geps-ptrvector.ll
===================================================================
--- /dev/null
+++ llvm/test/Transforms/ConstraintElimination/geps-ptrvector.ll
@@ -0,0 +1,14 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt -passes=constraint-elimination -S %s | FileCheck %s
+
+; Should not crash when GEP pointer operand is a vector.
+define <2 x i1> @test.vectorgep(<2 x ptr> %vec) {
+; CHECK-LABEL: @test.vectorgep(
+; CHECK-NEXT:    [[GEP:%.*]] = getelementptr inbounds i32, <2 x ptr> [[VEC:%.*]], i64 0
+; CHECK-NEXT:    [[COND:%.*]] = icmp ule <2 x ptr> [[GEP]], zeroinitializer
+; CHECK-NEXT:    ret <2 x i1> [[COND]]
+;
+  %gep = getelementptr inbounds i32, <2 x ptr> %vec, i64 0
+  %cond = icmp ule <2 x ptr> %gep, zeroinitializer
+  ret <2 x i1> %cond
+}
Index: llvm/lib/Transforms/Scalar/ConstraintElimination.cpp
===================================================================
--- llvm/lib/Transforms/Scalar/ConstraintElimination.cpp
+++ llvm/lib/Transforms/Scalar/ConstraintElimination.cpp
@@ -209,9 +209,7 @@
              const DataLayout &DL) {
   // Do not reason about pointers where the index size is larger than 64 bits,
   // as the coefficients used to encode constraints are 64 bit integers.
-  unsigned AS =
-      cast<PointerType>(GEP.getPointerOperand()->getType())->getAddressSpace();
-  if (DL.getIndexSizeInBits(AS) > 64)
+  if (DL.getIndexTypeSizeInBits(GEP.getPointerOperand()->getType()) > 64)
     return {};
 
   if (!GEP.isInBounds())


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D137185.472538.patch
Type: text/x-patch
Size: 1571 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221102/199b44fe/attachment.bin>


More information about the llvm-commits mailing list