This is an archive of the discontinued LLVM Phabricator instance.

[ARM] don't transform an add(ext Cond), C to select unless there's a setcc of the condition
ClosedPublic

Authored by spatel on Feb 24 2017, 2:23 PM.

Details

Summary

The transform in question claims to be doing:

// fold (add (select cc, 0, c), x) -> (select cc, x, (add, x, c))

...starting in PerformADDCombineWithOperands(), but it wasn't actually checking for a setcc node for the sext/zext patterns.

This is exactly the opposite of a transform I'd like to add to DAGCombiner's foldSelectOfConstants(), so I was seeing infinite loops with my draft of a patch applied.

Selecting condition-flag-setting instructions (ands/adds) in "test_tst_assessment" may be a separate bug?

Diff Detail

Repository
rL LLVM

Event Timeline

spatel created this revision.Feb 24 2017, 2:23 PM
efriedma edited edge metadata.Feb 24 2017, 3:37 PM

Selecting condition-flag-setting instructions (ands/adds) in "test_tst_assessment" may be a separate bug?

That testcase definitely isn't testing what it's supposed to test anymore. Can you change it to generate approximately the same code as before? (Basically something like "a &= 3; return b & 3 ? a : a-1;".)

The change essentially looks fine; the point of the transform is to favor a predicated operation over a predicated mov, but that only makes sense if we were actually going to generate a predicated move in the first place.

lib/Target/ARM/ARMISelLowering.cpp
9166 ↗(On Diff #89721)

How can "!CC.getNode()" possibly be true? CC was just set on the previous line.

spatel updated this revision to Diff 89892.Feb 27 2017, 9:09 AM

Patch updated based on Eli's feedback (thanks!):

  1. Don't check CC.getNode() because that's obviously unnecessary.
  2. Change "test_tst_assessment" to preserve the intent of that test (now there's only a diff for a thumb target).

Patch updated based on Eli's feedback (thanks!):

  1. Don't check CC.getNode() because that's obviously unnecessary.
  2. Change "test_tst_assessment" to preserve the intent of that test (now there's only a diff for a thumb target).

Actually, there's no diff on that test from the proposed code change in this patch, so I should commit that before this patch as an independent change?

efriedma accepted this revision.Feb 27 2017, 12:01 PM

LGTM.

Actually, there's no diff on that test from the proposed code change in this patch, so I should commit that before this patch as an independent change?

If you want; doesn't really matter either way.

This revision is now accepted and ready to land.Feb 27 2017, 12:01 PM
This revision was automatically updated to reflect the committed changes.