This is an archive of the discontinued LLVM Phabricator instance.

[InstCombine] Support non-splat vectors in icmp eq + add/sub fold
ClosedPublic

Authored by nikic on Jan 29 2020, 10:33 AM.

Details

Summary

For the icmp eq (add X, C1), C2 => icmp eq X, C2-C1 and icmp eq (sub C1, X), C2 => icmp eq X, C1-C2 folds, this allows C1 to be non-splat and contain undefs. C2 is still splat, due to the structure of the code.

This is to address the remaining part of the regression in D73411, where demanded element analysis replaces some elements with undef.

Diff Detail

Event Timeline

nikic created this revision.Jan 29 2020, 10:33 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 29 2020, 10:33 AM
lebedev.ri accepted this revision.Jan 29 2020, 11:04 AM

This LG.

llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
2933

:/

2971–2972

Add a comment that we don't handle the case where we have constant on RHS because we expect it to get folded to add and the add fold above to happen?

This revision is now accepted and ready to land.Jan 29 2020, 11:04 AM
nikic marked 2 inline comments as done.Jan 29 2020, 12:04 PM
nikic added inline comments.
llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
2933

IIRC that one actually has a somewhat sensible motivation... it prevents post-inc IVs from being converted to pre-inc IVs, which LSR cannot always recover.

This revision was automatically updated to reflect the committed changes.