[llvm-commits] CVS: llvm/lib/Bytecode/Reader/Reader.cpp

Reid Spencer reid at x10sys.com
Tue Nov 7 22:48:16 PST 2006



Changes in directory llvm/lib/Bytecode/Reader:

Reader.cpp updated: 1.202 -> 1.203
---
Log message:

For PR950: http://llvm.org/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.


---
Diffs of the changes:  (+15 -3)

 Reader.cpp |   18 +++++++++++++++---
 1 files changed, 15 insertions(+), 3 deletions(-)


Index: llvm/lib/Bytecode/Reader/Reader.cpp
diff -u llvm/lib/Bytecode/Reader/Reader.cpp:1.202 llvm/lib/Bytecode/Reader/Reader.cpp:1.203
--- llvm/lib/Bytecode/Reader/Reader.cpp:1.202	Thu Nov  2 14:25:49 2006
+++ llvm/lib/Bytecode/Reader/Reader.cpp	Wed Nov  8 00:47:33 2006
@@ -719,7 +719,15 @@
       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 @@
     }
 
     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 @@
       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;






More information about the llvm-commits mailing list