[llvm-dev] SCEV and <nsw>

Alexandre Isoard via llvm-dev llvm-dev at lists.llvm.org
Fri Oct 26 10:41:07 PDT 2018


Hello,

I'm running into an issue where SCEV misses explicit nsw flags on the
following expressions:

  %mm.07 = phi i32 [ 0, %for.body.lr.ph ], [ %add, %for.inc30 ]
  -->  {0,+,1}<nuw><nsw><%for.body> U: [0,2147483647) S: [0,2147483647) Exits:
(-1 + %m) LoopDispositions: { %for.body: Computable, %for.body5: Invariant,
%for.inc: Invariant }
  %add = add nsw i32 %mm.07, 1
  -->  {1,+,1}<nuw><nsw><%for.body> U: [1,-2147483648) S:
[1,-2147483648) Exits:
%m LoopDispositions: { %for.body: Computable, %for.body5: Invariant,
%for.inc: Invariant }
  %add2 = add nsw i32 %mm.07, 96
  -->  {96,+,1}<nuw><%for.body> U: [96,-2147483553) S: [96,-2147483553) Exits:
(95 + %m) LoopDispositions: { %for.body: Computable, %for.body5: Invariant,
%for.inc: Invariant }

My problem is with the later one, where the <nsw> is missing (which cause
me problems down the line with gep computation on 64 bit address space).

Any clue as to what could be the source of that disappearance? I tried to
reproduce the issue on simple cases but to no avail. I get the following
expected result:

  %i = phi i32 [ 0, %loop.prehead ], [ %i.next, %loop.body ]
  -->  {0,+,1}<nuw><nsw><%loop.body> U: [0,2147483647) S: [0,2147483647) Exits:
(-1 + %x) LoopDispositions: { %loop.body: Computable }
  %i.next = add nsw i32 %i, 1
  -->  {1,+,1}<nuw><nsw><%loop.body> U: [1,-2147483648) S:
[1,-2147483648) Exits:
%x LoopDispositions: { %loop.body: Computable }
  %i.96 = add nsw i32 %i, 96
  -->  {96,+,1}<nuw><nsw><%loop.body> U: [96,-2147483648) S:
[96,-2147483648) Exits: (95 + %x) LoopDispositions: { %loop.body:
Computable }

Help?

-- 
*Alexandre Isoard*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20181026/fa9460ab/attachment.html>


More information about the llvm-dev mailing list