[PATCH] D110076: [AMDGPU][GlobalISel] Code quality: Combine V_RSQ

Mateja Marjanovic via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 4 05:29:51 PDT 2021


matejam added a comment.

In D110076#3108478 <https://reviews.llvm.org/D110076#3108478>, @foad wrote:

>> Added implementation for all possible cases which should be combined into rsq (rcp(sqrt(x)), sqrt(rcp(x)), 1/sqrt(x), sqrt(1/x)).
>
> I thought this would be two separate combines:
>
> 1. (1.0 / x) -> (rcp x)
> 2. (sqrt (rcp x)) or (rcp (sqrt x)) -> (rsq x)
>
> Is there some reason we don't implement the first combine, e.g. because of the precision of the rcp instruction is not good enough? What does SelectionDAG do?

If we run an .ll test which has (1.0 / x), by the time it gets to the amdgpu-postlegalizer-combiner it will be combined into rcp, just like SDAG.
This is a 'fake' case of a .mir test, where we put the (1.0 / x) in the test and let the combiner take care of that.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D110076/new/

https://reviews.llvm.org/D110076



More information about the llvm-commits mailing list