This is an archive of the discontinued LLVM Phabricator instance.

[AArch64] Fix comparison peephole opt with non-0/1 immediate (PR51476)
ClosedPublic

Authored by nikic on Aug 14 2021, 2:51 PM.

Details

Summary

This is a non-intrusive fix for https://bugs.llvm.org/show_bug.cgi?id=51476 intended for backport to the 13.x release branch. It expands on the current hack by distinguishing between CmpValue of 0, 1 and 2, where 0 and 1 have the obvious meaning and 2 means "anything else". The new optimization from D98564 should only be performed for CmpValue of 0 or 1.

For main, I think we should switch the analyzeCompare() + optimizeCompare() APIs to use int64_t instead of int, which is in line with MachineOperand's notion of an immediate, and avoids this problem altogether.

Diff Detail

Event Timeline

nikic created this revision.Aug 14 2021, 2:51 PM
nikic requested review of this revision.Aug 14 2021, 2:51 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 14 2021, 2:51 PM
dmgreen accepted this revision.Aug 15 2021, 12:10 AM

This sounds good to me. Thanks for the fix.
I like the idea of using int64_t in the long run, and in the short term this LGTM.

This revision is now accepted and ready to land.Aug 15 2021, 12:10 AM
This revision was landed with ongoing or failed builds.Aug 15 2021, 3:42 AM
This revision was automatically updated to reflect the committed changes.