[mlir] Honor IntrHasSideEffects on IntrNoMem LLVM intrinsics (#212760)

`[IntrNoMem, IntrHasSideEffects]` is a perfectly valid intrinsic trait
combination, and MLIR would CSE/DCE those without checking. This mirrors
how LLVM models this, see getEffectiveME in IntrinsicEmitter.cpp
This commit is contained in:
Benjamin Kramer 2026-07-30 14:32:20 +02:00 committed by GitHub
parent e9777c58be
commit dc6cd6a29a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -161,11 +161,15 @@ public:
}
/// Return true if the intrinsic may have side effects, i.e. does not have the
/// `IntrNoMem` property.
/// `IntrNoMem` property or has the `IntrHasSideEffects` property.
bool hasSideEffects() const {
return llvm::none_of(
record.getValueAsListOfDefs(fieldTraits),
[](const Record *r) { return r->getName() == "IntrNoMem"; });
record.getValueAsListOfDefs(fieldTraits),
[](const Record *r) { return r->getName() == "IntrNoMem"; }) ||
llvm::any_of(record.getValueAsListOfDefs(fieldTraits),
[](const Record *r) {
return r->getName() == "IntrHasSideEffects";
});
}
/// Return true if the intrinsic is commutative, i.e. has the respective