[all-commits] [llvm/llvm-project] c44266: [RISCV][NFC] Add Test for (select (or B1, B2), X, Y)

Sam Elliott via All-commits all-commits at lists.llvm.org
Wed Jul 1 03:57:28 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: c44266dc4816ec3df084232055ec02060eec0616
      https://github.com/llvm/llvm-project/commit/c44266dc4816ec3df084232055ec02060eec0616
  Author: Sam Elliott <selliott at lowrisc.org>
  Date:   2020-07-01 (Wed, 01 Jul 2020)

  Changed paths:
    A llvm/test/CodeGen/RISCV/select-and.ll
    A llvm/test/CodeGen/RISCV/select-or.ll

  Log Message:
  -----------
  [RISCV][NFC] Add Test for (select (or B1, B2), X, Y)

Summary:
As shown, LLVM is keen to avoid logic and introduce selects (in DAGCombiner, and
other places). This leads to control flow on RISC-V which we should attempt to
avoid.

Reviewed By: luismarques

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


  Commit: 7dc892661edde4eb90229dd5a14f45a1ceb08653
      https://github.com/llvm/llvm-project/commit/7dc892661edde4eb90229dd5a14f45a1ceb08653
  Author: Sam Elliott <selliott at lowrisc.org>
  Date:   2020-07-01 (Wed, 01 Jul 2020)

  Changed paths:
    M llvm/lib/Target/RISCV/RISCVISelLowering.cpp
    M llvm/test/CodeGen/RISCV/double-previous-failure.ll
    M llvm/test/CodeGen/RISCV/select-and.ll
    M llvm/test/CodeGen/RISCV/select-or.ll
    M llvm/test/CodeGen/RISCV/zext-with-load-is-free.ll

  Log Message:
  -----------
  [RISCV] Implement Hooks to avoid chaining SELECT

Summary:
This implements two hooks that attempt to avoid control flow for RISC-V. RISC-V
will lower SELECTs into control flow, which is not a great idea.

The hook `hasMultipleConditionRegisters()` turns off the following
DAGCombiner folds:
    select(C0|C1, x, y) <=> select(C0, x, select(C1, x, y))
    select(C0&C1, x, y) <=> select(C0, select(C1, x, y), y)

The second hook `setJumpIsExpensive` controls a flag that has a similar purpose
and is used in CodeGenPrepare and the SelectionDAGBuilder.

Both of these have the effect of ensuring more logic is done before fewer jumps.

Note: with the `B` extension, we may be able to lower select into a conditional
move instruction, so at some point these hooks will need to be guarded based on
enabled extensions.

Reviewed By: luismarques

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


Compare: https://github.com/llvm/llvm-project/compare/c79745ed48f3...7dc892661edd


More information about the All-commits mailing list