[all-commits] [llvm/llvm-project] 8f3d16: [ScalarEvolution] Ensure backedge-taken counts are...

Eli Friedman via All-commits all-commits at lists.llvm.org
Mon Jun 21 16:25:37 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 8f3d16905d75b07a933d01dc29677fe5867c1b3e
      https://github.com/llvm/llvm-project/commit/8f3d16905d75b07a933d01dc29677fe5867c1b3e
  Author: Eli Friedman <efriedma at quicinc.com>
  Date:   2021-06-21 (Mon, 21 Jun 2021)

  Changed paths:
    M llvm/lib/Analysis/ScalarEvolution.cpp
    M llvm/test/Analysis/ScalarEvolution/max-backedge-taken-count-guard-info.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/Transforms/IndVarSimplify/2011-11-01-lftrptr.ll
    M llvm/test/Transforms/IndVarSimplify/eliminate-exit-no-dl.ll
    M llvm/test/Transforms/LoopIdiom/memset-debugify-remarks.ll
    M llvm/test/Transforms/LoopReroll/ptrindvar.ll
    M llvm/test/Transforms/LoopVectorize/X86/cost-model-assert.ll
    M llvm/test/Transforms/LoopVectorize/pointer-induction.ll
    M llvm/test/Transforms/LoopVectorize/pr45259.ll
    M llvm/test/Transforms/PhaseOrdering/scev-custom-dl.ll

  Log Message:
  -----------
  [ScalarEvolution] Ensure backedge-taken counts are not pointers.

A backedge-taken count doesn't refer to memory; returning a pointer type
is nonsense. So make sure we always return an integer.

The obvious way to do this would be to just convert the operands of the
icmp to integers, but that doesn't quite work out at the moment:
isLoopEntryGuardedByCond currently gets confused by ptrtoint operations.
So we perform the ptrtoint conversion late for lt/gt operations.

The test changes are mostly innocuous. The most interesting changes are
more complex SCEV expressions of the form "(-1 * (ptrtoint i8* %ptr to
i64)) + %ptr)". This is expected: we can't fold this to zero because we
need to preserve the pointer base.

The call to isLoopEntryGuardedByCond in howFarToZero is less precise
because of ptrtoint operations; this shows up in the function
pr46786_c26_char in ptrtoint.ll. Fixing it here would require more
complex refactoring.  It should eventually be fixed by future
improvements to isImpliedCond.

See https://bugs.llvm.org/show_bug.cgi?id=46786 for context.

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




More information about the All-commits mailing list