@@ -447,14 +447,8 @@ LoadInst *InstCombiner::combineLoadToNewType(LoadInst &LI, Type *NewTy,
447
447
NewPtr->getType ()->getPointerAddressSpace () == AS))
448
448
NewPtr = Builder.CreateBitCast (Ptr, NewTy->getPointerTo (AS));
449
449
450
- // If old load did not have an explicit alignment specified,
451
- // manually preserve the implied (ABI) alignment of the load.
452
- // Else we may inadvertently incorrectly over-promise alignment.
453
- const auto Align =
454
- getDataLayout ().getValueOrABITypeAlignment (LI.getAlign (), LI.getType ());
455
-
456
450
LoadInst *NewLoad = Builder.CreateAlignedLoad (
457
- NewTy, NewPtr, Align , LI.isVolatile (), LI.getName () + Suffix);
451
+ NewTy, NewPtr, LI. getAlign () , LI.isVolatile (), LI.getName () + Suffix);
458
452
NewLoad->setAtomic (LI.getOrdering (), LI.getSyncScopeID ());
459
453
copyMetadataForLoad (*NewLoad, LI);
460
454
return NewLoad;
@@ -656,8 +650,7 @@ static Instruction *unpackLoadToAggregate(InstCombiner &IC, LoadInst &LI) {
656
650
if (SL->hasPadding ())
657
651
return nullptr ;
658
652
659
- const auto Align = DL.getValueOrABITypeAlignment (LI.getAlign (), ST);
660
-
653
+ const auto Align = LI.getAlign ();
661
654
auto *Addr = LI.getPointerOperand ();
662
655
auto *IdxType = Type::getInt32Ty (T->getContext ());
663
656
auto *Zero = ConstantInt::get (IdxType, 0 );
@@ -705,7 +698,7 @@ static Instruction *unpackLoadToAggregate(InstCombiner &IC, LoadInst &LI) {
705
698
706
699
const DataLayout &DL = IC.getDataLayout ();
707
700
auto EltSize = DL.getTypeAllocSize (ET);
708
- const auto Align = DL. getValueOrABITypeAlignment ( LI.getAlign (), T );
701
+ const auto Align = LI.getAlign ();
709
702
710
703
auto *Addr = LI.getPointerOperand ();
711
704
auto *IdxType = Type::getInt64Ty (T->getContext ());
@@ -945,14 +938,8 @@ Instruction *InstCombiner::visitLoadInst(LoadInst &LI) {
945
938
// Attempt to improve the alignment.
946
939
Align KnownAlign = getOrEnforceKnownAlignment (
947
940
Op, DL.getPrefTypeAlign (LI.getType ()), DL, &LI, &AC, &DT);
948
- MaybeAlign LoadAlign = LI.getAlign ();
949
- Align EffectiveLoadAlign =
950
- LoadAlign ? *LoadAlign : DL.getABITypeAlign (LI.getType ());
951
-
952
- if (KnownAlign > EffectiveLoadAlign)
941
+ if (KnownAlign > LI.getAlign ())
953
942
LI.setAlignment (KnownAlign);
954
- else if (LoadAlign == 0 )
955
- LI.setAlignment (EffectiveLoadAlign);
956
943
957
944
// Replace GEP indices if possible.
958
945
if (Instruction *NewGEPI = replaceGEPIdxWithZero (*this , Op, LI)) {
@@ -1179,7 +1166,7 @@ static bool unpackStoreToAggregate(InstCombiner &IC, StoreInst &SI) {
1179
1166
if (SL->hasPadding ())
1180
1167
return false ;
1181
1168
1182
- const auto Align = DL. getValueOrABITypeAlignment ( SI.getAlign (), ST );
1169
+ const auto Align = SI.getAlign ();
1183
1170
1184
1171
SmallString<16 > EltName = V->getName ();
1185
1172
EltName += " .elt" ;
@@ -1225,7 +1212,7 @@ static bool unpackStoreToAggregate(InstCombiner &IC, StoreInst &SI) {
1225
1212
1226
1213
const DataLayout &DL = IC.getDataLayout ();
1227
1214
auto EltSize = DL.getTypeAllocSize (AT->getElementType ());
1228
- const auto Align = DL. getValueOrABITypeAlignment ( SI.getAlign (), T );
1215
+ const auto Align = SI.getAlign ();
1229
1216
1230
1217
SmallString<16 > EltName = V->getName ();
1231
1218
EltName += " .elt" ;
@@ -1350,14 +1337,8 @@ Instruction *InstCombiner::visitStoreInst(StoreInst &SI) {
1350
1337
// Attempt to improve the alignment.
1351
1338
const Align KnownAlign = getOrEnforceKnownAlignment (
1352
1339
Ptr, DL.getPrefTypeAlign (Val->getType ()), DL, &SI, &AC, &DT);
1353
- const MaybeAlign StoreAlign = SI.getAlign ();
1354
- const Align EffectiveStoreAlign =
1355
- StoreAlign ? *StoreAlign : DL.getABITypeAlign (Val->getType ());
1356
-
1357
- if (KnownAlign > EffectiveStoreAlign)
1340
+ if (KnownAlign > SI.getAlign ())
1358
1341
SI.setAlignment (KnownAlign);
1359
- else if (!StoreAlign)
1360
- SI.setAlignment (EffectiveStoreAlign);
1361
1342
1362
1343
// Try to canonicalize the stored type.
1363
1344
if (unpackStoreToAggregate (*this , SI))
0 commit comments