[llvm] Decompose gep of complex type struct to its element type (PR #107848)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 27 09:38:03 PDT 2024
================
@@ -2827,13 +2827,16 @@ Instruction *InstCombinerImpl::visitGetElementPtrInst(GetElementPtrInst &GEP) {
bool NSW = GEPOp->hasNoUnsignedSignedWrap();
bool NUW = GEPOp->hasNoUnsignedWrap();
// We'll let instcombine(mul) convert this to a shl if possible.
- auto IntTy = SExtI->getOperand(0)->getType();
- Value *Offset =
- Builder.CreateMul(SExtI->getOperand(0), ConstantInt::get(IntTy, 2),
- SExtI->getName() + ".scale", NUW, NSW);
- return replaceInstUsesWith(
- GEP, Builder.CreateGEP(GepResElTy->getStructElementType(0), PtrOp,
- Offset, "", GEP.getNoWrapFlags()));
+ unsigned EleTypeBytes =
+ GepResElTy->getStructElementType(0)->getScalarSizeInBits() / 8;
+ if (EleTypeBytes > 0) {
----------------
goldsteinn wrote:
Missing test with `{ i1, i1 }`?
https://github.com/llvm/llvm-project/pull/107848
More information about the llvm-commits
mailing list