[all-commits] [llvm/llvm-project] f3124a: [SCEV] Fix nsw flags for GEP expressions

Nikita Popov via All-commits all-commits at lists.llvm.org
Fri Nov 13 09:19:54 PST 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: f3124a46c17e4683f96695aeceaf607920694710
      https://github.com/llvm/llvm-project/commit/f3124a46c17e4683f96695aeceaf607920694710
  Author: Nikita Popov <nikita.ppv at gmail.com>
  Date:   2020-11-13 (Fri, 13 Nov 2020)

  Changed paths:
    M llvm/lib/Analysis/ScalarEvolution.cpp
    M llvm/test/Analysis/LoopAccessAnalysis/memcheck-wrapping-pointers.ll
    M llvm/test/Analysis/LoopAccessAnalysis/number-of-memchecks.ll
    M llvm/test/Analysis/LoopAccessAnalysis/reverse-memcheck-bounds.ll
    M llvm/test/Analysis/LoopAccessAnalysis/wrapping-pointer-versioning.ll
    M llvm/test/Analysis/ScalarEvolution/add-expr-pointer-operand-sorting.ll
    M llvm/test/Analysis/ScalarEvolution/load.ll
    M llvm/test/Analysis/ScalarEvolution/max-backedge-taken-count-guard-info.ll
    M llvm/test/Analysis/ScalarEvolution/no-wrap-add-exprs.ll
    M llvm/test/Analysis/ScalarEvolution/nsw-offset-assume.ll
    M llvm/test/Analysis/ScalarEvolution/nsw-offset.ll
    M llvm/test/Analysis/ScalarEvolution/nsw.ll
    M llvm/test/Analysis/ScalarEvolution/pr46786.ll
    M llvm/test/Analysis/ScalarEvolution/ptrtoint.ll
    M llvm/test/Analysis/ScalarEvolution/sdiv.ll
    M llvm/test/Analysis/ScalarEvolution/srem.ll
    M llvm/test/Transforms/LoopFusion/simple.ll

  Log Message:
  -----------
  [SCEV] Fix nsw flags for GEP expressions

The SCEV code for constructing GEP expressions currently assumes
that the addition of the base and all the offsets is nsw if the GEP
is inbounds. While the addition of the offsets is indeed nsw, the
addition to the base address is not, as the base address is
interpreted as an unsigned value.

Fix the GEP expression code to not assume nsw for the base+offset
calculation. However, do assume nuw if we know that the offset is
non-negative. With this, we use the same behavior as the
construction of GEP addrecs does. (Modulo the fact that we
disregard SCEV unification, as the pre-existing FIXME points out).

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




More information about the All-commits mailing list