diff options
author | Eric Christopher <echristo@gmail.com> | 2016-01-29 07:20:01 +0000 |
---|---|---|
committer | Eric Christopher <echristo@gmail.com> | 2016-01-29 07:20:01 +0000 |
commit | 5a2429e239483daada19b09581dc095bfff8dec3 (patch) | |
tree | 50a6acaa275b9fad09cdc048666b6cdbf90bf86a /llvm/lib/Target/PowerPC/PPCFastISel.cpp | |
parent | 80ba58a15c28614c472b5ab561b5cf77af3173b2 (diff) | |
download | llvm-5a2429e239483daada19b09581dc095bfff8dec3.zip llvm-5a2429e239483daada19b09581dc095bfff8dec3.tar.gz llvm-5a2429e239483daada19b09581dc095bfff8dec3.tar.bz2 |
Since LI/LIS sign extend the constant passed into the instruction we should
check that the sign extended constant fits into 16-bits if we want a
zero extended value, otherwise go ahead and put it together piecemeal.
Fixes PR26356.
llvm-svn: 259177
Diffstat (limited to 'llvm/lib/Target/PowerPC/PPCFastISel.cpp')
-rw-r--r-- | llvm/lib/Target/PowerPC/PPCFastISel.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/llvm/lib/Target/PowerPC/PPCFastISel.cpp b/llvm/lib/Target/PowerPC/PPCFastISel.cpp index 81682dd..41f5f39 100644 --- a/llvm/lib/Target/PowerPC/PPCFastISel.cpp +++ b/llvm/lib/Target/PowerPC/PPCFastISel.cpp @@ -2098,7 +2098,9 @@ unsigned PPCFastISel::PPCMaterializeInt(const ConstantInt *CI, MVT VT, BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc, TII.get(Opc), ImmReg) .addImm(CI->getSExtValue()); return ImmReg; - } else if (!UseSExt && isUInt<16>(CI->getZExtValue())) { + } 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) @@ -2108,7 +2110,6 @@ unsigned PPCFastISel::PPCMaterializeInt(const ConstantInt *CI, MVT VT, // Construct the constant piecewise. int64_t Imm = CI->getZExtValue(); - if (VT == MVT::i64) return PPCMaterialize64BitInt(Imm, RC); else if (VT == MVT::i32) |