Skip to content

Commit 2cb3935

Browse files
committed
Reland "[NFC][SROA] speculateSelectInstLoads(): play nice with typed pointers for now"
This reverts commit bf88ba0, relands 9f27f45, but without a bug: we *REALLY* should not be defaulting to address space 0 when address space is not specified...
1 parent 19a004b commit 2cb3935

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

llvm/lib/Transforms/Scalar/SROA.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1511,14 +1511,20 @@ static void speculateSelectInstLoads(SelectInst &SI, LoadInst &LI,
15111511
IRBuilderTy &IRB) {
15121512
LLVM_DEBUG(dbgs() << " original load: " << SI << "\n");
15131513

1514-
IRB.SetInsertPoint(&SI);
15151514
Value *TV = SI.getTrueValue();
15161515
Value *FV = SI.getFalseValue();
15171516
// Replace the given load of the select with a select of two loads.
15181517

15191518
assert(LI.isSimple() && "We only speculate simple loads");
15201519

15211520
IRB.SetInsertPoint(&LI);
1521+
1522+
if (auto *TypedPtrTy = LI.getPointerOperandType();
1523+
!TypedPtrTy->isOpaquePointerTy() && SI.getType() != TypedPtrTy) {
1524+
TV = IRB.CreateBitOrPointerCast(TV, TypedPtrTy, "");
1525+
FV = IRB.CreateBitOrPointerCast(FV, TypedPtrTy, "");
1526+
}
1527+
15221528
LoadInst *TL =
15231529
IRB.CreateAlignedLoad(LI.getType(), TV, LI.getAlign(),
15241530
LI.getName() + ".sroa.speculate.load.true");

0 commit comments

Comments
 (0)