This is an archive of the discontinued LLVM Phabricator instance.

[MachineCSE] Use TargetInstrInfo::isAsCheapAsAMove in isPRECandidate.
ClosedPublic

Authored by craig.topper on Aug 30 2022, 3:45 PM.

Details

Summary

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.

Diff Detail

Event Timeline

craig.topper created this revision.Aug 30 2022, 3:45 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 30 2022, 3:45 PM
craig.topper requested review of this revision.Aug 30 2022, 3:45 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 30 2022, 3:45 PM

Looks like this was previously submitted as D113885

reames accepted this revision.Aug 31 2022, 3:00 PM
This revision is now accepted and ready to land.Aug 31 2022, 3:00 PM
This revision was landed with ongoing or failed builds.Aug 31 2022, 3:39 PM
This revision was automatically updated to reflect the committed changes.