This is an archive of the discontinued LLVM Phabricator instance.

[PPCMIPeephole] Fix incorrect compare elimination
ClosedPublic

Authored by MaskRay on Apr 23 2023, 1:33 PM.

Details

Reviewers
nemanjai
Group Reviewers
Restricted Project
Commits
rG398d68f624d6: [PPCMIPeephole] Fix incorrect compare elimination
Summary

D38236 moves a redundant compare instruction from the loop body to the
preheader.

It has a bug: when MBB1 == &MBB2, there may be only one compare instruction in the
loop. The code will lift the compare instruction to the preheader, failing to
account for the change of the compare result in a tail call, leading to a miscompile.

Suppress the compare elimination to fix https://github.com/llvm/llvm-project/issues/62294

Diff Detail

Event Timeline

MaskRay created this revision.Apr 23 2023, 1:33 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 23 2023, 1:33 PM
MaskRay requested review of this revision.Apr 23 2023, 1:33 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 23 2023, 1:33 PM
MaskRay edited the summary of this revision. (Show Details)Apr 23 2023, 1:39 PM
q66 added a subscriber: q66.Apr 23 2023, 4:48 PM

this works for me

nemanjai accepted this revision.Apr 24 2023, 4:34 AM

LGTM. Thanks for the fix.

This revision is now accepted and ready to land.Apr 24 2023, 4:34 AM
This revision was landed with ongoing or failed builds.Apr 24 2023, 10:02 AM
This revision was automatically updated to reflect the committed changes.