diff options
author | Chris Lattner <sabre@nondot.org> | 2006-10-06 17:34:12 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2006-10-06 17:34:12 +0000 |
commit | f5839a08162841a7abe469ab83153675a7e38363 (patch) | |
tree | 3de85de73227b24f7f25ffdcaa530932ca1603b6 /llvm/lib/CodeGen | |
parent | ef01656ea4231fcc643d48c24e91a7452f9ac7e2 (diff) | |
download | bcm5719-llvm-f5839a08162841a7abe469ab83153675a7e38363.tar.gz bcm5719-llvm-f5839a08162841a7abe469ab83153675a7e38363.zip |
Fix a miscompilation of:
long long foo(long long X) {
return (long long)(signed char)(int)X;
}
Instead of:
_foo:
extsb r2, r4
srawi r3, r4, 31
mr r4, r2
blr
we now produce:
_foo:
extsb r4, r4
srawi r3, r4, 31
blr
This fixes a miscompilation in ConstantFolding.cpp.
llvm-svn: 30768
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp index 3a956d0f9bb..fc14b062aae 100644 --- a/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp @@ -4349,12 +4349,14 @@ void SelectionDAGLegalize::ExpandOp(SDOperand Op, SDOperand &Lo, SDOperand &Hi){ case ISD::SIGN_EXTEND_INREG: ExpandOp(Node->getOperand(0), Lo, Hi); - // Sign extend the lo-part. + // sext_inreg the low part if needed. + Lo = DAG.getNode(ISD::SIGN_EXTEND_INREG, NVT, Lo, Node->getOperand(1)); + + // The high part gets the sign extension from the lo-part. This handles + // things like sextinreg V:i64 from i8. Hi = DAG.getNode(ISD::SRA, NVT, Lo, DAG.getConstant(MVT::getSizeInBits(NVT)-1, TLI.getShiftAmountTy())); - // sext_inreg the low part if needed. - Lo = DAG.getNode(ISD::SIGN_EXTEND_INREG, NVT, Lo, Node->getOperand(1)); break; case ISD::BSWAP: { |