[all-commits] [llvm/llvm-project] 545128: [SCEV] Constant fold MultExpr before applying dept...

dantrushin via All-commits all-commits at lists.llvm.org
Fri May 22 08:35:23 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 5451289abafd8879adf892ede7660ce8c46c6a6f
      https://github.com/llvm/llvm-project/commit/5451289abafd8879adf892ede7660ce8c46c6a6f
  Author: Denis Antrushin <dantrushin at gmail.com>
  Date:   2020-05-22 (Fri, 22 May 2020)

  Changed paths:
    M llvm/lib/Analysis/ScalarEvolution.cpp
    A llvm/test/Analysis/ScalarEvolution/depth-limit-overrun.ll
    M llvm/test/Analysis/ScalarEvolution/limit-depth.ll

  Log Message:
  -----------
  [SCEV] Constant fold MultExpr before applying depth limit.

Summary:
Users of SCEV reasonably assume that multiplication of two constant
SCEVs will in turn be constant.
However, that is not always the case:
First, we can get here with reached depth limit, and will create
MultExpr SCEV `C1 * C2` and cache it.
Then, we can get here with the same operands, but with small depth
level. But this time we will find existing MultExpr SCEV and return
it, instead of expected constant SCEV.

This patch changes getMultExpr to not apply depth limit to all constant
operands expression, allowing them to be folded.

Reviewers: reames, mkazantsev

Subscribers: hiraditya, javed.absar, llvm-commits

Tags: #llvm

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




More information about the All-commits mailing list