Page MenuHomePhabricator

[SCEV] add NW flag for AddExpr (start + stride)

Authored by shchenz on Jul 17 2019, 6:39 AM.


%i = phi i4 [ %start, %entry ], [, %loop ] = add nsw i4 %i, %stride

If we know that SCEV {(%start + %stride), +, %stride} poison value wil cause UB, it is safe to add SCEV::FlagNSW for it. And it should also be safe for (%start + %stride) to add SCEV::FlagNSW.

Diff Detail


Event Timeline

shchenz created this revision.Jul 17 2019, 6:39 AM
reames accepted this revision.Jul 17 2019, 9:11 AM

LGTM, but please update your submit comment to emphasize that the only reason this is correct is that we've proven that the inc can't be poison without triggering UB in the original program. (i.e. it's not the fact the add is nsw which lets us do this, it's the fact that the add is nsw and can be proven to trigger UB if actually poison)

This revision is now accepted and ready to land.Jul 17 2019, 9:11 AM
shchenz edited the summary of this revision. (Show Details)Jul 18 2019, 2:07 AM
This revision was automatically updated to reflect the committed changes.