Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SCEV] Simplify trunc-of-add/mul to add/mul-of-trunc under more circu…
…mstances. Summary: Previously we would do this simplification only if it did not introduce any new truncs (excepting new truncs which replace other cast ops). This change weakens this condition: If the number of truncs stays the same, but we're able to transform trunc(X + Y) to X + trunc(Y), that's still simpler, and it may open up additional transformations. While we're here, also clean up some duplicated code. Reviewers: sanjoy Subscribers: hiraditya, llvm-commits Differential Revision: https://reviews.llvm.org/D48160 llvm-svn: 334736
- Loading branch information
Justin Lebar
committed
Jun 14, 2018
1 parent
62a0747
commit b326904
Showing
6 changed files
with
56 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
; RUN: opt < %s -analyze -scalar-evolution | FileCheck %s | ||
|
||
; Check that we convert | ||
; trunc(C * a) -> trunc(C) * trunc(a) | ||
; if C is a constant. | ||
; CHECK-LABEL: @trunc_of_mul | ||
define i8 @trunc_of_mul(i32 %a) { | ||
%b = mul i32 %a, 100 | ||
; CHECK: %c | ||
; CHECK-NEXT: --> (100 * (trunc i32 %a to i8)) | ||
%c = trunc i32 %b to i8 | ||
ret i8 %c | ||
} | ||
|
||
; Check that we convert | ||
; trunc(C + a) -> trunc(C) + trunc(a) | ||
; if C is a constant. | ||
; CHECK-LABEL: @trunc_of_add | ||
define i8 @trunc_of_add(i32 %a) { | ||
%b = add i32 %a, 100 | ||
; CHECK: %c | ||
; CHECK-NEXT: --> (100 + (trunc i32 %a to i8)) | ||
%c = trunc i32 %b to i8 | ||
ret i8 %c | ||
} |