• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; This is a regression test that idiv and div operands are legalized
2; (they cannot be constants and can only be reg/mem for x86).
3
4; RUN: %p2i --filetype=obj --disassemble -i %s --args -O2 | FileCheck %s
5; RUN: %p2i --filetype=obj --disassemble -i %s --args -Om1 | FileCheck %s
6
7define internal i32 @Sdiv_const8_b(i32 %a32) {
8; CHECK-LABEL: Sdiv_const8_b
9entry:
10  %a = trunc i32 %a32 to i8
11  %div = sdiv i8 %a, 12
12; CHECK: mov {{.*}},0xc
13; CHECK-NOT: idiv 0xc
14  %div_ext = sext i8 %div to i32
15  ret i32 %div_ext
16}
17
18define internal i32 @Sdiv_const16_b(i32 %a32) {
19; CHECK-LABEL: Sdiv_const16_b
20entry:
21  %a = trunc i32 %a32 to i16
22  %div = sdiv i16 %a, 1234
23; CHECK: mov {{.*}},0x4d2
24; CHECK-NOT: idiv 0x4d2
25  %div_ext = sext i16 %div to i32
26  ret i32 %div_ext
27}
28
29define internal i32 @Sdiv_const32_b(i32 %a) {
30; CHECK-LABEL: Sdiv_const32_b
31entry:
32  %div = sdiv i32 %a, 1234
33; CHECK: mov {{.*}},0x4d2
34; CHECK-NOT: idiv 0x4d2
35  ret i32 %div
36}
37
38define internal i32 @Srem_const_b(i32 %a) {
39; CHECK-LABEL: Srem_const_b
40entry:
41  %rem = srem i32 %a, 2345
42; CHECK: mov {{.*}},0x929
43; CHECK-NOT: idiv 0x929
44  ret i32 %rem
45}
46
47define internal i32 @Udiv_const_b(i32 %a) {
48; CHECK-LABEL: Udiv_const_b
49entry:
50  %div = udiv i32 %a, 3456
51; CHECK: mov {{.*}},0xd80
52; CHECK-NOT: div 0xd80
53  ret i32 %div
54}
55
56define internal i32 @Urem_const_b(i32 %a) {
57; CHECK-LABEL: Urem_const_b
58entry:
59  %rem = urem i32 %a, 4567
60; CHECK: mov {{.*}},0x11d7
61; CHECK-NOT: div 0x11d7
62  ret i32 %rem
63}
64