1 ; RUN: opt < %s -disable-output "-passes=print<scalar-evolution>" 2>&1 | FileCheck %s
3 ; Check that we convert
4 ; trunc(C * a) -> trunc(C) * trunc(a)
6 ; CHECK-LABEL: @trunc_of_mul
7 define i8 @trunc_of_mul(i32 %a) {
10 ; CHECK-NEXT: --> (100 * (trunc i32 %a to i8))
11 %c = trunc i32 %b to i8
15 ; Check that we convert
16 ; trunc(C + a) -> trunc(C) + trunc(a)
18 ; CHECK-LABEL: @trunc_of_add
19 define i8 @trunc_of_add(i32 %a) {
22 ; CHECK-NEXT: --> (100 + (trunc i32 %a to i8))
23 %c = trunc i32 %b to i8
27 ; Check that we truncate to zero values assumed to have at least as many
28 ; trailing zeros as the target type.
29 ; CHECK-LABEL: @trunc_to_assumed_zeros
30 define i8 @trunc_to_assumed_zeros(ptr %p) {
32 %and = and i32 %a, 255
33 %cmp = icmp eq i32 %and, 0
34 tail call void @llvm.assume(i1 %cmp)
37 %c = trunc i32 %a to i8
39 ; CHECK-NEXT: --> false
40 %d = trunc i32 %a to i1
42 ; CHECK-NEXT: --> (trunc i32 %a to i16)
43 %e = trunc i32 %a to i16
47 declare void @llvm.assume(i1 noundef) nofree nosync nounwind willreturn