[llvm] [InstCombine] Support offsets in `memset` to load forwarding (PR #151924)
Pedro Lobo via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 4 10:04:58 PDT 2025
================
@@ -645,7 +650,11 @@ static Value *getAvailableLoadStore(Instruction *Inst, const Value *Ptr,
// Make sure the read bytes are contained in the memset.
uint64_t LoadSize = LoadTypeSize.getFixedValue();
- if ((Len->getValue() * 8).ult(LoadSize))
+ if ((Len->getValue() * 8).ult(LoadSize + Offset * 8))
+ return nullptr;
+
+ // If there is an offset, make sure the load size is a multiple of 8.
+ if (Offset && LoadSize % 8 != 0)
----------------
pedroclobo wrote:
Right. I forgot loads with those types raise UB (https://alive2.llvm.org/ce/z/2Ws4Xd).
https://github.com/llvm/llvm-project/pull/151924
More information about the llvm-commits
mailing list