This is an archive of the discontinued LLVM Phabricator instance.

[ValueTracking] Match select abs pattern when there's an sext involved
ClosedPublic

Authored by john.brawn on Jun 1 2018, 6:26 AM.

Details

Summary

When checking a select to see if it matches an abs, allow the true/false values to be a sign-extension of the comparison value instead of requiring that they're directly the comparison value, as all the comparison cares about is the sign of the value.

This fixes a regression due to r333702, where we were no longer generating ctlz due to isKnownNonNegative failing to match such a pattern.

Diff Detail

Repository
rL LLVM

Event Timeline

john.brawn created this revision.Jun 1 2018, 6:26 AM
craig.topper added inline comments.Jun 1 2018, 10:21 AM
lib/Analysis/ValueTracking.cpp
4607–4622

I think it might be better to make LHS assigned to the sign extended value here.

craig.topper added inline comments.Jun 1 2018, 10:47 AM
lib/Analysis/ValueTracking.cpp
4611

Can we just check m_Neg(TrueVal)?

john.brawn updated this revision to Diff 149745.Jun 4 2018, 6:22 AM

Update according to review comments.

This revision is now accepted and ready to land.Jun 4 2018, 9:44 AM
This revision was automatically updated to reflect the committed changes.

It seems like this started triggering assertions in builds, I was about to file a bug about it, but it seems someone else already beat me to it, in https://bugs.llvm.org/show_bug.cgi?id=37686.

It seems like this started triggering assertions in builds, I was about to file a bug about it, but it seems someone else already beat me to it, in https://bugs.llvm.org/show_bug.cgi?id=37686.

Fixed in https://reviews.llvm.org/rL334019.