From 019ecf3b91bd1116793f9f327b65c84e82b9b058 Mon Sep 17 00:00:00 2001 From: Evan Cheng Date: Wed, 1 Aug 2007 23:46:47 +0000 Subject: [PATCH] Can't handle offset and scale if rip-relative addressing is to be used. llvm-svn: 40703 --- lib/Target/X86/X86ISelLowering.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/Target/X86/X86ISelLowering.cpp b/lib/Target/X86/X86ISelLowering.cpp index 939ddf819a6..91da4c0b6c8 100644 --- a/lib/Target/X86/X86ISelLowering.cpp +++ b/lib/Target/X86/X86ISelLowering.cpp @@ -4449,14 +4449,18 @@ bool X86TargetLowering::isLegalAddressingMode(const AddrMode &AM, return false; if (AM.BaseGV) { - // X86-64 only supports addr of globals in small code model. - if (Subtarget->is64Bit() && - getTargetMachine().getCodeModel() != CodeModel::Small) - return false; - - // We can only fold this if we don't need a load either. + // We can only fold this if we don't need an extra load. if (Subtarget->GVRequiresExtraLoad(AM.BaseGV, getTargetMachine(), false)) return false; + + // X86-64 only supports addr of globals in small code model. + if (Subtarget->is64Bit()) { + if (getTargetMachine().getCodeModel() != CodeModel::Small) + return false; + // If lower 4G is not available, then we must use rip-relative addressing. + if (AM.BaseOffs || AM.Scale > 1) + return false; + } } switch (AM.Scale) {