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
4 ; These testcases aren't *identical* but they have the same/similar meaning.
7 define i32 @div(i32 %val, i32 %num) nounwind {
9 ; CHECK-NEXT: Classifying expressions for: @div
10 ; CHECK-NEXT: %tmp1 = udiv i32 %val, %num
11 ; CHECK-NEXT: --> (%val /u %num) U: full-set S: full-set
12 ; CHECK-NEXT: %tmp2 = mul i32 %tmp1, %num
13 ; CHECK-NEXT: --> ((%val /u %num) * %num)<nuw> U: full-set S: full-set
14 ; CHECK-NEXT: Determining loop execution counts for: @div
16 %tmp1 = udiv i32 %val, %num
17 %tmp2 = mul i32 %tmp1, %num
21 define i32 @sdiv(i32 %val, i32 %num) nounwind {
23 ; CHECK-NEXT: Classifying expressions for: @sdiv
24 ; CHECK-NEXT: %tmp1 = sdiv i32 %val, %num
25 ; CHECK-NEXT: --> %tmp1 U: full-set S: full-set
26 ; CHECK-NEXT: %tmp2 = mul i32 %tmp1, %num
27 ; CHECK-NEXT: --> (%num * %tmp1) U: full-set S: full-set
28 ; CHECK-NEXT: Determining loop execution counts for: @sdiv
30 %tmp1 = sdiv i32 %val, %num
31 %tmp2 = mul i32 %tmp1, %num
35 ; Or, it could be a number of equivalent patterns with mask:
36 ; b) x & (-1 << nbits)
37 ; d) x >> (32 - y) << (32 - y)
39 define i32 @mask_b(i32 %val, i32 %numlowbits) nounwind {
40 ; CHECK-LABEL: 'mask_b'
41 ; CHECK-NEXT: Classifying expressions for: @mask_b
42 ; CHECK-NEXT: %mask = shl i32 -1, %numlowbits
43 ; CHECK-NEXT: --> %mask U: [-2147483648,0) S: [-2147483648,0)
44 ; CHECK-NEXT: %masked = and i32 %mask, %val
45 ; CHECK-NEXT: --> %masked U: full-set S: full-set
46 ; CHECK-NEXT: Determining loop execution counts for: @mask_b
48 %mask = shl i32 -1, %numlowbits
49 %masked = and i32 %mask, %val
53 define i32 @mask_d(i32 %val, i32 %lowbits) nounwind {
54 ; CHECK-LABEL: 'mask_d'
55 ; CHECK-NEXT: Classifying expressions for: @mask_d
56 ; CHECK-NEXT: %numlowbits = sub i32 32, %lowbits
57 ; CHECK-NEXT: --> (32 + (-1 * %lowbits)) U: full-set S: full-set
58 ; CHECK-NEXT: %lowbitscleared = lshr i32 %val, %numlowbits
59 ; CHECK-NEXT: --> %lowbitscleared U: full-set S: full-set
60 ; CHECK-NEXT: %masked = shl i32 %lowbitscleared, %numlowbits
61 ; CHECK-NEXT: --> %masked U: full-set S: full-set
62 ; CHECK-NEXT: Determining loop execution counts for: @mask_d
64 %numlowbits = sub i32 32, %lowbits
65 %lowbitscleared = lshr i32 %val, %numlowbits
66 %masked = shl i32 %lowbitscleared, %numlowbits