]> granicus.if.org Git - llvm/commit
[RISCV] Optimize emission of SELECT sequences
authorAlex Bradbury <asb@lowrisc.org>
Fri, 22 Mar 2019 10:45:03 +0000 (10:45 +0000)
committerAlex Bradbury <asb@lowrisc.org>
Fri, 22 Mar 2019 10:45:03 +0000 (10:45 +0000)
commitd580c5bceded7eeeae2516b08dfcc377e70b8c12
tree7434ee900a9229c0babf8666d51cea1f1aef62ce
parent9ac8aecbf9dc032fa7f3f9de4724e41b2e0920a9
[RISCV] Optimize emission of SELECT sequences

This patch optimizes the emission of a sequence of SELECTs with the same
condition, avoiding the insertion of unnecessary control flow. Such a sequence
often occurs when a SELECT of values wider than XLEN is legalized into two
SELECTs with legal types. We have identified several use cases where the
SELECTs could be interleaved with other instructions. Therefore, we extend the
sequence to include non-SELECT instructions if we are able to detect that the
non-SELECT instructions do not impact the optimization.

This patch supersedes https://reviews.llvm.org/D59096, which attempted to
address this issue by introducing a new SelectionDAG node. Hat tip to Eli
Friedman for his feedback on how to best handle this issue.

Differential Revision: https://reviews.llvm.org/D59355
Patch by Luís Marques.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@356741 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Target/RISCV/RISCVISelLowering.cpp
test/CodeGen/RISCV/atomic-rmw.ll
test/CodeGen/RISCV/select-optimize-multiple.ll [new file with mode: 0644]
test/CodeGen/RISCV/select-optimize-multiple.mir [new file with mode: 0644]