This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Use analyzeBranch in RISCVRedundantCopyElimination.
ClosedPublic

Authored by craig.topper on Aug 21 2022, 10:06 PM.

Details

Summary

The existing code was incorrect if we had more than one conditional
branch instruction in a basic block. Though I don't think that will
occur, using analyzeBranch detects that as an unsupported case.

Overall this results in simpler code in RISCVRedundantCopyElimination.

Diff Detail

Event Timeline

craig.topper created this revision.Aug 21 2022, 10:06 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 21 2022, 10:06 PM
craig.topper requested review of this revision.Aug 21 2022, 10:06 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 21 2022, 10:06 PM
kito-cheng added inline comments.Aug 22 2022, 1:13 AM
llvm/lib/Target/RISCV/RISCVRedundantCopyElimination.cpp
157

CondBr is gone, maybe we need to update this comment.

reames accepted this revision.Aug 22 2022, 8:00 AM

LGTM w/the comment change already pointed out.

llvm/lib/Target/RISCV/RISCVRedundantCopyElimination.cpp
123

The reserved register check can be pulled out of the loop and become an early return. Not related to this change, just noticed while glancing at the code. Might be worth a separate cleanup change.

This revision is now accepted and ready to land.Aug 22 2022, 8:00 AM
craig.topper planned changes to this revision.Aug 22 2022, 8:31 AM
craig.topper added inline comments.
llvm/lib/Target/RISCV/RISCVRedundantCopyElimination.cpp
151

This line is wrong. It’s a copy of the operand not a reference to the original operand. This doesn’t change the original instruction

craig.topper updated this revision to Diff 455309.EditedAug 24 2022, 11:42 AM

Use getFirstTerminator to find the CondBr instruction. Add asserts to make sure
it matches what analyzeBranch found.

This revision is now accepted and ready to land.Aug 24 2022, 11:42 AM
craig.topper requested review of this revision.Aug 25 2022, 9:15 AM
kito-cheng accepted this revision.Aug 25 2022, 11:45 PM
This revision is now accepted and ready to land.Aug 25 2022, 11:45 PM
This revision was landed with ongoing or failed builds.Aug 29 2022, 9:06 AM
This revision was automatically updated to reflect the committed changes.