1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-26 12:43:36 +01:00

[SROA] convertValue(): we can have <N x iK*> to <M x iQ> cast

Provided test case crashes otherwise.
Much like to the opposite case.
This commit is contained in:
Roman Lebedev 2020-06-25 00:51:18 +03:00
parent 5bd582e3b4
commit 7de805e824
2 changed files with 24 additions and 11 deletions

View File

@ -1757,20 +1757,14 @@ static Value *convertValue(const DataLayout &DL, IRBuilderTy &IRB, Value *V,
NewTy); NewTy);
} }
// See if we need ptrtoint for this type pair. A cast involving both scalars // See if we need ptrtoint for this type pair. May require additional bitcast.
// and vectors requires and additional bitcast.
if (OldTy->isPtrOrPtrVectorTy() && NewTy->isIntOrIntVectorTy()) { if (OldTy->isPtrOrPtrVectorTy() && NewTy->isIntOrIntVectorTy()) {
// Expand <2 x i8*> to i128 --> <2 x i8*> to <2 x i64> to i128 // Expand <2 x i8*> to i128 --> <2 x i8*> to <2 x i64> to i128
if (OldTy->isVectorTy() && !NewTy->isVectorTy())
return IRB.CreateBitCast(IRB.CreatePtrToInt(V, DL.getIntPtrType(OldTy)),
NewTy);
// Expand i8* to <2 x i32> --> i8* to i64 to <2 x i32> // Expand i8* to <2 x i32> --> i8* to i64 to <2 x i32>
if (!OldTy->isVectorTy() && NewTy->isVectorTy()) // Expand <2 x i8*> to <4 x i32> --> <2 x i8*> to <2 x i64> to <4 x i32>
return IRB.CreateBitCast(IRB.CreatePtrToInt(V, DL.getIntPtrType(OldTy)), // Expand i8* to i64 --> i8* to i64 to i64
NewTy); return IRB.CreateBitCast(IRB.CreatePtrToInt(V, DL.getIntPtrType(OldTy)),
NewTy);
return IRB.CreatePtrToInt(V, NewTy);
} }
if (OldTy->isPtrOrPtrVectorTy() && NewTy->isPtrOrPtrVectorTy()) { if (OldTy->isPtrOrPtrVectorTy() && NewTy->isPtrOrPtrVectorTy()) {

View File

@ -70,3 +70,22 @@ define <2 x i8*> @vector_inttoptrbitcast_vector({<16 x i8>, <16 x i8>} %x) {
ret <2 x i8*> %vec ret <2 x i8*> %vec
} }
define <16 x i8> @vector_ptrtointbitcast_vector({<2 x i8*>, <2 x i8*>} %x) {
; CHECK-LABEL: @vector_ptrtointbitcast_vector(
%a = alloca {<2 x i8*>, <2 x i8*>}
; CHECK-NOT: alloca
store {<2 x i8*>, <2 x i8*>} %x, {<2 x i8*>, <2 x i8*>}* %a
; CHECK-NOT: store
%cast = bitcast {<2 x i8*>, <2 x i8*>}* %a to <16 x i8>*
%vec = load <16 x i8>, <16 x i8>* %cast
; CHECK-NOT: load
; CHECK: extractvalue
; CHECK: ptrtoint
; CHECK: bitcast
; CHECK: extractvalue
ret <16 x i8> %vec
}