From 7d9b9b2d7d947bdc8e11b78e65ddd74aebfd8742 Mon Sep 17 00:00:00 2001 From: Eric Christopher Date: Fri, 29 Jan 2016 07:20:30 +0000 Subject: [PATCH] Refactor common code for PPC fast isel load immediate selection. llvm-svn: 259178 --- llvm/lib/Target/PowerPC/PPCFastISel.cpp | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/llvm/lib/Target/PowerPC/PPCFastISel.cpp b/llvm/lib/Target/PowerPC/PPCFastISel.cpp index 41f5f39..c4090fb 100644 --- a/llvm/lib/Target/PowerPC/PPCFastISel.cpp +++ b/llvm/lib/Target/PowerPC/PPCFastISel.cpp @@ -2092,20 +2092,16 @@ unsigned PPCFastISel::PPCMaterializeInt(const ConstantInt *CI, MVT VT, ((VT == MVT::i64) ? &PPC::G8RCRegClass : &PPC::GPRCRegClass); // If the constant is in range, use a load-immediate. - if (UseSExt && isInt<16>(CI->getSExtValue())) { + // Since LI will sign extend the constant we need to make sure that for + // our zeroext constants that the sign extended constant fits into 16-bits - + // a range of 0..0x7fff. + if ((UseSExt && isInt<16>(CI->getSExtValue())) || + (!UseSExt && isUInt<16>(CI->getSExtValue()))) { unsigned Opc = (VT == MVT::i64) ? PPC::LI8 : PPC::LI; unsigned ImmReg = createResultReg(RC); BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc, TII.get(Opc), ImmReg) .addImm(CI->getSExtValue()); return ImmReg; - } else if (!UseSExt && isUInt<16>(CI->getSExtValue())) { - // Since LI will sign extend the constant we need to make sure that for - // our zeroext constants that the sign extended constant fits into 16-bits. - unsigned Opc = (VT == MVT::i64) ? PPC::LI8 : PPC::LI; - unsigned ImmReg = createResultReg(RC); - BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc, TII.get(Opc), ImmReg) - .addImm(CI->getZExtValue()); - return ImmReg; } // Construct the constant piecewise. -- 2.7.4