xref: /llvm-project/llvm/test/CodeGen/X86/absolute-cmp.ll (revision 2f448bf509432c1a19ec46ab8cbc7353c03c6280)
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2; RUN: llc < %s -show-mc-encoding | FileCheck %s --check-prefix=NOPIC
3; RUN: llc -relocation-model=pic -show-mc-encoding < %s | FileCheck %s --check-prefix=PIC
4
5target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
6target triple = "x86_64-unknown-linux-gnu"
7
8@cmp8 = external hidden global i8, !absolute_symbol !0
9@cmp32 = external hidden global i8, !absolute_symbol !1
10
11declare void @f()
12
13define void @foo8(i64 %val) {
14; NOPIC-LABEL: foo8:
15; NOPIC:       # %bb.0:
16; NOPIC-NEXT:    cmpq $cmp8@ABS8, %rdi # encoding: [0x48,0x83,0xff,A]
17; NOPIC-NEXT:    # fixup A - offset: 3, value: cmp8@ABS8, kind: FK_Data_1
18; NOPIC-NEXT:    ja .LBB0_2 # encoding: [0x77,A]
19; NOPIC-NEXT:    # fixup A - offset: 1, value: .LBB0_2-1, kind: FK_PCRel_1
20; NOPIC-NEXT:  # %bb.1: # %t
21; NOPIC-NEXT:    pushq %rax # encoding: [0x50]
22; NOPIC-NEXT:    .cfi_def_cfa_offset 16
23; NOPIC-NEXT:    callq f@PLT # encoding: [0xe8,A,A,A,A]
24; NOPIC-NEXT:    # fixup A - offset: 1, value: f@PLT-4, kind: FK_PCRel_4
25; NOPIC-NEXT:    popq %rax # encoding: [0x58]
26; NOPIC-NEXT:    .cfi_def_cfa_offset 8
27; NOPIC-NEXT:  .LBB0_2: # %f
28; NOPIC-NEXT:    retq # encoding: [0xc3]
29;
30; PIC-LABEL: foo8:
31; PIC:       # %bb.0:
32; PIC-NEXT:    cmpq $cmp8@ABS8, %rdi # encoding: [0x48,0x83,0xff,A]
33; PIC-NEXT:    # fixup A - offset: 3, value: cmp8@ABS8, kind: FK_Data_1
34; PIC-NEXT:    ja .LBB0_2 # encoding: [0x77,A]
35; PIC-NEXT:    # fixup A - offset: 1, value: .LBB0_2-1, kind: FK_PCRel_1
36; PIC-NEXT:  # %bb.1: # %t
37; PIC-NEXT:    pushq %rax # encoding: [0x50]
38; PIC-NEXT:    .cfi_def_cfa_offset 16
39; PIC-NEXT:    callq f@PLT # encoding: [0xe8,A,A,A,A]
40; PIC-NEXT:    # fixup A - offset: 1, value: f@PLT-4, kind: FK_PCRel_4
41; PIC-NEXT:    popq %rax # encoding: [0x58]
42; PIC-NEXT:    .cfi_def_cfa_offset 8
43; PIC-NEXT:  .LBB0_2: # %f
44; PIC-NEXT:    retq # encoding: [0xc3]
45  %cmp = icmp ule i64 %val, ptrtoint (ptr @cmp8 to i64)
46  br i1 %cmp, label %t, label %f
47
48t:
49  call void @f()
50  ret void
51
52f:
53  ret void
54}
55
56define void @foo32(i64 %val) {
57; NOPIC-LABEL: foo32:
58; NOPIC:       # %bb.0:
59; NOPIC-NEXT:    cmpq $cmp32, %rdi # encoding: [0x48,0x81,0xff,A,A,A,A]
60; NOPIC-NEXT:    # fixup A - offset: 3, value: cmp32, kind: reloc_signed_4byte
61; NOPIC-NEXT:    ja .LBB1_2 # encoding: [0x77,A]
62; NOPIC-NEXT:    # fixup A - offset: 1, value: .LBB1_2-1, kind: FK_PCRel_1
63; NOPIC-NEXT:  # %bb.1: # %t
64; NOPIC-NEXT:    pushq %rax # encoding: [0x50]
65; NOPIC-NEXT:    .cfi_def_cfa_offset 16
66; NOPIC-NEXT:    callq f@PLT # encoding: [0xe8,A,A,A,A]
67; NOPIC-NEXT:    # fixup A - offset: 1, value: f@PLT-4, kind: FK_PCRel_4
68; NOPIC-NEXT:    popq %rax # encoding: [0x58]
69; NOPIC-NEXT:    .cfi_def_cfa_offset 8
70; NOPIC-NEXT:  .LBB1_2: # %f
71; NOPIC-NEXT:    retq # encoding: [0xc3]
72;
73; PIC-LABEL: foo32:
74; PIC:       # %bb.0:
75; PIC-NEXT:    cmpq $cmp32, %rdi # encoding: [0x48,0x81,0xff,A,A,A,A]
76; PIC-NEXT:    # fixup A - offset: 3, value: cmp32, kind: reloc_signed_4byte
77; PIC-NEXT:    ja .LBB1_2 # encoding: [0x77,A]
78; PIC-NEXT:    # fixup A - offset: 1, value: .LBB1_2-1, kind: FK_PCRel_1
79; PIC-NEXT:  # %bb.1: # %t
80; PIC-NEXT:    pushq %rax # encoding: [0x50]
81; PIC-NEXT:    .cfi_def_cfa_offset 16
82; PIC-NEXT:    callq f@PLT # encoding: [0xe8,A,A,A,A]
83; PIC-NEXT:    # fixup A - offset: 1, value: f@PLT-4, kind: FK_PCRel_4
84; PIC-NEXT:    popq %rax # encoding: [0x58]
85; PIC-NEXT:    .cfi_def_cfa_offset 8
86; PIC-NEXT:  .LBB1_2: # %f
87; PIC-NEXT:    retq # encoding: [0xc3]
88  %cmp = icmp ule i64 %val, ptrtoint (ptr @cmp32 to i64)
89  br i1 %cmp, label %t, label %f
90
91t:
92  call void @f()
93  ret void
94
95f:
96  ret void
97}
98
99!0 = !{i64 0, i64 128}
100!1 = !{i64 0, i64 2147483648}
101