This is an archive of the discontinued LLVM Phabricator instance.

[DAGCombine] Add (sext_in_reg (zext x)) -> (sext x) combine
ClosedPublic

Authored by RKSimon on Dec 6 2016, 8:28 AM.

Details

Summary

Handle the case where a sign extension has ended up being split into separate stages (typically to get around vector legal ops) and a zext + sext_in_reg gets inserted.

Diff Detail

Repository
rL LLVM

Event Timeline

RKSimon updated this revision to Diff 80424.Dec 6 2016, 8:28 AM
RKSimon retitled this revision from to [DAGCombine] Add (sext_in_reg (zext x)) -> (sext x) combine.
RKSimon updated this object.
RKSimon added reviewers: mkuper, delena, spatel, andreadb.
RKSimon set the repository for this revision to rL LLVM.
RKSimon added a subscriber: llvm-commits.
andreadb accepted this revision.Dec 6 2016, 9:02 AM
andreadb edited edge metadata.

Hi Simon,
I only have one question. Otherwise the patch LGMT.

Thanks

lib/CodeGen/SelectionDAG/DAGCombiner.cpp
7130–7148 ↗(On Diff #80424)

Your new rule has a lot in common with the folding rules between lines [7130:7138]. You could potentially extend those folding rules to accomodate your extra case (ISD::ZERO_EXTEND). The only difference seems to be the check for EVTBits. All other checks (for legal operations) are identical.

This revision is now accepted and ready to land.Dec 6 2016, 9:02 AM
RKSimon added inline comments.Dec 6 2016, 9:09 AM
lib/CodeGen/SelectionDAG/DAGCombiner.cpp
7130–7148 ↗(On Diff #80424)

Thanks Andrea, I did try to merge the two but I the extra EVTBits logic just made it difficult to grok.

andreadb added inline comments.Dec 6 2016, 9:33 AM
lib/CodeGen/SelectionDAG/DAGCombiner.cpp
7130–7148 ↗(On Diff #80424)

Ah I see. I think it is fine then.

LGTM.

Thanks!

This revision was automatically updated to reflect the committed changes.