[llvm] 9f27f45 - [NFC][SROA] `speculateSelectInstLoads()`: play nice with typed pointers for now
Roman Lebedev via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 20 18:17:47 PST 2022
Author: Roman Lebedev
Date: 2022-12-21T05:17:02+03:00
New Revision: 9f27f4536e19e93349b0662338408efe6d1cb2fd
URL: https://github.com/llvm/llvm-project/commit/9f27f4536e19e93349b0662338408efe6d1cb2fd
DIFF: https://github.com/llvm/llvm-project/commit/9f27f4536e19e93349b0662338408efe6d1cb2fd.diff
LOG: [NFC][SROA] `speculateSelectInstLoads()`: play nice with typed pointers for now
As requested in https://reviews.llvm.org/D138238#inline-1356685
Added:
Modified:
llvm/lib/Transforms/Scalar/SROA.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Scalar/SROA.cpp b/llvm/lib/Transforms/Scalar/SROA.cpp
index 1bea80b69bc52..350e8bdc09314 100644
--- a/llvm/lib/Transforms/Scalar/SROA.cpp
+++ b/llvm/lib/Transforms/Scalar/SROA.cpp
@@ -1518,6 +1518,14 @@ static void speculateSelectInstLoads(SelectInst &SI, LoadInst &LI,
assert(LI.isSimple() && "We only speculate simple loads");
+ if (auto *TypedPtrTy = LI.getType()->getPointerTo();
+ SI.getType() != TypedPtrTy) {
+ TV = BitCastInst::CreatePointerBitCastOrAddrSpaceCast(TV, TypedPtrTy, "",
+ &LI);
+ FV = BitCastInst::CreatePointerBitCastOrAddrSpaceCast(FV, TypedPtrTy, "",
+ &LI);
+ }
+
IRB.SetInsertPoint(&LI);
LoadInst *TL =
IRB.CreateAlignedLoad(LI.getType(), TV, LI.getAlign(),
More information about the llvm-commits
mailing list