aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2014-01-29 16:59:05 -0800
committerAlon Zakai <alonzakai@gmail.com>2014-01-29 16:59:13 -0800
commit3f282f31a179ecbe242bcc3b7f98c8fd261c492d (patch)
tree37b682964106898b2295a082bb84faac9a3c24ab
parentb8c6d7658d89d53acaae44e8f4359578a7fa5dba (diff)
generalize and fix select legalization code
-rw-r--r--lib/Transforms/NaCl/ExpandI64.cpp19
1 files changed, 10 insertions, 9 deletions
diff --git a/lib/Transforms/NaCl/ExpandI64.cpp b/lib/Transforms/NaCl/ExpandI64.cpp
index dc4cd4f9fe..b8b627e1d1 100644
--- a/lib/Transforms/NaCl/ExpandI64.cpp
+++ b/lib/Transforms/NaCl/ExpandI64.cpp
@@ -504,12 +504,12 @@ void ExpandI64::splitInst(Instruction *I, DataLayout& DL) {
break;
}
case Instruction::Select: {
- assert(I->getType() == i64);
Value *Cond = I->getOperand(0);
- Instruction *L = CopyDebug(SelectInst::Create(Cond, Zero, Zero, "", I), I); // will be fixed
- Instruction *H = CopyDebug(SelectInst::Create(Cond, Zero, Zero, "", I), I); // will be fixed
- Split.Chunks.push_back(L);
- Split.Chunks.push_back(H);
+ int Num = getNumChunks(I->getOperand(1)->getType());
+ for (int i = 0; i < Num; i++) {
+ Instruction *C = CopyDebug(SelectInst::Create(Cond, Zero, Zero, "", I), I); // will be fixed
+ Split.Chunks.push_back(C);
+ }
break;
}
case Instruction::PHI: {
@@ -926,12 +926,13 @@ void ExpandI64::finalizeInst(Instruction *I) {
break;
}
case Instruction::Select: {
+ int Num = getNumChunks(I->getOperand(1)->getType());
ChunksVec True = getChunks(I->getOperand(1));
ChunksVec False = getChunks(I->getOperand(2));
- Instruction *L = cast<Instruction>(Split.Chunks[0]);
- Instruction *H = cast<Instruction>(Split.Chunks[1]);
- L->setOperand(1, True[0]); L->setOperand(2, False[0]);
- H->setOperand(1, True[1]); H->setOperand(2, False[1]);
+ for (int i = 0; i < Num; i++) {
+ cast<Instruction>(Split.Chunks[i])->setOperand(1, True[i]);
+ cast<Instruction>(Split.Chunks[i])->setOperand(2, False[i]);
+ }
break;
}
case Instruction::PHI: {