[llvm] [GlobalISel] Look between instructions to be matched (PR #101675)
Pierre van Houtryve via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 2 06:51:50 PDT 2024
================
@@ -70,6 +70,35 @@ bool GIMatchTableExecutor::isObviouslySafeToFold(MachineInstr &MI,
if (MI.isConvergent() && MI.getParent() != IntoMI.getParent())
return false;
- return !MI.mayLoadOrStore() && !MI.mayRaiseFPException() &&
- !MI.hasUnmodeledSideEffects() && MI.implicit_operands().empty();
+ if (!MI.mayLoadOrStore() && !MI.mayRaiseFPException() &&
+ !MI.hasUnmodeledSideEffects() && MI.implicit_operands().empty()) {
+ return true;
+ }
+
+ // If the load is simple, check instructions between MI and IntoMI
+ auto CurrMI = MI.getIterator();
+ if (MI.mayLoad() && MI.getParent() == IntoMI.getParent()) {
+ if (MI.memoperands_empty())
+ return false;
+ auto MMO = **(MI.memoperands_begin());
+ if (MMO.isAtomic() || MMO.isVolatile())
+ return false;
+
+ // Ensure instructions between MI and IntoMI sare not affected when combined
+ for (unsigned i = 1; i < 15 && CurrMI != IntoMI.getIterator(); i++) {
----------------
Pierre-vh wrote:
Why 15 exactly?
https://github.com/llvm/llvm-project/pull/101675
More information about the llvm-commits
mailing list