[Mlir-commits] [mlir] Folding extract_strided_metadata input into reinterpret_cast on constant layout (PR #134845)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Tue Apr 8 14:00:03 PDT 2025


================
@@ -1973,6 +1994,22 @@ OpFoldResult ReinterpretCastOp::fold(FoldAdaptor /*operands*/) {
   return nullptr;
 }
 
+bool ReinterpretCastOp::isLayoutConstant() {
+  if (llvm::all_of(
+          getOffsets(),
+          [](OpFoldResult val) { return isConstantIntValue(val, 0); }) &&
----------------
ivangarcia44 wrote:

I moved the folding code into the ReinterpretCastOpExtractStridedMetadataFolder structure, that worked already with the expand_strided_metadata / reinterpret_cast pair. With this move, I was able to make the fold unconditionally. With this I don't need the isLayoutConstant method anymore (removed it).



https://github.com/llvm/llvm-project/pull/134845


More information about the Mlir-commits mailing list