This is an archive of the discontinued LLVM Phabricator instance.

[X86] Correct SHRUNKBLEND creation to work correctly when there are multiple uses of the condition.
ClosedPublic

Authored by craig.topper on Feb 18 2018, 10:39 AM.

Details

Summary

SimplifyDemandedBits forces the demanded mask to all 1s if the node has multiple uses, unless the AssumeSingleUse flag is set.

So previously we were only really likely to simplify something if the condition had a single use. And on the off chance we did simplify with multiple uses the demanded mask being used was all ones so there was no reason to create a shrunkblend.

This patch now checks that the condition is only used by selects first, and then sets the AssumeSingleUse flag for the simplifcation. Then we convert the selects to shrunkblend, and finally replace condition.

Diff Detail

Repository
rL LLVM

Event Timeline

craig.topper created this revision.Feb 18 2018, 10:39 AM
RKSimon accepted this revision.Feb 20 2018, 4:15 AM

LGTM with a couple of minors.

lib/Target/X86/X86ISelLowering.cpp
31880 ↗(On Diff #134841)

Can you convert this to a for-range loop using Cond->uses()

31898 ↗(On Diff #134841)

Update

31909 ↗(On Diff #134841)

I take it there's no reason to re-evaluate this?

This revision is now accepted and ready to land.Feb 20 2018, 4:15 AM
craig.topper added inline comments.Feb 20 2018, 9:49 AM
lib/Target/X86/X86ISelLowering.cpp
31880 ↗(On Diff #134841)

No because uses() returns a SDNode* and I would need the SDUse* to get the operand number or I would need another loop over the SDNode's operands.

31909 ↗(On Diff #134841)

We don't have any combines on SHRUNKBLEND today. Do you think I should add it to teh worklist anyway?

This revision was automatically updated to reflect the committed changes.

Cheers.

lib/Target/X86/X86ISelLowering.cpp
31909 ↗(On Diff #134841)

Probably not worth it - if a use case arises its a trivial change.