[llvm-commits] CVS: llvm/lib/Target/SparcV8/README.txt SparcV8ISelSimple.cpp

Brian Gaeke gaeke at cs.uiuc.edu
Tue Dec 14 00:21:23 PST 2004



Changes in directory llvm/lib/Target/SparcV8:

README.txt updated: 1.34 -> 1.35
SparcV8ISelSimple.cpp updated: 1.85 -> 1.86
---
Log message:

Get rid of shifts by zero in most cases.


---
Diffs of the changes:  (+7 -13)

Index: llvm/lib/Target/SparcV8/README.txt
diff -u llvm/lib/Target/SparcV8/README.txt:1.34 llvm/lib/Target/SparcV8/README.txt:1.35
--- llvm/lib/Target/SparcV8/README.txt:1.34	Mon Dec 13 14:13:10 2004
+++ llvm/lib/Target/SparcV8/README.txt	Tue Dec 14 02:21:02 2004
@@ -55,13 +55,6 @@
 * support casting 64-bit integers to FP types (fhourstones needs this)
 * support FP rem (call fmod)
 
-* Eliminate srl/sll by zero bits like this:
-        sll %l0, 0, %l0
-        srl %l0, 0, %o0
-
-  We think these are only used by V9 to clear off the top 32 bits of a reg,
-  so they are not needed.
-
 * Keep the address of the constant pool in a register instead of forming its
   address all of the time.
 
@@ -75,5 +68,5 @@
 * We can fold small constant offsets into the %hi/%lo references to constant
   pool addresses as well.
 
-$Date: 2004/12/13 20:13:10 $
+$Date: 2004/12/14 08:21:02 $
 


Index: llvm/lib/Target/SparcV8/SparcV8ISelSimple.cpp
diff -u llvm/lib/Target/SparcV8/SparcV8ISelSimple.cpp:1.85 llvm/lib/Target/SparcV8/SparcV8ISelSimple.cpp:1.86
--- llvm/lib/Target/SparcV8/SparcV8ISelSimple.cpp:1.85	Sun Dec 12 01:42:58 2004
+++ llvm/lib/Target/SparcV8/SparcV8ISelSimple.cpp	Tue Dec 14 02:21:02 2004
@@ -71,7 +71,8 @@
     unsigned emitIntegerCast (MachineBasicBlock *BB,
                               MachineBasicBlock::iterator IP,
                               const Type *oldTy, unsigned SrcReg,
-                              const Type *newTy, unsigned DestReg);
+                              const Type *newTy, unsigned DestReg,
+                              bool castToLong = false);
     void emitFPToIntegerCast (MachineBasicBlock *BB,
                               MachineBasicBlock::iterator IP, const Type *oldTy,
                               unsigned SrcReg, const Type *newTy,
@@ -606,15 +607,15 @@
 unsigned V8ISel::emitIntegerCast (MachineBasicBlock *BB,
                               MachineBasicBlock::iterator IP, const Type *oldTy,
                               unsigned SrcReg, const Type *newTy,
-                              unsigned DestReg) {
-  if (oldTy == newTy) {
+                              unsigned DestReg, bool castToLong) {
+  unsigned shiftWidth = 32 - (8 * TM.getTargetData ().getTypeSize (newTy));
+  if (oldTy == newTy || (!castToLong && shiftWidth == 0)) {
     // No-op cast - just emit a copy; assume the reg. allocator will zap it.
     BuildMI (*BB, IP, V8::ORrr, 2, DestReg).addReg (V8::G0).addReg(SrcReg);
     return SrcReg;
   }
   // Emit left-shift, then right-shift to sign- or zero-extend.
   unsigned TmpReg = makeAnotherReg (newTy);
-  unsigned shiftWidth = 32 - (8 * TM.getTargetData ().getTypeSize (newTy));
   BuildMI (*BB, IP, V8::SLLri, 2, TmpReg).addZImm (shiftWidth).addReg(SrcReg);
   if (newTy->isSigned ()) { // sign-extend with SRA
     BuildMI(*BB, IP, V8::SRAri, 2, DestReg).addZImm (shiftWidth).addReg(TmpReg);
@@ -739,7 +740,7 @@
         const Type *OldHalfTy = oldTy->isSigned() ? Type::IntTy : Type::UIntTy;
         const Type *NewHalfTy = newTy->isSigned() ? Type::IntTy : Type::UIntTy;
         unsigned TempReg = emitIntegerCast (BB, IP, OldHalfTy, SrcReg,
-                                            NewHalfTy, DestReg+1);
+                                            NewHalfTy, DestReg+1, true);
         if (newTy->isSigned ()) {
           BuildMI (*BB, IP, V8::SRAri, 2, DestReg).addReg (TempReg) 
             .addZImm (31);






More information about the llvm-commits mailing list