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

Max Kazantsev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon May 31 23:42:02 PDT 2021


mkazantsev added a comment.

Did you try a lightweight (and absolutely NFCish) approach of dropping SCEV 1 time instead of 2? Like

  if (!BO->hasNoUnsignedWrap() &&
      willNotOverflow(SE, BO->getOpcode(), /* Signed */ false, LHS, RHS)) {
    BO->setHasNoUnsignedWrap();
    Changed = true;
  }
  
  if (!BO->hasNoSignedWrap() &&
      willNotOverflow(SE, BO->getOpcode(), /* Signed */ true, LHS, RHS)) {
    BO->setHasNoSignedWrap();
    Changed = true;
  }
  if (Changed)
    SE->forgetValue(BO);

? Curious if it improves the situation.

As for this patch, I don't have a strong opinion. To me it looks that dropping SCEV here can be useful to infer nsw/nuw for some AddRec involving BO, and, consequently, prove iteration count of some loop that depends on it. Not sure how often does it happen and how useful it is, though.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103424



More information about the llvm-commits mailing list