xref: /aosp_15_r20/external/llvm/test/MC/X86/AlignedBundling/single-inst-bundling.s (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker# RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o - \
2*9880d681SAndroid Build Coastguard Worker# RUN:   | llvm-objdump -disassemble -no-show-raw-insn - | FileCheck -check-prefix=CHECK -check-prefix=CHECK-OPT %s
3*9880d681SAndroid Build Coastguard Worker# RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu -mc-relax-all %s -o - \
4*9880d681SAndroid Build Coastguard Worker# RUN:   | llvm-objdump -disassemble -no-show-raw-insn - | FileCheck -check-prefix=CHECK -check-prefix=CHECK-RELAX %s
5*9880d681SAndroid Build Coastguard Worker
6*9880d681SAndroid Build Coastguard Worker# Test simple NOP insertion for single instructions.
7*9880d681SAndroid Build Coastguard Worker
8*9880d681SAndroid Build Coastguard Worker  .text
9*9880d681SAndroid Build Coastguard Workerfoo:
10*9880d681SAndroid Build Coastguard Worker  # Will be bundle-aligning to 16 byte boundaries
11*9880d681SAndroid Build Coastguard Worker  .bundle_align_mode 4
12*9880d681SAndroid Build Coastguard Worker  pushq   %rbp
13*9880d681SAndroid Build Coastguard Worker  pushq   %r14
14*9880d681SAndroid Build Coastguard Worker  pushq   %rbx
15*9880d681SAndroid Build Coastguard Worker
16*9880d681SAndroid Build Coastguard Worker  movl    %edi, %ebx
17*9880d681SAndroid Build Coastguard Worker  callq   bar
18*9880d681SAndroid Build Coastguard Worker  movl    %eax, %r14d
19*9880d681SAndroid Build Coastguard Worker
20*9880d681SAndroid Build Coastguard Worker  imull   $17, %ebx, %ebp
21*9880d681SAndroid Build Coastguard Worker# This imull is 3 bytes long and should have started at 0xe, so two bytes
22*9880d681SAndroid Build Coastguard Worker# of nop padding are inserted instead and it starts at 0x10
23*9880d681SAndroid Build Coastguard Worker# CHECK:          nop
24*9880d681SAndroid Build Coastguard Worker# CHECK-NEXT:     10: imull
25*9880d681SAndroid Build Coastguard Worker
26*9880d681SAndroid Build Coastguard Worker  movl    %ebx, %edi
27*9880d681SAndroid Build Coastguard Worker  callq   bar
28*9880d681SAndroid Build Coastguard Worker  cmpl    %r14d, %ebp
29*9880d681SAndroid Build Coastguard Worker# CHECK-RELAX:   nopl
30*9880d681SAndroid Build Coastguard Worker  jle     .L_ELSE
31*9880d681SAndroid Build Coastguard Worker# Due to the padding that's inserted before the addl, the jump target
32*9880d681SAndroid Build Coastguard Worker# becomes farther by one byte.
33*9880d681SAndroid Build Coastguard Worker# CHECK-OPT:     jle 5
34*9880d681SAndroid Build Coastguard Worker# CHECK-RELAX:   jle 7
35*9880d681SAndroid Build Coastguard Worker
36*9880d681SAndroid Build Coastguard Worker  addl    %ebp, %eax
37*9880d681SAndroid Build Coastguard Worker# CHECK-OPT:     nop
38*9880d681SAndroid Build Coastguard Worker# CHECK-OPT-NEXT:20: addl
39*9880d681SAndroid Build Coastguard Worker# CHECK-RELAX:   26: addl
40*9880d681SAndroid Build Coastguard Worker
41*9880d681SAndroid Build Coastguard Worker  jmp     .L_RET
42*9880d681SAndroid Build Coastguard Worker.L_ELSE:
43*9880d681SAndroid Build Coastguard Worker  imull   %ebx, %eax
44*9880d681SAndroid Build Coastguard Worker.L_RET:
45*9880d681SAndroid Build Coastguard Worker  ret
46*9880d681SAndroid Build Coastguard Worker
47*9880d681SAndroid Build Coastguard Worker# Just sanity checking that data fills don't drive bundling crazy
48*9880d681SAndroid Build Coastguard Worker  .data
49*9880d681SAndroid Build Coastguard Worker  .byte 40
50*9880d681SAndroid Build Coastguard Worker  .byte 98
51*9880d681SAndroid Build Coastguard Worker
52*9880d681SAndroid Build Coastguard Worker
53