[llvm] GlobalISel needs fdiv 1 / sqrt(x) to rsq combine (PR #78673)
Thorsten Schütt via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 19 00:07:28 PST 2024
================
@@ -334,6 +337,59 @@ bool AMDGPUPostLegalizerCombinerImpl::matchRcpSqrtToRsq(
return false;
}
+bool AMDGPUPostLegalizerCombinerImpl::matchFDivSqrt(
+ MachineInstr &MI,
+ std::function<void(MachineIRBuilder &)> &MatchInfo) const {
+
+ // TODO: Can I match fdiv 1.0 / sqrt(x) from here?
+ // My apologies, this code is still a mess. Trying to figure out
+ // what value MI should hold when getting to this point
+
+ auto getSqrtSrc = [=](const MachineInstr &MI) -> MachineInstr * {
----------------
tschuett wrote:
Does not compile, but ...
```
std::optional<FPValueAndVReg > One;
Register SqrtReg;
if (!mi_match(MI.getOperand(1).getReg(), MRI, m_GFCstOrSplat(One)) || !mi_match(MI.getOperand(2).getReg(), MIR, m_OneNonDBGUse (m_GFSqrt(m_Reg(SqrtReg)))
return false;
```
```
https://github.com/llvm/llvm-project/pull/78673
More information about the llvm-commits
mailing list