[PATCH] D61934: [SCEV] Use wrap flags in InsertBinop

Philip Reames via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 11 15:59:44 PDT 2019


reames added a comment.

A suggestion on how to make progress here.  Introduce the wrap flags to the API, but have *all* callers pass AnyWrap.  That must be NFC.

Then land each API usage one by one.  (Without separate review is fine, but let them sit for a day or two between commits.)  Whichever one breaks is the problematic one, and you'll then know where to spend your debugging cycles.



================
Comment at: llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp:747
       Sum = InsertNoopCastOfTo(Sum, Ty);
-      Sum = InsertBinop(Instruction::Sub, Sum, W, /*IsSafeToHoist*/ true);
+      Sum = InsertBinop(Instruction::Sub, Sum, W, S->getNoWrapFlags(),
+                        /*IsSafeToHoist*/ true);
----------------
This particular pair of lines looks really suspicious.  The flags which are correct on an add are very different from those valid on a subtract.

Consider:
add nsw  i32 %a, -1
sub nsw nuw i32 %a, 1
OR
add nsw  nuw i8 %a, 127 ;; %a must be zero
sub i32 %a, 128 


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D61934/new/

https://reviews.llvm.org/D61934





More information about the llvm-commits mailing list