mirror of
https://github.com/RPCS3/llvm.git
synced 2025-01-26 20:57:15 +00:00
It's safe to remat t2LDRpci; Add PseudoSourceValue to load / store's to enable more machine licm. More changes coming.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85643 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
a4006c6dbf
commit
9eda68988e
@ -1021,7 +1021,8 @@ ARMTargetLowering::LowerCall(SDValue Chain, SDValue Callee,
|
||||
SDValue CPAddr = DAG.getTargetConstantPool(CPV, getPointerTy(), 4);
|
||||
CPAddr = DAG.getNode(ARMISD::Wrapper, dl, MVT::i32, CPAddr);
|
||||
Callee = DAG.getLoad(getPointerTy(), dl,
|
||||
DAG.getEntryNode(), CPAddr, NULL, 0);
|
||||
DAG.getEntryNode(), CPAddr,
|
||||
PseudoSourceValue::getConstantPool(), 0);
|
||||
SDValue PICLabel = DAG.getConstant(ARMPCLabelIndex++, MVT::i32);
|
||||
Callee = DAG.getNode(ARMISD::PIC_ADD, dl,
|
||||
getPointerTy(), Callee, PICLabel);
|
||||
@ -1040,7 +1041,8 @@ ARMTargetLowering::LowerCall(SDValue Chain, SDValue Callee,
|
||||
SDValue CPAddr = DAG.getTargetConstantPool(CPV, getPointerTy(), 4);
|
||||
CPAddr = DAG.getNode(ARMISD::Wrapper, dl, MVT::i32, CPAddr);
|
||||
Callee = DAG.getLoad(getPointerTy(), dl,
|
||||
DAG.getEntryNode(), CPAddr, NULL, 0);
|
||||
DAG.getEntryNode(), CPAddr,
|
||||
PseudoSourceValue::getConstantPool(), 0);
|
||||
SDValue PICLabel = DAG.getConstant(ARMPCLabelIndex++, MVT::i32);
|
||||
Callee = DAG.getNode(ARMISD::PIC_ADD, dl,
|
||||
getPointerTy(), Callee, PICLabel);
|
||||
@ -1224,7 +1226,8 @@ ARMTargetLowering::LowerToTLSGeneralDynamicModel(GlobalAddressSDNode *GA,
|
||||
ARMCP::CPValue, PCAdj, "tlsgd", true);
|
||||
SDValue Argument = DAG.getTargetConstantPool(CPV, PtrVT, 4);
|
||||
Argument = DAG.getNode(ARMISD::Wrapper, dl, MVT::i32, Argument);
|
||||
Argument = DAG.getLoad(PtrVT, dl, DAG.getEntryNode(), Argument, NULL, 0);
|
||||
Argument = DAG.getLoad(PtrVT, dl, DAG.getEntryNode(), Argument,
|
||||
PseudoSourceValue::getConstantPool(), 0);
|
||||
SDValue Chain = Argument.getValue(1);
|
||||
|
||||
SDValue PICLabel = DAG.getConstant(ARMPCLabelIndex++, MVT::i32);
|
||||
@ -1266,19 +1269,22 @@ ARMTargetLowering::LowerToTLSExecModels(GlobalAddressSDNode *GA,
|
||||
ARMCP::CPValue, PCAdj, "gottpoff", true);
|
||||
Offset = DAG.getTargetConstantPool(CPV, PtrVT, 4);
|
||||
Offset = DAG.getNode(ARMISD::Wrapper, dl, MVT::i32, Offset);
|
||||
Offset = DAG.getLoad(PtrVT, dl, Chain, Offset, NULL, 0);
|
||||
Offset = DAG.getLoad(PtrVT, dl, Chain, Offset,
|
||||
PseudoSourceValue::getConstantPool(), 0);
|
||||
Chain = Offset.getValue(1);
|
||||
|
||||
SDValue PICLabel = DAG.getConstant(ARMPCLabelIndex++, MVT::i32);
|
||||
Offset = DAG.getNode(ARMISD::PIC_ADD, dl, PtrVT, Offset, PICLabel);
|
||||
|
||||
Offset = DAG.getLoad(PtrVT, dl, Chain, Offset, NULL, 0);
|
||||
Offset = DAG.getLoad(PtrVT, dl, Chain, Offset,
|
||||
PseudoSourceValue::getConstantPool(), 0);
|
||||
} else {
|
||||
// local exec model
|
||||
ARMConstantPoolValue *CPV = new ARMConstantPoolValue(GV, "tpoff");
|
||||
Offset = DAG.getTargetConstantPool(CPV, PtrVT, 4);
|
||||
Offset = DAG.getNode(ARMISD::Wrapper, dl, MVT::i32, Offset);
|
||||
Offset = DAG.getLoad(PtrVT, dl, Chain, Offset, NULL, 0);
|
||||
Offset = DAG.getLoad(PtrVT, dl, Chain, Offset,
|
||||
PseudoSourceValue::getConstantPool(), 0);
|
||||
}
|
||||
|
||||
// The address of the thread local variable is the add of the thread
|
||||
@ -1347,7 +1353,8 @@ SDValue ARMTargetLowering::LowerGlobalAddressDarwin(SDValue Op,
|
||||
}
|
||||
CPAddr = DAG.getNode(ARMISD::Wrapper, dl, MVT::i32, CPAddr);
|
||||
|
||||
SDValue Result = DAG.getLoad(PtrVT, dl, DAG.getEntryNode(), CPAddr, NULL, 0);
|
||||
SDValue Result = DAG.getLoad(PtrVT, dl, DAG.getEntryNode(), CPAddr,
|
||||
PseudoSourceValue::getConstantPool(), 0);
|
||||
SDValue Chain = Result.getValue(1);
|
||||
|
||||
if (RelocM == Reloc::PIC_) {
|
||||
@ -1356,7 +1363,8 @@ SDValue ARMTargetLowering::LowerGlobalAddressDarwin(SDValue Op,
|
||||
}
|
||||
|
||||
if (Subtarget->GVIsIndirectSymbol(GV, RelocM))
|
||||
Result = DAG.getLoad(PtrVT, dl, Chain, Result, NULL, 0);
|
||||
Result = DAG.getLoad(PtrVT, dl, Chain, Result,
|
||||
PseudoSourceValue::getGOT(), 0);
|
||||
|
||||
return Result;
|
||||
}
|
||||
@ -1403,7 +1411,8 @@ ARMTargetLowering::LowerINTRINSIC_WO_CHAIN(SDValue Op, SelectionDAG &DAG) {
|
||||
CPAddr = DAG.getTargetConstantPool(CPV, PtrVT, 4);
|
||||
CPAddr = DAG.getNode(ARMISD::Wrapper, dl, MVT::i32, CPAddr);
|
||||
SDValue Result =
|
||||
DAG.getLoad(PtrVT, dl, DAG.getEntryNode(), CPAddr, NULL, 0);
|
||||
DAG.getLoad(PtrVT, dl, DAG.getEntryNode(), CPAddr,
|
||||
PseudoSourceValue::getConstantPool(), 0);
|
||||
SDValue Chain = Result.getValue(1);
|
||||
|
||||
if (RelocM == Reloc::PIC_) {
|
||||
@ -1500,7 +1509,8 @@ ARMTargetLowering::GetF64FormalArgument(CCValAssign &VA, CCValAssign &NextVA,
|
||||
|
||||
// Create load node to retrieve arguments from the stack.
|
||||
SDValue FIN = DAG.getFrameIndex(FI, getPointerTy());
|
||||
ArgValue2 = DAG.getLoad(MVT::i32, dl, Root, FIN, NULL, 0);
|
||||
ArgValue2 = DAG.getLoad(MVT::i32, dl, Root, FIN,
|
||||
PseudoSourceValue::getFixedStack(FI), 0);
|
||||
} else {
|
||||
Reg = MF.addLiveIn(NextVA.getLocReg(), RC);
|
||||
ArgValue2 = DAG.getCopyFromReg(Root, dl, Reg, MVT::i32);
|
||||
@ -1613,7 +1623,8 @@ ARMTargetLowering::LowerFormalArguments(SDValue Chain,
|
||||
|
||||
// Create load nodes to retrieve arguments from the stack.
|
||||
SDValue FIN = DAG.getFrameIndex(FI, getPointerTy());
|
||||
InVals.push_back(DAG.getLoad(VA.getValVT(), dl, Chain, FIN, NULL, 0));
|
||||
InVals.push_back(DAG.getLoad(VA.getValVT(), dl, Chain, FIN,
|
||||
PseudoSourceValue::getFixedStack(FI), 0));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1649,7 +1660,8 @@ ARMTargetLowering::LowerFormalArguments(SDValue Chain,
|
||||
|
||||
unsigned VReg = MF.addLiveIn(GPRArgRegs[NumGPRs], RC);
|
||||
SDValue Val = DAG.getCopyFromReg(Chain, dl, VReg, MVT::i32);
|
||||
SDValue Store = DAG.getStore(Val.getValue(1), dl, Val, FIN, NULL, 0);
|
||||
SDValue Store = DAG.getStore(Val.getValue(1), dl, Val, FIN,
|
||||
PseudoSourceValue::getFixedStack(VarArgsFrameIndex), 0);
|
||||
MemOps.push_back(Store);
|
||||
FIN = DAG.getNode(ISD::ADD, dl, getPointerTy(), FIN,
|
||||
DAG.getConstant(4, getPointerTy()));
|
||||
@ -1849,12 +1861,14 @@ SDValue ARMTargetLowering::LowerBR_JT(SDValue Op, SelectionDAG &DAG) {
|
||||
Addr, Op.getOperand(2), JTI, UId);
|
||||
}
|
||||
if (getTargetMachine().getRelocationModel() == Reloc::PIC_) {
|
||||
Addr = DAG.getLoad((EVT)MVT::i32, dl, Chain, Addr, NULL, 0);
|
||||
Addr = DAG.getLoad((EVT)MVT::i32, dl, Chain, Addr,
|
||||
PseudoSourceValue::getJumpTable(), 0);
|
||||
Chain = Addr.getValue(1);
|
||||
Addr = DAG.getNode(ISD::ADD, dl, PTy, Addr, Table);
|
||||
return DAG.getNode(ARMISD::BR_JT, dl, MVT::Other, Chain, Addr, JTI, UId);
|
||||
} else {
|
||||
Addr = DAG.getLoad(PTy, dl, Chain, Addr, NULL, 0);
|
||||
Addr = DAG.getLoad(PTy, dl, Chain, Addr,
|
||||
PseudoSourceValue::getJumpTable(), 0);
|
||||
Chain = Addr.getValue(1);
|
||||
return DAG.getNode(ARMISD::BR_JT, dl, MVT::Other, Chain, Addr, JTI, UId);
|
||||
}
|
||||
|
@ -362,7 +362,9 @@ multiclass T2I_ld<string opc, PatFrag opnode> {
|
||||
[(set GPR:$dst, (opnode t2addrmode_so_reg:$addr))]>;
|
||||
def pci : T2Ipc <(outs GPR:$dst), (ins i32imm:$addr), IIC_iLoadi,
|
||||
opc, ".w\t$dst, $addr",
|
||||
[(set GPR:$dst, (opnode (ARMWrapper tconstpool:$addr)))]>;
|
||||
[(set GPR:$dst, (opnode (ARMWrapper tconstpool:$addr)))]> {
|
||||
let isReMaterializable = 1;
|
||||
}
|
||||
}
|
||||
|
||||
/// T2I_st - Defines a set of (op r, {imm12|imm8|so_reg}) store patterns.
|
||||
|
34
test/CodeGen/Thumb2/machine-licm.ll
Normal file
34
test/CodeGen/Thumb2/machine-licm.ll
Normal file
@ -0,0 +1,34 @@
|
||||
; RUN: llc < %s -mtriple=thumbv7-apple-darwin -relocation-model=pic -disable-fp-elim | FileCheck %s
|
||||
; rdar://7353541
|
||||
|
||||
; The generated code is no where near ideal. It's not recognizing the two
|
||||
; constantpool entries being loaded can be merged into one.
|
||||
|
||||
@GV = external global i32 ; <i32*> [#uses=2]
|
||||
|
||||
define arm_apcscc void @t(i32* nocapture %vals, i32 %c) nounwind {
|
||||
entry:
|
||||
%0 = icmp eq i32 %c, 0 ; <i1> [#uses=1]
|
||||
br i1 %0, label %return, label %bb.nph
|
||||
|
||||
bb.nph: ; preds = %entry
|
||||
; CHECK: BB#1
|
||||
; CHECK: ldr r{{[0-9]+}}, LCPI1_0
|
||||
; CHECK: ldr{{.*}} r{{[0-9]+}}, LCPI1_1
|
||||
%.pre = load i32* @GV, align 4 ; <i32> [#uses=1]
|
||||
br label %bb
|
||||
|
||||
bb: ; preds = %bb, %bb.nph
|
||||
%1 = phi i32 [ %.pre, %bb.nph ], [ %3, %bb ] ; <i32> [#uses=1]
|
||||
%i.03 = phi i32 [ 0, %bb.nph ], [ %4, %bb ] ; <i32> [#uses=2]
|
||||
%scevgep = getelementptr i32* %vals, i32 %i.03 ; <i32*> [#uses=1]
|
||||
%2 = load i32* %scevgep, align 4 ; <i32> [#uses=1]
|
||||
%3 = add nsw i32 %1, %2 ; <i32> [#uses=2]
|
||||
store i32 %3, i32* @GV, align 4
|
||||
%4 = add i32 %i.03, 1 ; <i32> [#uses=2]
|
||||
%exitcond = icmp eq i32 %4, %c ; <i1> [#uses=1]
|
||||
br i1 %exitcond, label %return, label %bb
|
||||
|
||||
return: ; preds = %bb, %entry
|
||||
ret void
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user