This is an archive of the discontinued LLVM Phabricator instance.

Possible bug in isKnownPredicateViaConstantRanges
Needs RevisionPublic

Authored by tdangeti on Apr 7 2022, 1:39 PM.

Details

Summary

I have a problem with getMinusSCEV in isKnownPredicateViaConstantRanges function:

The following is the scenario:
LHS = X,
RHS = -1,

SE already has a computed SCEV (X + 1)<nuw> in the cache. This SCEV corresponds to an instruction at different scope where nuw flag is valid.

I am expecting the "Diff = getMinusSCEV(LHS, RHS)" to be simply (X + 1) instead, I get (X + 1)<nuw> and isKnownNonZero(Diff) returns true which doesn't look correct for me.

Diff Detail

Event Timeline

tdangeti created this revision.Apr 7 2022, 1:39 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 7 2022, 1:39 PM
tdangeti requested review of this revision.Apr 7 2022, 1:39 PM
tdangeti edited the summary of this revision. (Show Details)Apr 7 2022, 1:42 PM
nikic requested changes to this revision.Apr 7 2022, 2:06 PM
nikic added a subscriber: nikic.

No wrap flags in SCEV are required to be valid independent of scope. If you see nowrap flags for which this is not the case, then the calculation of the nowrap flags is at fault.

This revision now requires changes to proceed.Apr 7 2022, 2:06 PM
fhahn added a comment.Apr 7 2022, 2:14 PM

This also needs a test case. Without that it is impossible to figure out what the actual issue is.

sanjoy resigned from this revision.Oct 10 2022, 2:43 PM