This is an archive of the discontinued LLVM Phabricator instance.

[PatternMatch] Add m_APInt/m_APFloat matchers accepting undef
ClosedPublic

Authored by nikic on Jan 18 2020, 3:28 AM.

Details

Summary

The current m_APInt() and m_APFloat() matchers do not accept splats that include undefs (unlike m_Zero() and other matchers for specific values). We can't simply change the default behavior, as there are existing transforms that would not be safe with undefs.

For this reason, I'm introducing new m_APIntAllowUndef() and m_APFloatAllowUndef() matchers, that allow splats with undefs. Additionally, m_APIntForbidUndef() and m_APFloatForbidUndef() are added. These have the same behavior as the existing m_APInt() and m_APFloat(), but serve as an explicit indication that undefs were explicitly considered and found unsound for this transform. This helps distinguish them from existing uses of m_APInt() where we do not know whether undefs can or cannot be allowed without additional review.

Diff Detail

Event Timeline

nikic created this revision.Jan 18 2020, 3:28 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 18 2020, 3:28 AM
spatel accepted this revision.Jan 20 2020, 6:01 AM

LGTM - @lebedev.ri may have some notes about existing code where we can use 'allow' or 'forbid' flavors explicitly. (There were earlier experiments with allowing undefs wholesale in these matchers.)

This revision is now accepted and ready to land.Jan 20 2020, 6:01 AM
This revision was automatically updated to reflect the committed changes.