Skip to content

Commit

Permalink
[NFC][SROA] rewriteMemOpOfSelect(): play nice with typed pointers f…
Browse files Browse the repository at this point in the history
  • Loading branch information
LebedevRI committed Dec 12, 2022
1 parent fc7b8e7 commit fd21361
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions llvm/lib/Transforms/Scalar/SROA.cpp
Expand Up @@ -1596,8 +1596,13 @@ static void rewriteMemOpOfSelect(SelectInst &SI, T &I,
++NumLoadsSpeculated;
auto &CondMemOp = cast<T>(*I.clone());
CondMemOp.insertBefore(NewMemOpBB->getTerminator());
CondMemOp.setOperand(I.getPointerOperandIndex(),
SI.getOperand(1 + SuccIdx));
Value *Ptr = SI.getOperand(1 + SuccIdx);
if (auto *PtrTy = Ptr->getType();
!PtrTy->isOpaquePointerTy() &&
PtrTy != CondMemOp.getPointerOperandType())
Ptr = BitCastInst::CreatePointerBitCastOrAddrSpaceCast(
Ptr, CondMemOp.getPointerOperandType(), "", &CondMemOp);
CondMemOp.setOperand(I.getPointerOperandIndex(), Ptr);
if (isa<LoadInst>(I)) {
CondMemOp.setName(I.getName() + (IsThen ? ".then" : ".else") + ".val");
PN->addIncoming(&CondMemOp, NewMemOpBB);
Expand Down

0 comments on commit fd21361

Please sign in to comment.