This is an archive of the discontinued LLVM Phabricator instance.

[SCEV] Use nowrap flags to infer that start > start - stride in howManyLessThans
AbandonedPublic

Authored by bsmith on May 17 2022, 7:33 AM.

Details

Summary

If the induction variable being looked at has a nowrap increment, then we
can infer that start > start - stride, otherwise the value produced would
be poison.

Diff Detail

Event Timeline

bsmith created this revision.May 17 2022, 7:33 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 17 2022, 7:34 AM
Herald added a subscriber: hiraditya. · View Herald Transcript
bsmith requested review of this revision.May 17 2022, 7:34 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 17 2022, 7:34 AM

It should be noted that I'm not 100% certain this patch is sound so would very much like some guidance here, I'm looking to address the discussion from here as we have hit this case: https://reviews.llvm.org/D105942#inline-1007492. It's not clear to me whether more needs to be done to cope with the fact that we are dealing with a poison value here.

It isn't enough that AddRec is nowrap; you have to prove that the initial value of the AddRec was produced by a nowrap add.

I should probably get https://reviews.llvm.org/D106331 landed, assuming it still applies; forgot I never merged it.

bsmith abandoned this revision.May 18 2022, 3:21 AM

Ah, a quick check suggests your patch also works for our case. I'll abandon this in favour of that one. Thanks!