[all-commits] [llvm/llvm-project] cbba71: [ScalarEvolution] Fix overflow in computeBECount.

Eli Friedman via All-commits all-commits at lists.llvm.org
Fri Jul 16 16:15:35 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: cbba71bfb50fb668b80ed430125a460279928272
      https://github.com/llvm/llvm-project/commit/cbba71bfb50fb668b80ed430125a460279928272
  Author: Eli Friedman <efriedma at quicinc.com>
  Date:   2021-07-16 (Fri, 16 Jul 2021)

  Changed paths:
    M llvm/include/llvm/Analysis/ScalarEvolution.h
    M llvm/lib/Analysis/ScalarEvolution.cpp
    M llvm/test/Analysis/ScalarEvolution/2008-11-18-Stride2.ll
    M llvm/test/Analysis/ScalarEvolution/trip-count-unknown-stride.ll

  Log Message:
  -----------
  [ScalarEvolution] Fix overflow in computeBECount.

The current implementation of computeBECount doesn't account for the
possibility that adding "Stride - 1" to Delta might overflow. For almost
all loops, it doesn't, but it's not actually proven anywhere.

To deal with this, use a variety of tricks to try to prove that the
addition doesn't overflow.  If the proof is impossible, use an alternate
sequence which never overflows.

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




More information about the All-commits mailing list