[Mlir-commits] [mlir] [MLIR][LLVM][Mem2Reg] Extends support for partial stores (PR #89740)
Tobias Gysi
llvmlistbot at llvm.org
Tue Apr 23 06:03:55 PDT 2024
================
@@ -224,20 +245,67 @@ static Value createConversionSequence(RewriterBase &rewriter, Location loc,
}
// Now cast the integer to the actual target type if required.
- if (isa<LLVM::LLVMPointerType>(targetType))
- replacement =
- rewriter.createOrFold<LLVM::IntToPtrOp>(loc, targetType, replacement);
- else if (replacement.getType() != targetType)
- replacement =
- rewriter.createOrFold<LLVM::BitcastOp>(loc, targetType, replacement);
-
- return replacement;
+ return convertIntValueToType(rewriter, loc, replacement, targetType);
}
Value LLVM::StoreOp::getStored(const MemorySlot &slot, RewriterBase &rewriter,
+ Value reachingDef,
const DataLayout &dataLayout) {
- return createConversionSequence(rewriter, getLoc(), getValue(), slot.elemType,
- dataLayout);
+ uint64_t valueTypeSize = dataLayout.getTypeSizeInBits(getValue().getType());
+ uint64_t slotTypeSize = dataLayout.getTypeSizeInBits(slot.elemType);
+ if (slotTypeSize <= valueTypeSize)
+ return createConversionSequence(rewriter, getLoc(), getValue(),
+ slot.elemType, dataLayout);
+
+ assert(reachingDef && reachingDef.getType() == slot.elemType &&
+ "expected the reaching definition's type to slot's type");
----------------
gysit wrote:
```suggestion
"expected the reaching definition's type to match the slot's type");
```
nit: could this be at the beginning of the function. I assume this should always be true?
https://github.com/llvm/llvm-project/pull/89740
More information about the Mlir-commits
mailing list