[flang-commits] [flang] [flang][Lower] Reassociate sums containing pure calls (PR #217286)

Tom Eccles via flang-commits flang-commits at lists.llvm.org
Thu Aug 20 03:34:15 PDT 2026


================
@@ -1354,6 +1354,16 @@ struct HasProcedureRefHelper : public AnyTraverse<HasProcedureRefHelper> {
   bool operator()(const ProcedureRef &) const { return true; }
 };
 
+struct HasImpureProcedureRefHelper
+    : public AnyTraverse<HasImpureProcedureRefHelper> {
+  using Base = AnyTraverse<HasImpureProcedureRefHelper>;
+  HasImpureProcedureRefHelper() : Base{*this} {}
+  using Base::operator();
+  bool operator()(const ProcedureRef &ref) const {
+    return ref.proc().IsPure() ? Base::operator()(ref) : true;
+  }
+};
+
----------------
tblah wrote:

Thanks for the review. I was trying to avoid passing a folding context around, but it isn't actually as bad as I imagined. I'll update the patch.

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


More information about the flang-commits mailing list