Skip to content

Commit a98707e

Browse files
authored
[AggressiveInstCombine] Merge consecutive loads of mixed sizes (llvm#129263)
Proof: https://alive2.llvm.org/ce/z/r7M-Sf Closes: llvm#128134
1 parent e1cea0d commit a98707e

File tree

3 files changed

+430
-123
lines changed

3 files changed

+430
-123
lines changed

llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -675,14 +675,15 @@ static bool foldLoadsRecursive(Value *V, LoadOps &LOps, const DataLayout &DL,
675675
Load2Ptr->stripAndAccumulateConstantOffsets(DL, Offset2,
676676
/* AllowNonInbounds */ true);
677677

678-
// Verify if both loads have same base pointers and load sizes are same.
678+
// Verify if both loads have same base pointers
679679
uint64_t LoadSize1 = LI1->getType()->getPrimitiveSizeInBits();
680680
uint64_t LoadSize2 = LI2->getType()->getPrimitiveSizeInBits();
681-
if (Load1Ptr != Load2Ptr || LoadSize1 != LoadSize2)
681+
if (Load1Ptr != Load2Ptr)
682682
return false;
683683

684-
// Support Loadsizes greater or equal to 8bits and only power of 2.
685-
if (LoadSize1 < 8 || !isPowerOf2_64(LoadSize1))
684+
// Make sure that there are no padding bits.
685+
if (!DL.typeSizeEqualsStoreSize(LI1->getType()) ||
686+
!DL.typeSizeEqualsStoreSize(LI2->getType()))
686687
return false;
687688

688689
// Alias Analysis to check for stores b/w the loads.

0 commit comments

Comments
 (0)