[PATCH] D94546: [RISCV] Optimize select_cc after fp compare expansion

Jessica Clarke via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 12 12:59:11 PST 2021


jrtc27 added inline comments.


================
Comment at: llvm/lib/Target/RISCV/RISCVISelLowering.cpp:1819-1820
+    // Transform
+    // (select_cc (xor X, 1), 0, setne, trueV, falseV) ->
+    // (select_cc X, 0, seteq, trueV, falseV) if we can prove X is 0/1.
+    // This can occur when legalizing some floating point comparisons.
----------------
Is there a reason not to generalise this to be any condition code and its negation?


================
Comment at: llvm/lib/Target/RISCV/RISCVISelLowering.cpp:1826
+    if (N->getConstantOperandVal(2) == ISD::SETNE && isNullConstant(RHS) &&
+        LHS.getOpcode() == ISD::XOR && LHS.hasOneUse() &&
+        isOneConstant(LHS.getOperand(1)) &&
----------------
Hm, do we need it to have just one use? I could imagine it being better for instruction scheduling to be able to do:
```
%0 = ...
%1 = xor %0, 1
%2 = select_cc %0, 0, seteq, trueV, falseV
%3 = ... %1 ...
```
even though it's not a code size win, though it does come at the expense of slightly increased register pressure.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94546



More information about the llvm-commits mailing list