Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / llvm / test / MC / X86 / align-via-padding.s
blob2946434087cca798415b9b493fe183e294aa796d
1 # RUN: llvm-mc -mcpu=skylake -filetype=obj -triple x86_64-pc-linux-gnu %s -x86-pad-max-prefix-size=5 -x86-pad-for-align=1 | llvm-objdump --no-print-imm-hex -d - | FileCheck %s
3 # This test file highlights the interactions between prefix padding and
4 # relaxation padding.
6 .file "test.c"
7 .text
8 .section .text
9 # We can both relax and prefix for padding purposes, but the moment, we
10 # can't prefix without first having relaxed.
11 # CHECK: .text
12 # CHECK: 0: eb 1f jmp
13 # CHECK: 2: eb 1d jmp
14 # CHECK: 4: eb 1b jmp
15 # CHECK: 6: eb 19 jmp
16 # CHECK: 8: eb 17 jmp
17 # CHECK: a: 2e 2e 2e 2e 2e e9 0d 00 00 00 jmp
18 # CHECK: 14: 2e 2e 2e 2e 2e e9 03 00 00 00 jmp
19 # CHECK: 1e: 66 90 nop
20 # CHECK: 20: cc int3
21 .p2align 4
22 jmp foo
23 jmp foo
24 jmp foo
25 jmp foo
26 jmp foo
27 jmp foo
28 jmp foo
29 .p2align 5
30 int3
31 foo:
32 ret
34 # Canonical toy loop to show benefit - we can align the loop header with
35 # fewer nops by relaxing the branch, even though we don't need to
36 # CHECK: <loop_preheader>:
37 # CHECK: 45: 48 85 c0 testq %rax, %rax
38 # CHECK: 48: 2e 2e 2e 2e 0f 8e 1e 00 00 00 jle 0x70 <loop_exit>
39 # CHECK: 52: 66 66 66 66 66 2e 0f 1f 84 00 00 00 00 00 nopw %cs:(%rax,%rax)
40 # CHECK: <loop_header>:
41 # CHECK: 60: 48 83 e8 01 subq $1, %rax
42 # CHECK: 64: 48 85 c0 testq %rax, %rax
43 # CHECK: 67: 7e 07 jle 0x70 <loop_exit>
44 # CHECK: 69: 2e 2e e9 f0 ff ff ff jmp
45 # CHECK: <loop_exit>:
46 # CHECK: 70: c3 retq
47 .p2align 5
48 .skip 5
49 loop_preheader:
50 testq %rax, %rax
51 jle loop_exit
52 .p2align 5
53 loop_header:
54 subq $1, %rax
55 testq %rax, %rax
56 jle loop_exit
57 jmp loop_header
58 .p2align 4
59 loop_exit:
60 ret
62 # Correctness cornercase - can't prefix pad jmp without having relaxed it
63 # first as doing so would make the relative offset too large
64 # CHECK: fd: cc int3
65 # CHECK: fe: eb 80 jmp 0x80 <loop_exit+0x10>
66 # CHECK: 100: cc int3
67 .p2align 5
68 .L1:
69 .rept 126
70 int3
71 .endr
72 jmp .L1
73 .rept 30
74 int3
75 .endr
76 .p2align 5