xref: /llvm-project/llvm/test/Analysis/ScalarEvolution/mul.ll (revision 9bdb19cca292f7a8335148e5c1b85f7e9120a1a5)
1; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py
2; RUN: opt < %s "-passes=print<scalar-evolution>" -disable-output 2>&1 | FileCheck %s
3
4define i8 @test(i8 %x, i8 %y) {
5; CHECK-LABEL: 'test'
6; CHECK-NEXT:  Classifying expressions for: @test
7; CHECK-NEXT:    %udiv = udiv i8 %x, %y
8; CHECK-NEXT:    --> (%x /u %y) U: full-set S: full-set
9; CHECK-NEXT:    %res = mul i8 %udiv, %y
10; CHECK-NEXT:    --> ((%x /u %y) * %y)<nuw> U: full-set S: full-set
11; CHECK-NEXT:  Determining loop execution counts for: @test
12;
13  %udiv = udiv i8 %x, %y
14  %res = mul i8 %udiv, %y
15  ret i8 %res
16}
17
18define i8 @test2(i8 %x) {
19; CHECK-LABEL: 'test2'
20; CHECK-NEXT:  Classifying expressions for: @test2
21; CHECK-NEXT:    %udiv = udiv i8 %x, 2
22; CHECK-NEXT:    --> (%x /u 2) U: [0,-128) S: [0,-128)
23; CHECK-NEXT:    %res = mul i8 %udiv, 2
24; CHECK-NEXT:    --> (2 * (%x /u 2))<nuw> U: [0,-1) S: [-128,127)
25; CHECK-NEXT:  Determining loop execution counts for: @test2
26;
27  %udiv = udiv i8 %x, 2
28  %res = mul i8 %udiv, 2
29  ret i8 %res
30}
31
32define i8 @test3(i8 %x) {
33; CHECK-LABEL: 'test3'
34; CHECK-NEXT:  Classifying expressions for: @test3
35; CHECK-NEXT:    %udiv = udiv i8 %x, -128
36; CHECK-NEXT:    --> (%x /u -128) U: [0,2) S: [0,2)
37; CHECK-NEXT:    %res = mul i8 %udiv, -128
38; CHECK-NEXT:    --> (-128 * (%x /u -128))<nuw><nsw> U: [0,-127) S: [-128,1)
39; CHECK-NEXT:  Determining loop execution counts for: @test3
40;
41  %udiv = udiv i8 %x, 128
42  %res = mul i8 %udiv, 128
43  ret i8 %res
44}
45
46define i8 @test4(i8 %x) {
47; CHECK-LABEL: 'test4'
48; CHECK-NEXT:  Classifying expressions for: @test4
49; CHECK-NEXT:    %udiv = udiv i8 %x, -1
50; CHECK-NEXT:    --> (%x /u -1) U: [0,2) S: [0,2)
51; CHECK-NEXT:    %res = mul i8 %udiv, -1
52; CHECK-NEXT:    --> (-1 * (%x /u -1))<nuw><nsw> U: [-1,1) S: [-1,1)
53; CHECK-NEXT:  Determining loop execution counts for: @test4
54;
55  %udiv = udiv i8 %x, 255
56  %res = mul i8 %udiv, 255
57  ret i8 %res
58}
59
60define i8 @test5(i8 %x, i32 %y32) {
61; CHECK-LABEL: 'test5'
62; CHECK-NEXT:  Classifying expressions for: @test5
63; CHECK-NEXT:    %y = trunc i32 %y32 to i8
64; CHECK-NEXT:    --> (trunc i32 %y32 to i8) U: full-set S: full-set
65; CHECK-NEXT:    %udiv = udiv i8 %x, %y
66; CHECK-NEXT:    --> (%x /u (trunc i32 %y32 to i8)) U: full-set S: full-set
67; CHECK-NEXT:    %res = mul i8 %udiv, %y
68; CHECK-NEXT:    --> ((trunc i32 %y32 to i8) * (%x /u (trunc i32 %y32 to i8)))<nuw> U: full-set S: full-set
69; CHECK-NEXT:  Determining loop execution counts for: @test5
70;
71  %y = trunc i32 %y32 to i8
72  %udiv = udiv i8 %x, %y
73  %res = mul i8 %udiv, %y
74  ret i8 %res
75}
76