• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; This tests various strength reduction operations.
2
3; RUN: %if --need=target_X8632 --command %p2i --filetype=obj --disassemble \
4; RUN:   --target x8632 -i %s --args -O2 \
5; RUN:   | %if --need=target_X8632 --command FileCheck %s
6
7define internal i32 @mul_i32_arg_5(i32 %arg) {
8  %result = mul i32 %arg, 5
9  ret i32 %result
10}
11; CHECK-LABEL: mul_i32_arg_5
12; CHECK: lea [[REG:e..]],{{\[}}[[REG]]+[[REG]]*4]
13
14define internal i32 @mul_i32_5_arg(i32 %arg) {
15  %result = mul i32 5, %arg
16  ret i32 %result
17}
18; CHECK-LABEL: mul_i32_5_arg
19; CHECK: lea [[REG:e..]],{{\[}}[[REG]]+[[REG]]*4]
20
21define internal i32 @mul_i32_arg_18(i32 %arg) {
22  %result = mul i32 %arg, 18
23  ret i32 %result
24}
25; CHECK-LABEL: mul_i32_arg_18
26; CHECK-DAG: lea [[REG:e..]],{{\[}}[[REG]]+[[REG]]*8]
27; CHECK-DAG: shl [[REG]],1
28
29define internal i32 @mul_i32_arg_27(i32 %arg) {
30  %result = mul i32 %arg, 27
31  ret i32 %result
32}
33; CHECK-LABEL: mul_i32_arg_27
34; CHECK-DAG: lea [[REG:e..]],{{\[}}[[REG]]+[[REG]]*2]
35; CHECK-DAG: lea [[REG]],{{\[}}[[REG]]+[[REG]]*8]
36
37define internal i32 @mul_i32_arg_m45(i32 %arg) {
38  %result = mul i32 %arg, -45
39  ret i32 %result
40}
41; CHECK-LABEL: mul_i32_arg_m45
42; CHECK-DAG: lea [[REG:e..]],{{\[}}[[REG]]+[[REG]]*8]
43; CHECK-DAG: lea [[REG]],{{\[}}[[REG]]+[[REG]]*4]
44; CHECK: neg [[REG]]
45
46define internal i32 @mul_i16_arg_18(i32 %arg) {
47  %arg.16 = trunc i32 %arg to i16
48  %result = mul i16 %arg.16, 18
49  %result.i32 = zext i16 %result to i32
50  ret i32 %result.i32
51}
52; CHECK-LABEL: mul_i16_arg_18
53; CHECK: imul
54
55define internal i32 @mul_i8_arg_16(i32 %arg) {
56  %arg.8 = trunc i32 %arg to i8
57  %result = mul i8 %arg.8, 16
58  %result.i32 = zext i8 %result to i32
59  ret i32 %result.i32
60}
61; CHECK-LABEL: mul_i8_arg_16
62; CHECK: shl {{.*}},0x4
63
64define internal i32 @mul_i8_arg_18(i32 %arg) {
65  %arg.8 = trunc i32 %arg to i8
66  %result = mul i8 %arg.8, 18
67  %result.i32 = zext i8 %result to i32
68  ret i32 %result.i32
69}
70; CHECK-LABEL: mul_i8_arg_18
71; CHECK: imul
72