[Mlir-commits] [mlir] [MLIR][LLVM] Fold extract of constant (PR #127927)
Christian Ulmann
llvmlistbot at llvm.org
Wed Feb 19 22:54:53 PST 2025
================
@@ -1932,6 +1932,20 @@ OpFoldResult LLVM::ExtractValueOp::fold(FoldAdaptor adaptor) {
getContainerMutable().set(extractValueOp.getContainer());
return getResult();
}
+
+ {
+ DenseElementsAttr constval;
+ matchPattern(getContainer(), m_Constant(&constval));
+ if (constval && constval.getElementType() == getType()) {
+ if (isa<SplatElementsAttr>(constval)) {
+ return constval.getSplatValue<Attribute>();
+ }
----------------
Dinistro wrote:
```suggestion
if (isa<SplatElementsAttr>(constval))
return constval.getSplatValue<Attribute>();
```
https://github.com/llvm/llvm-project/pull/127927
More information about the Mlir-commits
mailing list