xref: /llvm-project/llvm/test/CodeGen/X86/negative-offset.ll (revision 2f448bf509432c1a19ec46ab8cbc7353c03c6280)
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2; RUN: llc < %s | FileCheck %s
3
4target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
5target triple = "x86_64-unknown-linux-gnu"
6
7; Test that a constant consisting of a global symbol with a negative offset
8; is properly folded and isel'd.
9
10@G = external dso_local global [8 x i32]
11define ptr @negative_offset(ptr %a) {
12; CHECK-LABEL: negative_offset:
13; CHECK:       # %bb.0:
14; CHECK-NEXT:    movl $G, %eax
15; CHECK-NEXT:    notq %rax
16; CHECK-NEXT:    addq %rdi, %rax
17; CHECK-NEXT:    retq
18  %t = getelementptr i8, ptr %a, i64 sub (i64 -1, i64 ptrtoint (ptr @G to i64))
19  ret ptr %t
20}
21