This is an archive of the discontinued LLVM Phabricator instance.

[PowerPC] Fix the check for the instruction using FRSP/XSRSP output register
ClosedPublic

Authored by NeHuang on Jan 14 2021, 12:28 PM.

Details

Summary

When performing peephole optimization to simplify the code, after removing passed FPSP/XSRSP instruction we will set any uses of that FRSP/XSRSP to the source of the FRSP/XSRSP.

We are finding the machine instruction using virtual register holding FRSP/XSRSP results by searching all following instructions. We are encountering an issue that the first use of the virtual register is a debug MI causing two issues

  • virtual register in the debug MI removed unexpectedly
  • virtual register used in non-debug MI not replaced with the source of FRSP/XSRSP. which stays in a undef status.

This patch fix the issue by only searching non-debug machine instruction using virtual register holding FRSP/XSRSP results

Diff Detail

Event Timeline

NeHuang created this revision.Jan 14 2021, 12:28 PM
NeHuang requested review of this revision.Jan 14 2021, 12:28 PM
nemanjai requested changes to this revision.Jan 14 2021, 12:37 PM

Test case is missing. Please add it.

This revision now requires changes to proceed.Jan 14 2021, 12:37 PM
NeHuang updated this revision to Diff 317105.Jan 15 2021, 4:13 PM

Thanks @nemanjai. Test case added.

nemanjai added inline comments.Jan 18 2021, 8:58 AM
llvm/test/CodeGen/PowerPC/non-debug-mi-search-frspxsrsp.ll
2

Why this triple? It won't crash with that triple even without this fix.
It should be -mtriple=powerpc64le-unknown-linux-gnu

NeHuang updated this revision to Diff 317412.EditedJan 18 2021, 1:14 PM

Address review comment in the test case.

nemanjai accepted this revision.Jan 18 2021, 3:47 PM

LGTM with a couple more minor nits about the test case.

llvm/test/CodeGen/PowerPC/non-debug-mi-search-frspxsrsp.ll
57

The extraneous attributes can be removed. You only need nounwind for #0 and you don't need #1 at all.

65

The directory may lead someone to conclude that the test case comes from FFMPEG based on the directory you happen to have the file. However this is not the case, please remove the directory name to avoid confusion.

This revision is now accepted and ready to land.Jan 18 2021, 3:47 PM
NeHuang updated this revision to Diff 317549.Jan 19 2021, 6:51 AM

Address comments in the test case.

NeHuang marked 3 inline comments as done.Jan 19 2021, 6:51 AM
NeHuang closed this revision.Mar 8 2021, 6:18 AM

Patch committed on Jan 19, 2021
Commit hash: 909d6c86eae32ef350ac35ba8564ed728544ac63