[all-commits] [llvm/llvm-project] 2ca8a3: [SCEV] Stop blindly propagating flags from inbound...

Philip Reames via All-commits all-commits at lists.llvm.org
Fri Oct 1 16:32:32 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 2ca8a3f2132ec7d46151b4553ee166c4e635fd70
      https://github.com/llvm/llvm-project/commit/2ca8a3f2132ec7d46151b4553ee166c4e635fd70
  Author: Philip Reames <listmail at philipreames.com>
  Date:   2021-10-01 (Fri, 01 Oct 2021)

  Changed paths:
    M llvm/lib/Analysis/ScalarEvolution.cpp
    M llvm/test/Analysis/LoopAccessAnalysis/memcheck-wrapping-pointers.ll
    M llvm/test/Analysis/LoopCacheAnalysis/PowerPC/stencil.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/no-wrap-symbolic-becount.ll
    M llvm/test/Analysis/ScalarEvolution/nsw.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/IndVarSimplify/eliminate-exit-no-dl.ll
    M llvm/test/Transforms/LoopStrengthReduce/X86/expander-crashes.ll
    M polly/test/ScopInfo/NonAffine/non-affine-loop-condition-dependent-access_2.ll
    M polly/test/ScopInfo/pointer-type-expressions.ll
    M polly/test/ScopInfo/unsigned-division-5.ll

  Log Message:
  -----------
  [SCEV] Stop blindly propagating flags from inbound geps to SCEV nodes

This fixes a violation of the wrap flag rules introduced in c4048d8f. This was also noted in the (very old) PR23527.

The issue being fixed is that we assume the inbound flag on any GEP assumes that all users of *any* gep (or add) which happens to map to that SCEV would also be UB if the (other) gep overflowed. That's simply not true.

In terms of the test diffs, I don't see anything seriously problematic. The lost flags are expected (given the semantic restriction on when its legal to tag the SCEV), and there are several cases where the previously inferred flags are unsound per the new semantics.

The only common trend I noticed when looking at the deltas is that by not considering branch on poison as immediate UB in ValueTracking, we do miss a few cases we could reclaim. We may be able to claw some of these back with the follow ideas mentioned in PR51817.

It's worth noting that most of the changes are analysis result only changes. The two transform changes are pretty minimal. In one case, we miss the opportunity to infer a nuw (correctly). In the other, we fail to fold an exit and produce a loop invariant form instead. This one is probably over-reduced as the program appears to be undefined in practice, and neither before or after exploits that.

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




More information about the All-commits mailing list