]> granicus.if.org Git - llvm/commit
[SCEV] Generalize folding of trunc(x)+n*trunc(y) into folding m*trunc(x)+n*trunc(y)
authorDaniel Neilson <dneilson@azul.com>
Fri, 22 Sep 2017 15:47:57 +0000 (15:47 +0000)
committerDaniel Neilson <dneilson@azul.com>
Fri, 22 Sep 2017 15:47:57 +0000 (15:47 +0000)
commitbd3b41b46961ef1dfa7bf109c915036df6807775
tree487b205d92b7abc0cea64d9804b476bdba3bbaf0
parent36d03a028869873b6301047020d01cfb2b044272
[SCEV] Generalize folding of trunc(x)+n*trunc(y) into folding m*trunc(x)+n*trunc(y)

Summary:
A SCEV such as:
 {%v2,+,((-1 * (trunc i64 (-1 * %v1) to i32)) + (-1 * (trunc i64 %v1 to i32)))}<%loop>

can be folded into, simply, {%v2,+,0}. However, the current code in ::getAddExpr()
will not try to apply the simplification m*trunc(x)+n*trunc(y) -> trunc(trunc(m)*x+trunc(n)*y)
because it only keys off having a non-multiplied trunc as the first term in the simplification.

This patch generalizes this code to try to do a more generic fold of these trunc
expressions.

Reviewers: sanjoy

Reviewed By: sanjoy

Subscribers: llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@313988 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Analysis/ScalarEvolution.cpp
unittests/Analysis/ScalarEvolutionTest.cpp