diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-12-12 16:57:30 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-12-12 16:58:56 -0800 |
commit | 2753cec6b7ac26a98e7c564c7ef1387d195cc835 (patch) | |
tree | d9328222a4f8ce379536588a93829d85a9b80b09 | |
parent | a2a9a7bc14f2e5f9e1989dc6f96095d2333a75bd (diff) |
legalize truncs to <32 bits
-rw-r--r-- | lib/Transforms/NaCl/ExpandI64.cpp | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/lib/Transforms/NaCl/ExpandI64.cpp b/lib/Transforms/NaCl/ExpandI64.cpp index 7710e3aee4..149e28d300 100644 --- a/lib/Transforms/NaCl/ExpandI64.cpp +++ b/lib/Transforms/NaCl/ExpandI64.cpp @@ -195,8 +195,12 @@ void ExpandI64::splitInst(Instruction *I, DataLayout& DL) { break; } case Instruction::Trunc: { - assert(I->getType()->getIntegerBitWidth() == 32); - Splits[I]; + SplitInfo &Split = Splits[I]; + if (I->getType()->getIntegerBitWidth() < 32) { + // we need to add a trunc of the low 32 bits + Instruction *L = CopyDebug(new TruncInst(Zero, I->getType(), "", I), I); + Split.ToFix.push_back(L); + } break; } case Instruction::Load: { @@ -472,9 +476,15 @@ void ExpandI64::finalizeInst(Instruction *I) { break; // input was legal } case Instruction::Trunc: { - assert(I->getType()->getIntegerBitWidth() == 32); LowHighPair LowHigh = getLowHigh(I->getOperand(0)); - I->replaceAllUsesWith(LowHigh.Low); + if (I->getType()->getIntegerBitWidth() == 32) { + I->replaceAllUsesWith(LowHigh.Low); // just use the lower 32 bits and you're set + } else { + assert(I->getType()->getIntegerBitWidth() < 32); + Instruction *L = Split.ToFix[0]; + L->setOperand(0, LowHigh.Low); + I->replaceAllUsesWith(L); + } break; } case Instruction::Store: |