diff options
author | Reid Spencer <rspencer@reidspencer.com> | 2006-11-08 06:47:33 +0000 |
---|---|---|
committer | Reid Spencer <rspencer@reidspencer.com> | 2006-11-08 06:47:33 +0000 |
commit | 3822ff5c71478c7c90a50ca57045fb676fcb5005 (patch) | |
tree | 44d109d0052024ecdbcfceb248446b56a7bfce0f /lib/Bytecode/Reader/Reader.cpp | |
parent | 73fb07566b24d43bb116c2ade0297d90ec72490d (diff) |
For PR950:
This patch converts the old SHR instruction into two instructions,
AShr (Arithmetic) and LShr (Logical). The Shr instructions now are not
dependent on the sign of their operands.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31542 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Bytecode/Reader/Reader.cpp')
-rw-r--r-- | lib/Bytecode/Reader/Reader.cpp | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/lib/Bytecode/Reader/Reader.cpp b/lib/Bytecode/Reader/Reader.cpp index c20eeddcbf..ec74f78e7a 100644 --- a/lib/Bytecode/Reader/Reader.cpp +++ b/lib/Bytecode/Reader/Reader.cpp @@ -719,7 +719,15 @@ BytecodeReader::handleObsoleteOpcodes( Opcode = Instruction::Shl; break; case 31: // Shr - Opcode = Instruction::Shr; + // The type of the instruction is based on the operands. We need to + // select ashr or lshr based on that type. The iType values are hardcoded + // to the values used in bytecode version 5 (and prior) because it is + // likely these codes will change in future versions of LLVM. This if + // statement says "if (integer type and signed)" + if (iType >= 2 && iType <= 9 && iType % 2 != 0) + Opcode = Instruction::AShr; + else + Opcode = Instruction::LShr; break; case 32: { //VANext_old ( <= llvm 1.5 ) const Type* ArgTy = getValue(iType, Oprnds[0])->getType(); @@ -987,7 +995,8 @@ void BytecodeReader::ParseInstruction(std::vector<unsigned> &Oprnds, } case Instruction::Shl: - case Instruction::Shr: + case Instruction::LShr: + case Instruction::AShr: Result = new ShiftInst(Instruction::OtherOps(Opcode), getValue(iType, Oprnds[0]), getValue(Type::UByteTyID, Oprnds[1])); @@ -1707,7 +1716,10 @@ inline unsigned fixCEOpcodes( Opcode = Instruction::Shl; break; case 31: // Shr - Opcode = Instruction::Shr; + if (ArgVec[0]->getType()->isSigned()) + Opcode = Instruction::AShr; + else + Opcode = Instruction::LShr; break; case 34: // Select Opcode = Instruction::Select; |