This is an archive of the discontinued LLVM Phabricator instance.

[InstCombine] enhance vector demanded elements to look at a vector select condition operand
ClosedPublic

Authored by spatel on Aug 29 2018, 8:45 AM.

Details

Summary

I noticed that we were not back-propagating undef lanes to shuffle masks when we have a shuffle that reduces the vector width. This is part of investigating/solving PR38691:
https://bugs.llvm.org/show_bug.cgi?id=38691

Diff Detail

Repository
rL LLVM

Event Timeline

spatel created this revision.Aug 29 2018, 8:45 AM

I don't see any obvious problems here, but i'm unfamiliar with this area at all..
Do we not have any one-use concerns in such transforms?

I don't see any obvious problems here, but i'm unfamiliar with this area at all..
Do we not have any one-use concerns in such transforms?

Its handled at the top of the function

RKSimon added inline comments.Sep 6 2018, 2:49 AM
lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
1267 ↗(On Diff #163102)

Won't using UndefElts interfere with the Left/Right cases below?

1275 ↗(On Diff #163102)

Separate NFC change

spatel marked 2 inline comments as done.Sep 6 2018, 6:55 AM
spatel added inline comments.
lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
1267 ↗(On Diff #163102)

Yes, good catch. Not sure how to expose that in a test, but I'll fix the code in the next rev.

spatel updated this revision to Diff 164213.Sep 6 2018, 7:07 AM
spatel marked an inline comment as done.

Patch updated:
Corrected the recursive call on the condition to use its own 'UndefElts' constant (which is unused currently as explained in the new code comments).
I cleaned up the surrounding code with rL341545.

craig.topper added inline comments.Sep 10 2018, 10:26 AM
lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
1263 ↗(On Diff #164213)

What would you think about casting to SelectInst and using getCondition, getTrueValue, getFalseValue, setCondition, etc. throughout this code?

spatel added inline comments.Sep 10 2018, 11:00 AM
lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
1263 ↗(On Diff #164213)

Sure - let me clean that up and rebase.

spatel updated this revision to Diff 164714.Sep 10 2018, 12:13 PM

Patch updated:
Rebased after cleanup and rL341708.
I made a subtle change here to not use a local Cond variable because that could become stale if we setCond() in the new block.

This revision is now accepted and ready to land.Sep 11 2018, 9:51 AM
This revision was automatically updated to reflect the committed changes.