[llvm] [DAG] Lower frem of power-2 using div/trunc/mul+sub (PR #91148)

Jay Foad via llvm-commits llvm-commits at lists.llvm.org
Thu May 9 04:10:28 PDT 2024


================
@@ -17289,8 +17289,13 @@ SDValue DAGCombiner::visitFREM(SDNode *N) {
       (Flags.hasNoSignedZeros() || DAG.isKnownNonNegativeFP(N0))) {
     SDValue Div = DAG.getNode(ISD::FDIV, DL, VT, N0, N1);
     SDValue Rnd = DAG.getNode(ISD::FTRUNC, DL, VT, Div);
-    SDValue Mul = DAG.getNode(ISD::FMUL, DL, VT, Rnd, N1);
-    return DAG.getNode(ISD::FSUB, DL, VT, N0, Mul);
+    if (TLI.isFMAFasterThanFMulAndFAdd(DAG.getMachineFunction(), VT)) {
+      return DAG.getNode(ISD::FMA, DL, VT, DAG.getNode(ISD::FNEG, DL, VT, Rnd),
+                         N1, N0);
+    } else {
----------------
jayfoad wrote:

No `else` after `return`

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


More information about the llvm-commits mailing list