1 ; RUN: opt -analyze -enable-new-pm=0 -scalar-evolution -S < %s | FileCheck %s
2 ; RUN: opt -disable-output "-passes=print<scalar-evolution>" -S < %s 2>&1 | FileCheck %s
4 define i16 @test1(i8 %x) {
6 %B = sext i12 %A to i16
7 ; CHECK: zext i8 %x to i16
11 define i8 @test2(i8 %x) {
12 %A = zext i8 %x to i16
14 %C = trunc i16 %B to i8
19 define i8 @test3(i8 %x) {
20 %A = zext i8 %x to i16
22 %C = trunc i16 %B to i8
27 define void @test4(i32 %x, i32 %y) {
32 %A = phi i32 [0, %entry], [%I, %loop]
33 %rand1 = icmp sgt i32 %A, %Y
34 %Z1 = select i1 %rand1, i32 %A, i32 %Y
35 %rand2 = icmp ugt i32 %A, %Z1
36 %Z2 = select i1 %rand2, i32 %A, i32 %Z1
38 ; CHECK-NEXT: --> ([[EXPR:.*]]){{ U: [^ ]+ S: [^ ]+}}{{ +}}Exits: 20
39 %B = trunc i32 %Z2 to i16
40 %C = sext i16 %B to i30
42 ; CHECK-NEXT: (trunc i32 ([[EXPR]]) to i30)
43 %D = sext i16 %B to i32
45 ; CHECK-NEXT: ([[EXPR]])
46 %E = sext i16 %B to i34
48 ; CHECK-NEXT: (zext i32 ([[EXPR]]) to i34)
49 %F = zext i16 %B to i30
51 ; CHECK-NEXT: (trunc i32 ([[EXPR]]) to i30
52 %G = zext i16 %B to i32
54 ; CHECK-NEXT: ([[EXPR]])
55 %H = zext i16 %B to i34
57 ; CHECK-NEXT: (zext i32 ([[EXPR]]) to i34)
59 %0 = icmp ne i32 %A, 20
60 br i1 %0, label %loop, label %exit
65 define void @test5(i32 %i) {
68 ; CHECK: --> (zext i1 (trunc i32 %i to i1) to i32)
70 ; CHECK: --> (2 * (zext i1 (trunc i32 (%i /u 2) to i1) to i32))
72 ; CHECK: --> (zext i6 (trunc i32 %i to i6) to i32)
74 ; CHECK: --> (2 * (zext i6 (trunc i32 (%i /u 2) to i6) to i32))
76 ; CHECK: --> (64 * (zext i1 (trunc i32 (%i /u 64) to i1) to i32))
77 %F = and i32 %i, -2147483648
78 ; CHECK: --> (-2147483648 * (%i /u -2147483648))
82 define void @test6(i8 %x) {
84 %A = zext i8 %x to i16
85 %B = shl nuw i16 %A, 8
86 %C = and i16 %B, -2048
87 ; CHECK: --> (2048 * ((zext i8 %x to i16) /u 8))
92 define void @test7(i32 %A) {
94 %B = sext i32 %A to i64
95 %C = zext i32 %A to i64
97 %E = trunc i64 %D to i16
103 define i64 @test8(i64 %a) {
104 ; CHECK-LABEL: @test8
105 %t0 = udiv i64 %a, 56
106 %t1 = udiv i64 %t0, 56
108 ; CHECK-NEXT: --> (%a /u 3136)
112 define i64 @test9(i64 %a) {
113 ; CHECK-LABEL: @test9
114 %t0 = udiv i64 %a, 100000000000000
115 %t1 = udiv i64 %t0, 100000000000000
121 define i64 @test10(i64 %a, i64 %b) {
122 ; CHECK-LABEL: @test10
123 %t0 = udiv i64 %a, 100000000000000
124 %t1 = udiv i64 %t0, 100000000000000
125 %t2 = mul i64 %b, %t1
131 define i64 @test11(i64 %a) {
132 ; CHECK-LABEL: @test11