[all-commits] [llvm/llvm-project] d17798: [SCEV] Retain AddExpr flags when subtracting a fol...

Florian Hahn via All-commits all-commits at lists.llvm.org
Tue Jun 22 04:09:05 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: d17798823ca2213af353e125f6f5233522dda7ce
      https://github.com/llvm/llvm-project/commit/d17798823ca2213af353e125f6f5233522dda7ce
  Author: Florian Hahn <flo at fhahn.com>
  Date:   2021-06-22 (Tue, 22 Jun 2021)

  Changed paths:
    M llvm/lib/Analysis/ScalarEvolution.cpp
    M llvm/test/Analysis/LoopAccessAnalysis/reverse-memcheck-bounds.ll
    M llvm/test/Transforms/IndVarSimplify/eliminate-exit-no-dl.ll

  Log Message:
  -----------
  [SCEV] Retain AddExpr flags when subtracting a foldable constant.

Currently we drop wrapping flags for expressions like (A + C1)<flags> - C2.

But we can retain flags under certain conditions:

* Adding a smaller constant is NUW if the original AddExpr was NUW.

* Adding a constant with the same sign and small magnitude is NSW, if the
  original AddExpr was NSW.

This can improve results after using `SimplifyICmpOperands`, which may
subtract one in order to use stricter predicates, as is the case for
`isKnownPredicate`.

Reviewed By: efriedma

Differential Revision: https://reviews.llvm.org/D104319




More information about the All-commits mailing list