[llvm] GlobalISel needs fdiv 1 / sqrt(x) to rsq combine (PR #78673)

Pierre van Houtryve via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 19 00:06:41 PST 2024


https://github.com/Pierre-vh requested changes to this pull request.

You're indeed trying to match something like this:
```
%sqrt:_(s16) = contract G_FSQRT %x
%one:_(s16) = G_FCONSTANT half 1.0
%rsq:_(s16) = contract G_FDIV %one, %sqrt
```

@arsenm posted a few examples in the ticket. Please add them all to a `.mir` file in `test/CodeGen/AMDGPU/GlobalISel` and use `update_mir_test_checks` to generate check lines. This allows you to test your changes because you can just rebuild llc, regen the checks and see what your new combine does.

When adding things to the combiner, I would recommend doing it in a test-driven way. It's very helpful IMO because you can verify changes fast: implement something, build llc, regen the lines

Lastly, once this all looks good, don't forget to run `check-llvm-codegen` to catch issues :)



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


More information about the llvm-commits mailing list