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.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Please remove the typed pointer test case. I'm willing to accept the patch at this time, but not the test case.
llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp | ||
---|---|---|
814 | Checking for opaque pointers is not necessary, the bitcast will just not be emitted in that case. | |
817 | You can sue getPointerAddressSpace() here and save the cast. | |
824 | Extract the IntegerType into a variable for reuse. It is used a third time in the isTypeLegal check above. |
llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp | ||
---|---|---|
816 | We already have the Pointer Address space defined for the Load Instruction. So the below should suffice Type *NewTy = IntegerType::get(Load1Ptr->getContext(), LOps.LoadSize); Value *NewPtr = Builder.CreateBitCast(Load1Ptr, NewTy->getPointerTo()); NewLoad = Builder.CreateAlignedLoad(NewTy, NewPtr, LI1->getAlign(), LI1->isVolatile(), ""); |
llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp | ||
---|---|---|
816 | I don't think that's entirely correct, use still need to pass AS to getPointerTo(). |
Checking for opaque pointers is not necessary, the bitcast will just not be emitted in that case.