1 ; RUN: opt -analyze -scalar-evolution -S < %s | FileCheck %s
3 define i16 @test1(i8 %x) {
5 %B = sext i12 %A to i16
6 ; CHECK: zext i8 %x to i16
10 define i8 @test2(i8 %x) {
11 %A = zext i8 %x to i16
13 %C = trunc i16 %B to i8
18 define i8 @test3(i8 %x) {
19 %A = zext i8 %x to i16
21 %C = trunc i16 %B to i8
26 define void @test4(i32 %x, i32 %y) {
31 %A = phi i32 [0, %entry], [%I, %loop]
32 %rand1 = icmp sgt i32 %A, %Y
33 %Z1 = select i1 %rand1, i32 %A, i32 %Y
34 %rand2 = icmp ugt i32 %A, %Z1
35 %Z2 = select i1 %rand2, i32 %A, i32 %Z1
37 ; CHECK-NEXT: --> ([[EXPR:.*]]){{ U: [^ ]+ S: [^ ]+}}{{ +}}Exits: 20
38 %B = trunc i32 %Z2 to i16
39 %C = sext i16 %B to i30
41 ; CHECK-NEXT: (trunc i32 ([[EXPR]]) to i30)
42 %D = sext i16 %B to i32
44 ; CHECK-NEXT: ([[EXPR]])
45 %E = sext i16 %B to i34
47 ; CHECK-NEXT: (zext i32 ([[EXPR]]) to i34)
48 %F = zext i16 %B to i30
50 ; CHECK-NEXT: (trunc i32 ([[EXPR]]) to i30
51 %G = zext i16 %B to i32
53 ; CHECK-NEXT: ([[EXPR]])
54 %H = zext i16 %B to i34
56 ; CHECK-NEXT: (zext i32 ([[EXPR]]) to i34)
58 %0 = icmp ne i32 %A, 20
59 br i1 %0, label %loop, label %exit
64 define void @test5(i32 %i) {
67 ; CHECK: --> (zext i1 (trunc i32 %i to i1) to i32)
69 ; CHECK: --> (2 * (zext i1 (trunc i32 (%i /u 2) to i1) to i32))
71 ; CHECK: --> (zext i6 (trunc i32 %i to i6) to i32)
73 ; CHECK: --> (2 * (zext i6 (trunc i32 (%i /u 2) to i6) to i32))
75 ; CHECK: --> (64 * (zext i1 (trunc i32 (%i /u 64) to i1) to i32))
76 %F = and i32 %i, -2147483648
77 ; CHECK: --> (-2147483648 * (%i /u -2147483648))
81 define void @test6(i8 %x) {
83 %A = zext i8 %x to i16
84 %B = shl nuw i16 %A, 8
85 %C = and i16 %B, -2048
86 ; CHECK: --> (2048 * ((zext i8 %x to i16) /u 8))
91 define void @test7(i32 %A) {
93 %B = sext i32 %A to i64
94 %C = zext i32 %A to i64
96 %E = trunc i64 %D to i16
102 define i64 @test8(i64 %a) {
103 ; CHECK-LABEL: @test8
104 %t0 = udiv i64 %a, 56
105 %t1 = udiv i64 %t0, 56
107 ; CHECK-NEXT: --> (%a /u 3136)
111 define i64 @test9(i64 %a) {
112 ; CHECK-LABEL: @test9
113 %t0 = udiv i64 %a, 100000000000000
114 %t1 = udiv i64 %t0, 100000000000000
120 define i64 @test10(i64 %a, i64 %b) {
121 ; CHECK-LABEL: @test10
122 %t0 = udiv i64 %a, 100000000000000
123 %t1 = udiv i64 %t0, 100000000000000
124 %t2 = mul i64 %b, %t1