[all-commits] [llvm/llvm-project] 141e45: [RISCV] Optimize Branch Comparisons

Sam Elliott via All-commits all-commits at lists.llvm.org
Fri Jan 15 03:33:17 PST 2021


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 141e45b99ca09235b985504e8108dbb3cf210fbd
      https://github.com/llvm/llvm-project/commit/141e45b99ca09235b985504e8108dbb3cf210fbd
  Author: Sam Elliott <selliott at lowrisc.org>
  Date:   2021-01-15 (Fri, 15 Jan 2021)

  Changed paths:
    M llvm/lib/Target/RISCV/RISCVInstrInfo.td
    M llvm/test/CodeGen/RISCV/double-br-fcmp.ll
    M llvm/test/CodeGen/RISCV/float-br-fcmp.ll
    M llvm/test/CodeGen/RISCV/half-br-fcmp.ll

  Log Message:
  -----------
  [RISCV] Optimize Branch Comparisons

I noticed in D94450 that there were quite a few places where we generate
the sequence:
```
  xN <- comparison ...
  xN <- xor xN, 1
  bnez xN, symbol
```

Given we know the XOR will be used by BRCOND, which only looks at the lowest
bit, I think we can remove the XOR and just invert the branch condition in
these cases?

The case mostly seems to come up in floating point tests, where there is often
more logic to combine the results of multiple SETCCs, rather than a single
(BRCOND (SETCC ...) ...).

Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D94535




More information about the All-commits mailing list