This is an archive of the discontinued LLVM Phabricator instance.

[SDAG] Deal with deleted node in PromoteIntShiftOp
ClosedPublic

Authored by niravd on Mar 27 2017, 11:34 AM.

Details

Summary

Deal with case that initial node is deleted during dag-combine leading
to an assertional failure in promoteIntShiftOp.

Fixes PR32420.

Event Timeline

niravd created this revision.Mar 27 2017, 11:34 AM
RKSimon added inline comments.Mar 27 2017, 12:57 PM
lib/CodeGen/SelectionDAG/DAGCombiner.cpp
1156

These N0 arg changes should probably be done as a NFCI commit now

1172
if (Op && Op.getOpcode() != ISD::DELETED_NODE)
spatel added inline comments.Mar 27 2017, 1:04 PM
lib/CodeGen/SelectionDAG/DAGCombiner.cpp
1171–1174

Only the 'PromoteOperand' path can set 'Replace' to true, right? Can you move this into that else clause, and move the 'Replace' declaration into that else clause too?

test/CodeGen/X86/pr32420.ll
33–47

The bug is triggered by the 16-bit shifts. Can you remove the memops, globals, and struct?

niravd updated this revision to Diff 93235.Mar 28 2017, 6:49 AM

Simplify test case and minor cleanup

niravd marked 3 inline comments as done.Mar 28 2017, 6:53 AM
niravd added inline comments.
lib/CodeGen/SelectionDAG/DAGCombiner.cpp
1171–1174

Yes, but it would require us to duplicate the construction of RV which needs to be after the N0 change but before the replaceload call so in case N0 and N1 are closely related so we don't end up with a stale N1 value (another bug we've caught onto recently, e.g. https://reviews.llvm.org/D31148).

Given that I think this way is cleaner.

RKSimon added inline comments.Mar 28 2017, 7:57 AM
test/CodeGen/X86/pr32420.ll
30

please don't leave commented out instructions in the test case

niravd updated this revision to Diff 93245.Mar 28 2017, 8:34 AM

Revert accidental comment and rebase

RKSimon added inline comments.Mar 28 2017, 9:49 AM
lib/CodeGen/SelectionDAG/DAGCombiner.cpp
1161

Is there any case where the promotion of N0 will affect N1? Wouldn't shift(N0, N0) do this?

RKSimon accepted this revision.Mar 28 2017, 10:07 AM

No more comments from me - LGTM

lib/CodeGen/SelectionDAG/DAGCombiner.cpp
1161

Actually it seems we combine shift(N0, N0) --> 0

This revision is now accepted and ready to land.Mar 28 2017, 10:07 AM
This revision was automatically updated to reflect the committed changes.