[llvm] [GlobalISel] replace right identity X * -1.0 with fneg(x) (PR #80526)

Pierre van Houtryve via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 8 06:22:11 PST 2024


Pierre-vh wrote:

> I believe that we should move to a visitOpcode model like the Dag combiner eventually. If this combine is registered before, `constant_fold_fp_binop`, then we get a `fneg`. Otherwise, we may have gotten a constant for `fmul 1000,0 * -1`.

No, a `visitOpcode` model would be a regression compared to what we have now, IMHO.

I agree we need a way to tell the combiner which combine goes first. Currently I _think_ it's decided by the order in which the combines appear in the list, but I don't think it's actually enforced much (well, a bunch of tests check the match table as a whole so if its order changes, those tests will fail).

We can achieve ordering differently:

- Use a system like AddedComplexity, maybe with a bit more syntactic sugar, to tell which combine goes first.
- Allow a combine to explicitly mention some dependencies so it can't run unless something else has been checked first (probably overkill)
- etc.

Is it a concern/issue currently? Do we have bugs due to combine ordering?
If so, please create an issue. I don't mind looking into it and coming up with more detail proposals

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


More information about the llvm-commits mailing list