[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
================
@@ -33,6 +33,11 @@ def rcp_sqrt_to_rsq : GICombineRule<
[{ return matchRcpSqrtToRsq(*${rcp}, ${matchinfo}); }]),
(apply [{ Helper.applyBuildFn(*${rcp}, ${matchinfo}); }])>;
+def fdiv_1_by_sqrt_to_rsq : GICombineRule<
+ (defs root:$root, build_fn_matchinfo:$matchinfo),
+ (match (wip_match_opcode G_FSQRT, G_FDIV):$root,
+ [{ return matchFDivSqrt(*${root}, ${matchinfo}); }]),
+ (apply [{ Helper.applyBuildFn(*${root}, ${matchinfo}); }])>;
----------------
Pierre-vh wrote:
We can't create intrinsics in MIR patterns yet (I always forget to work on it haha), so that needs to stay in C++.
You will need to create your own apply function with the contents of the BuildFn you have below.
- You won't need matchdata, you can directly pass `${x}.getReg()` - `${x}` is a substitution that'll be replaced with a reference to the operand `$x` matched
- You will need to pass the `G_FDIV` inst so you can delete it. You can do that by adding a name to that pattern (just like the wip_match_opcode earlier was named $root). It'll be a `MachineInstr *`.
https://github.com/llvm/llvm-project/pull/78673
More information about the llvm-commits
mailing list