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

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 14 10:01:24 PST 2021


craig.topper added inline comments.


================
Comment at: llvm/lib/Target/RISCV/RISCVISelLowering.cpp:1817
     break;
+  case RISCVISD::SELECT_CC: {
+    // Transform
----------------
lenary wrote:
> We should absolutely document that this expects the condition to be an `xleni` with values corresponding to `getBooleanContents`. This should go where the opcode is defined in RISCVISelLowering.h though.
> 
> Given this seems to be the case, I think this optimization is correct (or as correct as my patch).
> 
> 
The operands of SELECT_CC aren't required to follow getBooleanContents. There is no condition input. The inputs are the left and right hand side of a comparison. Those can have any value. We use MaskedValueIsZero to check if the input to an xor on the LHS has only 2 possible values(0/1). Knowing that tells us the xor is just flipping those 2 values.

For your brcond patch, I think it is true that the condition matches getBooleanContents.


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