[llvm] d1d7d22 - [AggressiveInstCombine] Fix cases where non-opaque pointers are used
David Stuttard via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 5 05:44:06 PDT 2022
Author: David Stuttard
Date: 2022-10-05T13:42:46+01:00
New Revision: d1d7d2235ced0a959bf0d2513f8adc50c0e5efd8
URL: https://github.com/llvm/llvm-project/commit/d1d7d2235ced0a959bf0d2513f8adc50c0e5efd8
DIFF: https://github.com/llvm/llvm-project/commit/d1d7d2235ced0a959bf0d2513f8adc50c0e5efd8.diff
LOG: [AggressiveInstCombine] Fix cases where non-opaque pointers are used
In the case of non-opaque pointers, when combining consecutive loads,
need to bitcast the pointer source to the combined type size, otherwise
asserts are triggered.
Differential Revision: https://reviews.llvm.org/D135249
Added:
Modified:
llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp b/llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp
index 359aa286572c2..0ac9881a5a710 100644
--- a/llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp
+++ b/llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp
@@ -795,9 +795,9 @@ static bool foldConsecutiveLoads(Instruction &I, const DataLayout &DL,
IRBuilder<> Builder(&I);
LoadInst *NewLoad = nullptr, *LI1 = LOps.Root;
+ IntegerType *WiderType = IntegerType::get(I.getContext(), LOps.LoadSize);
// TTI based checks if we want to proceed with wider load
- bool Allowed =
- TTI.isTypeLegal(IntegerType::get(I.getContext(), LOps.LoadSize));
+ bool Allowed = TTI.isTypeLegal(WiderType);
if (!Allowed)
return false;
@@ -811,9 +811,9 @@ static bool foldConsecutiveLoads(Instruction &I, const DataLayout &DL,
// New load can be generated
Value *Load1Ptr = LI1->getPointerOperand();
Builder.SetInsertPoint(LI1);
- NewLoad = Builder.CreateAlignedLoad(
- IntegerType::get(Load1Ptr->getContext(), LOps.LoadSize), Load1Ptr,
- LI1->getAlign(), LI1->isVolatile(), "");
+ Value *NewPtr = Builder.CreateBitCast(Load1Ptr, WiderType->getPointerTo(AS));
+ NewLoad = Builder.CreateAlignedLoad(WiderType, NewPtr, LI1->getAlign(),
+ LI1->isVolatile(), "");
NewLoad->takeName(LI1);
// Set the New Load AATags Metadata.
if (LOps.AATags)
More information about the llvm-commits
mailing list