1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-24 03:33:20 +01:00
llvm-mirror/test/Analysis/ScalarEvolution/trunc-simplify.ll
Justin Lebar 4a161bf875 [SCEV] Simplify trunc-of-add/mul to add/mul-of-trunc under more circumstances.
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
2018-06-14 17:13:35 +00:00

26 lines
610 B
LLVM

; 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
}