1 # RUN: llc -run-pass x86-fixup-LEAs -mtriple=x86_64-gnu-unknown -verify-machineinstrs -mcpu=corei7-avx -o - %s | FileCheck %s --check-prefixes=COREI7,CHECK
2 # RUN: llc -run-pass x86-fixup-LEAs -mtriple=x86_64-gnu-unknown -verify-machineinstrs -mcpu=haswell -o - %s | FileCheck %s --check-prefixes=HASWELL,CHECK
3 # RUN: llc -run-pass x86-fixup-LEAs -mtriple=x86_64-unknown-unknown -verify-machineinstrs -mcpu=atom -o - %s | FileCheck %s --check-prefixes=ATOM,CHECK
5 # Test several LEA <=> ADD transformations that the fixup-leas pass performs,
6 # and check that any debug-instr-number attached to the original instruction
7 # is substituted onto the new instruction.
8 # Some are only reachable under specific CPU modes it seems -- each function
9 # in this file is only tested by one prefix / CPU mode. Some i386 specific
10 # behaviours are in the -2 flavour of this file.
12 # COREI7-LABEL: name: pr43758
15 tracksRegLiveness: true
20 # COREI7: debugValueSubstitutions:
21 # COREI7-NEXT: - { srcinst: 1, srcop: 0, dstinst: 2, dstop: 0, subreg: 0 }
26 $ebp = LEA64_32r killed $rbp, 1, killed $rax, 0, $noreg, debug-instr-number 1
27 ; COREI7: ADD32rr {{.*}} debug-instr-number 2
33 # HASWELL-LABEL: name: test_mul_spec
35 tracksRegLiveness: true
42 machineFunctionInfo: {}
43 # HASWELL: debugValueSubstitutions:
44 # HASWELL-NEXT: - { srcinst: 1, srcop: 0, dstinst: 3, dstop: 0, subreg: 0 }
45 # HASWELL-NEXT: - { srcinst: 2, srcop: 0, dstinst: 4, dstop: 0, subreg: 0 }
50 renamable $edi = KILL $edi, implicit-def $rdi
51 renamable $ecx = nsw LEA64_32r renamable $rdi, 8, renamable $rdi, 42, $noreg, debug-instr-number 1
52 ; HASWELL: ADD32ri {{.*}} debug-instr-number 3
53 renamable $eax = nsw LEA64_32r killed renamable $rdi, 4, renamable $rdi, 2, $noreg, debug-instr-number 2
54 ; HASWELL: ADD32ri {{.*}} debug-instr-number 4
55 renamable $eax = nsw IMUL32rr killed renamable $eax, killed renamable $ecx, implicit-def dead $eflags
61 # ATOM-LABEL: name: testthree
63 tracksRegLiveness: true
68 machineFunctionInfo: {}
69 # ATOM: debugValueSubstitutions:
70 # ATOM-NEXT: - { srcinst: 1, srcop: 0, dstinst: 2, dstop: 0, subreg: 0 }
73 renamable $ecx = MOV32ri 0
74 renamable $eax = XOR32rr undef $eax, undef $eax, implicit-def dead $eflags
75 renamable $ecx = nsw ADD32rr renamable $ecx, renamable $eax, implicit-def dead $eflags, implicit killed $rax, implicit killed $rcx, implicit-def $rcx, debug-instr-number 1
76 ; ATOM: LEA64_32r {{.*}} debug-instr-number 2
77 renamable $eax = MOV32rm killed renamable $rcx, 1, $noreg, 0, $noreg :: (load (s32) from `i32 *undef`)
82 # CHECK-LABEL: testfour
83 # In this code sequence, an LEA is converted into a subtract that's combined
84 # with another subtract. The instruction number on the computed value should
85 # only be attached to the last subtract.
88 tracksRegLiveness: true
89 tracksDebugUserValues: true
96 machineFunctionInfo: {}
97 # CHECK: debugValueSubstitutions:
98 # CHECK-NEXT: - { srcinst: 1, srcop: 0, dstinst: 2, dstop: 0, subreg: 0 }
99 # CHECK-NEXT: constants:
104 $eax = MOV32rr $esi, implicit-def $rax
106 renamable $ecx = LEA64_32r renamable $rax, 1, renamable $rax, 0, $noreg
107 renamable $edx = MOV32ri 1
108 renamable $edx = SUB32rr killed renamable $edx, killed renamable $ecx, implicit-def dead $eflags, debug-instr-number 1
111 ; CHECK-NOT: debug-instr-number
112 ; CHECK-NEXT: SUB32rr
113 ; CHECK-NOT: debug-instr-number
114 ; CHECK-NEXT: SUB32rr
115 ; CHECK-SAME: debug-instr-number 2
117 MOV32mr $noreg, 1, $noreg, 0, $noreg, killed renamable $edx
118 $eax = KILL renamable $eax, implicit killed $rax