1 ; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py
2 ; RUN: opt -S -analyze -enable-new-pm=0 -scalar-evolution < %s | FileCheck %s
3 ; RUN: opt -S -disable-output "-passes=print<scalar-evolution>" < %s 2>&1 | FileCheck %s
5 ; These testcases aren't *identical* but they have the same/similar meaning.
8 define i32 @div(i32 %val, i32 %num) nounwind {
10 ; CHECK-NEXT: Classifying expressions for: @div
11 ; CHECK-NEXT: %tmp1 = udiv i32 %val, %num
12 ; CHECK-NEXT: --> (%val /u %num) U: full-set S: full-set
13 ; CHECK-NEXT: %tmp2 = mul i32 %tmp1, %num
14 ; CHECK-NEXT: --> ((%val /u %num) * %num) U: full-set S: full-set
15 ; CHECK-NEXT: Determining loop execution counts for: @div
17 %tmp1 = udiv i32 %val, %num
18 %tmp2 = mul i32 %tmp1, %num
22 define i32 @sdiv(i32 %val, i32 %num) nounwind {
24 ; CHECK-NEXT: Classifying expressions for: @sdiv
25 ; CHECK-NEXT: %tmp1 = sdiv i32 %val, %num
26 ; CHECK-NEXT: --> %tmp1 U: full-set S: full-set
27 ; CHECK-NEXT: %tmp2 = mul i32 %tmp1, %num
28 ; CHECK-NEXT: --> (%num * %tmp1) U: full-set S: full-set
29 ; CHECK-NEXT: Determining loop execution counts for: @sdiv
31 %tmp1 = sdiv i32 %val, %num
32 %tmp2 = mul i32 %tmp1, %num
36 ; Or, it could be a number of equivalent patterns with mask:
37 ; b) x & (-1 << nbits)
38 ; d) x >> (32 - y) << (32 - y)
40 define i32 @mask_b(i32 %val, i32 %numlowbits) nounwind {
41 ; CHECK-LABEL: 'mask_b'
42 ; CHECK-NEXT: Classifying expressions for: @mask_b
43 ; CHECK-NEXT: %mask = shl i32 -1, %numlowbits
44 ; CHECK-NEXT: --> %mask U: full-set S: full-set
45 ; CHECK-NEXT: %masked = and i32 %mask, %val
46 ; CHECK-NEXT: --> %masked U: full-set S: full-set
47 ; CHECK-NEXT: Determining loop execution counts for: @mask_b
49 %mask = shl i32 -1, %numlowbits
50 %masked = and i32 %mask, %val
54 define i32 @mask_d(i32 %val, i32 %lowbits) nounwind {
55 ; CHECK-LABEL: 'mask_d'
56 ; CHECK-NEXT: Classifying expressions for: @mask_d
57 ; CHECK-NEXT: %numlowbits = sub i32 32, %lowbits
58 ; CHECK-NEXT: --> (32 + (-1 * %lowbits)) U: full-set S: full-set
59 ; CHECK-NEXT: %lowbitscleared = lshr i32 %val, %numlowbits
60 ; CHECK-NEXT: --> %lowbitscleared U: full-set S: full-set
61 ; CHECK-NEXT: %masked = shl i32 %lowbitscleared, %numlowbits
62 ; CHECK-NEXT: --> %masked U: full-set S: full-set
63 ; CHECK-NEXT: Determining loop execution counts for: @mask_d
65 %numlowbits = sub i32 32, %lowbits
66 %lowbitscleared = lshr i32 %val, %numlowbits
67 %masked = shl i32 %lowbitscleared, %numlowbits