This is an archive of the discontinued LLVM Phabricator instance.

[DAGCombiner][X86] Prevent visitSIGN_EXTEND from returning N when (sext (setcc)) already has the target desired type for the setcc
ClosedPublic

Authored by craig.topper on Dec 7 2018, 2:04 PM.

Details

Summary

If the setcc already has the target desired type we can reach the getSetCC/getSExtOrTrunc after the MatchingVecType check with the exact same types as the nodes we started with. This causes those causes VsetCC to be CSEd to N0 and the getSExtOrTrunc will CSE to N. When we return N, the caller will think that meant we called CombineTo and did our own worklist management. But that's not what happened. This prevents target hooks from being called for the node.

To fix this, I've now returned SDValue if the setcc is already the desired type. But to avoid some regressions in X86 I've had to disable one of the target combines that wasn't being reached before in the case of a (sext (setcc)). If we get vector widening legalization enabled that entire function will be deleted anyway so hopefully this is only for the short term.

Diff Detail

Event Timeline

craig.topper created this revision.Dec 7 2018, 2:04 PM
RKSimon added inline comments.Dec 9 2018, 4:07 AM
lib/CodeGen/SelectionDAG/DAGCombiner.cpp
8631

Does it matter that this early outs so later combines (matchVSelectOpSizesWithSetCC) can't run?

Don't return SDValue, just skip code instead.

spatel added inline comments.Dec 13 2018, 1:16 PM
lib/Target/X86/X86ISelLowering.cpp
39145

Just in case we don't get vector widening legalization done soon, I think this comment should describe the potential regressions and/or what's broken/missing that would prevent that problem.

Add explanatory comment for the regressions I'm seeing without the X86ISelLowering change.

This revision is now accepted and ready to land.Dec 14 2018, 12:15 AM
This revision was automatically updated to reflect the committed changes.