[llvm] 2cb3935 - Reland "[NFC][SROA] `speculateSelectInstLoads()`: play nice with typed pointers for now"
Roman Lebedev via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 21 13:47:56 PST 2022
Author: Roman Lebedev
Date: 2022-12-22T00:47:40+03:00
New Revision: 2cb393590ea537b06fa66e6d847a1159c227a313
URL: https://github.com/llvm/llvm-project/commit/2cb393590ea537b06fa66e6d847a1159c227a313
DIFF: https://github.com/llvm/llvm-project/commit/2cb393590ea537b06fa66e6d847a1159c227a313.diff
LOG: Reland "[NFC][SROA] `speculateSelectInstLoads()`: play nice with typed pointers for now"
This reverts commit bf88ba0f8718c1e89e28e977839ad0a6186d44fe,
relands 9f27f4536e19e93349b0662338408efe6d1cb2fd, but without a bug:
we *REALLY* should not be defaulting to address space 0
when address space is not specified...
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..6c13589cd6eba 100644
--- a/llvm/lib/Transforms/Scalar/SROA.cpp
+++ b/llvm/lib/Transforms/Scalar/SROA.cpp
@@ -1511,7 +1511,6 @@ static void speculateSelectInstLoads(SelectInst &SI, LoadInst &LI,
IRBuilderTy &IRB) {
LLVM_DEBUG(dbgs() << " original load: " << SI << "\n");
- IRB.SetInsertPoint(&SI);
Value *TV = SI.getTrueValue();
Value *FV = SI.getFalseValue();
// Replace the given load of the select with a select of two loads.
@@ -1519,6 +1518,13 @@ static void speculateSelectInstLoads(SelectInst &SI, LoadInst &LI,
assert(LI.isSimple() && "We only speculate simple loads");
IRB.SetInsertPoint(&LI);
+
+ if (auto *TypedPtrTy = LI.getPointerOperandType();
+ !TypedPtrTy->isOpaquePointerTy() && SI.getType() != TypedPtrTy) {
+ TV = IRB.CreateBitOrPointerCast(TV, TypedPtrTy, "");
+ FV = IRB.CreateBitOrPointerCast(FV, TypedPtrTy, "");
+ }
+
LoadInst *TL =
IRB.CreateAlignedLoad(LI.getType(), TV, LI.getAlign(),
LI.getName() + ".sroa.speculate.load.true");
More information about the llvm-commits
mailing list