mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-24 03:33:20 +01:00
Use a 8 bit immediate when possible.
This fixes pr21529. llvm-svn: 221700
This commit is contained in:
parent
b342691298
commit
d10e16c7f3
@ -82,6 +82,17 @@ static unsigned getADDriOpcode(unsigned IsLP64, int64_t Imm) {
|
||||
}
|
||||
}
|
||||
|
||||
static unsigned getANDriOpcode(bool IsLP64, int64_t Imm) {
|
||||
if (IsLP64) {
|
||||
if (isInt<8>(Imm))
|
||||
return X86::AND64ri8;
|
||||
return X86::AND64ri32;
|
||||
}
|
||||
if (isInt<8>(Imm))
|
||||
return X86::AND32ri8;
|
||||
return X86::AND32ri;
|
||||
}
|
||||
|
||||
static unsigned getLEArOpcode(unsigned IsLP64) {
|
||||
return IsLP64 ? X86::LEA64r : X86::LEA32r;
|
||||
}
|
||||
@ -657,11 +668,12 @@ void X86FrameLowering::emitPrologue(MachineFunction &MF) const {
|
||||
// able to calculate their offsets from the frame pointer).
|
||||
if (RegInfo->needsStackRealignment(MF)) {
|
||||
assert(HasFP && "There should be a frame pointer if stack is realigned.");
|
||||
uint64_t Val = -MaxAlign;
|
||||
MachineInstr *MI =
|
||||
BuildMI(MBB, MBBI, DL,
|
||||
TII.get(Uses64BitFramePtr ? X86::AND64ri32 : X86::AND32ri), StackPtr)
|
||||
TII.get(getANDriOpcode(Uses64BitFramePtr, Val)), StackPtr)
|
||||
.addReg(StackPtr)
|
||||
.addImm(-MaxAlign)
|
||||
.addImm(Val)
|
||||
.setMIFlag(MachineInstr::FrameSetup);
|
||||
|
||||
// The EFLAGS implicit def is dead.
|
||||
|
15
test/CodeGen/X86/pr21529.ll
Normal file
15
test/CodeGen/X86/pr21529.ll
Normal file
@ -0,0 +1,15 @@
|
||||
; RUN: llc -filetype=obj < %s | llvm-objdump -d - | FileCheck %s
|
||||
|
||||
; Test that the direct object emission selects the and variant with 8 bit
|
||||
; immediate.
|
||||
; We used to get this wrong when using direct object emission, but not when
|
||||
; reading assembly.
|
||||
|
||||
; CHECK: 48 83 e4 e0 andq $-32, %rsp
|
||||
|
||||
target triple = "x86_64-pc-linux"
|
||||
|
||||
define void @f() {
|
||||
%foo = alloca i8, align 32
|
||||
ret void
|
||||
}
|
Loading…
Reference in New Issue
Block a user