summaryrefslogtreecommitdiffstats
path: root/llvm/test/CodeGen/X86/negative-offset.ll
diff options
context:
space:
mode:
authorDan Gohman <dan433584@gmail.com>2016-01-22 03:57:34 +0000
committerDan Gohman <dan433584@gmail.com>2016-01-22 03:57:34 +0000
commit0bf3ae84cada4bbc6e21b70952e0bf8b723d8cd4 (patch)
treeaf99a8d9c638cecd47f2ec6301db79eea9b77edf /llvm/test/CodeGen/X86/negative-offset.ll
parentd05b899252b6108ba73bbd88dbd4f51dc09e5119 (diff)
downloadbcm5719-llvm-0bf3ae84cada4bbc6e21b70952e0bf8b723d8cd4.tar.gz
bcm5719-llvm-0bf3ae84cada4bbc6e21b70952e0bf8b723d8cd4.zip
[SelectionDAG] Fold more offsets into GlobalAddresses
This reapplies r258296 and r258366, and also fixes an existing bug in SelectionDAG.cpp's isMemSrcFromString, neglecting to account for the offset in a GlobalAddressSDNode, which is uncovered by those patches. llvm-svn: 258482
Diffstat (limited to 'llvm/test/CodeGen/X86/negative-offset.ll')
-rw-r--r--llvm/test/CodeGen/X86/negative-offset.ll18
1 files changed, 18 insertions, 0 deletions
diff --git a/llvm/test/CodeGen/X86/negative-offset.ll b/llvm/test/CodeGen/X86/negative-offset.ll
new file mode 100644
index 00000000000..dc1b255d020
--- /dev/null
+++ b/llvm/test/CodeGen/X86/negative-offset.ll
@@ -0,0 +1,18 @@
+; RUN: llc < %s -asm-verbose=false | FileCheck %s
+
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+; Test that a constant consisting of a global symbol with a negative offset
+; is properly folded and isel'd.
+
+; CHECK-LABEL: negative_offset:
+; CHECK: movl $G, %eax
+; CHECK: notq %rax
+; CHECK: addq %rdi, %rax
+; CHECK: retq
+@G = external global [8 x i32]
+define i8* @negative_offset(i8* %a) {
+ %t = getelementptr i8, i8* %a, i64 sub (i64 -1, i64 ptrtoint ([8 x i32]* @G to i64))
+ ret i8* %t
+}
OpenPOWER on IntegriCloud