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

Jay Foad via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 19 05:50:14 PST 2024


jayfoad wrote:

> 1. is the MIR I am trying to match against
>    `%sqrt:_(s16) = contract G_FSQRT %x`
>    ` %one:_(s16) = G_FCONSTANT half 1.0`
>    `%rsq:_(s16) = contract G_FDIV %one, %sqrt`
>    ?

Slightly off-topic, but why do we need to match against 1.0? Wouldn't it be better to combine `y/sqrt(x)` into `y*rsq(x)` for all `y`, and then later optimize away the multiply if `y` happened to be 1.0?

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


More information about the llvm-commits mailing list