Skip to content

Commit ddf7cc2

Browse files
committed
[SROA] Remove unnecessary IsStorePastEnd handling (NFCI)
Unlike the load case, stores past the end of the alloca are removed by SROA as undefined behavior. As such, there is no need to handle this case when rewriting stores.
1 parent 188d5c7 commit ddf7cc2

File tree

1 file changed

+1
-17
lines changed

1 file changed

+1
-17
lines changed

llvm/lib/Transforms/Scalar/SROA.cpp

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2891,26 +2891,10 @@ class llvm::sroa::AllocaSliceRewriter
28912891
if (IntTy && V->getType()->isIntegerTy())
28922892
return rewriteIntegerStore(V, SI, AATags);
28932893

2894-
const bool IsStorePastEnd =
2895-
DL.getTypeStoreSize(V->getType()).getFixedValue() > SliceSize;
28962894
StoreInst *NewSI;
28972895
if (NewBeginOffset == NewAllocaBeginOffset &&
28982896
NewEndOffset == NewAllocaEndOffset &&
2899-
(canConvertValue(DL, V->getType(), NewAllocaTy) ||
2900-
(IsStorePastEnd && NewAllocaTy->isIntegerTy() &&
2901-
V->getType()->isIntegerTy()))) {
2902-
// If this is an integer store past the end of slice (and thus the bytes
2903-
// past that point are irrelevant or this is unreachable), truncate the
2904-
// value prior to storing.
2905-
if (auto *VITy = dyn_cast<IntegerType>(V->getType()))
2906-
if (auto *AITy = dyn_cast<IntegerType>(NewAllocaTy))
2907-
if (VITy->getBitWidth() > AITy->getBitWidth()) {
2908-
if (DL.isBigEndian())
2909-
V = IRB.CreateLShr(V, VITy->getBitWidth() - AITy->getBitWidth(),
2910-
"endian_shift");
2911-
V = IRB.CreateTrunc(V, AITy, "load.trunc");
2912-
}
2913-
2897+
canConvertValue(DL, V->getType(), NewAllocaTy)) {
29142898
V = convertValue(DL, IRB, V, NewAllocaTy);
29152899
Value *NewPtr =
29162900
getPtrToNewAI(SI.getPointerAddressSpace(), SI.isVolatile());

0 commit comments

Comments
 (0)