1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -O0 -relocation-model=pic -frame-pointer=all < %s | FileCheck %s
3 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
4 target triple = "x86_64-apple-darwin10"
6 ; This file contains functions that may crash llc -O0
8 ; The DIV8 instruction produces results in AH and AL, but we don't want to use
9 ; AH in 64-bit mode. The hack used must not generate copyFromReg nodes for
10 ; aliased registers (AX and AL) - RegAllocFast does not like that.
12 define i32 @div8() nounwind {
14 ; CHECK: ## %bb.0: ## %entry
15 ; CHECK-NEXT: pushq %rbp
16 ; CHECK-NEXT: movq %rsp, %rbp
17 ; CHECK-NEXT: ## implicit-def: $rax
18 ; CHECK-NEXT: movb %al, %cl
19 ; CHECK-NEXT: xorl %eax, %eax
20 ; CHECK-NEXT: ## kill: def $al killed $al killed $eax
21 ; CHECK-NEXT: movzbw %al, %ax
22 ; CHECK-NEXT: divb %cl
23 ; CHECK-NEXT: movb %al, {{[-0-9]+}}(%r{{[sb]}}p) ## 1-byte Spill
24 ; CHECK-NEXT: xorl %eax, %eax
25 ; CHECK-NEXT: ## kill: def $al killed $al killed $eax
26 ; CHECK-NEXT: movzbw %al, %ax
27 ; CHECK-NEXT: divb %cl
28 ; CHECK-NEXT: shrw $8, %ax
29 ; CHECK-NEXT: ## kill: def $al killed $al killed $ax
30 ; CHECK-NEXT: cmpb %cl, %al
31 ; CHECK-NEXT: jae LBB0_2
32 ; CHECK-NEXT: ## %bb.1: ## %"39"
33 ; CHECK-NEXT: movb {{[-0-9]+}}(%r{{[sb]}}p), %al ## 1-byte Reload
34 ; CHECK-NEXT: movzbl %al, %eax
35 ; CHECK-NEXT: ## implicit-def: $ecx
36 ; CHECK-NEXT: imull %ecx, %eax
37 ; CHECK-NEXT: ## implicit-def: $ecx
38 ; CHECK-NEXT: addl %ecx, %eax
39 ; CHECK-NEXT: ## implicit-def: $ecx
40 ; CHECK-NEXT: cmpl %ecx, %eax
41 ; CHECK-NEXT: je LBB0_3
42 ; CHECK-NEXT: LBB0_2: ## %"40"
44 ; CHECK-NEXT: LBB0_3: ## %"41"
47 %0 = trunc i64 undef to i8 ; <i8> [#uses=3]
48 %1 = udiv i8 0, %0 ; <i8> [#uses=1]
49 %2 = urem i8 0, %0 ; <i8> [#uses=1]
50 %3 = icmp uge i8 %2, %0 ; <i1> [#uses=1]
51 br i1 %3, label %"40", label %"39"
54 %4 = zext i8 %1 to i32 ; <i32> [#uses=1]
55 %5 = mul nsw i32 %4, undef ; <i32> [#uses=1]
56 %6 = add nsw i32 %5, undef ; <i32> [#uses=1]
57 %7 = icmp ne i32 %6, undef ; <i1> [#uses=1]
58 br i1 %7, label %"40", label %"41"
60 "40": ; preds = %"39", %"36"
67 ; When using fast isel, sdiv is lowered into a sequence of CQO + DIV64.
68 ; CQO defines implicitly AX and DIV64 uses it implicitly too.
69 ; When an instruction gets between those two, RegAllocFast was reusing
70 ; AX for the vreg defined in between and the compiler crashed.
72 ; An instruction gets between CQO and DIV64 because the load is folded
73 ; into the division but it requires a sign extension.
75 define i64 @addressModeWith32bitIndex(i32 %V) {
76 ; CHECK-LABEL: addressModeWith32bitIndex:
78 ; CHECK-NEXT: pushq %rbp
79 ; CHECK-NEXT: .cfi_def_cfa_offset 16
80 ; CHECK-NEXT: .cfi_offset %rbp, -16
81 ; CHECK-NEXT: movq %rsp, %rbp
82 ; CHECK-NEXT: .cfi_def_cfa_register %rbp
83 ; CHECK-NEXT: xorl %eax, %eax
84 ; CHECK-NEXT: movl %eax, %ecx
85 ; CHECK-NEXT: movq %rcx, %rax
87 ; CHECK-NEXT: movslq %edi, %rsi
88 ; CHECK-NEXT: idivq (%rcx,%rsi,8)
89 ; CHECK-NEXT: popq %rbp
91 %gep = getelementptr i64, ptr null, i32 %V
92 %load = load i64, ptr %gep
93 %sdiv = sdiv i64 0, %load