[all-commits] [llvm/llvm-project] ccbb4c: [RISCV] Fold (RISCVISD::SELECT_CC X, Y, CC, Z, Z) ...
Craig Topper via All-commits
all-commits at lists.llvm.org
Wed Sep 1 12:38:09 PDT 2021
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: ccbb4c8b4ffd00588f0c21c7e5208bf210b26a53
https://github.com/llvm/llvm-project/commit/ccbb4c8b4ffd00588f0c21c7e5208bf210b26a53
Author: Craig Topper <craig.topper at sifive.com>
Date: 2021-09-01 (Wed, 01 Sep 2021)
Changed paths:
M llvm/lib/Target/RISCV/RISCVISelLowering.cpp
M llvm/test/CodeGen/RISCV/rvv/rvv-vscale.i64.ll
Log Message:
-----------
[RISCV] Fold (RISCVISD::SELECT_CC X, Y, CC, Z, Z) -> Z.
If the true and false values are the same, we don't need a SELECT_CC.
This would normally be folded before a select is legalized to
select_cc. The test case exploits the late legalization of vscale
to trigger a case where they become identical after legalization.
This works around an issue found on a test case in D107957. In that
case the true/false values were both eventually 0 and the select was
used by a vector AVL operand. The select_cc got expanded to control
flow and a phi, but the phi inputs were both copies from X0. MachineIR
optimizations simplified this to a single copy from X0 going into the
vector instruction. This became the input of a vsetvli after vsetvli
insertion. Then register coalescing folded the copy into the vsetvli.
X0 as the source of a vsetvli is a special encoding and should not be
created by coalesing. We need to fix our vsetvli handling to make sure
this can never happen any other way, but removing the unneeded select
is still a worthwhile optimization.
More information about the All-commits
mailing list