This is an archive of the discontinued LLVM Phabricator instance.

[DAGCombiner] Fold (sext/zext undef) -> 0 and aext(undef) -> undef.
ClosedPublic

Authored by craig.topper on May 5 2022, 12:19 AM.

Diff Detail

Event Timeline

craig.topper created this revision.May 5 2022, 12:19 AM
craig.topper requested review of this revision.May 5 2022, 12:19 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 5 2022, 12:19 AM
RKSimon accepted this revision.May 5 2022, 1:03 AM

LGTM

This revision is now accepted and ready to land.May 5 2022, 1:03 AM
This revision was landed with ongoing or failed builds.May 5 2022, 9:40 AM
This revision was automatically updated to reflect the committed changes.

What's the justification for 0 rather than undef? That the high bits need to be guaranteed equal even for undef input?

What's the justification for 0 rather than undef? That the high bits need to be guaranteed equal even for undef input?

For zext the high bits need to be 0 and for sext the high bits need to match. The result of the fold needs to produce a value that is possible given the undefined input we received. If we folded to undef that would be a larger set of values than were possible. We're allowed to assume a specific value for the input. So here we've assume the input is 0.