[flang-commits] [flang] [flang][FIR][Mem2Reg] Add supoort for FIR. (PR #172808)
Kareem Ergawy via flang-commits
flang-commits at lists.llvm.org
Thu Dec 18 22:14:34 PST 2025
================
@@ -2861,6 +2891,40 @@ llvm::SmallVector<mlir::Attribute> fir::LenParamIndexOp::getAttributes() {
// LoadOp
//===----------------------------------------------------------------------===//
+bool fir::LoadOp::loadsFrom(const mlir::MemorySlot &slot) {
+ return getMemref() == slot.ptr;
+}
+
+bool fir::LoadOp::storesTo(const mlir::MemorySlot &slot) { return false; }
+
+mlir::Value fir::LoadOp::getStored(const mlir::MemorySlot &slot,
+ mlir::OpBuilder &builder,
+ mlir::Value reachingDef,
+ const mlir::DataLayout &dataLayout) {
+ return mlir::Value();
+}
+
+bool fir::LoadOp::canUsesBeRemoved(
+ const mlir::MemorySlot &slot,
+ const SmallPtrSetImpl<mlir::OpOperand *> &blockingUses,
+ mlir::SmallVectorImpl<mlir::OpOperand *> &newBlockingUses,
+ const mlir::DataLayout &dataLayout) {
+ if (blockingUses.size() != 1)
+ return false;
+ mlir::Value blockingUse = (*blockingUses.begin())->get();
+ return blockingUse == slot.ptr && getMemref() == slot.ptr &&
+ getType() == slot.elemType;
----------------
ergawy wrote:
nit: Is the type equivalence check redundent here?
https://github.com/llvm/llvm-project/pull/172808
More information about the flang-commits
mailing list