From c5d2892e62203e4701bb7807af8f8ef121fab6fb Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Tue, 16 Sep 2008 01:01:33 +0000 Subject: Re-enables the new vector select in the bitcode reader, by modifying the bitcode reader/writer as follows: - add and use new bitcode FUNC_CODE_INST_VSELECT to handle the llvm select opcode using either i1 or [N x i1] as the selector. - retain old BITCODE FUNC_CODE_INST_SELECT in the bitcode reader to handle select on i1 for backwards compatibility with existing bitcode files. - re-enable the vector-select.ll test program. Also, rename the recently added bitcode opcode FUNC_CODE_INST_VCMP to FUNC_CODE_INST_CMP2 and make the bitcode writer use it to handle fcmp/icmp on scalars or vectors. In the bitcode writer, use FUNC_CODE_INST_CMP for vfcmp/vicmp only. In the bitcode reader, have FUNC_CODE_INST_CMP handle icmp/fcmp returning bool, for backwards compatibility with existing bitcode files. Patch by Preston Gurd! llvm-svn: 56233 --- llvm/lib/Bitcode/Writer/BitcodeWriter.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'llvm/lib/Bitcode/Writer/BitcodeWriter.cpp') diff --git a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp index 19f5bea..c647828 100644 --- a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp +++ b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp @@ -746,10 +746,10 @@ static void WriteInstruction(const Instruction &I, unsigned InstID, break; } case Instruction::Select: - Code = bitc::FUNC_CODE_INST_SELECT; + Code = bitc::FUNC_CODE_INST_VSELECT; PushValueAndType(I.getOperand(1), InstID, Vals, VE); Vals.push_back(VE.getValueID(I.getOperand(2))); - Vals.push_back(VE.getValueID(I.getOperand(0))); + PushValueAndType(I.getOperand(0), InstID, Vals, VE); break; case Instruction::ExtractElement: Code = bitc::FUNC_CODE_INST_EXTRACTELT; @@ -772,11 +772,10 @@ static void WriteInstruction(const Instruction &I, unsigned InstID, case Instruction::FCmp: case Instruction::VICmp: case Instruction::VFCmp: - if (isa(I.getOperand(0)->getType()) - && (I.getOpcode() == Instruction::ICmp - || I.getOpcode() == Instruction::FCmp)) { - // compare returning vector of Int1Ty - Code = bitc::FUNC_CODE_INST_VCMP; + if (I.getOpcode() == Instruction::ICmp + || I.getOpcode() == Instruction::FCmp) { + // compare returning Int1Ty or vector of Int1Ty + Code = bitc::FUNC_CODE_INST_CMP2; } else { Code = bitc::FUNC_CODE_INST_CMP; } -- cgit v1.1