1 ; RUN: opt < %s -analyze -enable-new-pm=0 -scalar-evolution | FileCheck %s
2 ; RUN: opt < %s -disable-output "-passes=print<scalar-evolution>" 2>&1 | FileCheck %s
4 ; Check that we convert
5 ; trunc(C * a) -> trunc(C) * trunc(a)
7 ; CHECK-LABEL: @trunc_of_mul
8 define i8 @trunc_of_mul(i32 %a) {
11 ; CHECK-NEXT: --> (100 * (trunc i32 %a to i8))
12 %c = trunc i32 %b to i8
16 ; Check that we convert
17 ; trunc(C + a) -> trunc(C) + trunc(a)
19 ; CHECK-LABEL: @trunc_of_add
20 define i8 @trunc_of_add(i32 %a) {
23 ; CHECK-NEXT: --> (100 + (trunc i32 %a to i8))
24 %c = trunc i32 %b to i8
28 ; Check that we truncate to zero values assumed to have at least as many
29 ; trailing zeros as the target type.
30 ; CHECK-LABEL: @trunc_to_assumed_zeros
31 define i8 @trunc_to_assumed_zeros(i32* %p) {
32 %a = load i32, i32* %p
33 %and = and i32 %a, 255
34 %cmp = icmp eq i32 %and, 0
35 tail call void @llvm.assume(i1 %cmp)
38 %c = trunc i32 %a to i8
40 ; CHECK-NEXT: --> false
41 %d = trunc i32 %a to i1
43 ; CHECK-NEXT: --> (trunc i32 %a to i16)
44 %e = trunc i32 %a to i16
48 declare void @llvm.assume(i1 noundef) nofree nosync nounwind willreturn