This is an archive of the discontinued LLVM Phabricator instance.

[ARM] Ensure we update the correct flags in the peephole optimiser
ClosedPublic

Authored by dmgreen on Feb 13 2019, 6:19 AM.

Details

Summary

The Arm peephole optimiser code keeps track of both an MI and a SubAdd that can be
used to optimise away a CMP. In the rare case that both are found and not ruled-out as
valid, we could end up setting the flags on the wrong one.

Instead make sure we are using SubAdd if it exists, as it will be closer to the CMP.

The testcase here is a little theoretical, with a dead def of cpsr. It should hopefully show
the point.

Diff Detail

Event Timeline

dmgreen created this revision.Feb 13 2019, 6:19 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 13 2019, 6:19 AM
dmgreen updated this revision to Diff 186640.Feb 13 2019, 6:29 AM
SjoerdMeijer accepted this revision.Feb 13 2019, 6:44 AM

LGTM, with one nit inline.
Perhaps wait a day in case someone else has comments.

lib/Target/ARM/ARMBaseInstrInfo.cpp
2828

You've already put it in quotes, but perhaps you can describe closer a bit better.

This revision is now accepted and ready to land.Feb 13 2019, 6:44 AM
dmgreen updated this revision to Diff 186678.Feb 13 2019, 8:36 AM

Update comment

This revision was automatically updated to reflect the committed changes.