1 ; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py
2 ; RUN: opt -S -disable-output "-passes=print<scalar-evolution>" < %s 2>&1 | FileCheck %s
5 define i32 @mul_biggerShl(i32 %val) nounwind {
6 ; CHECK-LABEL: 'mul_biggerShl'
7 ; CHECK-NEXT: Classifying expressions for: @mul_biggerShl
8 ; CHECK-NEXT: %tmp1 = mul i32 %val, 64
9 ; CHECK-NEXT: --> (64 * %val) U: [0,-63) S: [-2147483648,2147483585)
10 ; CHECK-NEXT: %tmp2 = udiv i32 %tmp1, 16
11 ; CHECK-NEXT: --> ((64 * %val) /u 16) U: [0,268435453) S: [0,268435456)
12 ; CHECK-NEXT: Determining loop execution counts for: @mul_biggerShl
14 %tmp1 = mul i32 %val, 64
15 %tmp2 = udiv i32 %tmp1, 16
19 define i32 @mul_biggerLshl(i32 %val) nounwind {
20 ; CHECK-LABEL: 'mul_biggerLshl'
21 ; CHECK-NEXT: Classifying expressions for: @mul_biggerLshl
22 ; CHECK-NEXT: %tmp1 = mul i32 %val, 16
23 ; CHECK-NEXT: --> (16 * %val) U: [0,-15) S: [-2147483648,2147483633)
24 ; CHECK-NEXT: %tmp2 = udiv i32 %tmp1, 64
25 ; CHECK-NEXT: --> ((16 * %val) /u 64) U: [0,67108864) S: [0,67108864)
26 ; CHECK-NEXT: Determining loop execution counts for: @mul_biggerLshl
28 %tmp1 = mul i32 %val, 16
29 %tmp2 = udiv i32 %tmp1, 64
33 ; Or, it could have been transformed to shifts
35 define i32 @shifty_biggerShl(i32 %val) {
36 ; CHECK-LABEL: 'shifty_biggerShl'
37 ; CHECK-NEXT: Classifying expressions for: @shifty_biggerShl
38 ; CHECK-NEXT: %tmp1 = shl i32 %val, 6
39 ; CHECK-NEXT: --> (64 * %val) U: [0,-63) S: [-2147483648,2147483585)
40 ; CHECK-NEXT: %tmp2 = lshr i32 %tmp1, 4
41 ; CHECK-NEXT: --> ((64 * %val) /u 16) U: [0,268435453) S: [0,268435456)
42 ; CHECK-NEXT: Determining loop execution counts for: @shifty_biggerShl
44 %tmp1 = shl i32 %val, 6
45 %tmp2 = lshr i32 %tmp1, 4
49 define i32 @shifty_biggerShl_shlnuw(i32 %val) {
50 ; CHECK-LABEL: 'shifty_biggerShl_shlnuw'
51 ; CHECK-NEXT: Classifying expressions for: @shifty_biggerShl_shlnuw
52 ; CHECK-NEXT: %tmp1 = shl nuw i32 %val, 6
53 ; CHECK-NEXT: --> (64 * %val) U: [0,-63) S: [-2147483648,2147483585)
54 ; CHECK-NEXT: %tmp2 = lshr i32 %tmp1, 4
55 ; CHECK-NEXT: --> ((64 * %val) /u 16) U: [0,268435453) S: [0,268435456)
56 ; CHECK-NEXT: Determining loop execution counts for: @shifty_biggerShl_shlnuw
58 %tmp1 = shl nuw i32 %val, 6
59 %tmp2 = lshr i32 %tmp1, 4
63 define i32 @shifty_biggerLshr(i32 %val) {
64 ; CHECK-LABEL: 'shifty_biggerLshr'
65 ; CHECK-NEXT: Classifying expressions for: @shifty_biggerLshr
66 ; CHECK-NEXT: %tmp1 = shl i32 %val, 4
67 ; CHECK-NEXT: --> (16 * %val) U: [0,-15) S: [-2147483648,2147483633)
68 ; CHECK-NEXT: %tmp2 = lshr i32 %tmp1, 6
69 ; CHECK-NEXT: --> ((16 * %val) /u 64) U: [0,67108864) S: [0,67108864)
70 ; CHECK-NEXT: Determining loop execution counts for: @shifty_biggerLshr
72 %tmp1 = shl i32 %val, 4
73 %tmp2 = lshr i32 %tmp1, 6
77 define i32 @shifty_biggerLshr_shlnuw(i32 %val) {
78 ; CHECK-LABEL: 'shifty_biggerLshr_shlnuw'
79 ; CHECK-NEXT: Classifying expressions for: @shifty_biggerLshr_shlnuw
80 ; CHECK-NEXT: %tmp1 = shl nuw i32 %val, 4
81 ; CHECK-NEXT: --> (16 * %val) U: [0,-15) S: [-2147483648,2147483633)
82 ; CHECK-NEXT: %tmp2 = lshr i32 %tmp1, 6
83 ; CHECK-NEXT: --> ((16 * %val) /u 64) U: [0,67108864) S: [0,67108864)
84 ; CHECK-NEXT: Determining loop execution counts for: @shifty_biggerLshr_shlnuw
86 %tmp1 = shl nuw i32 %val, 4
87 %tmp2 = lshr i32 %tmp1, 6
91 ; Or, further folded into mask variant.
93 define i32 @masky_biggerShl(i32 %val) {
94 ; CHECK-LABEL: 'masky_biggerShl'
95 ; CHECK-NEXT: Classifying expressions for: @masky_biggerShl
96 ; CHECK-NEXT: %tmp1 = shl i32 %val, 2
97 ; CHECK-NEXT: --> (4 * %val) U: [0,-3) S: [-2147483648,2147483645)
98 ; CHECK-NEXT: %tmp2 = and i32 %tmp1, 268435452
99 ; CHECK-NEXT: --> (4 * (zext i26 (trunc i32 %val to i26) to i32))<nuw><nsw> U: [0,268435453) S: [0,268435453)
100 ; CHECK-NEXT: Determining loop execution counts for: @masky_biggerShl
102 %tmp1 = shl i32 %val, 2
103 %tmp2 = and i32 %tmp1, 268435452
107 define i32 @masky_biggerShl_shlnuw(i32 %val) {
108 ; CHECK-LABEL: 'masky_biggerShl_shlnuw'
109 ; CHECK-NEXT: Classifying expressions for: @masky_biggerShl_shlnuw
110 ; CHECK-NEXT: %tmp1 = shl nuw i32 %val, 2
111 ; CHECK-NEXT: --> (4 * %val) U: [0,-3) S: [-2147483648,2147483645)
112 ; CHECK-NEXT: Determining loop execution counts for: @masky_biggerShl_shlnuw
114 %tmp1 = shl nuw i32 %val, 2
118 define i32 @masky_biggerLshr(i32 %val) {
119 ; CHECK-LABEL: 'masky_biggerLshr'
120 ; CHECK-NEXT: Classifying expressions for: @masky_biggerLshr
121 ; CHECK-NEXT: %tmp1 = lshr i32 %val, 2
122 ; CHECK-NEXT: --> (%val /u 4) U: [0,1073741824) S: [0,1073741824)
123 ; CHECK-NEXT: %tmp2 = and i32 %tmp1, 67108863
124 ; CHECK-NEXT: --> (zext i26 (trunc i32 (%val /u 4) to i26) to i32) U: [0,67108864) S: [0,67108864)
125 ; CHECK-NEXT: Determining loop execution counts for: @masky_biggerLshr
127 %tmp1 = lshr i32 %val, 2
128 %tmp2 = and i32 %tmp1, 67108863
132 define i32 @masky_biggerLshr_shlnuw(i32 %val) {
133 ; CHECK-LABEL: 'masky_biggerLshr_shlnuw'
134 ; CHECK-NEXT: Classifying expressions for: @masky_biggerLshr_shlnuw
135 ; CHECK-NEXT: %tmp1 = lshr i32 %val, 2
136 ; CHECK-NEXT: --> (%val /u 4) U: [0,1073741824) S: [0,1073741824)
137 ; CHECK-NEXT: Determining loop execution counts for: @masky_biggerLshr_shlnuw
139 %tmp1 = lshr i32 %val, 2