[flang-commits] [flang] [flang][Lower] Add alternative real expression lowering (PR #207371)

Tom Eccles via flang-commits flang-commits at lists.llvm.org
Tue Jul 7 03:43:28 PDT 2026


tblah wrote:

 > FWIW, we could try using `llvm.arithmetic.fence` for `fir.no_ressoc` conversion, so that we can enable LLVM reassociation intra-statement only. I believe @eugeneepshteyn has experimented with something like this before.

Thanks for this. I vibe coded a prototype but the results weren't as good as I hoped. I don't think the middle end and aarch64 back end are capable of optimising this case:
1) The loop vectorizer currently refuses to vectorise the arithmetic fence
2) Even with the vectoriser patched, llvm doesn't actually do much reassociation even with the reassoc flags (maybe it is limited by the arithmetic fence bounding the expression, I'm not sure). It leaves the expression as a mostly left-fold chain so the inter-loop arithmetic dependency from the self-update isn't improved: `x = (x + y) + ...`.

The branch I was testing: https://github.com/llvm/llvm-project/compare/main...tblah:llvm-project:ecclescake/reassoc-experiment

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


More information about the flang-commits mailing list