[PATCH] D98449: [RISCV] Add isel-patterns to optimize (a < 1) into bgez

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 12 11:30:11 PST 2021


craig.topper added inline comments.


================
Comment at: llvm/lib/Target/RISCV/RISCVInstrInfo.td:999
           (BGE GPR:$rs1, X0, bb:$imm12)>;
+// Lower (a < 1) as (0 >= a) into the bgez pattern.
+def : Pat<(brcond (XLenVT (setlt GPR:$lhs, 1)), bb:$imm12),
----------------
Isn't this the blez pattern?

The "into" doesn't read right after the "as"

Maybe 
" Lower (a < 1) as (X0 >= a), the blez pattern."


================
Comment at: llvm/test/CodeGen/RISCV/branch.ll:121
+; Check that we use bgez (0 >= X) for X < 1
+test14:
+  %val14 = load volatile i32, i32* %b
----------------
This code is pretty trivially unreachable. The block above jumps over it. I'm a little surprised CodeGenPrepare or UnreachableBlockElim didn't notice that. I'd prefer we make it reachable so it can't break in the future.


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

https://reviews.llvm.org/D98449



More information about the llvm-commits mailing list