[all-commits] [llvm/llvm-project] 162522: [SCEV] Replace assert with returning CouldNotComp ...

Florian Hahn via All-commits all-commits at lists.llvm.org
Wed Oct 19 03:24:34 PDT 2022

  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 1625224fbb7b911d492437c1613d83e1f85efb9e
  Author: Florian Hahn <flo at fhahn.com>
  Date:   2022-10-19 (Wed, 19 Oct 2022)

  Changed paths:
    M llvm/lib/Analysis/ScalarEvolution.cpp
    M llvm/test/Analysis/ScalarEvolution/max-trip-count.ll
    M llvm/test/Analysis/ScalarEvolution/trip-count-negative-stride.ll

  Log Message:
  [SCEV] Replace assert with returning CouldNotComp in computeMaxBECountForLT.

This patch removes the bail out for signed predicates and non-positive
strides in howManyLessThans and updates computeMaxBECountForLT to return
SCEVCouldNotCompute for signed predicates with negative strides.

AFAICT bail-out was only added because computeMaxBECountForLT may not
handle negative signed strides correctly. Instead of not calling
computeMaxBECountForLT at all because we bail out earlier, we can
instead return SCEVCouldNotCompute in computeMaxBECountForLT.

The max backedge taken count will be computed as the max value of the
symbolic backedge taken count.

This improves precision in cases where we can compute symbolic backedge
taken counts and also fixes a crash.

Fixes #57818.

Reviewed By: nikic

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

More information about the All-commits mailing list