summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2006-10-06 17:34:12 +0000
committerChris Lattner <sabre@nondot.org>2006-10-06 17:34:12 +0000
commitf5839a08162841a7abe469ab83153675a7e38363 (patch)
tree3de85de73227b24f7f25ffdcaa530932ca1603b6 /llvm/lib/CodeGen
parentef01656ea4231fcc643d48c24e91a7452f9ac7e2 (diff)
downloadbcm5719-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.cpp8
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: {
OpenPOWER on IntegriCloud