[PATCH] D27389: ConstantFolding: Don't crash when encountering vector GEP
Phabricator via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 8 09:33:02 PST 2016
This revision was automatically updated to reflect the committed changes.
Closed by commit rL289073: ConstantFolding: Don't crash when encountering vector GEP (authored by kfischer).
Changed prior to commit:
https://reviews.llvm.org/D27389?vs=80197&id=80775#toc
Repository:
rL LLVM
https://reviews.llvm.org/D27389
Files:
llvm/trunk/lib/Analysis/ConstantFolding.cpp
llvm/trunk/test/Analysis/ConstantFolding/vectorgep-crash.ll
Index: llvm/trunk/test/Analysis/ConstantFolding/vectorgep-crash.ll
===================================================================
--- llvm/trunk/test/Analysis/ConstantFolding/vectorgep-crash.ll
+++ llvm/trunk/test/Analysis/ConstantFolding/vectorgep-crash.ll
@@ -0,0 +1,19 @@
+; RUN: opt -instcombine -S -o - %s | FileCheck %s
+; Tests that we don't crash upon encountering a vector GEP
+
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+%Dual = type { %Dual.72, %Partials.73 }
+%Dual.72 = type { double, %Partials }
+%Partials = type { [2 x double] }
+%Partials.73 = type { [2 x %Dual.72] }
+
+; Function Attrs: sspreq
+define <8 x i64*> @"julia_axpy!_65480"(%Dual* %arg1, <8 x i64> %arg2) {
+top:
+; CHECK: %VectorGep14 = getelementptr inbounds %Dual, %Dual* %arg1, <8 x i64> %arg2, i32 1, i32 0, i64 0, i32 1, i32 0, i64 0
+ %VectorGep14 = getelementptr inbounds %Dual, %Dual* %arg1, <8 x i64> %arg2, i32 1, i32 0, i64 0, i32 1, i32 0, i64 0
+ %0 = bitcast <8 x double*> %VectorGep14 to <8 x i64*>
+ ret <8 x i64*> %0
+}
Index: llvm/trunk/lib/Analysis/ConstantFolding.cpp
===================================================================
--- llvm/trunk/lib/Analysis/ConstantFolding.cpp
+++ llvm/trunk/lib/Analysis/ConstantFolding.cpp
@@ -734,14 +734,15 @@
Type *ResultTy, Optional<unsigned> InRangeIndex,
const DataLayout &DL, const TargetLibraryInfo *TLI) {
Type *IntPtrTy = DL.getIntPtrType(ResultTy);
+ Type *IntPtrScalarTy = IntPtrTy->getScalarType();
bool Any = false;
SmallVector<Constant*, 32> NewIdxs;
for (unsigned i = 1, e = Ops.size(); i != e; ++i) {
if ((i == 1 ||
- !isa<StructType>(GetElementPtrInst::getIndexedType(SrcElemTy,
- Ops.slice(1, i - 1)))) &&
- Ops[i]->getType() != IntPtrTy) {
+ !isa<StructType>(GetElementPtrInst::getIndexedType(
+ SrcElemTy, Ops.slice(1, i - 1)))) &&
+ Ops[i]->getType() != (i == 1 ? IntPtrTy : IntPtrScalarTy)) {
Any = true;
NewIdxs.push_back(ConstantExpr::getCast(CastInst::getCastOpcode(Ops[i],
true,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D27389.80775.patch
Type: text/x-patch
Size: 2232 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161208/18f928df/attachment-0001.bin>
More information about the llvm-commits
mailing list