This is an archive of the discontinued LLVM Phabricator instance.

[SelectionDAG] Make SelectionDAG aware of the known bits in UADDO and SADDO.
ClosedPublic

Authored by deadalnix on Feb 25 2017, 8:33 AM.

Diff Detail

Repository
rL LLVM

Event Timeline

deadalnix created this revision.Feb 25 2017, 8:33 AM
deadalnix updated this revision to Diff 89794.Feb 25 2017, 9:10 AM

Regenerate some tests in master to reduce noise in this diff.

deadalnix updated this revision to Diff 89824.Feb 26 2017, 5:30 PM

Fix the ISD::SUB case, which needs to was threated as ADDE. It is probably possible to do somethign better, but it's good enough for now.

jyknight edited edge metadata.Feb 27 2017, 2:02 PM

The multiple fall-throughs make this confusing. Since there's now three different properties that need to be checked (ADD vs SUB, carry-result vs no carry-result, carry-in vs no carry-in), a single fallthrough chain isn't really sufficient. I'd put all of the variants for all kinds of ADD/SUB in one case section, with ifs for the parts that need to be distinguished from each-other.

Should also move USUBO and SSUBO support down with the ADD/SUB variants, and treat them appropriately.

Also, ought to fix the exact same issue that occurs in ComputeNumSignBits for these operations.

deadalnix updated this revision to Diff 89954.Feb 27 2017, 4:45 PM

Simplify the sub logic.

RKSimon added inline comments.Mar 5 2017, 2:21 AM
lib/CodeGen/SelectionDAG/SelectionDAG.cpp
2505 ↗(On Diff #89954)

Add some description comments

2508 ↗(On Diff #89954)

Worth doing an early out here if KnownZeroLow == 0?

2513 ↗(On Diff #89954)

KnownZero.setBits(0, KnownZeroLow);

2523 ↗(On Diff #89954)

KnownZero.setBits(1, BitWidth);

2555 ↗(On Diff #89954)

KnownZero.setBit(1, KnownZeroLow);

deadalnix updated this revision to Diff 90628.Mar 5 2017, 4:46 PM
  • Add comment for the sub case.
  • Bail out early when KnownZeroLow == 0
  • Use setBits
deadalnix updated this revision to Diff 90629.Mar 5 2017, 5:13 PM

More setBits

RKSimon accepted this revision.Mar 10 2017, 6:10 AM

LGTM with a couple of minors

lib/CodeGen/SelectionDAG/SelectionDAG.cpp
2579 ↗(On Diff #90629)

KnownZero.setLowBits ?

2581 ↗(On Diff #90629)

KnownZero.setHighBits ?

This revision is now accepted and ready to land.Mar 10 2017, 6:10 AM
deadalnix updated this revision to Diff 91354.Mar 10 2017, 8:18 AM

Use setLowBits and setHighBits

LGTM - thanks.

This revision was automatically updated to reflect the committed changes.