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: xorl %eax, %eax
18 ; CHECK-NEXT: movb %al, %cl
19 ; CHECK-NEXT: ## implicit-def: $rdx
20 ; CHECK-NEXT: movb %dl, %sil
21 ; CHECK-NEXT: movzbw %cl, %ax
22 ; CHECK-NEXT: divb %sil
23 ; CHECK-NEXT: movb %al, {{[-0-9]+}}(%r{{[sb]}}p) ## 1-byte Spill
24 ; CHECK-NEXT: movzbw %cl, %ax
25 ; CHECK-NEXT: divb %sil
26 ; CHECK-NEXT: shrw $8, %ax
27 ; CHECK-NEXT: movb %al, %cl
28 ; CHECK-NEXT: cmpb %sil, %cl
29 ; CHECK-NEXT: jae LBB0_2
30 ; CHECK-NEXT: ## %bb.1: ## %"39"
31 ; CHECK-NEXT: movb {{[-0-9]+}}(%r{{[sb]}}p), %al ## 1-byte Reload
32 ; CHECK-NEXT: movzbl %al, %ecx
33 ; CHECK-NEXT: ## implicit-def: $edx
34 ; CHECK-NEXT: imull %edx, %ecx
35 ; CHECK-NEXT: addl %edx, %ecx
36 ; CHECK-NEXT: cmpl %edx, %ecx
37 ; CHECK-NEXT: je LBB0_3
38 ; CHECK-NEXT: LBB0_2: ## %"40"
40 ; CHECK-NEXT: LBB0_3: ## %"41"
43 %0 = trunc i64 undef to i8 ; <i8> [#uses=3]
44 %1 = udiv i8 0, %0 ; <i8> [#uses=1]
45 %2 = urem i8 0, %0 ; <i8> [#uses=1]
46 %3 = icmp uge i8 %2, %0 ; <i1> [#uses=1]
47 br i1 %3, label %"40", label %"39"
50 %4 = zext i8 %1 to i32 ; <i32> [#uses=1]
51 %5 = mul nsw i32 %4, undef ; <i32> [#uses=1]
52 %6 = add nsw i32 %5, undef ; <i32> [#uses=1]
53 %7 = icmp ne i32 %6, undef ; <i1> [#uses=1]
54 br i1 %7, label %"40", label %"41"
56 "40": ; preds = %"39", %"36"
63 ; When using fast isel, sdiv is lowered into a sequence of CQO + DIV64.
64 ; CQO defines implicitly AX and DIV64 uses it implicitly too.
65 ; When an instruction gets between those two, RegAllocFast was reusing
66 ; AX for the vreg defined in between and the compiler crashed.
68 ; An instruction gets between CQO and DIV64 because the load is folded
69 ; into the division but it requires a sign extension.
71 define i64 @addressModeWith32bitIndex(i32 %V) {
72 ; CHECK-LABEL: addressModeWith32bitIndex:
74 ; CHECK-NEXT: pushq %rbp
75 ; CHECK-NEXT: .cfi_def_cfa_offset 16
76 ; CHECK-NEXT: .cfi_offset %rbp, -16
77 ; CHECK-NEXT: movq %rsp, %rbp
78 ; CHECK-NEXT: .cfi_def_cfa_register %rbp
79 ; CHECK-NEXT: xorl %eax, %eax
80 ; CHECK-NEXT: movl %eax, %ecx
81 ; CHECK-NEXT: movq %rcx, %rax
83 ; CHECK-NEXT: movslq %edi, %rsi
84 ; CHECK-NEXT: idivq (%rcx,%rsi,8)
85 ; CHECK-NEXT: popq %rbp
87 %gep = getelementptr i64, i64* null, i32 %V
88 %load = load i64, i64* %gep
89 %sdiv = sdiv i64 0, %load