This is an archive of the discontinued LLVM Phabricator instance.

[TypePromotion] Promote undef by converting to 0.
ClosedPublic

Authored by craig.topper on Apr 5 2022, 7:17 PM.

Details

Summary

If we're promoting an undef I think that means that we expect the
upper bits are zero. undef doesn't guarantee that.

This patch replaces undef with 0 to ensure this. This matches how
a zext or sext of undef would be folded by InstCombine/InstSimplify.

I haven't found a failure from this was just thinking through the code.

Diff Detail

Event Timeline

craig.topper created this revision.Apr 5 2022, 7:17 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 5 2022, 7:17 PM
craig.topper requested review of this revision.Apr 5 2022, 7:17 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 5 2022, 7:17 PM
craig.topper abandoned this revision.Apr 5 2022, 8:32 PM

Maybe if this usually phis. It isn't a problem?

Hi @craig.topper, so this is interesting because the AArch64 trunc-zext-chain.ll test file is a reproducer for a bug that I couldn't solve. The test function has two versions, because I couldn't figure out if having an undef was the underlying issue. I think it was causing some trouble with GetDemandedBits, but I was unable to figure it out with some very dense logic in the AArch64 backend. So I'm certainly happy to entertain this idea and matching the behaviour of InstCombine/InstSimplify sounds good to me.

@craig.topper ping, I'd like to get this committed. So would you be happy to continue or for me to commandeer this? Although I would just ask you for the review :)

craig.topper reclaimed this revision.May 12 2022, 12:31 AM
samparker accepted this revision.May 12 2022, 12:39 AM

Thanks!

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