diff options
author | Eric Christopher <echristo@apple.com> | 2010-11-03 20:21:17 +0000 |
---|---|---|
committer | Eric Christopher <echristo@apple.com> | 2010-11-03 20:21:17 +0000 |
commit | e5b13cfdd0fc6529f8e2b3704ccaf20369aec486 (patch) | |
tree | 074102af5ebe769704badfbb44a4053acc619cad | |
parent | c0b14a250b61beb78d75d10c3124bbfd5355905c (diff) | |
download | external_llvm-e5b13cfdd0fc6529f8e2b3704ccaf20369aec486.zip external_llvm-e5b13cfdd0fc6529f8e2b3704ccaf20369aec486.tar.gz external_llvm-e5b13cfdd0fc6529f8e2b3704ccaf20369aec486.tar.bz2 |
Optimize generated code for integer materialization a bit.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@118192 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Target/ARM/ARMFastISel.cpp | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/lib/Target/ARM/ARMFastISel.cpp b/lib/Target/ARM/ARMFastISel.cpp index 0982ca0..cf4d61e 100644 --- a/lib/Target/ARM/ARMFastISel.cpp +++ b/lib/Target/ARM/ARMFastISel.cpp @@ -434,6 +434,19 @@ unsigned ARMFastISel::ARMMaterializeInt(const Constant *C, EVT VT) { // For now 32-bit only. if (VT != MVT::i32) return false; + unsigned DestReg = createResultReg(TLI.getRegClassFor(VT)); + + // If we can do this in a single instruction without a constant pool entry + // do so now. + const ConstantInt *CI = cast<ConstantInt>(C); + if (isUInt<16>(CI->getSExtValue())) { + unsigned Opc = isThumb ? ARM::t2MOVi16 : ARM::MOVi16; + AddOptionalDefs(BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, + TII.get(Opc), DestReg) + .addImm(CI->getSExtValue())); + return DestReg; + } + // MachineConstantPool wants an explicit alignment. unsigned Align = TD.getPrefTypeAlignment(C->getType()); if (Align == 0) { @@ -441,7 +454,6 @@ unsigned ARMFastISel::ARMMaterializeInt(const Constant *C, EVT VT) { Align = TD.getTypeAllocSize(C->getType()); } unsigned Idx = MCP.getConstantPoolIndex(C, Align); - unsigned DestReg = createResultReg(TLI.getRegClassFor(VT)); if (isThumb) AddOptionalDefs(BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, |