[PATCH] D103424: [IndVars] Don't forget value when inferring nowrap flags

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon May 31 12:28:00 PDT 2021


nikic created this revision.
nikic added reviewers: lebedev.ri, reames, mkazantsev.
Herald added subscribers: javed.absar, hiraditya.
nikic requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

When SimplifyIndVars infers IR nowrap flags from SCEV, it forgets the SCEV value. This doesn't make a lot of sense, as the nowrap fact is derived from SCEV in the first place, so there shouldn't be any need to invalidate to make use of the nowrap information (as it is information that SCEV already has...)

I'm sure this is not strictly NFC in some edge-cases because SCEV sometimes infers nowrap flags lazily, but at least on test-suite this change showed no differences.

This drops compile-time for n=128 from https://bugs.llvm.org/show_bug.cgi?id=50384 from 1.0s to 0.4s for me.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D103424

Files:
  llvm/lib/Transforms/Utils/SimplifyIndVar.cpp


Index: llvm/lib/Transforms/Utils/SimplifyIndVar.cpp
===================================================================
--- llvm/lib/Transforms/Utils/SimplifyIndVar.cpp
+++ llvm/lib/Transforms/Utils/SimplifyIndVar.cpp
@@ -772,14 +772,12 @@
   if (!BO->hasNoUnsignedWrap() &&
       willNotOverflow(SE, BO->getOpcode(), /* Signed */ false, LHS, RHS)) {
     BO->setHasNoUnsignedWrap();
-    SE->forgetValue(BO);
     Changed = true;
   }
 
   if (!BO->hasNoSignedWrap() &&
       willNotOverflow(SE, BO->getOpcode(), /* Signed */ true, LHS, RHS)) {
     BO->setHasNoSignedWrap();
-    SE->forgetValue(BO);
     Changed = true;
   }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D103424.348851.patch
Type: text/x-patch
Size: 633 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210531/85d88c8b/attachment.bin>


More information about the llvm-commits mailing list