[all-commits] [llvm/llvm-project] e08f98: [SCEV] Preserve NSW for AddRec multiplied by -1 if...

Dmitry Makogon via All-commits all-commits at lists.llvm.org
Fri Apr 14 05:37:43 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: e08f9894ec8ca5ea600d2d2acafdd4b6c2aa5d29
      https://github.com/llvm/llvm-project/commit/e08f9894ec8ca5ea600d2d2acafdd4b6c2aa5d29
  Author: Dmitry Makogon <d.makogon at g.nsu.ru>
  Date:   2023-04-14 (Fri, 14 Apr 2023)

  Changed paths:
    M llvm/lib/Analysis/ScalarEvolution.cpp
    M llvm/test/Analysis/ScalarEvolution/addrec-sub-nsw.ll
    M llvm/test/Analysis/ScalarEvolution/decrementing_addrecs.ll
    M llvm/test/Analysis/ScalarEvolution/different-loops-recs.ll
    M llvm/test/Analysis/ScalarEvolution/sext-iv-2.ll

  Log Message:
  -----------
  [SCEV] Preserve NSW for AddRec multiplied by -1 if it cannot be signed minimum

This preserves NSW flag for AddRecs multiplied by -1 if we can prove
via constant ranges that the AddRec cannot be signed minimum.

An explanation:
Let M be signed minimum. If AddRec's range contains M, then M * (-1) will
stay M and (M + 1) * (-1) will be signed maximum, so we get a signed overflow.
In all other cases if an AddRec didn't signed overflow,
then AddRec * (-1) wouldn't too.

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




More information about the All-commits mailing list