[x32] Fast ISel should use LEA64_32r instead of LEA32r to adjust addresses in x32 mode.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226661 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Michael Kuperstein 2015-01-21 14:44:05 +00:00
parent 506c6ec22a
commit 0b4244ade1
2 changed files with 18 additions and 2 deletions

View File

@ -3224,7 +3224,10 @@ unsigned X86FastISel::X86MaterializeGV(const GlobalValue *GV, MVT VT) {
ResultReg)
.addGlobalAddress(GV);
} else {
unsigned Opc = TLI.getPointerTy() == MVT::i32 ? X86::LEA32r : X86::LEA64r;
unsigned Opc = TLI.getPointerTy() == MVT::i32
? (Subtarget->isTarget64BitILP32()
? X86::LEA64_32r : X86::LEA32r)
: X86::LEA64r;
addFullAddress(BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
TII.get(Opc), ResultReg), AM);
}
@ -3266,7 +3269,10 @@ unsigned X86FastISel::fastMaterializeAlloca(const AllocaInst *C) {
X86AddressMode AM;
if (!X86SelectAddress(C, AM))
return 0;
unsigned Opc = TLI.getPointerTy() == MVT::i32 ? X86::LEA32r : X86::LEA64r;
unsigned Opc = TLI.getPointerTy() == MVT::i32
? (Subtarget->isTarget64BitILP32()
? X86::LEA64_32r : X86::LEA32r)
: X86::LEA64r;
const TargetRegisterClass* RC = TLI.getRegClassFor(TLI.getPointerTy());
unsigned ResultReg = createResultReg(RC);
addFullAddress(BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,

View File

@ -0,0 +1,10 @@
; RUN: llc < %s -mtriple=x86_64-linux-gnux32 -O0 | FileCheck %s
; CHECK: leal {{[-0-9]*}}(%r{{s|b}}p),
; CHECK-NOT: leal {{[-0-9]*}}(%e{{s|b}}p),
define void @foo(i32** %p) {
%a = alloca i32, i32 10
%addr = getelementptr i32* %a, i32 4
store i32* %addr, i32** %p
ret void
}