[PATCH] D95286: [LSR] Drop potentially invalid nowrap flags when switching to post-inc IV (PR46943)

Philip Reames via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Jan 24 16:48:16 PST 2021


reames added a comment.

LGTM as well w/minor comments.



================
Comment at: llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp:1447
+    if (isa<OverflowingBinaryOperator>(Result)) {
+      if (auto *I = dyn_cast<Instruction>(Result)) {
+        if (!S->hasNoUnsignedWrap())
----------------
if (auto *op = dyn_cast<OBO>...)

e.g. you don't need the instruction, you can use the accessors on OBO.  


================
Comment at: llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp:1451
+        if (!S->hasNoSignedWrap())
+          I->setHasNoSignedWrap(false);
+      }
----------------
Any reason not to just copy the SCEV flags?  Inferring stronger flags should be legal here.


================
Comment at: llvm/test/Transforms/LoopStrengthReduce/X86/sibling-loops.ll:20
 ; CHECK-NEXT:    tail call void @goo(i64 [[I_0]], i64 [[I_0]])
-; CHECK-NEXT:    [[INC]] = add nuw nsw i64 [[I_0]], 1
+; CHECK-NEXT:    [[INC]] = add nuw i64 [[I_0]], 1
 ; CHECK-NEXT:    [[T0:%.*]] = load i64, i64* @cond, align 8
----------------
Given the nsw is present in the source, SCEV should know this is nsw.  Any idea why it doesn't?


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

https://reviews.llvm.org/D95286



More information about the llvm-commits mailing list