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