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 @div(i32 %val) nounwind {
7 ; CHECK-NEXT: Classifying expressions for: @div
8 ; CHECK-NEXT: %tmp1 = udiv i32 %val, 16
9 ; CHECK-NEXT: --> (%val /u 16) U: [0,268435456) S: [0,268435456)
10 ; CHECK-NEXT: %tmp2 = mul i32 %tmp1, 16
11 ; CHECK-NEXT: --> (16 * (%val /u 16))<nuw> U: [0,-15) S: [-2147483648,2147483633)
12 ; CHECK-NEXT: Determining loop execution counts for: @div
14 %tmp1 = udiv i32 %val, 16
15 %tmp2 = mul i32 %tmp1, 16
19 define i32 @sdiv(i32 %val) nounwind {
21 ; CHECK-NEXT: Classifying expressions for: @sdiv
22 ; CHECK-NEXT: %tmp1 = sdiv i32 %val, 16
23 ; CHECK-NEXT: --> %tmp1 U: [-134217728,134217728) S: [-134217728,134217728)
24 ; CHECK-NEXT: %tmp2 = mul i32 %tmp1, 16
25 ; CHECK-NEXT: --> (16 * %tmp1)<nsw> U: [0,-15) S: [-2147483648,2147483633)
26 ; CHECK-NEXT: Determining loop execution counts for: @sdiv
28 %tmp1 = sdiv i32 %val, 16
29 %tmp2 = mul i32 %tmp1, 16
33 ; Or, it could be a number of equivalent patterns with mask:
34 ; b) x & (-1 << nbits)
35 ; d) x >> nbits << nbits
37 define i32 @mask_b(i32 %val) nounwind {
38 ; CHECK-LABEL: 'mask_b'
39 ; CHECK-NEXT: Classifying expressions for: @mask_b
40 ; CHECK-NEXT: %masked = and i32 %val, -16
41 ; CHECK-NEXT: --> (16 * (%val /u 16))<nuw> U: [0,-15) S: [-2147483648,2147483633)
42 ; CHECK-NEXT: Determining loop execution counts for: @mask_b
44 %masked = and i32 %val, -16
48 define i32 @mask_d(i32 %val) nounwind {
49 ; CHECK-LABEL: 'mask_d'
50 ; CHECK-NEXT: Classifying expressions for: @mask_d
51 ; CHECK-NEXT: %lowbitscleared = lshr i32 %val, 4
52 ; CHECK-NEXT: --> (%val /u 16) U: [0,268435456) S: [0,268435456)
53 ; CHECK-NEXT: %masked = shl i32 %lowbitscleared, 4
54 ; CHECK-NEXT: --> (16 * (%val /u 16))<nuw> U: [0,-15) S: [-2147483648,2147483633)
55 ; CHECK-NEXT: Determining loop execution counts for: @mask_d
57 %lowbitscleared = lshr i32 %val, 4
58 %masked = shl i32 %lowbitscleared, 4