This is an archive of the discontinued LLVM Phabricator instance.

[X86] Improve test instruction shrinking when the sign flag is used and the output of the and is truncated
ClosedPublic

Authored by craig.topper on Sep 28 2018, 1:10 PM.

Details

Summary

Currently we skip looking through truncates if the sign flag is used. But that's overly restrictive.

It's safe to look through the truncate as long as we ensure one of the 3 things when we shrink. Either the MSB of the mask at the shrunken size isn't set. If the mask bit is set then either the shrunk size needs to be equal to the compare size or the sign flag needs to be unused.

It looks like there are still missed opportunities to shrink a load and fold it in here.

Diff Detail

Event Timeline

craig.topper created this revision.Sep 28 2018, 1:10 PM
RKSimon added inline comments.Sep 29 2018, 4:11 AM
lib/Target/X86/X86ISelDAGToDAG.cpp
3396

Can you add the explanation in the summary to the comments please?

3415

Possible to pull this repeated hasNoSignedComparisonUses(Node) call out?

test/CodeGen/X86/test-shrink.ll
692

Missed folding opportunity ?

735

Missed folding opportunity?

778

Missed folding opportunity?

craig.topper added inline comments.Sep 29 2018, 9:22 AM
lib/Target/X86/X86ISelDAGToDAG.cpp
3415

It contains a for loop over uses so I'd rather only call it when it necessary.

test/CodeGen/X86/test-shrink.ll
692

Yes this is the missed folding alluded to in the summary. I don't think its unique to this change. I'll add a FIXME.

Add more comments

  • [X86] Enable load folding in the test shrinking code.

Revert accidental addition of load folding. I was trying to create a new diff for that and failed

RKSimon accepted this revision.Oct 1 2018, 1:25 AM

LGTM - cheers

This revision is now accepted and ready to land.Oct 1 2018, 1:25 AM