[MachineCSE] Use TargetInstrInfo::isAsCheapAsAMove in isPRECandidate.
authorCraig Topper <craig.topper@sifive.com>
Wed, 31 Aug 2022 22:05:35 +0000 (15:05 -0700)
committerCraig Topper <craig.topper@sifive.com>
Wed, 31 Aug 2022 22:39:41 +0000 (15:39 -0700)
commit77dbc5200bb5bf8fbf42d6f183599c2ae9575f29
tree618dd066d12ef260880f91ab6e3fa0bf1df0bf35
parent53d1ae88f8b52c73654d08f72f03e63c0352ac00
[MachineCSE] Use TargetInstrInfo::isAsCheapAsAMove in isPRECandidate.

Some targets like RISC-V require operands to be inspected to
determine if an instruction is similar to a move.

Spotted while investigating code differences between using an ADDI
vs an ADDIW. RISC-V has the isAsCheapAsAMove flag for ADDI, but
the TII hook checks the immediate is 0 or the register is X0. ADDIW
is never generated with X0 or with an immediate of 0 so it doesn't
have the isAsCheapAsAMove flag.

I don't know enough about the PRE code to write a test for this yet.

Reviewed By: reames

Differential Revision: https://reviews.llvm.org/D132981
llvm/lib/CodeGen/MachineCSE.cpp