[llvm-commits] CVS: llvm/lib/CodeGen/VirtRegMap.cpp

2007-03-02 Thread Evan Cheng


Changes in directory llvm/lib/CodeGen:

VirtRegMap.cpp updated: 1.102 - 1.103
---
Log message:

- Keep track all def and uses of stack slot available in register.
- Available value use may be deleted (e.g. noop move).

---
Diffs of the changes:  (+51 -28)

 VirtRegMap.cpp |   79 -
 1 files changed, 51 insertions(+), 28 deletions(-)


Index: llvm/lib/CodeGen/VirtRegMap.cpp
diff -u llvm/lib/CodeGen/VirtRegMap.cpp:1.102 
llvm/lib/CodeGen/VirtRegMap.cpp:1.103
--- llvm/lib/CodeGen/VirtRegMap.cpp:1.102   Thu Mar  1 23:41:42 2007
+++ llvm/lib/CodeGen/VirtRegMap.cpp Fri Mar  2 02:52:00 2007
@@ -254,9 +254,9 @@
 
   // SpillSlotsAvailable - This map keeps track of all of the spilled virtual
   // register values that are still available, due to being loaded or stored 
to,
-  // but not invalidated yet. It also tracks the instruction that last defined
+  // but not invalidated yet. It also tracks the instructions that defined
   // or used the register.
-  typedef std::pairunsigned, MachineInstr* SSInfo;
+  typedef std::pairunsigned, std::vectorMachineInstr*  SSInfo;
   std::mapint, SSInfo SpillSlotsAvailable;
 
   // PhysRegsAvailable - This is the inverse of SpillSlotsAvailable, indicating
@@ -281,15 +281,16 @@
   unsigned getSpillSlotPhysReg(int Slot, MachineInstr *SSMI) const {
 std::mapint, SSInfo::const_iterator I = SpillSlotsAvailable.find(Slot);
 if (I != SpillSlotsAvailable.end()) {
-  SSMI = I-second.second;
+  if (!I-second.second.empty())
+SSMI = I-second.second.back();
   return I-second.first  1;  // Remove the CanClobber bit.
 }
 return 0;
   }
 
-  /// UpdateLastUses - Update the last use information of all stack slots whose
+  /// addLastUse - Add the last use information of all stack slots whose
   /// values are available in the specific register.
-  void UpdateLastUse(unsigned PhysReg, MachineInstr *Use) {
+  void addLastUse(unsigned PhysReg, MachineInstr *Use) {
 std::multimapunsigned, int::iterator I =
   PhysRegsAvailable.lower_bound(PhysReg);
 while (I != PhysRegsAvailable.end()  I-first == PhysReg) {
@@ -300,8 +301,25 @@
   assert(II != SpillSlotsAvailable.end()  Slot not available!);
   unsigned Val = II-second.first;
   assert((Val  1) == PhysReg  Bidirectional map mismatch!);
-  SpillSlotsAvailable.erase(Slot);
-  SpillSlotsAvailable[Slot] = std::make_pair(Val, Use);
+  II-second.second.push_back(Use);
+}
+  }
+  
+  /// removeLastUse - Remove the last use information of all stack slots whose
+  /// values are available in the specific register.
+  void removeLastUse(unsigned PhysReg, MachineInstr *Use) {
+std::multimapunsigned, int::iterator I =
+  PhysRegsAvailable.lower_bound(PhysReg);
+while (I != PhysRegsAvailable.end()  I-first == PhysReg) {
+  int Slot = I-second;
+  I++;
+
+  std::mapint, SSInfo::iterator II = SpillSlotsAvailable.find(Slot);
+  assert(II != SpillSlotsAvailable.end()  Slot not available!);
+  unsigned Val = II-second.first;
+  assert((Val  1) == PhysReg  Bidirectional map mismatch!);
+  if (II-second.second.back() == Use)
+II-second.second.pop_back();
 }
   }
   
@@ -315,8 +333,10 @@
 ModifyStackSlot(Slot);
 
 PhysRegsAvailable.insert(std::make_pair(Reg, Slot));
+std::vectorMachineInstr* DefUses;
+DefUses.push_back(MI);
 SpillSlotsAvailable[Slot] =
-  std::make_pair((Reg  1) | (unsigned)CanClobber, MI);
+  std::make_pair((Reg  1) | (unsigned)CanClobber, DefUses);
   
 DOUT  Remembering SS#  Slot   in physreg 
   MRI-getName(Reg)  \n;
@@ -683,15 +703,16 @@
 
   // Extend the live range of the MI that last kill the register if
   // necessary.
-  MachineOperand *MOK = SSMI-findRegisterUseOperand(PhysReg, true);
-  if (MOK) {
-MOK-unsetIsKill();
-if (ti == -1) {
-  // Unless it's the use of a two-address code, transfer the kill
-  // of the reused register to this use.
-  MI.getOperand(i).setIsKill();
-  Spills.UpdateLastUse(PhysReg, MI);
-}
+  if (SSMI) {
+MachineOperand *MOK = SSMI-findRegisterUseOperand(PhysReg, true);
+if (MOK)
+  MOK-unsetIsKill();
+  }
+  if (ti == -1) {
+// Unless it's the use of a two-address code, transfer the kill
+// of the reused register to this use.
+MI.getOperand(i).setIsKill();
+Spills.addLastUse(PhysReg, MI);
   }
 
   // The only technical detail we have is that we don't know that
@@ -763,14 +784,13 @@
 // necessary.
 if (SSMI) {
   MachineOperand *MOK = SSMI-findRegisterUseOperand(PhysReg, true);
-  if (MOK) {
-MachineInstr *CopyMI = prior(MII);
-MachineOperand *MOU = 

Re: [llvm-commits] llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp

2007-03-02 Thread Nicolas Geoffray
Chris Lattner wrote:

 Why can't you just mark the frame address callee save?  Why isn't it 
 getting saved automatically for you?


Because R31 is not used as a callee saved register when 
llvm::NoFramePointerElim is set to 1. The algorithm
that calculates the callee saved registers' addresses does not save 
R31's offset when used as a frame pointer.
And with the ELF Abi, R31's offset is in the callee saved registers 
area. Therefore I have to force its allocation
(at the -4 offset).

 Index: PPCRegisterInfo.cpp
 ===
 RCS file: /var/cvs/llvm/llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp,v
 retrieving revision 1.114
 diff -t -d -u -p -5 -r1.114 PPCRegisterInfo.cpp
 --- PPCRegisterInfo.cpp 27 Feb 2007 11:55:45 - 1.114
 +++ PPCRegisterInfo.cpp 27 Feb 2007 17:29:51 -
 @@ -879,10 +879,30 @@ void PPCRegisterInfo::processFunctionBef
//  Save and clear the LR state.
PPCFunctionInfo *FI = MF.getInfoPPCFunctionInfo();
unsigned LR = getRARegister();
FI-setUsesLR(MF.isPhysRegUsed(LR));
MF.changePhyRegUsed(LR, false);
 +
 +
 +  //  Save R31 if necessary
 +  int FPSI = FI-getFramePointerSaveIndex();
 +  bool IsPPC64 = Subtarget.isPPC64();
 +  bool IsMachoABI = Subtarget.isMachoABI();
 +  const MachineFrameInfo *MFI = MF.getFrameInfo();
 + +  // If the frame pointer save index hasn't been defined yet.
 +  if (!FPSI   (NoFramePointerElim || MFI-hasVarSizedObjects()) 
 +   !IsMachoABI) {
 +// Find out what the fix offset of the frame pointer save area.
 +int FPOffset = PPCFrameInfo::getFramePointerSaveOffset(IsPPC64, 
 +  
 IsMachoABI);
 +// Allocate the frame index for frame pointer save area.
 +FPSI = MF.getFrameInfo()-CreateFixedObject(IsPPC64? 8 : 4, 
 FPOffset);
 +// Save the result.
 +FI-setFramePointerSaveIndex(FPSI);  +  }
 +
  }

  

  void PPCRegisterInfo::emitPrologue(MachineFunction MF) const {
MachineBasicBlock MBB = MF.front();   // Prolog goes in entry BB
MachineBasicBlock::iterator MBBI = MBB.begin();
 ___
 llvm-commits mailing list
 llvm-commits@cs.uiuc.edu mailto:llvm-commits@cs.uiuc.edu
 http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/test/CodeGen/X86/2007-03-01-SpillerCrash.ll

2007-03-02 Thread Evan Cheng


Changes in directory llvm/test/CodeGen/X86:

2007-03-01-SpillerCrash.ll added (r1.1)
---
Log message:

Add a new test case.

---
Diffs of the changes:  (+85 -0)

 2007-03-01-SpillerCrash.ll |   85 +
 1 files changed, 85 insertions(+)


Index: llvm/test/CodeGen/X86/2007-03-01-SpillerCrash.ll
diff -c /dev/null llvm/test/CodeGen/X86/2007-03-01-SpillerCrash.ll:1.1
*** /dev/null   Fri Mar  2 04:37:29 2007
--- llvm/test/CodeGen/X86/2007-03-01-SpillerCrash.llFri Mar  2 04:37:19 2007
***
*** 0 
--- 1,85 
+ ; RUN: llvm-as  %s | llc -mtriple=x86_64-apple-darwin8 -mattr=+sse2
+ 
+ define void @test() {
+ test.exit:
+   mul 4 x float zeroinitializer, zeroinitializer; 4 x 
float:0 [#uses=4]
+   load 4 x float* null  ; 4 x float:1 [#uses=1]
+   shufflevector 4 x float %1, 4 x float undef, 4 x i32  i32 3, i32 
3, i32 3, i32 3; 4 x float:2 [#uses=1]
+   mul 4 x float %0, %2  ; 4 x float:3 [#uses=1]
+   sub 4 x float zeroinitializer, %3 ; 4 x float:4 
[#uses=1]
+   mul 4 x float %4, zeroinitializer ; 4 x float:5 
[#uses=2]
+   bitcast 4 x float zeroinitializer to 4 x i32; 4 x 
i32:0 [#uses=1]
+   and 4 x i32 %0,  i32 2147483647, i32 2147483647, i32 2147483647, i32 
2147483647 ; 4 x i32:1 [#uses=1]
+   bitcast 4 x i32 %1 to 4 x float ; 4 x float:6 
[#uses=2]
+   extractelement 4 x float %6, i32 0; float:0 [#uses=1]
+   extractelement 4 x float %6, i32 1; float:1 [#uses=2]
+   br i1 false, label %0, label %5
+ 
+ ; label:0   ; preds = %test.exit
+   br i1 false, label %3, label %1
+ 
+ ; label:1   ; preds = %0
+   br i1 false, label %5, label %2
+ 
+ ; label:2   ; preds = %1
+   sub float -0.00e+00, 0.00e+00   ; float:2 [#uses=1]
+   %tmp207 = extractelement 4 x float zeroinitializer, i32 0 
; float [#uses=1]
+   %tmp208 = extractelement 4 x float zeroinitializer, i32 2 
; float [#uses=1]
+   sub float -0.00e+00, %tmp208; float:3 [#uses=1]
+   %tmp155 = extractelement 4 x float zeroinitializer, i32 0 
; float [#uses=1]
+   %tmp156 = extractelement 4 x float zeroinitializer, i32 2 
; float [#uses=1]
+   sub float -0.00e+00, %tmp156; float:4 [#uses=1]
+   br label %5
+ 
+ ; label:3   ; preds = %0
+   br i1 false, label %5, label %4
+ 
+ ; label:4   ; preds = %3
+   br label %5
+ 
+ ; label:5   ; preds = %4, %3, %2, %1, %test.exit
+   phi i32 [ 5, %4 ], [ 3, %2 ], [ 1, %test.exit ], [ 2, %1 ], [ 4, %3 ]   
; i32:0 [#uses=0]
+   phi float [ 0.00e+00, %4 ], [ %4, %2 ], [ 0.00e+00, %test.exit 
], [ 0.00e+00, %1 ], [ 0.00e+00, %3 ]; float:5 [#uses=1]
+   phi float [ 0.00e+00, %4 ], [ %tmp155, %2 ], [ 0.00e+00, 
%test.exit ], [ 0.00e+00, %1 ], [ 0.00e+00, %3 ]   ; 
float:6 [#uses=1]
+   phi float [ 0.00e+00, %4 ], [ %3, %2 ], [ 0.00e+00, %test.exit 
], [ 0.00e+00, %1 ], [ 0.00e+00, %3 ]; float:7 [#uses=1]
+   phi float [ 0.00e+00, %4 ], [ %tmp207, %2 ], [ 0.00e+00, 
%test.exit ], [ 0.00e+00, %1 ], [ 0.00e+00, %3 ]   ; 
float:8 [#uses=1]
+   phi float [ 0.00e+00, %4 ], [ %1, %2 ], [ %0, %test.exit ], [ %1, 
%1 ], [ 0.00e+00, %3 ]; float:9 [#uses=2]
+   phi float [ 0.00e+00, %4 ], [ %2, %2 ], [ 0.00e+00, %test.exit 
], [ 0.00e+00, %1 ], [ 0.00e+00, %3 ]; float:10 [#uses=1]
+   phi float [ 0.00e+00, %4 ], [ 0.00e+00, %2 ], [ 0.00e+00, 
%test.exit ], [ 0.00e+00, %1 ], [ 0.00e+00, %3 ]  ; float:11 
[#uses=1]
+   insertelement 4 x float undef, float %11, i32 0   ; 4 x 
float:7 [#uses=1]
+   insertelement 4 x float %7, float %10, i32 1  ; 4 x 
float:8 [#uses=0]
+   insertelement 4 x float undef, float %8, i32 0; 4 x 
float:9 [#uses=1]
+   insertelement 4 x float %9, float %7, i32 1   ; 4 x 
float:10 [#uses=1]
+   insertelement 4 x float %10, float %9, i32 2  ; 4 x 
float:11 [#uses=1]
+   insertelement 4 x float %11, float %9, i32 3  ; 4 x 
float:12 [#uses=1]
+   fdiv 4 x float %12, zeroinitializer   ; 4 x float:13 
[#uses=1]
+   mul 4 x float %13,  float 5.00e-01, float 5.00e-01, float 
5.00e-01, float 5.00e-01  ; 4 x float:14 [#uses=1]
+   insertelement 4 x float undef, float %6, i32 0; 4 x 
float:15 [#uses=1]
+   insertelement 4 x float %15, float %5, i32 1  ; 4 x 
float:16 [#uses=0]
+   br i1 false, label %foo.exit, label %6
+ 
+ ; label:6   ; preds = %5
+   extractelement 4 x float %0, i32 0   

[llvm-commits] CVS: llvm/lib/CodeGen/LiveIntervalAnalysis.cpp

2007-03-02 Thread Evan Cheng


Changes in directory llvm/lib/CodeGen:

LiveIntervalAnalysis.cpp updated: 1.218 - 1.219
---
Log message:

Dead live-in detection bug.

---
Diffs of the changes:  (+2 -2)

 LiveIntervalAnalysis.cpp |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)


Index: llvm/lib/CodeGen/LiveIntervalAnalysis.cpp
diff -u llvm/lib/CodeGen/LiveIntervalAnalysis.cpp:1.218 
llvm/lib/CodeGen/LiveIntervalAnalysis.cpp:1.219
--- llvm/lib/CodeGen/LiveIntervalAnalysis.cpp:1.218 Wed Feb 28 20:05:35 2007
+++ llvm/lib/CodeGen/LiveIntervalAnalysis.cpp   Fri Mar  2 04:41:15 2007
@@ -938,11 +938,11 @@
   if (JoinIntervals(DestInt, SrcInt)) {
 if (isDead) {
   // Result of the copy is dead. Propagate this property.
-  if (SrcStart == 0  MRegisterInfo::isPhysicalRegister(SrcReg)) {
+  if (SrcStart == 0  MRegisterInfo::isPhysicalRegister(repSrcReg)) {
 // Live-in to the function but dead. Remove it from MBB live-in set.
 // JoinIntervals may end up swapping the two intervals.
 MachineBasicBlock *MBB = CopyMI-getParent();
-MBB-removeLiveIn(SrcReg);
+MBB-removeLiveIn(repSrcReg);
   } else {
 MachineInstr *SrcMI = getInstructionFromIndex(SrcStart);
 if (SrcMI) {



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/lib/CodeGen/RegisterScavenging.cpp

2007-03-02 Thread Evan Cheng


Changes in directory llvm/lib/CodeGen:

RegisterScavenging.cpp updated: 1.9 - 1.10
---
Log message:

Mark dead def as unused.

---
Diffs of the changes:  (+6 -2)

 RegisterScavenging.cpp |8 ++--
 1 files changed, 6 insertions(+), 2 deletions(-)


Index: llvm/lib/CodeGen/RegisterScavenging.cpp
diff -u llvm/lib/CodeGen/RegisterScavenging.cpp:1.9 
llvm/lib/CodeGen/RegisterScavenging.cpp:1.10
--- llvm/lib/CodeGen/RegisterScavenging.cpp:1.9 Thu Mar  1 02:56:24 2007
+++ llvm/lib/CodeGen/RegisterScavenging.cpp Fri Mar  2 04:43:16 2007
@@ -100,14 +100,18 @@
 if (!MO.isReg() || !MO.isDef())
   continue;
 unsigned Reg = MO.getReg();
+// If it's dead upon def, then it is now free.
+if (MO.isDead()) {
+  setUnused(Reg);
+  continue;
+}
 // Skip two-address destination operand.
 if (TID-findTiedToSrcOperand(i) != -1) {
   assert(isUsed(Reg));
   continue;
 }
 assert(isUnused(Reg) || isReserved(Reg));
-if (!MO.isDead())
-  setUsed(Reg);
+setUsed(Reg);
   }
 }
 



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


Re: [llvm-commits] llvm-gcc: check that fields are laid out in ConvertRecordCONSTRUCTOR

2007-03-02 Thread Duncan Sands
Testcase triggering this.
Index: llvm/test/AdaFrontend/fat_fields.adb
===
--- /dev/null	1970-01-01 00:00:00.0 +
+++ llvm/test/AdaFrontend/fat_fields.adb	2007-03-02 12:50:25.0 +0100
@@ -0,0 +1,10 @@
+-- RUN: %llvmgcc -c %s -o /dev/null
+-- RUN: %llvmgcc -c %s -O2 -o /dev/null
+package body Fat_Fields is
+   procedure Proc is
+   begin
+  if P = null then
+ null;
+  end if;
+   end;
+end;
Index: llvm/test/AdaFrontend/fat_fields.ads
===
--- /dev/null	1970-01-01 00:00:00.0 +
+++ llvm/test/AdaFrontend/fat_fields.ads	2007-03-02 12:50:25.0 +0100
@@ -0,0 +1,6 @@
+package Fat_Fields is
+   pragma Elaborate_Body;
+   type A is array (Positive range ) of Boolean;
+   type A_Ptr is access A;
+   P : A_Ptr := null;
+end;
___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


Re: [llvm-commits] llvm-gcc: only call rest_of_decl_compilation on VAR_DECLs in EmitBIND_EXPR

2007-03-02 Thread Duncan Sands
Ada testcase triggering this.
Index: llvm/test/AdaFrontend/emit_var.ads
===
--- /dev/null	1970-01-01 00:00:00.0 +
+++ llvm/test/AdaFrontend/emit_var.ads	2007-03-02 12:50:25.0 +0100
@@ -0,0 +1,5 @@
+-- RUN: %llvmgcc -c %s -o /dev/null
+with Ada.Finalization;
+package Emit_Var is
+   type Search_Type is new Ada.Finalization.Controlled with null record;
+end;
___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


Re: [llvm-commits] llvm-gcc: support for NON_LVALUE_EXPR

2007-03-02 Thread Duncan Sands
Ada testcase triggering this.
Index: llvm/test/AdaFrontend/non_lvalue.adb
===
--- /dev/null	1970-01-01 00:00:00.0 +
+++ llvm/test/AdaFrontend/non_lvalue.adb	2007-03-02 12:50:25.0 +0100
@@ -0,0 +1,7 @@
+-- RUN: %llvmgcc -c %s -o /dev/null
+package body Non_LValue is
+   function A (Y : U) return String is
+   begin
+  return Y.X.B;
+   end;
+end;
Index: llvm/test/AdaFrontend/non_lvalue.ads
===
--- /dev/null	1970-01-01 00:00:00.0 +
+++ llvm/test/AdaFrontend/non_lvalue.ads	2007-03-02 12:50:25.0 +0100
@@ -0,0 +1,11 @@
+package Non_LValue is
+   type T (Length : Natural) is record
+  A : String (1 .. Length);
+  B : String (1 .. Length);
+   end record;
+   type T_Ptr is access all T;
+   type U is record
+  X : T_Ptr;
+   end record;
+   function A (Y : U) return String;
+end;
___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


Re: [llvm-commits] llvm-gcc: support arrays with non-zero lower bound

2007-03-02 Thread Duncan Sands
Additional Ada testcase.
Index: llvm/test/AdaFrontend/array_size.adb
===
--- /dev/null	1970-01-01 00:00:00.0 +
+++ llvm/test/AdaFrontend/array_size.adb	2007-03-02 12:50:25.0 +0100
@@ -0,0 +1,10 @@
+-- RUN: %llvmgcc -c %s -o /dev/null
+procedure Array_Size is
+   subtype S is String (1 .. 2);
+   type R is record
+  A : S;
+   end record;
+   X : R;
+begin
+   null;
+end;
___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


Re: [llvm-commits] llvm-gcc: check that fields are laid out in ConvertRecordCONSTRUCTOR

2007-03-02 Thread Duncan Sands
 Testcase triggering this.

An Ada testcase, so currently unusable except by me,
since I'm the only person on the planet who has a
working llvm-gcc Ada compiler.  Hopefully this will
not be the case for much longer.
___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


Re: [llvm-commits] llvm-gcc: support arrays with non-zero lower bound

2007-03-02 Thread Duncan Sands
Refreshed patch after Chris's array indexing changes.
Both Ada testcases attached.
Index: gcc.llvm/gcc/llvm-abi.h
===
--- gcc.llvm.orig/gcc/llvm-abi.h	2007-02-18 19:21:10.0 +0100
+++ gcc.llvm/gcc/llvm-abi.h	2007-03-02 15:17:52.0 +0100
@@ -109,15 +109,10 @@
   }
 return FoundField ? isSingleElementStructOrArray(FoundField) : 0;
   case ARRAY_TYPE:
-tree Domain = TYPE_DOMAIN(type);
-if (!Domain || !TYPE_MIN_VALUE(Domain) || !TYPE_MAX_VALUE(Domain))
+if (TREE_CODE(TYPE_SIZE(type)) != INTEGER_CST)
   return 0;
-if (TREE_CODE(TYPE_SIZE(type)) != INTEGER_CST ||
-TREE_CODE(TYPE_MIN_VALUE(Domain)) != INTEGER_CST ||
-TREE_CODE(TYPE_MAX_VALUE(Domain)) != INTEGER_CST)
-  return 0;
-if (TREE_INT_CST_LOW(TYPE_MAX_VALUE(Domain)) !=
-TREE_INT_CST_LOW(TYPE_MIN_VALUE(Domain)))
+tree length = arrayLength(type);
+if (!length || !integer_onep(length))
   return 0;
 return isSingleElementStructOrArray(TREE_TYPE(type));
   }
Index: gcc.llvm/gcc/llvm-convert.cpp
===
--- gcc.llvm.orig/gcc/llvm-convert.cpp	2007-03-02 15:16:32.0 +0100
+++ gcc.llvm/gcc/llvm-convert.cpp	2007-03-02 15:17:51.0 +0100
@@ -1353,18 +1353,14 @@
 DECL_USER_ALIGN(decl) = 0;
 Alignment = DECL_ALIGN(decl)/8;
   } else {
+tree length;
+
 // Dynamic-size object: must push space on the stack.
-if (TREE_CODE(type) == ARRAY_TYPE  TYPE_DOMAIN(type)) {
+if (TREE_CODE(type) == ARRAY_TYPE  (length = arrayLength(type))) {
   Ty = ConvertType(TREE_TYPE(type));  // Get array element type.
-  // Compute the size of the number of elements of the array.
-  Size = Emit(TYPE_MAX_VALUE(TYPE_DOMAIN(type)), 0);
-  Size = CastToUIntType(Size, Type::Int32Ty);
-  
-  // Annoyingly, TYPE_MAX_VALUE returns the maximum valid index, NOT the
-  // number of elements in the array.  Thus, we must add one to the returned
-  // value.  This addition should be optimized out later.
-  Size = BinaryOperator::createAdd(Size, ConstantInt::get(Type::Int32Ty, 1),
-   tmp, CurBB);
+  // Compute the number of elements in the array.
+  Size = Emit(length, 0);
+  Size = CastToUIntType(Size, Size-getType());
 } else {
   // Compute the variable's size in bytes.
   Size = CastToUIntType(Emit(DECL_SIZE_UNIT(decl), 0), Type::Int32Ty);
@@ -4537,9 +4533,8 @@
   // If this is an index into an array, codegen as a GEP.
   if (TREE_CODE(TREE_TYPE(Array)) == ARRAY_TYPE) {
 // Check for variable sized array reference.
-tree Domain = TYPE_DOMAIN(TREE_TYPE(Array));
-if (Domain  TYPE_MAX_VALUE(Domain) 
-TREE_CODE(TYPE_MAX_VALUE(Domain)) != INTEGER_CST) {
+tree length = arrayLength(TREE_TYPE(Array));
+if (length  !host_integerp(length, 1)) {
   // Make sure that ArrayAddr is of type ElementTy*, then do a 2-index gep.
   tree ElTy = TREE_TYPE(TREE_TYPE(Array));
   // This cast only deals with pointers so BitCast is appropriate
@@ -4982,7 +4977,7 @@
 // If this is a variable sized array type, set the length to Len.
 if (ConstantSize == 0) {
   tree Domain = TYPE_DOMAIN(TREE_TYPE(exp));
-  if (Domain == 0 || TYPE_MAX_VALUE(Domain) == 0) {
+  if (!Domain || !TYPE_MAX_VALUE(Domain)) {
 ConstantSize = Len;
 StrTy = ArrayType::get(ElTy, Len);
   }
@@ -5081,21 +5076,23 @@
   // type indirectly.
   assert(TREE_CODE(TREE_TYPE(exp)) != VECTOR_TYPE 
  VECTOR_TYPE's haven't been tested!);
-  
-  // If we have constant lower bound for the range of the type, get it.  */
+
+  // If we have a lower bound for the range of the type, get it.  */
   tree Domain = TYPE_DOMAIN(TREE_TYPE(exp));
-  unsigned MinElement = 0;
-  if (Domain  TYPE_MIN_VALUE(Domain)  
-  host_integerp(TYPE_MIN_VALUE(Domain), 0))
-MinElement = tree_low_cst(TYPE_MIN_VALUE(Domain), 0);
-  
+  tree min_element = size_zero_node;
+  if (Domain  TYPE_MIN_VALUE(Domain))
+min_element = fold_convert(sizetype, TYPE_MIN_VALUE(Domain));
+
   std::vectorConstant* ResultElts;
   Constant *SomeVal = 0;
   
-  if (Domain  TYPE_MAX_VALUE(Domain)  
-  host_integerp(TYPE_MAX_VALUE(Domain), 0)) {
-unsigned MaxElement = tree_low_cst(TYPE_MAX_VALUE(Domain), 0);
-ResultElts.resize(MaxElement-MinElement+1);
+  if (Domain  TYPE_MAX_VALUE(Domain)) {
+tree max_element = fold_convert(sizetype, TYPE_MAX_VALUE(Domain));
+tree size = size_binop (MINUS_EXPR, max_element, min_element);
+size = size_binop (PLUS_EXPR, size, size_one_node);
+
+if (host_integerp(size, 1))
+  ResultElts.resize(tree_low_cst(size, 1));
   }
 
   unsigned NextFieldToFill = 0;
@@ -5111,14 +5108,21 @@
 // The first and last field to fill in, inclusive.
 unsigned FieldOffset, FieldLastOffset;
 if (index  TREE_CODE(index) == RANGE_EXPR) 

[llvm-commits] llvm-gcc: use component_ref_field_offset in component references

2007-03-02 Thread Duncan Sands
The third operand of a COMPONENT_REF represents the byte offset of
the field; it is accessed using component_ref_field_offset.  Most of
the time you can get away with extracting the offset from the type,
using DECL_FIELD_OFFSET, which is what is done currently, but this
can fail if DECL_FIELD_OFFSET contains a PLACEHOLDER_EXPR for example.
The NON_LVALUE_EXPR Ada testcase also tests this one.
Index: gcc.llvm.master/gcc/llvm-convert.cpp
===
--- gcc.llvm.master.orig/gcc/llvm-convert.cpp	2007-03-02 15:19:49.0 +0100
+++ gcc.llvm.master/gcc/llvm-convert.cpp	2007-03-02 15:19:51.0 +0100
@@ -4588,6 +4588,20 @@
   return Result;
 }
 
+/// getComponentRefOffsetInBits - Return the offset (in bits) of the field
+/// referenced in a COMPONENT_REF exp.
+static unsigned getComponentRefOffsetInBits(tree exp) {
+  assert(TREE_CODE(exp) == COMPONENT_REF  not a COMPONENT_REF!);
+  tree field = TREE_OPERAND(exp, 1);
+  assert(TREE_CODE(field) == FIELD_DECL  not a FIELD_DECL!);
+  tree field_offset = component_ref_field_offset (exp);
+  assert(DECL_FIELD_BIT_OFFSET(field)  field_offset);
+  unsigned Result = TREE_INT_CST_LOW(DECL_FIELD_BIT_OFFSET(field));
+  if (TREE_CODE(field_offset) == INTEGER_CST)
+Result += TREE_INT_CST_LOW(field_offset)*8;
+  return Result;
+}
+
 LValue TreeToLLVM::EmitLV_COMPONENT_REF(tree exp) {
   LValue StructAddrLV = EmitLV(TREE_OPERAND(exp, 0));
   tree FieldDecl = TREE_OPERAND(exp, 1);
@@ -4610,11 +4624,12 @@
   
   // BitStart - This is the actual offset of the field from the start of the
   // struct, in bits.  For bitfields this may be on a non-byte boundary.
-  unsigned BitStart = getFieldOffsetInBits(FieldDecl);
+  unsigned BitStart = getComponentRefOffsetInBits(exp);
   Value *FieldPtr;
   
+  tree field_offset = component_ref_field_offset (exp);
   // If this is a normal field at a fixed offset from the start, handle it.
-  if (TREE_CODE(DECL_FIELD_OFFSET(FieldDecl)) == INTEGER_CST) {
+  if (TREE_CODE(field_offset) == INTEGER_CST) {
 assert(DECL_LLVM_SET_P(FieldDecl)  Struct not laid out for LLVM?);
 ConstantInt *CI = castConstantInt(DECL_LLVM(FieldDecl));
 uint32_t MemberIndex = CI-getZExtValue();
@@ -4638,7 +4653,7 @@
 }
 
   } else {
-Value *Offset = Emit(DECL_FIELD_OFFSET(FieldDecl), 0);
+Value *Offset = Emit(field_offset, 0);
 Value *Ptr = CastToType(Instruction::PtrToInt, StructAddrLV.Ptr, 
 Offset-getType());
 Ptr = BinaryOperator::createAdd(Ptr, Offset, tmp, CurBB);
@@ -5662,13 +5677,14 @@
   
   // BitStart - This is the actual offset of the field from the start of the
   // struct, in bits.  For bitfields this may be on a non-byte boundary.
-  unsigned BitStart = getFieldOffsetInBits(FieldDecl);
+  unsigned BitStart = getComponentRefOffsetInBits(exp);
   unsigned BitSize  = 0;
   Constant *FieldPtr;
   const TargetData TD = getTargetData();
-  
+
+  tree field_offset = component_ref_field_offset (exp);
   // If this is a normal field at a fixed offset from the start, handle it.
-  if (TREE_CODE(DECL_FIELD_OFFSET(FieldDecl)) == INTEGER_CST) {
+  if (TREE_CODE(field_offset) == INTEGER_CST) {
 assert(DECL_LLVM_SET_P(FieldDecl)  Struct not laid out for LLVM?);
 ConstantInt *CI = castConstantInt(DECL_LLVM(FieldDecl));
 uint64_t MemberIndex = CI-getZExtValue();
@@ -5688,18 +5704,18 @@
   }
 } else {
   // We were unable to make a nice offset, emit an ugly one.
-  Constant *Offset = Convert(DECL_FIELD_OFFSET(FieldDecl));
+  Constant *Offset = Convert(field_offset);
   FieldPtr = ConstantExpr::getPtrToInt(StructAddrLV, Offset-getType());
   FieldPtr = ConstantExpr::getAdd(FieldPtr, Offset);
   FieldPtr = ConstantExpr::getIntToPtr(FieldPtr, PointerType::get(FieldTy));
   
   // Do horrible pointer arithmetic to get the address of the field.
-  unsigned ByteOffset = TREE_INT_CST_LOW(DECL_FIELD_OFFSET(FieldDecl));
+  unsigned ByteOffset = TREE_INT_CST_LOW(field_offset);
   BitStart -= ByteOffset * 8;
 }
 
   } else {
-Constant *Offset = Convert(DECL_FIELD_OFFSET(FieldDecl));
+Constant *Offset = Convert(field_offset);
 Constant *Ptr = ConstantExpr::getPtrToInt(StructAddrLV, Offset-getType());
 Ptr = ConstantExpr::getAdd(Ptr, Offset);
 FieldPtr = ConstantExpr::getIntToPtr(Ptr, PointerType::get(FieldTy));
___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/include/llvm/ADT/SmallPtrSet.h

2007-03-02 Thread Chris Lattner


Changes in directory llvm/include/llvm/ADT:

SmallPtrSet.h updated: 1.7 - 1.8
---
Log message:

Fix PR1234: http://llvm.org/PR1234  by working around a compiler bug.


---
Diffs of the changes:  (+1 -2)

 SmallPtrSet.h |3 +--
 1 files changed, 1 insertion(+), 2 deletions(-)


Index: llvm/include/llvm/ADT/SmallPtrSet.h
diff -u llvm/include/llvm/ADT/SmallPtrSet.h:1.7 
llvm/include/llvm/ADT/SmallPtrSet.h:1.8
--- llvm/include/llvm/ADT/SmallPtrSet.h:1.7 Tue Feb  6 19:11:24 2007
+++ llvm/include/llvm/ADT/SmallPtrSet.h Fri Mar  2 12:16:29 2007
@@ -187,8 +187,7 @@
   enum {
 // We could just use NextVal = N+1, but this converges faster.  N|(N-1) 
sets
 // the right-most zero bits to one all at once, e.g. 0b0011000 - 
0b001.
-NextVal = (N|(N-1)) + 1,
-Val = NextPowerOfTwoNextVal::Val
+Val = NextPowerOfTwo(N|(N-1)) + 1::Val
   };
 };
 



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/lib/Transforms/Scalar/InstructionCombining.cpp

2007-03-02 Thread Chris Lattner


Changes in directory llvm/lib/Transforms/Scalar:

InstructionCombining.cpp updated: 1.638 - 1.639
---
Log message:

minor cleanup


---
Diffs of the changes:  (+2 -6)

 InstructionCombining.cpp |8 ++--
 1 files changed, 2 insertions(+), 6 deletions(-)


Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp
diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.638 
llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.639
--- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.638   Thu Mar  1 
13:33:52 2007
+++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp Fri Mar  2 13:59:19 2007
@@ -5799,13 +5799,9 @@
   while (UI != E  *UI == User)
 ++UI; // If this instruction uses AI more than once, don't break UI.
   
-  // Add operands to the worklist.
-  AddUsesToWorkList(*User);
   ++NumDeadInst;
   DOUT  IC: DCE:   *User;
-  
-  User-eraseFromParent();
-  removeFromWorkList(User);
+  EraseInstFromFunction(*User);
 }
   }
   
@@ -7389,7 +7385,7 @@
 
   if (Caller-getType() != Type::VoidTy  !Caller-use_empty())
 Caller-replaceAllUsesWith(NV);
-  Caller-getParent()-getInstList().erase(Caller);
+  Caller-eraseFromParent();
   removeFromWorkList(Caller);
   return true;
 }



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm-test/SingleSource/UnitTests/Integer/APInt/gptest.cpp

2007-03-02 Thread Reid Spencer


Changes in directory llvm-test/SingleSource/UnitTests/Integer/APInt:

gptest.cpp updated: 1.9 - 1.10
---
Log message:

Hack around pari/gp's inability to do an arithmetic shift right.


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

 gptest.cpp |   24 +++-
 1 files changed, 11 insertions(+), 13 deletions(-)


Index: llvm-test/SingleSource/UnitTests/Integer/APInt/gptest.cpp
diff -u llvm-test/SingleSource/UnitTests/Integer/APInt/gptest.cpp:1.9 
llvm-test/SingleSource/UnitTests/Integer/APInt/gptest.cpp:1.10
--- llvm-test/SingleSource/UnitTests/Integer/APInt/gptest.cpp:1.9   Thu Mar 
 1 22:56:56 2007
+++ llvm-test/SingleSource/UnitTests/Integer/APInt/gptest.cpp   Fri Mar  2 
14:52:41 2007
@@ -265,22 +265,20 @@
   printf( u %d = %s (not %s)\n, i, gpresult.c_str(), apresult.c_str());
   fflush(stdout);
 }
+cmd = shift( + v1.toString(10,false) + ,- + utostr(i) + );
 if (v1.isNegative()) {
-  cmd = shift( + v1.toString(10,true) + ,- + utostr(i-1) + )\n;
-  R1 = v1.ashr(i-1);
-  apresult = R1.toString(10,true);
-} else {
-  cmd = shift( + v1.toString(10,false) + ,- + utostr(i) + )\n;
-  R1 = v1.ashr(i);
-  apresult = R1.toString(10,false);
-}
+  APInt hiMask(32, -1ULL);
+  hiMask.sextOrTrunc(v1.getBitWidth());
+  hiMask = hiMask.shl(v1.getBitWidth()-i);
+  cmd = bitor( + cmd + , + hiMask.toString(10,false) + );
+}
+cmd += \n;
+R1 = v1.ashr(i);
+apresult = R1.toString(10,false);
 gpresult = getResult(cmd);
 if (gpresult != apresult) {
-  if (v1.isNegative())
-print(v1, true);
-  else
-print(v1, false);
-  printf( s %d = %s (not %s)\n, i, gpresult.c_str(), apresult.c_str());
+  print(v1, false);
+  printf( s %d = %s (not %s) cmd=%s\n, i, gpresult.c_str(), 
apresult.c_str(), cmd.c_str());
   fflush(stdout);
 }
   }



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/lib/Transforms/Scalar/InstructionCombining.cpp

2007-03-02 Thread Chris Lattner


Changes in directory llvm/lib/Transforms/Scalar:

InstructionCombining.cpp updated: 1.639 - 1.640
---
Log message:

Fix a significant algorithm problem with the instcombine worklist.  removing
a value from the worklist required scanning the entire worklist to remove all
entries.  We now use a combination map+vector to prevent duplicates from 
happening and prevent the scan.  This speeds up instcombine on a large file
from the llvm-gcc bootstrap from 189.7s to 4.84s in a debug build and from
5.04s to 1.37s in a release build.


---
Diffs of the changes:  (+70 -54)

 InstructionCombining.cpp |  124 ++-
 1 files changed, 70 insertions(+), 54 deletions(-)


Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp
diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.639 
llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.640
--- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.639   Fri Mar  2 
13:59:19 2007
+++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp Fri Mar  2 15:28:56 2007
@@ -50,6 +50,7 @@
 #include llvm/Support/MathExtras.h
 #include llvm/Support/PatternMatch.h
 #include llvm/Support/Compiler.h
+#include llvm/ADT/DenseMap.h
 #include llvm/ADT/SmallVector.h
 #include llvm/ADT/SmallPtrSet.h
 #include llvm/ADT/Statistic.h
@@ -70,9 +71,36 @@
 : public FunctionPass,
   public InstVisitorInstCombiner, Instruction* {
 // Worklist of all of the instructions that need to be simplified.
-std::vectorInstruction* WorkList;
+std::vectorInstruction* Worklist;
+DenseMapInstruction*, unsigned WorklistMap;
 TargetData *TD;
+  public:
+/// AddToWorkList - Add the specified instruction to the worklist if it
+/// isn't already in it.
+void AddToWorkList(Instruction *I) {
+  if (WorklistMap.insert(std::make_pair(I, Worklist.size(
+Worklist.push_back(I);
+}
+
+// RemoveFromWorkList - remove I from the worklist if it exists.
+void RemoveFromWorkList(Instruction *I) {
+  DenseMapInstruction*, unsigned::iterator It = WorklistMap.find(I);
+  if (It == WorklistMap.end()) return; // Not in worklist.
+  
+  // Don't bother moving everything down, just null out the slot.
+  Worklist[It-second] = 0;
+  
+  WorklistMap.erase(It);
+}
+
+Instruction *RemoveOneFromWorkList() {
+  Instruction *I = Worklist.back();
+  Worklist.pop_back();
+  WorklistMap.erase(I);
+  return I;
+}
 
+
 /// AddUsersToWorkList - When an instruction is simplified, add all users 
of
 /// the instruction to the work lists because they might get more 
simplified
 /// now.
@@ -80,7 +108,7 @@
 void AddUsersToWorkList(Value I) {
   for (Value::use_iterator UI = I.use_begin(), UE = I.use_end();
UI != UE; ++UI)
-WorkList.push_back(castInstruction(*UI));
+AddToWorkList(castInstruction(*UI));
 }
 
 /// AddUsesToWorkList - When an instruction is simplified, add operands to
@@ -89,7 +117,7 @@
 void AddUsesToWorkList(Instruction I) {
   for (unsigned i = 0, e = I.getNumOperands(); i != e; ++i)
 if (Instruction *Op = dyn_castInstruction(I.getOperand(i)))
-  WorkList.push_back(Op);
+  AddToWorkList(Op);
 }
 
 /// AddSoonDeadInstToWorklist - The specified instruction is about to 
become
@@ -103,7 +131,7 @@
   
   for (unsigned i = 0, e = I.getNumOperands(); i != e; ++i)
 if (Instruction *Op = dyn_castInstruction(I.getOperand(i))) {
-  WorkList.push_back(Op);
+  AddToWorkList(Op);
   // Set the operand to undef to drop the use.
   I.setOperand(i, UndefValue::get(Op-getType()));
 }
@@ -111,8 +139,6 @@
   return R;
 }
 
-// removeFromWorkList - remove all instances of I from the worklist.
-void removeFromWorkList(Instruction *I);
   public:
 virtual bool runOnFunction(Function F);
 
@@ -206,7 +232,7 @@
  New instruction already inserted into a basic block!);
   BasicBlock *BB = Old.getParent();
   BB-getInstList().insert(Old, New);  // Insert inst
-  WorkList.push_back(New);  // Add to worklist
+  AddToWorkList(New);
   return New;
 }
 
@@ -221,7 +247,7 @@
 return ConstantExpr::getCast(opc, CV, Ty);
   
   Instruction *C = CastInst::create(opc, V, Ty, V-getName(), Pos);
-  WorkList.push_back(C);
+  AddToWorkList(C);
   return C;
 }
 
@@ -255,9 +281,9 @@
   if (Old != New)
 Old-replaceAllUsesWith(New);
   if (Instruction *I = dyn_castInstruction(Old))
-WorkList.push_back(I);
+AddToWorkList(I);
   if (Instruction *I = dyn_castInstruction(New))
-WorkList.push_back(I);
+AddToWorkList(I);
   return true;
 }
 
@@ -268,7 +294,7 @@
 Instruction *EraseInstFromFunction(Instruction I) {
   assert(I.use_empty()  Cannot erase instruction that is used!);
   

[llvm-commits] CVS: llvm/lib/Target/X86/X86ISelLowering.cpp

2007-03-02 Thread Anton Korobeynikov


Changes in directory llvm/lib/Target/X86:

X86ISelLowering.cpp updated: 1.358 - 1.359
---
Log message:

Simplify things


---
Diffs of the changes:  (+2 -8)

 X86ISelLowering.cpp |   10 ++
 1 files changed, 2 insertions(+), 8 deletions(-)


Index: llvm/lib/Target/X86/X86ISelLowering.cpp
diff -u llvm/lib/Target/X86/X86ISelLowering.cpp:1.358 
llvm/lib/Target/X86/X86ISelLowering.cpp:1.359
--- llvm/lib/Target/X86/X86ISelLowering.cpp:1.358   Thu Mar  1 23:12:29 2007
+++ llvm/lib/Target/X86/X86ISelLowering.cpp Fri Mar  2 15:50:27 2007
@@ -30,16 +30,11 @@
 #include llvm/CodeGen/MachineInstrBuilder.h
 #include llvm/CodeGen/SelectionDAG.h
 #include llvm/CodeGen/SSARegMap.h
-#include llvm/Support/CommandLine.h
 #include llvm/Support/MathExtras.h
 #include llvm/Target/TargetOptions.h
 #include llvm/ADT/StringExtras.h
 using namespace llvm;
 
-static cl::optbool FastCallAlignStack(x86-fastcc-align-stack, cl::Hidden,
- cl::desc(Align stack to 8-byte boundary for fastcall function),
-cl::init(false));
-
 X86TargetLowering::X86TargetLowering(TargetMachine TM)
   : TargetLowering(TM) {
   Subtarget = TM.getSubtargetX86Subtarget();
@@ -909,7 +904,7 @@
 
   unsigned StackSize = CCInfo.getNextStackOffset();
 
-  if (FastCallAlignStack) {
+  if (!Subtarget-isTargetCygMing()  !Subtarget-isTargetWindows()) {
 // Make sure the instruction takes 8n+4 bytes to make sure the start of the
 // arguments and the arguments after the retaddr has been pushed are 
aligned.
 if ((StackSize  7) == 0)
@@ -943,7 +938,7 @@
   // Get a count of how many bytes are to be pushed on the stack.
   unsigned NumBytes = CCInfo.getNextStackOffset();
 
-  if (FastCallAlignStack) {
+  if (!Subtarget-isTargetCygMing()  !Subtarget-isTargetWindows()) {
 // Make sure the instruction takes 8n+4 bytes to make sure the start of the
 // arguments and the arguments after the retaddr has been pushed are 
aligned.
 if ((NumBytes  7) == 0)
@@ -951,7 +946,6 @@
   }
 
   Chain = DAG.getCALLSEQ_START(Chain,DAG.getConstant(NumBytes, 
getPointerTy()));
-
   
   SmallVectorstd::pairunsigned, SDOperand, 8 RegsToPass;
   SmallVectorSDOperand, 8 MemOpChains;



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/include/llvm/Support/MathExtras.h

2007-03-02 Thread Anton Korobeynikov


Changes in directory llvm/include/llvm/Support:

MathExtras.h updated: 1.40 - 1.41
---
Log message:

Fix uninitialized use of variable. Remove tabs and fix identation.


---
Diffs of the changes:  (+19 -19)

 MathExtras.h |   38 +++---
 1 files changed, 19 insertions(+), 19 deletions(-)


Index: llvm/include/llvm/Support/MathExtras.h
diff -u llvm/include/llvm/Support/MathExtras.h:1.40 
llvm/include/llvm/Support/MathExtras.h:1.41
--- llvm/include/llvm/Support/MathExtras.h:1.40 Thu Mar  1 23:03:07 2007
+++ llvm/include/llvm/Support/MathExtras.h  Fri Mar  2 16:19:41 2007
@@ -205,10 +205,10 @@
 #if __GNUC__ = 4
   return Value ? __builtin_ctz(Value) : 32;
 #else
-   const unsigned Mod37BitPosition[] = {32, 0, 1, 26, 2, 23, 27, 0, 3, 16, 
24, 30, 28, 11, 0, 13,
-  4, 7, 17, 0, 25, 22, 31, 15, 
29, 10, 12, 6, 0, 21, 14, 9,
-  5, 20, 8, 19, 18 };
-   return Mod37BitPosition[(-Value  Value) % 37];
+  const unsigned Mod37BitPosition[] = {32, 0, 1, 26, 2, 23, 27, 0, 3, 16, 24, 
30, 28, 11, 0, 13,
+   4, 7, 17, 0, 25, 22, 31, 15, 29, 10, 
12, 6, 0, 21, 14, 9,
+   5, 20, 8, 19, 18 };
+  return Mod37BitPosition[(-Value  Value) % 37];
 #endif
 }
 
@@ -220,12 +220,12 @@
 #if __GNUC__ = 4
   return Value ? __builtin_ctzll(Value) : 64;
 #else
-  const unsigned Mod67Position[] = { 64, 0, 1, 39, 2, 15, 40, 23, 3, 12, 16, 
59, 41, 19, 24, 54,
-  4, 64, 13, 10, 17, 62, 60, 28, 42, 
30, 20, 51, 25, 44, 55,
-  47, 5, 32, 65, 38, 14, 22, 11, 58, 
18, 53, 63, 9, 61, 27,
-  29, 50, 43, 46, 31, 37, 21, 57, 52, 
8, 26, 49, 45, 36, 56,
-  7, 48, 35, 6, 34, 33, 0 };
-   return Mod67Position[(-Value  Value) % 67];
+  const unsigned Mod67Position[] = {64, 0, 1, 39, 2, 15, 40, 23, 3, 12, 16, 
59, 41, 19, 24, 54,
+4, 64, 13, 10, 17, 62, 60, 28, 42, 30, 20, 
51, 25, 44, 55,
+47, 5, 32, 65, 38, 14, 22, 11, 58, 18, 53, 
63, 9, 61, 27,
+29, 50, 43, 46, 31, 37, 21, 57, 52, 8, 26, 
49, 45, 36, 56,
+7, 48, 35, 6, 34, 33, 0 };
+  return Mod67Position[(-Value  Value) % 67];
 #endif
 }
 
@@ -236,9 +236,9 @@
 #if __GNUC__ = 4
   return __builtin_popcount(Value);
 #else
-   uint32_t v = v - ((v  1)  0x);
-   v = (v  0x) + ((v  2)  0x);
-   return ((v + (v  4)  0xF0F0F0F) * 0x1010101)  24;
+  uint32_t v = Value - ((Value  1)  0x);
+  v = (v  0x) + ((v  2)  0x);
+  return ((v + (v  4)  0xF0F0F0F) * 0x1010101)  24;
 #endif
 }
 
@@ -248,10 +248,10 @@
 #if __GNUC__ = 4
   return __builtin_popcountll(Value);
 #else
-   uint64_t v = Value - ((Value  1)  0xULL);
-   v = (v  0xULL) + ((v  2)  0xULL);
-   v = (v + (v  4))  0x0F0F0F0F0F0F0F0FULL;
-   return (uint64_t)(v * 0x0101010101010101ULL)  56;
+  uint64_t v = Value - ((Value  1)  0xULL);
+  v = (v  0xULL) + ((v  2)  0xULL);
+  v = (v + (v  4))  0x0F0F0F0F0F0F0F0FULL;
+  return (uint64_t)(v * 0x0101010101010101ULL)  56;
 #endif
 }
 
@@ -259,13 +259,13 @@
 /// -1 if the value is zero. (32 bit edition.)
 /// Ex. Log2_32(32) == 5, Log2_32(1) == 0, Log2_32(0) == -1, Log2_32(6) == 2
 inline unsigned Log2_32(unsigned Value) {
-return 31 - CountLeadingZeros_32(Value);
+  return 31 - CountLeadingZeros_32(Value);
 }
 
 /// Log2_64 - This function returns the floor log base 2 of the specified 
value, 
 /// -1 if the value is zero. (64 bit edition.)
 inline unsigned Log2_64(uint64_t Value) {
-return 63 - CountLeadingZeros_64(Value);
+  return 63 - CountLeadingZeros_64(Value);
 }
 
 /// Log2_32_Ceil - This function returns the ceil log base 2 of the specified



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm-test/SingleSource/UnitTests/Integer/APInt/gptest.cpp

2007-03-02 Thread Reid Spencer


Changes in directory llvm-test/SingleSource/UnitTests/Integer/APInt:

gptest.cpp updated: 1.10 - 1.11
---
Log message:

Create an error function so that the command sent to pari/gp can be printed
out whenver and error occurs. Also, don't attempt sqrt validation after
192 bits because pari/gp loses precision and this can also cause false
negatives in subsequent (non-sqrt) tests.


---
Diffs of the changes:  (+49 -37)

 gptest.cpp |   86 ++---
 1 files changed, 49 insertions(+), 37 deletions(-)


Index: llvm-test/SingleSource/UnitTests/Integer/APInt/gptest.cpp
diff -u llvm-test/SingleSource/UnitTests/Integer/APInt/gptest.cpp:1.10 
llvm-test/SingleSource/UnitTests/Integer/APInt/gptest.cpp:1.11
--- llvm-test/SingleSource/UnitTests/Integer/APInt/gptest.cpp:1.10  Fri Mar 
 2 14:52:41 2007
+++ llvm-test/SingleSource/UnitTests/Integer/APInt/gptest.cpp   Fri Mar  2 
16:37:40 2007
@@ -31,6 +31,12 @@
   printf(%s, decstr.c_str());
 }
 
+void error(const std::string gp, const std::string ap, 
+   const std::string cmd) {
+  printf( = %s (not %s)\n cmd=%s\n, gp.c_str(), ap.c_str(), cmd.c_str());
+  fflush(stdout);
+}
+
 APInt randomAPInt(unsigned bits) {
   APInt val(bits, 0u);
   for (unsigned i = 0; i  bits; ++i) {
@@ -77,60 +83,65 @@
   cmd +=   + op +  ;
   cmd += v2.toString(10,wantSigned);
   cmd += ), bitneg(0, + utostr(unsigned(v1.getBitWidth())) + ))\n;
-  return getResult(cmd);
+  return cmd;
 }
 
 void report(const APInt v1, const APInt v2, const std::string op, 
-const std::string result, const std::string apresult) {
+const std::string result, const std::string apresult,
+const std::string cmd) {
   print(v1, false);
   printf(op.c_str());
   print(v2, false);
-  printf( = %s (not %s)\n, result.c_str(), apresult.c_str());
-  fflush(stdout);
+  error(result,apresult,cmd);
 }
 
 void doMultiply(const APInt v1, const APInt v2) {
-  std::string result = getBinop(v1, *, v2);
+  std::string cmd = getBinop(v1, *, v2);
+  std::string result = getResult(cmd);
   APInt r = v1 * v2;
   std::string apresult = r.toString(10, false);
   if (result != apresult) 
-report(v1,v2, * , result,apresult);
+report(v1,v2, * , result,apresult,cmd);
 }
 
 void doDivide(const APInt v1, const APInt v2) {
   if (v2 == APInt(v2.getBitWidth(),0))
 return;
-  std::string result = getBinop(v1, /, v2);
+  std::string cmd = getBinop(v1, /, v2);
+  std::string result = getResult(cmd);
   APInt r = APIntOps::udiv(v1, v2);
   std::string apresult = r.toString(10, false);
   if (result != apresult)
-report(v1,v2, / , result,apresult);
+report(v1,v2, / , result,apresult,cmd);
 }
 
 void doRemainder(const APInt v1, const APInt v2) {
   if (v2 == APInt(v2.getBitWidth(),0))
 return;
-  std::string result = getBinop(v1, %, v2);
+  std::string cmd = getBinop(v1, %, v2);
+  std::string result = getResult(cmd);
   APInt r = APIntOps::urem(v1, v2);
   std::string apresult = r.toString(10, false);
   if (result != apresult)
-report(v1,v2, %% , result,apresult);
+report(v1,v2, %% , result,apresult,cmd);
 }
 
 void doAdd(const APInt v1, const APInt v2) {
-  std::string result = getBinop(v1, +, v2);
+  std::string cmd = getBinop(v1, +, v2);
+  std::string result = getResult(cmd);
   APInt r = v1 + v2;
   std::string apresult = r.toString(10, false);
   if (result != apresult)
-report(v1,v2, + , result,apresult);
+report(v1,v2, + , result,apresult,cmd);
 }
 
 void doSubtract(const APInt v1, const APInt v2) {
-  std::string result = getBinop(v1, -, v2);
+  std::string cmd = getBinop(v1, -, v2);
+  std::string result = getResult(cmd);
   APInt r = v1 - v2;
   std::string apresult = r.toString(10, false);
   if (result != apresult)
-report(v1,v2, - , result,apresult);
+report(v1,v2, - , result,apresult,cmd);
 }
 
 void doAnd(const APInt v1, const APInt v2) {
@@ -144,7 +155,7 @@
   APInt r = v1  v2;
   std::string apresult = r.toString(10, false);
   if (result != apresult)
-report(v1, v2,  and , result,apresult);
+report(v1, v2,  and , result,apresult,cmd);
 }
 
 void doOr(const APInt v1, const APInt v2) {
@@ -158,7 +169,7 @@
   APInt r = v1 | v2;
   std::string apresult = r.toString(10, false);
   if (result != apresult)
-report(v1, v2,  or , result,apresult);
+report(v1, v2,  or , result,apresult,cmd);
 }
 
 void doXor(const APInt v1, const APInt v2) {
@@ -172,7 +183,7 @@
   APInt r = v1 ^ v2;
   std::string apresult = r.toString(10, false);
   if (result != apresult)
-report(v1, v2,  xor , result,apresult);
+report(v1, v2,  xor , result,apresult,cmd);
 }
 
 void doGCD(const APInt v1, const APInt v2) {
@@ -186,7 +197,7 @@
   APInt r = APIntOps::GreatestCommonDivisor(v1, v2);
   std::string apresult = r.toString(10, false);
   if (gpresult != apresult)
-report(v1, v2,  gcd , gpresult, apresult);
+report(v1, v2,  gcd , gpresult, apresult,cmd);
 }
 
 void doComplement(const 

[llvm-commits] CVS: llvm/lib/Support/APInt.cpp

2007-03-02 Thread Reid Spencer


Changes in directory llvm/lib/Support:

APInt.cpp updated: 1.67 - 1.68
---
Log message:

Fix ashr for bitwidths  64. This is now validated up to 1024 bits.


---
Diffs of the changes:  (+49 -33)

 APInt.cpp |   82 +-
 1 files changed, 49 insertions(+), 33 deletions(-)


Index: llvm/lib/Support/APInt.cpp
diff -u llvm/lib/Support/APInt.cpp:1.67 llvm/lib/Support/APInt.cpp:1.68
--- llvm/lib/Support/APInt.cpp:1.67 Thu Mar  1 22:21:55 2007
+++ llvm/lib/Support/APInt.cpp  Fri Mar  2 16:39:11 2007
@@ -1007,6 +1007,11 @@
 /// @brief Arithmetic right-shift function.
 APInt APInt::ashr(uint32_t shiftAmt) const {
   assert(shiftAmt = BitWidth  Invalid shift amount);
+  // Handle a degenerate case
+  if (shiftAmt == 0)
+return *this;
+
+  // Handle single word shifts with built-in ashr
   if (isSingleWord()) {
 if (shiftAmt == BitWidth)
   return APInt(BitWidth, 0); // undefined
@@ -1017,9 +1022,9 @@
 }
   }
 
-  // If all the bits were shifted out, the result is 0 or -1. This avoids 
issues
-  // with shifting by the size of the integer type, which produces undefined
-  // results. 
+  // If all the bits were shifted out, the result is, technically, undefined.
+  // We return -1 if it was negative, 0 otherwise. We check this early to avoid
+  // issues in the algorithm below.
   if (shiftAmt == BitWidth)
 if (isNegative())
   return APInt(BitWidth, -1ULL);
@@ -1029,42 +1034,53 @@
   // Create some space for the result.
   uint64_t * val = new uint64_t[getNumWords()];
 
-  // If we are shifting less than a word, compute the shift with a simple carry
-  if (shiftAmt  APINT_BITS_PER_WORD) {
-uint64_t carry = 0;
-for (int i = getNumWords()-1; i = 0; --i) {
-  val[i] = (pVal[i]  shiftAmt) | carry;
-  carry = pVal[i]  (APINT_BITS_PER_WORD - shiftAmt);
-}
-return APInt(val, BitWidth).clearUnusedBits();
-  }
-
-  // Compute some values needed by the remaining shift algorithms
-  uint32_t wordShift = shiftAmt % APINT_BITS_PER_WORD;
-  uint32_t offset = shiftAmt / APINT_BITS_PER_WORD;
+  // Compute some values needed by the following shift algorithms
+  uint32_t wordShift = shiftAmt % APINT_BITS_PER_WORD; // bits to shift per 
word
+  uint32_t offset = shiftAmt / APINT_BITS_PER_WORD; // word offset for shift
+  uint32_t breakWord = getNumWords() - 1 - offset; // last word affected
+  uint32_t bitsInWord = whichBit(BitWidth); // how many bits in last word?
+  if (bitsInWord == 0)
+bitsInWord = APINT_BITS_PER_WORD;
 
   // If we are shifting whole words, just move whole words
   if (wordShift == 0) {
-for (uint32_t i = 0; i  getNumWords() - offset; ++i) 
-  val[i] = pVal[i+offset];
-for (uint32_t i = getNumWords()-offset; i  getNumWords(); i++)
-  val[i] = (isNegative() ? -1ULL : 0);
-return APInt(val,BitWidth).clearUnusedBits();
-  }
+// Move the words containing significant bits
+for (uint32_t i = 0; i = breakWord; ++i) 
+  val[i] = pVal[i+offset]; // move whole word
 
-  // Shift the low order words 
-  uint32_t breakWord = getNumWords() - offset -1;
-  for (uint32_t i = 0; i  breakWord; ++i)
-val[i] = (pVal[i+offset]  wordShift) |
- (pVal[i+offset+1]  (APINT_BITS_PER_WORD - wordShift));
-  // Shift the break word.
-  uint32_t SignBit = APINT_BITS_PER_WORD - (BitWidth % APINT_BITS_PER_WORD);
-  val[breakWord] = uint64_t(
-(((int64_t(pVal[breakWord+offset])  SignBit)  SignBit)  wordShift));
+// Adjust the top significant word for sign bit fill, if negative
+if (isNegative())
+  if (bitsInWord  APINT_BITS_PER_WORD)
+val[breakWord] |= ~0ULL  bitsInWord; // set high bits
+  } else {
+// Shift the low order words 
+for (uint32_t i = 0; i  breakWord; ++i) {
+  // This combines the shifted corresponding word with the low bits from
+  // the next word (shifted into this word's high bits).
+  val[i] = (pVal[i+offset]  wordShift) | 
+   (pVal[i+offset+1]  (APINT_BITS_PER_WORD - wordShift));
+}
+
+// Shift the break word. In this case there are no bits from the next word
+// to include in this word.
+val[breakWord] = pVal[breakWord+offset]  wordShift;
+
+// Deal with sign extenstion in the break word, and possibly the word 
before
+// it.
+if (isNegative())
+  if (wordShift  bitsInWord) {
+if (breakWord  0)
+  val[breakWord-1] |= 
+~0ULL  (APINT_BITS_PER_WORD - (wordShift - bitsInWord));
+val[breakWord] |= ~0ULL;
+  } else 
+val[breakWord] |= (~0ULL  (bitsInWord - wordShift));
+  }
 
-  // Remaining words are 0 or -1
+  // Remaining words are 0 or -1, just assign them.
+  uint64_t fillValue = (isNegative() ? -1ULL : 0);
   for (uint32_t i = breakWord+1; i  getNumWords(); ++i)
-val[i] = (isNegative() ? -1ULL : 0);
+val[i] = fillValue;
   return APInt(val, BitWidth).clearUnusedBits();
 }
 




[llvm-commits] CVS: llvm/lib/Transforms/Utils/SimplifyCFG.cpp

2007-03-02 Thread Reid Spencer


Changes in directory llvm/lib/Transforms/Utils:

SimplifyCFG.cpp updated: 1.117 - 1.118
---
Log message:

Make sorting of ConstantInt be APInt clean through use of ult function.


---
Diffs of the changes:  (+1 -1)

 SimplifyCFG.cpp |2 +-
 1 files changed, 1 insertion(+), 1 deletion(-)


Index: llvm/lib/Transforms/Utils/SimplifyCFG.cpp
diff -u llvm/lib/Transforms/Utils/SimplifyCFG.cpp:1.117 
llvm/lib/Transforms/Utils/SimplifyCFG.cpp:1.118
--- llvm/lib/Transforms/Utils/SimplifyCFG.cpp:1.117 Mon Feb 12 20:10:56 2007
+++ llvm/lib/Transforms/Utils/SimplifyCFG.cpp   Fri Mar  2 17:01:14 2007
@@ -1167,7 +1167,7 @@
   /// applications that sort ConstantInt's to ensure uniqueness.
   struct ConstantIntOrdering {
 bool operator()(const ConstantInt *LHS, const ConstantInt *RHS) const {
-  return LHS-getZExtValue()  RHS-getZExtValue();
+  return LHS-getValue().ult(RHS-getValue());
 }
   };
 }



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/lib/Transforms/Utils/LowerAllocations.cpp

2007-03-02 Thread Reid Spencer


Changes in directory llvm/lib/Transforms/Utils:

LowerAllocations.cpp updated: 1.71 - 1.72
---
Log message:

Use APInt safe isOne() method on ConstantInt instead of getZExtValue()==1


---
Diffs of the changes:  (+1 -1)

 LowerAllocations.cpp |2 +-
 1 files changed, 1 insertion(+), 1 deletion(-)


Index: llvm/lib/Transforms/Utils/LowerAllocations.cpp
diff -u llvm/lib/Transforms/Utils/LowerAllocations.cpp:1.71 
llvm/lib/Transforms/Utils/LowerAllocations.cpp:1.72
--- llvm/lib/Transforms/Utils/LowerAllocations.cpp:1.71 Thu Jan 25 17:23:25 2007
+++ llvm/lib/Transforms/Utils/LowerAllocations.cpp  Fri Mar  2 17:03:17 2007
@@ -121,7 +121,7 @@
 
   if (MI-isArrayAllocation()) {
 if (isaConstantInt(MallocArg) 
-castConstantInt(MallocArg)-getZExtValue() == 1) {
+castConstantInt(MallocArg)-isOne()) {
   MallocArg = MI-getOperand(0); // Operand * 1 = Operand
 } else if (Constant *CO = dyn_castConstant(MI-getOperand(0))) {
   CO = ConstantExpr::getIntegerCast(CO, IntPtrTy, false /*ZExt*/);



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/lib/Transforms/Utils/LowerSwitch.cpp

2007-03-02 Thread Reid Spencer


Changes in directory llvm/lib/Transforms/Utils:

LowerSwitch.cpp updated: 1.32 - 1.33
---
Log message:

1. Sort switch cases using APInt safe comparison.
2. Make sure debug output of APInt values is safe for all bit widths.


---
Diffs of the changes:  (+2 -2)

 LowerSwitch.cpp |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)


Index: llvm/lib/Transforms/Utils/LowerSwitch.cpp
diff -u llvm/lib/Transforms/Utils/LowerSwitch.cpp:1.32 
llvm/lib/Transforms/Utils/LowerSwitch.cpp:1.33
--- llvm/lib/Transforms/Utils/LowerSwitch.cpp:1.32  Sat Dec 30 23:48:39 2006
+++ llvm/lib/Transforms/Utils/LowerSwitch.cpp   Fri Mar  2 17:05:28 2007
@@ -59,7 +59,7 @@
 
   const ConstantInt* CI1 = castconst ConstantInt(C1.first);
   const ConstantInt* CI2 = castconst ConstantInt(C2.first);
-  return CI1-getZExtValue()  CI2-getZExtValue();
+  return CI1-getValue().ult(CI2-getValue());
 }
   };
 
@@ -128,7 +128,7 @@
 
   Case Pivot = *(Begin + Mid);
   DOUT  Pivot == 
-castConstantInt(Pivot.first)-getSExtValue()  \n;
+castConstantInt(Pivot.first)-getValue().toStringSigned(10)  
\n;
 
   BasicBlock* LBranch = switchConvert(LHS.begin(), LHS.end(), Val,
   OrigBlock, Default);



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


Re: [llvm-commits] CVS: llvm/lib/Transforms/Utils/LowerSwitch.cpp

2007-03-02 Thread Chris Lattner
 1. Sort switch cases using APInt safe comparison.

Cool,
 @@ -128,7 +128,7 @@

Case Pivot = *(Begin + Mid);
DOUT  Pivot == 
 -castConstantInt(Pivot.first)-getSExtValue()  \n;
 +castConstantInt(Pivot.first)-getValue().toStringSigned 
 (10)  \n;

Please wrap this in a DEBUG line.  DOUT evaluates side-effects even  
when debugging is disabled.  This means it will evaluate  
toStringSigned() even if disabled.  In cases like this, please wrap  
in DEBUG().

Thanks Reid,

-Chris
___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/lib/Transforms/Utils/LowerSwitch.cpp

2007-03-02 Thread Reid Spencer


Changes in directory llvm/lib/Transforms/Utils:

LowerSwitch.cpp updated: 1.33 - 1.34
---
Log message:

Make sure debug code is not evaluated in non-debug case.


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

 LowerSwitch.cpp |5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)


Index: llvm/lib/Transforms/Utils/LowerSwitch.cpp
diff -u llvm/lib/Transforms/Utils/LowerSwitch.cpp:1.33 
llvm/lib/Transforms/Utils/LowerSwitch.cpp:1.34
--- llvm/lib/Transforms/Utils/LowerSwitch.cpp:1.33  Fri Mar  2 17:05:28 2007
+++ llvm/lib/Transforms/Utils/LowerSwitch.cpp   Fri Mar  2 17:15:21 2007
@@ -127,8 +127,9 @@
   DOUT  RHS:   RHS  \n;
 
   Case Pivot = *(Begin + Mid);
-  DOUT  Pivot == 
-castConstantInt(Pivot.first)-getValue().toStringSigned(10)  
\n;
+  DEBUG( DOUT  Pivot ==  
+   castConstantInt(Pivot.first)-getValue().toStringSigned(10) 
+   \n);
 
   BasicBlock* LBranch = switchConvert(LHS.begin(), LHS.end(), Val,
   OrigBlock, Default);



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/lib/Target/X86/X86ISelLowering.cpp X86ISelLowering.h

2007-03-02 Thread Evan Cheng


Changes in directory llvm/lib/Target/X86:

X86ISelLowering.cpp updated: 1.359 - 1.360
X86ISelLowering.h updated: 1.90 - 1.91
---
Log message:

X86-64 VACOPY needs custom expansion. va_list is a struct { i32, i32, i8*, i8* 
}.

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

 X86ISelLowering.cpp |   36 +---
 X86ISelLowering.h   |1 +
 2 files changed, 34 insertions(+), 3 deletions(-)


Index: llvm/lib/Target/X86/X86ISelLowering.cpp
diff -u llvm/lib/Target/X86/X86ISelLowering.cpp:1.359 
llvm/lib/Target/X86/X86ISelLowering.cpp:1.360
--- llvm/lib/Target/X86/X86ISelLowering.cpp:1.359   Fri Mar  2 15:50:27 2007
+++ llvm/lib/Target/X86/X86ISelLowering.cpp Fri Mar  2 17:16:35 2007
@@ -236,11 +236,13 @@
 
   // VASTART needs to be custom lowered to use the VarArgsFrameIndex
   setOperationAction(ISD::VASTART   , MVT::Other, Custom);
-
-  // Use the default implementation.
   setOperationAction(ISD::VAARG , MVT::Other, Expand);
-  setOperationAction(ISD::VACOPY, MVT::Other, Expand);
   setOperationAction(ISD::VAEND , MVT::Other, Expand);
+  if (Subtarget-is64Bit())
+setOperationAction(ISD::VACOPY  , MVT::Other, Custom);
+  else
+setOperationAction(ISD::VACOPY  , MVT::Other, Expand);
+
   setOperationAction(ISD::STACKSAVE,  MVT::Other, Expand);
   setOperationAction(ISD::STACKRESTORE,   MVT::Other, Expand);
   if (Subtarget-is64Bit())
@@ -3761,6 +3763,33 @@
   return DAG.getNode(ISD::TokenFactor, MVT::Other, MemOps[0], MemOps.size());
 }
 
+SDOperand X86TargetLowering::LowerVACOPY(SDOperand Op, SelectionDAG DAG) {
+  // X86-64 va_list is a struct { i32, i32, i8*, i8* }.
+  SDOperand Chain = Op.getOperand(0);
+  SDOperand DstPtr = Op.getOperand(1);
+  SDOperand SrcPtr = Op.getOperand(2);
+  SrcValueSDNode *DstSV = castSrcValueSDNode(Op.getOperand(3));
+  SrcValueSDNode *SrcSV = castSrcValueSDNode(Op.getOperand(4));
+
+  SrcPtr = DAG.getLoad(getPointerTy(), Chain, SrcPtr,
+   SrcSV-getValue(), SrcSV-getOffset());
+  Chain = SrcPtr.getValue(1);
+  for (unsigned i = 0; i  3; ++i) {
+SDOperand Val = DAG.getLoad(MVT::i64, Chain, SrcPtr,
+SrcSV-getValue(), SrcSV-getOffset());
+Chain = Val.getValue(1);
+Chain = DAG.getStore(Chain, Val, DstPtr,
+ DstSV-getValue(), DstSV-getOffset());
+if (i == 2)
+  break;
+SrcPtr = DAG.getNode(ISD::ADD, getPointerTy(), SrcPtr, 
+ DAG.getConstant(8, getPointerTy()));
+DstPtr = DAG.getNode(ISD::ADD, getPointerTy(), DstPtr, 
+ DAG.getConstant(8, getPointerTy()));
+  }
+  return Chain;
+}
+
 SDOperand
 X86TargetLowering::LowerINTRINSIC_WO_CHAIN(SDOperand Op, SelectionDAG DAG) {
   unsigned IntNo = castConstantSDNode(Op.getOperand(0))-getValue();
@@ -3925,6 +3954,7 @@
   case ISD::MEMCPY: return LowerMEMCPY(Op, DAG);
   case ISD::READCYCLECOUNTER:   return LowerREADCYCLCECOUNTER(Op, DAG);
   case ISD::VASTART:return LowerVASTART(Op, DAG);
+  case ISD::VACOPY: return LowerVACOPY(Op, DAG);
   case ISD::INTRINSIC_WO_CHAIN: return LowerINTRINSIC_WO_CHAIN(Op, DAG);
   case ISD::RETURNADDR: return LowerRETURNADDR(Op, DAG);
   case ISD::FRAMEADDR:  return LowerFRAMEADDR(Op, DAG);


Index: llvm/lib/Target/X86/X86ISelLowering.h
diff -u llvm/lib/Target/X86/X86ISelLowering.h:1.90 
llvm/lib/Target/X86/X86ISelLowering.h:1.91
--- llvm/lib/Target/X86/X86ISelLowering.h:1.90  Wed Feb 28 00:05:16 2007
+++ llvm/lib/Target/X86/X86ISelLowering.h   Fri Mar  2 17:16:35 2007
@@ -405,6 +405,7 @@
 SDOperand LowerFORMAL_ARGUMENTS(SDOperand Op, SelectionDAG DAG);
 SDOperand LowerREADCYCLCECOUNTER(SDOperand Op, SelectionDAG DAG);
 SDOperand LowerVASTART(SDOperand Op, SelectionDAG DAG);
+SDOperand LowerVACOPY(SDOperand Op, SelectionDAG DAG);
 SDOperand LowerINTRINSIC_WO_CHAIN(SDOperand Op, SelectionDAG DAG);
 SDOperand LowerRETURNADDR(SDOperand Op, SelectionDAG DAG);
 SDOperand LowerFRAMEADDR(SDOperand Op, SelectionDAG DAG);



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/lib/Transforms/Scalar/LoopUnroll.cpp

2007-03-02 Thread Reid Spencer


Changes in directory llvm/lib/Transforms/Scalar:

LoopUnroll.cpp updated: 1.36 - 1.37
---
Log message:

Guard against huge loop trip counts in an APInt safe way.


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

 LoopUnroll.cpp |9 +++--
 1 files changed, 7 insertions(+), 2 deletions(-)


Index: llvm/lib/Transforms/Scalar/LoopUnroll.cpp
diff -u llvm/lib/Transforms/Scalar/LoopUnroll.cpp:1.36 
llvm/lib/Transforms/Scalar/LoopUnroll.cpp:1.37
--- llvm/lib/Transforms/Scalar/LoopUnroll.cpp:1.36  Mon Feb  5 17:32:05 2007
+++ llvm/lib/Transforms/Scalar/LoopUnroll.cpp   Fri Mar  2 17:31:34 2007
@@ -190,10 +190,15 @@
   ConstantInt *TripCountC = dyn_cast_or_nullConstantInt(L-getTripCount());
   if (!TripCountC) return Changed;  // Must have constant trip count!
 
-  uint64_t TripCountFull = TripCountC-getZExtValue();
-  if (TripCountFull != TripCountC-getZExtValue() || TripCountFull == 0)
+  // Guard against huge trip counts. This also guards against assertions in
+  // APInt from the use of getZExtValue, below.
+  if (TripCountC-getValue().getActiveBits()  32)
 return Changed; // More than 2^32 iterations???
 
+  uint64_t TripCountFull = TripCountC-getZExtValue();
+  if (TripCountFull == 0)
+return Changed; // Zero iteraitons?
+
   unsigned LoopSize = ApproximateLoopSize(L);
   DOUT  Loop Unroll: F[  Header-getParent()-getName()
 ] Loop %  Header-getName()   Loop Size = 



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


Re: [llvm-commits] CVS: llvm/lib/Transforms/Scalar/LoopUnroll.cpp

2007-03-02 Thread Chris Lattner
On Mar 2, 2007, at 3:31 PM, Reid Spencer wrote:


 +  // Guard against huge trip counts. This also guards against  
 assertions in
 +  // APInt from the use of getZExtValue, below.
 +  if (TripCountC-getValue().getActiveBits()  32)
  return Changed; // More than 2^32 iterations???

 +  uint64_t TripCountFull = TripCountC-getZExtValue();
 +  if (TripCountFull == 0)
 +return Changed; // Zero iteraitons?
 +

Won't this still assert on 'i128 16' ?

-Chris
___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp LoopUnswitch.cpp

2007-03-02 Thread Reid Spencer


Changes in directory llvm/lib/Transforms/Scalar:

LoopStrengthReduce.cpp updated: 1.111 - 1.112
LoopUnswitch.cpp updated: 1.63 - 1.64
---
Log message:

Use more efficient test for one value in a ConstantInt.


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

 LoopStrengthReduce.cpp |   23 ---
 LoopUnswitch.cpp   |4 ++--
 2 files changed, 14 insertions(+), 13 deletions(-)


Index: llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
diff -u llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp:1.111 
llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp:1.112
--- llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp:1.111 Thu Mar  1 
18:31:39 2007
+++ llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp   Fri Mar  2 17:35:28 2007
@@ -540,7 +540,7 @@
   
   // If there is no immediate value, skip the next part.
   if (SCEVConstant *SC = dyn_castSCEVConstant(Imm))
-if (SC-getValue()-isNullValue())
+if (SC-getValue()-isZero())
   return Rewriter.expandCodeFor(NewBase, BaseInsertPt,
 OperandValToReplace-getType());
 
@@ -779,7 +779,7 @@
   SeparateSubExprs(SubExprs, SARE-getOperand(0));
 }
   } else if (!isaSCEVConstant(Expr) ||
- !castSCEVConstant(Expr)-getValue()-isNullValue()) {
+ !castSCEVConstant(Expr)-getValue()-isZero()) {
 // Do not add zero.
 SubExprs.push_back(Expr);
   }
@@ -869,7 +869,7 @@
 ///
 static bool isZero(SCEVHandle V) {
   if (SCEVConstant *SC = dyn_castSCEVConstant(V))
-return SC-getValue()-getZExtValue() == 0;
+return SC-getValue()-isZero();
   return false;
 }
 
@@ -883,17 +883,18 @@
   if (!TLI) return 0;
 
   if (SCEVConstant *SC = dyn_castSCEVConstant(Stride)) {
-int64_t SInt = SC-getValue()-getSExtValue();
-if (SInt == 1) return 0;
+APInt SInt(SC-getValue()-getValue());
+if (SInt == 1)
+  return 0;
 
 for (TargetLowering::legal_am_scale_iterator
I = TLI-legal_am_scale_begin(), E = TLI-legal_am_scale_end();
  I != E; ++I) {
-  unsigned Scale = *I;
-  if (unsigned(abs(SInt))  Scale || (SInt % Scale) != 0)
+  APInt Scale(SInt.getBitWidth(), *I);
+  if (SInt.abs().ult(Scale) || SInt.srem(Scale) != 0)
 continue;
   std::mapSCEVHandle, IVsOfOneStride::iterator SI =
-IVsByStride.find(SCEVUnknown::getIntegerSCEV(SInt/Scale, UIntPtrTy));
+IVsByStride.find(SCEVUnknown::getIntegerSCEV(SInt.sdiv(Scale)));
   if (SI == IVsByStride.end())
 continue;
   for (std::vectorIVExpr::iterator II = SI-second.IVs.begin(),
@@ -902,7 +903,7 @@
 // Only reuse previous IV if it would not require a type conversion.
 if (isZero(II-Base)  II-Base-getType() == Ty) {
   IV = *II;
-  return Scale;
+  return Scale.getZExtValue();
 }
 }
   }
@@ -1148,14 +1149,14 @@
 // are reusing an IV, it has not been used to initialize the PHI node.
 // Add it to the expression used to rewrite the uses.
 if (!isaConstantInt(CommonBaseV) ||
-!castConstantInt(CommonBaseV)-isNullValue())
+!castConstantInt(CommonBaseV)-isZero())
   RewriteExpr = SCEVAddExpr::get(RewriteExpr,
  SCEVUnknown::get(CommonBaseV));
   }
 
   // Now that we know what we need to do, insert code before User for the
   // immediate and any loop-variant expressions.
-  if (!isaConstantInt(BaseV) || !castConstantInt(BaseV)-isNullValue())
+  if (!isaConstantInt(BaseV) || !castConstantInt(BaseV)-isZero())
 // Add BaseV to the PHI value if needed.
 RewriteExpr = SCEVAddExpr::get(RewriteExpr, SCEVUnknown::get(BaseV));
 


Index: llvm/lib/Transforms/Scalar/LoopUnswitch.cpp
diff -u llvm/lib/Transforms/Scalar/LoopUnswitch.cpp:1.63 
llvm/lib/Transforms/Scalar/LoopUnswitch.cpp:1.64
--- llvm/lib/Transforms/Scalar/LoopUnswitch.cpp:1.63Mon Feb 26 14:22:50 2007
+++ llvm/lib/Transforms/Scalar/LoopUnswitch.cpp Fri Mar  2 17:35:28 2007
@@ -1048,7 +1048,7 @@
 castBinaryOperator(I)-swapOperands();
   if (ConstantInt *CB = dyn_castConstantInt(I-getOperand(1))) 
 if (CB-getType() == Type::Int1Ty) {
-  if (CB-getZExtValue())   // X  1 - X
+  if (CB-isOne())  // X  1 - X
 ReplaceUsesOfWith(I, I-getOperand(0), Worklist);
   else  // X  0 - 0
 ReplaceUsesOfWith(I, I-getOperand(1), Worklist);
@@ -1061,7 +1061,7 @@
 castBinaryOperator(I)-swapOperands();
   if (ConstantInt *CB = dyn_castConstantInt(I-getOperand(1)))
 if (CB-getType() == Type::Int1Ty) {
-  if (CB-getZExtValue())   // X | 1 - 1
+  if (CB-isOne())   // X | 1 - 1
 ReplaceUsesOfWith(I, I-getOperand(1), Worklist);
   else  // X | 0 - X
 ReplaceUsesOfWith(I, I-getOperand(0), Worklist);



___
llvm-commits mailing list

[llvm-commits] CVS: llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp

2007-03-02 Thread Reid Spencer


Changes in directory llvm/lib/Transforms/Scalar:

LoopStrengthReduce.cpp updated: 1.112 - 1.113
---
Log message:

Dang, I've done that twice now! Undo previous commit.


---
Diffs of the changes:  (+11 -12)

 LoopStrengthReduce.cpp |   23 +++
 1 files changed, 11 insertions(+), 12 deletions(-)


Index: llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
diff -u llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp:1.112 
llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp:1.113
--- llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp:1.112 Fri Mar  2 
17:35:28 2007
+++ llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp   Fri Mar  2 17:37:53 2007
@@ -540,7 +540,7 @@
   
   // If there is no immediate value, skip the next part.
   if (SCEVConstant *SC = dyn_castSCEVConstant(Imm))
-if (SC-getValue()-isZero())
+if (SC-getValue()-isNullValue())
   return Rewriter.expandCodeFor(NewBase, BaseInsertPt,
 OperandValToReplace-getType());
 
@@ -779,7 +779,7 @@
   SeparateSubExprs(SubExprs, SARE-getOperand(0));
 }
   } else if (!isaSCEVConstant(Expr) ||
- !castSCEVConstant(Expr)-getValue()-isZero()) {
+ !castSCEVConstant(Expr)-getValue()-isNullValue()) {
 // Do not add zero.
 SubExprs.push_back(Expr);
   }
@@ -869,7 +869,7 @@
 ///
 static bool isZero(SCEVHandle V) {
   if (SCEVConstant *SC = dyn_castSCEVConstant(V))
-return SC-getValue()-isZero();
+return SC-getValue()-getZExtValue() == 0;
   return false;
 }
 
@@ -883,18 +883,17 @@
   if (!TLI) return 0;
 
   if (SCEVConstant *SC = dyn_castSCEVConstant(Stride)) {
-APInt SInt(SC-getValue()-getValue());
-if (SInt == 1)
-  return 0;
+int64_t SInt = SC-getValue()-getSExtValue();
+if (SInt == 1) return 0;
 
 for (TargetLowering::legal_am_scale_iterator
I = TLI-legal_am_scale_begin(), E = TLI-legal_am_scale_end();
  I != E; ++I) {
-  APInt Scale(SInt.getBitWidth(), *I);
-  if (SInt.abs().ult(Scale) || SInt.srem(Scale) != 0)
+  unsigned Scale = *I;
+  if (unsigned(abs(SInt))  Scale || (SInt % Scale) != 0)
 continue;
   std::mapSCEVHandle, IVsOfOneStride::iterator SI =
-IVsByStride.find(SCEVUnknown::getIntegerSCEV(SInt.sdiv(Scale)));
+IVsByStride.find(SCEVUnknown::getIntegerSCEV(SInt/Scale, UIntPtrTy));
   if (SI == IVsByStride.end())
 continue;
   for (std::vectorIVExpr::iterator II = SI-second.IVs.begin(),
@@ -903,7 +902,7 @@
 // Only reuse previous IV if it would not require a type conversion.
 if (isZero(II-Base)  II-Base-getType() == Ty) {
   IV = *II;
-  return Scale.getZExtValue();
+  return Scale;
 }
 }
   }
@@ -1149,14 +1148,14 @@
 // are reusing an IV, it has not been used to initialize the PHI node.
 // Add it to the expression used to rewrite the uses.
 if (!isaConstantInt(CommonBaseV) ||
-!castConstantInt(CommonBaseV)-isZero())
+!castConstantInt(CommonBaseV)-isNullValue())
   RewriteExpr = SCEVAddExpr::get(RewriteExpr,
  SCEVUnknown::get(CommonBaseV));
   }
 
   // Now that we know what we need to do, insert code before User for the
   // immediate and any loop-variant expressions.
-  if (!isaConstantInt(BaseV) || !castConstantInt(BaseV)-isZero())
+  if (!isaConstantInt(BaseV) || !castConstantInt(BaseV)-isNullValue())
 // Add BaseV to the PHI value if needed.
 RewriteExpr = SCEVAddExpr::get(RewriteExpr, SCEVUnknown::get(BaseV));
 



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [124488] Fix another VLA array indexing bug.

2007-03-02 Thread clattner
Revision: 124488
Author:   clattner
Date: 2007-03-02 15:36:33 -0800 (Fri, 02 Mar 2007)

Log Message:
---
Fix another VLA array indexing bug.  PR1233.

Modified Paths:
--
apple-local/branches/llvm/gcc/llvm-convert.cpp

Modified: apple-local/branches/llvm/gcc/llvm-convert.cpp
===
--- apple-local/branches/llvm/gcc/llvm-convert.cpp  2007-03-02 23:19:09 UTC 
(rev 124487)
+++ apple-local/branches/llvm/gcc/llvm-convert.cpp  2007-03-02 23:36:33 UTC 
(rev 124488)
@@ -4541,10 +4541,14 @@
 TREE_CODE(TYPE_MAX_VALUE(Domain)) != INTEGER_CST) {
   // Make sure that ArrayAddr is of type ElementTy*, then do a 2-index gep.
   tree ElTy = TREE_TYPE(TREE_TYPE(Array));
-  // This cast only deals with pointers so BitCast is appropriate
-  ArrayAddr = CastInst::create(Instruction::BitCast, 
-  ArrayAddr, PointerType::get(ConvertType(ElTy)), tmp, CurBB);
-  return new GetElementPtrInst(ArrayAddr, IndexVal, tmp, CurBB);
+  ArrayAddr = BitCastToType(ArrayAddr, PointerType::get(Type::Int8Ty));
+  Value *Scale = Emit(TYPE_SIZE_UNIT(ElTy), 0);
+  if (Scale-getType() != IntPtrTy)
+Scale = CastToUIntType(Scale, IntPtrTy);
+
+  IndexVal = BinaryOperator::createMul(IndexVal, Scale, tmp, CurBB);
+  Value *Ptr = new GetElementPtrInst(ArrayAddr, IndexVal, tmp, CurBB);
+  return BitCastToType(Ptr, PointerType::get(ConvertType(TREE_TYPE(exp;
 }
 
 // Otherwise, this is not a variable-sized array, use a GEP to index.


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


Re: [llvm-commits] CVS: llvm/lib/Transforms/Scalar/LoopUnroll.cpp

2007-03-02 Thread Reid Spencer
On Fri, 2007-03-02 at 15:35 -0800, Chris Lattner wrote:
 On Mar 2, 2007, at 3:31 PM, Reid Spencer wrote:
 
 
  +  // Guard against huge trip counts. This also guards against  
  assertions in
  +  // APInt from the use of getZExtValue, below.
  +  if (TripCountC-getValue().getActiveBits()  32)
   return Changed; // More than 2^32 iterations???
 
  +  uint64_t TripCountFull = TripCountC-getZExtValue();
  +  if (TripCountFull == 0)
  +return Changed; // Zero iteraitons?
  +
 
 Won't this still assert on 'i128 16' ?

No. getZExtValue() doesn't look at the bit width, it looks at the
precision of the value. Regardless of the bit width, if the value fits
in 64 bits, it allows it. If not, it asserts. Which is why I check
getActiveBits()  32 to limit trip counts to  2^32. This makes the
getZExtValue() safe.

That precision check is another reason why I'm changing things like:

if (CI-getZExtValue() == 1)

into

if (CI-isOne())

because its cheaper :)

Reid.

 
 -Chris

___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp

2007-03-02 Thread Reid Spencer


Changes in directory llvm/lib/Transforms/Scalar:

LoopStrengthReduce.cpp updated: 1.113 - 1.114
---
Log message:

Finally get this patch right :)
Replace expensive getZExtValue() == 0 calls with isZero() calls.


---
Diffs of the changes:  (+5 -5)

 LoopStrengthReduce.cpp |   10 +-
 1 files changed, 5 insertions(+), 5 deletions(-)


Index: llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
diff -u llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp:1.113 
llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp:1.114
--- llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp:1.113 Fri Mar  2 
17:37:53 2007
+++ llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp   Fri Mar  2 17:51:25 2007
@@ -540,7 +540,7 @@
   
   // If there is no immediate value, skip the next part.
   if (SCEVConstant *SC = dyn_castSCEVConstant(Imm))
-if (SC-getValue()-isNullValue())
+if (SC-getValue()-isZero())
   return Rewriter.expandCodeFor(NewBase, BaseInsertPt,
 OperandValToReplace-getType());
 
@@ -779,7 +779,7 @@
   SeparateSubExprs(SubExprs, SARE-getOperand(0));
 }
   } else if (!isaSCEVConstant(Expr) ||
- !castSCEVConstant(Expr)-getValue()-isNullValue()) {
+ !castSCEVConstant(Expr)-getValue()-isZero()) {
 // Do not add zero.
 SubExprs.push_back(Expr);
   }
@@ -869,7 +869,7 @@
 ///
 static bool isZero(SCEVHandle V) {
   if (SCEVConstant *SC = dyn_castSCEVConstant(V))
-return SC-getValue()-getZExtValue() == 0;
+return SC-getValue()-isZero();
   return false;
 }
 
@@ -1148,14 +1148,14 @@
 // are reusing an IV, it has not been used to initialize the PHI node.
 // Add it to the expression used to rewrite the uses.
 if (!isaConstantInt(CommonBaseV) ||
-!castConstantInt(CommonBaseV)-isNullValue())
+!castConstantInt(CommonBaseV)-isZero())
   RewriteExpr = SCEVAddExpr::get(RewriteExpr,
  SCEVUnknown::get(CommonBaseV));
   }
 
   // Now that we know what we need to do, insert code before User for the
   // immediate and any loop-variant expressions.
-  if (!isaConstantInt(BaseV) || !castConstantInt(BaseV)-isNullValue())
+  if (!isaConstantInt(BaseV) || !castConstantInt(BaseV)-isZero())
 // Add BaseV to the PHI value if needed.
 RewriteExpr = SCEVAddExpr::get(RewriteExpr, SCEVUnknown::get(BaseV));
 



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


Re: [llvm-commits] CVS: llvm/lib/Transforms/Scalar/LoopUnroll.cpp

2007-03-02 Thread Chris Lattner

On Mar 2, 2007, at 3:40 PM, Reid Spencer wrote:

 On Fri, 2007-03-02 at 15:35 -0800, Chris Lattner wrote:
 On Mar 2, 2007, at 3:31 PM, Reid Spencer wrote:


 +  // Guard against huge trip counts. This also guards against
 assertions in
 +  // APInt from the use of getZExtValue, below.
 +  if (TripCountC-getValue().getActiveBits()  32)
  return Changed; // More than 2^32 iterations???

 +  uint64_t TripCountFull = TripCountC-getZExtValue();
 +  if (TripCountFull == 0)
 +return Changed; // Zero iteraitons?
 +

 Won't this still assert on 'i128 16' ?

 No. getZExtValue() doesn't look at the bit width, it looks at the
 precision of the value. Regardless of the bit width, if the value fits
 in 64 bits, it allows it. If not, it asserts. Which is why I check
 getActiveBits()  32 to limit trip counts to  2^32. This makes the
 getZExtValue() safe.

Ok, nifty.

 That precision check is another reason why I'm changing things like:

 if (CI-getZExtValue() == 1)

 into

 if (CI-isOne())

 because its cheaper :)

Woot!

-Chris
___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/include/llvm/ADT/APInt.h

2007-03-02 Thread Reid Spencer


Changes in directory llvm/include/llvm/ADT:

APInt.h updated: 1.35 - 1.36
---
Log message:

Add isPositive for symmetry with isNegative.


---
Diffs of the changes:  (+8 -1)

 APInt.h |9 -
 1 files changed, 8 insertions(+), 1 deletion(-)


Index: llvm/include/llvm/ADT/APInt.h
diff -u llvm/include/llvm/ADT/APInt.h:1.35 llvm/include/llvm/ADT/APInt.h:1.36
--- llvm/include/llvm/ADT/APInt.h:1.35  Thu Mar  1 17:37:09 2007
+++ llvm/include/llvm/ADT/APInt.h   Fri Mar  2 18:24:39 2007
@@ -106,7 +106,7 @@
   /// @returns a uint64_t type integer with just bit position at
   /// whichBit(bitPosition) setting, others zero.
   static inline uint64_t maskBit(uint32_t bitPosition) { 
-return (static_castuint64_t(1))  whichBit(bitPosition); 
+return 1ULL  whichBit(bitPosition); 
   }
 
   /// This method is used internally to clear the to N bits that are not used
@@ -365,6 +365,13 @@
 return (*this)[BitWidth - 1];
   }
 
+  /// This just tests the high bit of the APInt to determine if the value is
+  /// positove or not.
+  /// @brief Determine if this APInt Value is positive.
+  bool isPositive() const {
+return !isNegative();
+  }
+
   /// Arithmetic right-shift this APInt by shiftAmt.
   /// @brief Arithmetic right-shift function.
   APInt ashr(uint32_t shiftAmt) const;



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/lib/Transforms/Scalar/PredicateSimplifier.cpp

2007-03-02 Thread Reid Spencer


Changes in directory llvm/lib/Transforms/Scalar:

PredicateSimplifier.cpp updated: 1.52 - 1.53
---
Log message:

APIntify this pass.


---
Diffs of the changes:  (+36 -28)

 PredicateSimplifier.cpp |   64 +++-
 1 files changed, 36 insertions(+), 28 deletions(-)


Index: llvm/lib/Transforms/Scalar/PredicateSimplifier.cpp
diff -u llvm/lib/Transforms/Scalar/PredicateSimplifier.cpp:1.52 
llvm/lib/Transforms/Scalar/PredicateSimplifier.cpp:1.53
--- llvm/lib/Transforms/Scalar/PredicateSimplifier.cpp:1.52 Sun Feb  4 
17:43:05 2007
+++ llvm/lib/Transforms/Scalar/PredicateSimplifier.cpp  Fri Mar  2 18:48:31 2007
@@ -377,7 +377,7 @@
 RHS.first-getType()-getBitWidth())
   return LHS.first-getType()-getBitWidth() 
  RHS.first-getType()-getBitWidth();
-return LHS.first-getZExtValue()  RHS.first-getZExtValue();
+return LHS.first-getValue().ult(RHS.first-getValue());
   }
 };
 
@@ -407,40 +407,43 @@
   iULT = (iUGT == begin || begin == end) ? end : iUGT - 1;
 
   if (iUGT != end  iULT != end 
-  (iULT-first-getSExtValue()  63) ==
-  (iUGT-first-getSExtValue()  63)) { // signs match
+  iULT-first-getValue().isNegative() == 
+  iUGT-first-getValue().isNegative()) { // signs match
 iSGT = iUGT;
 iSLT = iULT;
   } else {
 if (iULT == end || iUGT == end) {
   if (iULT == end) iSLT = last;  else iSLT = iULT;
   if (iUGT == end) iSGT = begin; else iSGT = iUGT;
-} else if (iULT-first-getSExtValue()  0) {
-  assert(iUGT-first-getSExtValue() = 0  Bad sign comparison.);
+} else if (iULT-first-getValue().isNegative()) {
+  assert(iUGT-first-getValue().isPositive()  
+ Bad sign comparison.);
   iSGT = iUGT;
   iSLT = iULT;
 } else {
-  assert(iULT-first-getSExtValue() = 0 
- iUGT-first-getSExtValue()  0  Bad sign comparison.);
+  assert(iULT-first-getValue().isPositive() = 0 
+ iUGT-first-getValue().isNegative() Bad sign 
comparison.);
   iSGT = iULT;
   iSLT = iUGT;
 }
 
 if (iSGT != end 
-iSGT-first-getSExtValue()  CI-getSExtValue()) iSGT = end;
+iSGT-first-getValue().slt(CI-getValue())) 
+  iSGT = end;
 if (iSLT != end 
-iSLT-first-getSExtValue()  CI-getSExtValue()) iSLT = end;
+iSLT-first-getValue().sgt(CI-getValue())) 
+  iSLT = end;
 
 if (begin != end) {
-  if (begin-first-getSExtValue()  CI-getSExtValue())
+  if (begin-first-getValue().slt(CI-getValue()))
 if (iSLT == end ||
-begin-first-getSExtValue()  iSLT-first-getSExtValue())
+begin-first-getValue().sgt(iSLT-first-getValue()))
   iSLT = begin;
 }
 if (last != end) {
-  if (last-first-getSExtValue()  CI-getSExtValue())
+  if (last-first-getValue().sgt(CI-getValue()))
 if (iSGT == end ||
-last-first-getSExtValue()  iSGT-first-getSExtValue())
+last-first-getValue().slt(iSGT-first-getValue()))
   iSGT = last;
 }
   }
@@ -1201,8 +1204,7 @@
 
 if (ConstantInt *CI = dyn_castConstantInt(Canonical)) {
   if (ConstantInt *Arg = dyn_castConstantInt(LHS)) {
-add(RHS, ConstantInt::get(CI-getType(), CI-getZExtValue() ^
-  Arg-getZExtValue()),
+add(RHS, ConstantInt::get(CI-getValue() ^ Arg-getValue()),
 ICmpInst::ICMP_EQ, NewContext);
   }
 }
@@ -1454,21 +1456,22 @@
 if (ConstantInt *CI = dyn_castConstantInt(O.RHS)) {
   // xform doesn't apply to i1
   if (CI-getType()-getBitWidth()  1) {
-if (LV == SLT  CI-getSExtValue()  0) {
+if (LV == SLT  CI-getValue().isNegative()) {
   // i8 %x s -5 implies %x  -5 and %x u 127
 
   const IntegerType *Ty = CI-getType();
   LV = LT;
-  add(O.LHS, ConstantInt::get(Ty, Ty-getBitMask()  1),
+  add(O.LHS, ConstantInt::get(Ty-getMask().lshr(1)),
   ICmpInst::ICMP_UGT);
-} else if (LV == SGT  CI-getSExtValue() = 0) {
+} else if (LV == SGT  CI-getValue().isPositive()) {
   // i8 %x s 5 implies %x  5 and %x u 128
 
   const IntegerType *Ty = CI-getType();
   LV = LT;
-  add(O.LHS, ConstantInt::get(Ty, 1  Ty-getBitWidth()),
+  add(O.LHS, ConstantInt::get(
+APInt::getSignedMinValue(Ty-getBitWidth())),
   ICmpInst::ICMP_ULT);
-} else if (CI-getSExtValue() = 0) {
+} else if 

[llvm-commits] CVS: llvm-test/SingleSource/UnitTests/2007-03-02-VaCopy.c

2007-03-02 Thread Evan Cheng


Changes in directory llvm-test/SingleSource/UnitTests:

2007-03-02-VaCopy.c added (r1.1)
---
Log message:

New test.

---
Diffs of the changes:  (+17 -0)

 2007-03-02-VaCopy.c |   17 +
 1 files changed, 17 insertions(+)


Index: llvm-test/SingleSource/UnitTests/2007-03-02-VaCopy.c
diff -c /dev/null llvm-test/SingleSource/UnitTests/2007-03-02-VaCopy.c:1.1
*** /dev/null   Fri Mar  2 19:10:15 2007
--- llvm-test/SingleSource/UnitTests/2007-03-02-VaCopy.cFri Mar  2 
19:10:05 2007
***
*** 0 
--- 1,17 
+ #include stdio.h
+ #include stdarg.h
+ 
+ void testVaCopyArg(char *fmt, ...) {
+   va_list ap, aq;
+   char *s;
+   va_start(ap, fmt);
+   va_copy(aq, ap);/* test va_copy */
+ 
+   s = va_arg(aq, char *);
+   printf(string %s\n, s);
+ }
+ 
+ int main() {
+   testVaCopyArg(s, abc);
+   return 0;
+ }



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/lib/Transforms/Scalar/InstructionCombining.cpp

2007-03-02 Thread Chris Lattner


Changes in directory llvm/lib/Transforms/Scalar:

InstructionCombining.cpp updated: 1.640 - 1.641
---
Log message:

add a top-level iteration loop to instcombine.  This means that it will never
finish without combining something it is capable of.


---
Diffs of the changes:  (+21 -4)

 InstructionCombining.cpp |   25 +
 1 files changed, 21 insertions(+), 4 deletions(-)


Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp
diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.640 
llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.641
--- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.640   Fri Mar  2 
15:28:56 2007
+++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp Fri Mar  2 20:04:50 2007
@@ -141,6 +141,8 @@
 
   public:
 virtual bool runOnFunction(Function F);
+
+bool DoOneIteration(Function F, unsigned ItNum);
 
 virtual void getAnalysisUsage(AnalysisUsage AU) const {
   AU.addRequiredTargetData();
@@ -9164,9 +9166,12 @@
 AddReachableCodeToWorklist(TI-getSuccessor(i), Visited, IC, TD);
 }
 
-bool InstCombiner::runOnFunction(Function F) {
+bool InstCombiner::DoOneIteration(Function F, unsigned Iteration) {
   bool Changed = false;
   TD = getAnalysisTargetData();
+  
+  DEBUG(DOUT  \n\nINSTCOMBINE ITERATION #  Iteration   on 
+  F.getNameStr()  \n);
 
   {
 // Do a depth-first traversal of the function, populate the worklist with
@@ -9295,24 +9300,36 @@
 if (isInstructionTriviallyDead(I)) {
   // Make sure we process all operands now that we are reducing their
   // use counts.
-  AddUsesToWorkList(*I);;
+  AddUsesToWorkList(*I);
 
   // Instructions may end up in the worklist more than once.  Erase all
   // occurrences of this instruction.
   RemoveFromWorkList(I);
   I-eraseFromParent();
 } else {
-  AddToWorkList(Result);
-  AddUsersToWorkList(*Result);
+  AddToWorkList(I);
+  AddUsersToWorkList(*I);
 }
   }
   Changed = true;
 }
   }
 
+  assert(WorklistMap.empty()  Worklist empty, but map not?);
   return Changed;
 }
 
+
+bool InstCombiner::runOnFunction(Function F) {
+  bool EverMadeChange = false;
+
+  // Iterate while there is work to do.
+  unsigned Iteration = 0;
+  while (DoOneIteration(F, Iteration++)) 
+EverMadeChange = true;
+  return EverMadeChange;
+}
+
 FunctionPass *llvm::createInstructionCombiningPass() {
   return new InstCombiner();
 }



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [124490] Workaround to fix functionarguments aligment on arm-linux-gnueabi.

2007-03-02 Thread echeng
Revision: 124490
Author:   echeng
Date: 2007-03-02 18:10:50 -0800 (Fri, 02 Mar 2007)

Log Message:
---
Workaround to fix functionarguments aligment on arm-linux-gnueabi.

Modified Paths:
--
apple-local/branches/llvm/gcc/llvm-abi.h

Modified: apple-local/branches/llvm/gcc/llvm-abi.h
===
--- apple-local/branches/llvm/gcc/llvm-abi.h2007-03-03 01:27:27 UTC (rev 
124489)
+++ apple-local/branches/llvm/gcc/llvm-abi.h2007-03-03 02:10:50 UTC (rev 
124490)
@@ -32,6 +32,7 @@
 #include llvm-internal.h
 #include llvm/Constants.h
 #include llvm/DerivedTypes.h
+#include llvm/Target/TargetData.h
 
 namespace llvm {
   class BasicBlock;
@@ -274,17 +275,31 @@
   /// of the struct elements in.
   void PassInIntegerRegisters(tree type, const Type *Ty) {
 unsigned Size = TREE_INT_CST_LOW(TYPE_SIZE(type))/8;
-
+
+// FIXME: We should preserve all aggregate value alignment information.
+// Work around to preserve some aggregate value alignment information:
+// don't bitcast aggregate value to Int64 if its alignment is different
+// from Int64 alignment. ARM backend needs this.
+unsigned Align = TYPE_ALIGN(type)/8;
+unsigned Int64Align = getTargetData().getABITypeAlignment(Type::Int64Ty);
+bool UseInt64 = (Align = Int64Align);
+
 // FIXME: In cases where we can, we should use the original struct.
 // Consider cases like { int, int } and {int, short} for example!  This 
will
 // produce far better LLVM code!
 std::vectorconst Type* Elts;
-for (; Size = 8; Size -= 8)
-  Elts.push_back(Type::Int64Ty);
-if (Size = 4) {
-  Elts.push_back(Type::Int32Ty);
-  Size -= 4;
+if (UseInt64) {
+  for (; Size = 8; Size -= 8)
+Elts.push_back(Type::Int64Ty);
+  if (Size = 4) {
+Elts.push_back(Type::Int32Ty);
+Size -= 4;
+  }
+} else {
+  for (; Size = 4; Size -= 4)
+Elts.push_back(Type::Int32Ty);
 }
+
 if (Size = 2) {
   Elts.push_back(Type::Int16Ty);
   Size -= 2;


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [124491] Add support for NON_LVALUE_EXPR, patch by Duncan Sands.

2007-03-02 Thread clattner
Revision: 124491
Author:   clattner
Date: 2007-03-02 18:11:25 -0800 (Fri, 02 Mar 2007)

Log Message:
---
Add support for NON_LVALUE_EXPR, patch by Duncan Sands.

Modified Paths:
--
apple-local/branches/llvm/gcc/llvm-convert.cpp

Modified: apple-local/branches/llvm/gcc/llvm-convert.cpp
===
--- apple-local/branches/llvm/gcc/llvm-convert.cpp  2007-03-03 02:10:50 UTC 
(rev 124490)
+++ apple-local/branches/llvm/gcc/llvm-convert.cpp  2007-03-03 02:11:25 UTC 
(rev 124491)
@@ -704,6 +704,7 @@
   case CALL_EXPR:  Result = EmitCALL_EXPR(exp, DestLoc); break;
   case MODIFY_EXPR:Result = EmitMODIFY_EXPR(exp, DestLoc); break;
   case ASM_EXPR:   Result = EmitASM_EXPR(exp); break;
+  case NON_LVALUE_EXPR: Result = Emit(TREE_OPERAND(exp, 0), DestLoc); break;
 
 // Unary Operators
   case NOP_EXPR:   Result = EmitNOP_EXPR(exp, DestLoc); break;


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


Re: [llvm-commits] [llvm-gcc patch] workaround to fix function arguments aligment on arm-linux-gnueabi

2007-03-02 Thread Evan Cheng
Committed with one minor change:

bool UseInt64 = (Align = Int64Align);

Thanks,

Evan
On Mar 1, 2007, at 1:03 PM, Lauro Ramos Venancio wrote:

 This patch fixes SingleSource/UnitTests/2003-05-07-VarArgs.c test on
 arm-linux-gnueabi.

 Lauro
 llvm-gcc.patch
 ___
 llvm-commits mailing list
 llvm-commits@cs.uiuc.edu
 http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits

___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


Re: [llvm-commits] llvm-gcc: support for NON_LVALUE_EXPR

2007-03-02 Thread Chris Lattner

On Feb 28, 2007, at 10:17 AM, Duncan Sands wrote:

 According to the docs:

 NON_LVALUE_EXPR
 These nodes indicate that their one and only operand is not an lvalue.
 A back end can treat these identically to the single operand.

 And that is what this patch does.

Applied, thanks.  Please check in the testcase.

-Chris

___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [124492] Add an assert, patch by Duncan Sands.

2007-03-02 Thread clattner
Revision: 124492
Author:   clattner
Date: 2007-03-02 18:13:46 -0800 (Fri, 02 Mar 2007)

Log Message:
---
Add an assert, patch by Duncan Sands.

Modified Paths:
--
apple-local/branches/llvm/gcc/llvm-convert.cpp

Modified: apple-local/branches/llvm/gcc/llvm-convert.cpp
===
--- apple-local/branches/llvm/gcc/llvm-convert.cpp  2007-03-03 02:11:25 UTC 
(rev 124491)
+++ apple-local/branches/llvm/gcc/llvm-convert.cpp  2007-03-03 02:13:46 UTC 
(rev 124492)
@@ -5429,6 +5429,7 @@
   ProcessBitFieldInitialization(Field, Val, STy, ResultElts);
 } else {
   // If not, things are much simpler.
+  assert(DECL_LLVM_SET_P(Field)  Struct not laid out for LLVM?);
   unsigned FieldNo = castConstantInt(DECL_LLVM(Field))-getZExtValue();
   
   // If this is an initialization of a global that ends with a variable


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


Re: [llvm-commits] llvm-gcc: check that fields are laid out in ConvertRecordCONSTRUCTOR

2007-03-02 Thread Chris Lattner

On Feb 28, 2007, at 2:16 AM, Duncan Sands wrote:

 Die obviously, rather than obscurely deep down in make_decl_llvm.
 I hit this with the Ada f-e: it was replacing fields in a record type
 without updating constructors, with the result that the constructor
 element fields did not belong to the constructor type, and thus were
 not laid out when the type was.

Applied, thanks!

-Chris

___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [124493] Fix a bug that triggers with Ada, patch by Duncan Sands!

2007-03-02 Thread clattner
Revision: 124493
Author:   clattner
Date: 2007-03-02 18:15:45 -0800 (Fri, 02 Mar 2007)

Log Message:
---
Fix a bug that triggers with Ada, patch by Duncan Sands!

Modified Paths:
--
apple-local/branches/llvm/gcc/llvm-convert.cpp

Modified: apple-local/branches/llvm/gcc/llvm-convert.cpp
===
--- apple-local/branches/llvm/gcc/llvm-convert.cpp  2007-03-03 02:13:46 UTC 
(rev 124492)
+++ apple-local/branches/llvm/gcc/llvm-convert.cpp  2007-03-03 02:15:45 UTC 
(rev 124493)
@@ -1424,7 +1424,8 @@
   tree RealVar = DECL_ORIGIN(Var);
   
   // If we haven't already emitted the var, do so now.
-  if (!TREE_ASM_WRITTEN(RealVar)  !lang_hooks.expand_decl(RealVar))
+  if (!TREE_ASM_WRITTEN(RealVar)  !lang_hooks.expand_decl(RealVar) 
+  TREE_CODE (Var) == VAR_DECL)
 rest_of_decl_compilation(RealVar, 0, 0);
   continue;
 }


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


Re: [llvm-commits] llvm-gcc: only call rest_of_decl_compilation on VAR_DECLs in EmitBIND_EXPR

2007-03-02 Thread Chris Lattner
On Feb 28, 2007, at 3:09 AM, Duncan Sands wrote:

 The variable expansion part of EmitBIND_EXPR is clearly based on
 expand_var in expr.c, however unlike expand_var it doesn't check
 for VAR_DECL before calling rest_of_decl_compilation.  This patch
 adds the check.  Without it, the Ada run-time fails to build due to
 rest_of_decl_compilation getting called for a static CONSTANT_DECL.

Applied, please commit the testcase,

-Chris
___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/lib/CodeGen/LiveIntervalAnalysis.cpp

2007-03-02 Thread Evan Cheng


Changes in directory llvm/lib/CodeGen:

LiveIntervalAnalysis.cpp updated: 1.219 - 1.220
---
Log message:

Watch out for cases like this:

entry (0x8b056f0, LLVM BB @0x8b01b30, ID#0):
Live Ins: %r0 %r1 %r2 %r3
%reg1032 = tMOVrr %r3kill
%reg1033 = tMOVri8 1
%reg1034 = tMOVri8 0
tCMPi8 %reg1029kill, 0
tBcc mbbentry,0x8b06a10, 0
Successors according to CFG: 0x8b06980 0x8b06a10

entry (0x8b06980, LLVM BB @0x8b01b30, ID#12):
Predecessors according to CFG: 0x8b056f0
%reg1036 = tMOVrr %reg1034kill
Successors according to CFG: 0x8b06a10

entry (0x8b06a10, LLVM BB @0x8b01b30, ID#13):
Predecessors according to CFG: 0x8b056f0 0x8b06980
%reg1024dead = tMOVrr %reg1030kill
...

reg1030 and r1 have already been joined. When reg1024 and reg1030 are joined,
r1 live range from function entry to the tMOVrr instruction are dead. Eliminate
r1 from the livein set of the entry BB, not the BB where the copy is.

---
Diffs of the changes:  (+5 -4)

 LiveIntervalAnalysis.cpp |9 +
 1 files changed, 5 insertions(+), 4 deletions(-)


Index: llvm/lib/CodeGen/LiveIntervalAnalysis.cpp
diff -u llvm/lib/CodeGen/LiveIntervalAnalysis.cpp:1.219 
llvm/lib/CodeGen/LiveIntervalAnalysis.cpp:1.220
--- llvm/lib/CodeGen/LiveIntervalAnalysis.cpp:1.219 Fri Mar  2 04:41:15 2007
+++ llvm/lib/CodeGen/LiveIntervalAnalysis.cpp   Fri Mar  2 20:18:00 2007
@@ -938,11 +938,12 @@
   if (JoinIntervals(DestInt, SrcInt)) {
 if (isDead) {
   // Result of the copy is dead. Propagate this property.
-  if (SrcStart == 0  MRegisterInfo::isPhysicalRegister(repSrcReg)) {
-// Live-in to the function but dead. Remove it from MBB live-in set.
+  if (SrcStart == 0) {
+assert(MRegisterInfo::isPhysicalRegister(repSrcReg) 
+   Live-in must be a physical register!);
+// Live-in to the function but dead. Remove it from entry live-in set.
 // JoinIntervals may end up swapping the two intervals.
-MachineBasicBlock *MBB = CopyMI-getParent();
-MBB-removeLiveIn(repSrcReg);
+mf_-begin()-removeLiveIn(repSrcReg);
   } else {
 MachineInstr *SrcMI = getInstructionFromIndex(SrcStart);
 if (SrcMI) {



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/test/Transforms/InstCombine/bswap.ll

2007-03-02 Thread Chris Lattner


Changes in directory llvm/test/Transforms/InstCombine:

bswap.ll updated: 1.4 - 1.5
---
Log message:

instcombine doesn't do CSE, simplify unrelated detail


---
Diffs of the changes:  (+1 -2)

 bswap.ll |3 +--
 1 files changed, 1 insertion(+), 2 deletions(-)


Index: llvm/test/Transforms/InstCombine/bswap.ll
diff -u llvm/test/Transforms/InstCombine/bswap.ll:1.4 
llvm/test/Transforms/InstCombine/bswap.ll:1.5
--- llvm/test/Transforms/InstCombine/bswap.ll:1.4   Fri Dec  1 22:23:09 2006
+++ llvm/test/Transforms/InstCombine/bswap.ll   Fri Mar  2 20:27:02 2007
@@ -48,8 +48,7 @@
 %tmp1 = and int %tmp, 65280
 %tmp2 = ashr int %tmp1, ubyte 8
 %tmp2 = trunc int %tmp2 to short
-%tmp3 = zext ushort %a to int
-%tmp4 = and int %tmp3, 255
+%tmp4 = and int %tmp, 255
 %tmp5 = shl int %tmp4, ubyte 8
 %tmp5 = trunc int %tmp5 to short
 %tmp = or short %tmp2, %tmp5



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/lib/Transforms/Scalar/PredicateSimplifier.cpp

2007-03-02 Thread Nick Lewycky


Changes in directory llvm/lib/Transforms/Scalar:

PredicateSimplifier.cpp updated: 1.53 - 1.54
---
Log message:

Translate bit operations to English.


---
Diffs of the changes:  (+2 -1)

 PredicateSimplifier.cpp |3 ++-
 1 files changed, 2 insertions(+), 1 deletion(-)


Index: llvm/lib/Transforms/Scalar/PredicateSimplifier.cpp
diff -u llvm/lib/Transforms/Scalar/PredicateSimplifier.cpp:1.53 
llvm/lib/Transforms/Scalar/PredicateSimplifier.cpp:1.54
--- llvm/lib/Transforms/Scalar/PredicateSimplifier.cpp:1.53 Fri Mar  2 
18:48:31 2007
+++ llvm/lib/Transforms/Scalar/PredicateSimplifier.cpp  Fri Mar  2 21:14:40 2007
@@ -1461,7 +1461,8 @@
 
   const IntegerType *Ty = CI-getType();
   LV = LT;
-  add(O.LHS, ConstantInt::get(Ty-getMask().lshr(1)),
+  add(O.LHS, ConstantInt::get(
+APInt::getSignedMaxValue(Ty-getBitWidth())),
   ICmpInst::ICMP_UGT);
 } else if (LV == SGT  CI-getValue().isPositive()) {
   // i8 %x s 5 implies %x  5 and %x u 128



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [124494] Fix compilation of Benchmarks/Prolangs-C++/garage.

2007-03-02 Thread clattner
Revision: 124494
Author:   clattner
Date: 2007-03-02 21:17:25 -0800 (Fri, 02 Mar 2007)

Log Message:
---
Fix compilation of Benchmarks/Prolangs-C++/garage.

Modified Paths:
--
apple-local/branches/llvm/gcc/llvm-convert.cpp

Modified: apple-local/branches/llvm/gcc/llvm-convert.cpp
===
--- apple-local/branches/llvm/gcc/llvm-convert.cpp  2007-03-03 02:15:45 UTC 
(rev 124493)
+++ apple-local/branches/llvm/gcc/llvm-convert.cpp  2007-03-03 05:17:25 UTC 
(rev 124494)
@@ -622,9 +622,8 @@
CurBB);
   new UnreachableInst(CurBB);
 }
-#else
-new UnwindInst(UnwindBB);
 #endif
+new UnwindInst(UnwindBB);
   }
   
   // If this function takes the address of a label, emit the indirect goto


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/test/Transforms/InstCombine/cast2.ll

2007-03-02 Thread Chris Lattner


Changes in directory llvm/test/Transforms/InstCombine:

cast2.ll added (r1.1)
---
Log message:

new testcase: instcombine should remove all the casts.


---
Diffs of the changes:  (+24 -0)

 cast2.ll |   24 
 1 files changed, 24 insertions(+)


Index: llvm/test/Transforms/InstCombine/cast2.ll
diff -c /dev/null llvm/test/Transforms/InstCombine/cast2.ll:1.1
*** /dev/null   Fri Mar  2 23:24:16 2007
--- llvm/test/Transforms/InstCombine/cast2.ll   Fri Mar  2 23:24:06 2007
***
*** 0 
--- 1,24 
+ ; Tests to make sure elimination of casts is working correctly
+ ; RUN: llvm-as  %s | opt -instcombine -disable-output 
+ ; RUN: llvm-as  %s | opt -instcombine | llvm-dis | notcast
+ 
+ define i16 @test1(i16 %a) {
+ %tmp = zext i16 %a to i32   ; i32 [#uses=2]
+ %tmp21 = lshr i32 %tmp, 8   ; i32 [#uses=1]
+ %tmp5 = shl i32 %tmp, 8 ; i32 [#uses=1]
+ %tmp.upgrd.32 = or i32 %tmp21, %tmp5; i32 [#uses=1]
+ %tmp.upgrd.3 = trunc i32 %tmp.upgrd.32 to i16   ; i16 
[#uses=1]
+ ret i16 %tmp.upgrd.3
+ }
+ 
+ define i16 @test2(i16 %a) {
+ %tmp = zext i16 %a to i32   ; i32 [#uses=2]
+ %tmp21 = lshr i32 %tmp, 9   ; i32 [#uses=1]
+ %tmp5 = shl i32 %tmp, 8 ; i32 [#uses=1]
+ %tmp.upgrd.32 = or i32 %tmp21, %tmp5; i32 [#uses=1]
+ %tmp.upgrd.3 = trunc i32 %tmp.upgrd.32 to i16   ; i16 
[#uses=1]
+ ret i16 %tmp.upgrd.3
+ }
+ 
+ 
+ 



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/lib/Transforms/Scalar/InstructionCombining.cpp

2007-03-02 Thread Chris Lattner


Changes in directory llvm/lib/Transforms/Scalar:

InstructionCombining.cpp updated: 1.641 - 1.642
---
Log message:

my recent change caused a failure in a bswap testcase, because it changed
the order that instcombine processed instructions in the testcase.  The end
result is that instcombine finished with:

define i16 @test1(i16 %a) {
%tmp = zext i16 %a to i32   ; i32 [#uses=2]
%tmp21 = lshr i32 %tmp, 8   ; i32 [#uses=1]
%tmp5 = shl i32 %tmp, 8 ; i32 [#uses=1]
%tmp.upgrd.32 = or i32 %tmp21, %tmp5; i32 [#uses=1]
%tmp.upgrd.3 = trunc i32 %tmp.upgrd.32 to i16   ; i16 
[#uses=1]
ret i16 %tmp.upgrd.3
}

which can't get matched as a bswap.

This patch makes instcombine more sophisticated about removing truncating
casts, allowing it to turn this into:

define i16 @test2(i16 %a) {
%tmp211 = lshr i16 %a, 8
%tmp52 = shl i16 %a, 8
%tmp.upgrd.323 = or i16 %tmp211, %tmp52
ret i16 %tmp.upgrd.323
}

which then matches as bswap.  This fixes bswap.ll and implements 
InstCombine/cast2.ll:test[12].  This also implements cast elimination of
add/sub.



---
Diffs of the changes:  (+71 -48)

 InstructionCombining.cpp |  119 ---
 1 files changed, 71 insertions(+), 48 deletions(-)


Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp
diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.641 
llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.642
--- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.641   Fri Mar  2 
20:04:50 2007
+++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp Fri Mar  2 23:27:34 2007
@@ -5908,35 +5908,62 @@
 }
 
 /// CanEvaluateInDifferentType - Return true if we can take the specified value
-/// and return it without inserting any new casts.  This is used by code that
-/// tries to decide whether promoting or shrinking integer operations to wider
-/// or smaller types will allow us to eliminate a truncate or extend.
-static bool CanEvaluateInDifferentType(Value *V, const Type *Ty,
+/// and return it as type Ty without inserting any new casts and without
+/// changing the computed value.  This is used by code that tries to decide
+/// whether promoting or shrinking integer operations to wider or smaller types
+/// will allow us to eliminate a truncate or extend.
+///
+/// This is a truncation operation if Ty is smaller than V-getType(), or an
+/// extension operation if Ty is larger.
+static bool CanEvaluateInDifferentType(Value *V, const IntegerType *Ty,
int NumCastsRemoved) {
-  if (isaConstant(V)) return true;
+  // We can always evaluate constants in another type.
+  if (isaConstantInt(V))
+return true;
   
   Instruction *I = dyn_castInstruction(V);
-  if (!I || !I-hasOneUse()) return false;
+  if (!I) return false;
+  
+  const IntegerType *OrigTy = castIntegerType(V-getType());
   
   switch (I-getOpcode()) {
+  case Instruction::Add:
+  case Instruction::Sub:
   case Instruction::And:
   case Instruction::Or:
   case Instruction::Xor:
+if (!I-hasOneUse()) return false;
 // These operators can all arbitrarily be extended or truncated.
 return CanEvaluateInDifferentType(I-getOperand(0), Ty, NumCastsRemoved) 
CanEvaluateInDifferentType(I-getOperand(1), Ty, NumCastsRemoved);
-  case Instruction::AShr:
-  case Instruction::LShr:
+
   case Instruction::Shl:
-// If this is just a bitcast changing the sign of the operation, we can
-// convert if the operand can be converted.
-if (V-getType()-getPrimitiveSizeInBits() == Ty-getPrimitiveSizeInBits())
-  return CanEvaluateInDifferentType(I-getOperand(0), Ty, NumCastsRemoved);
+if (!I-hasOneUse()) return false;
+// If we are truncating the result of this SHL, and if it's a shift of a
+// constant amount, we can always perform a SHL in a smaller type.
+if (ConstantInt *CI = dyn_castConstantInt(I-getOperand(1))) {
+  if (Ty-getBitWidth()  OrigTy-getBitWidth() 
+  CI-getZExtValue()  Ty-getBitWidth())
+return CanEvaluateInDifferentType(I-getOperand(0), 
Ty,NumCastsRemoved);
+}
+break;
+  case Instruction::LShr:
+if (!I-hasOneUse()) return false;
+// If this is a truncate of a logical shr, we can truncate it to a smaller
+// lshr iff we know that the bits we would otherwise be shifting in are
+// already zeros.
+if (ConstantInt *CI = dyn_castConstantInt(I-getOperand(1))) {
+  if (Ty-getBitWidth()  OrigTy-getBitWidth() 
+  MaskedValueIsZero(I-getOperand(0),
+OrigTy-getBitMask()  ~Ty-getBitMask()) 
+  CI-getZExtValue()  Ty-getBitWidth()) {
+return CanEvaluateInDifferentType(I-getOperand(0), Ty, 
NumCastsRemoved);
+  }
+}
 break;
   case Instruction::Trunc:
   case Instruction::ZExt:
   case Instruction::SExt:
-  case Instruction::BitCast:
 // If this is 

[llvm-commits] CVS: llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp

2007-03-02 Thread Nick Lewycky


Changes in directory llvm/lib/Target/PowerPC:

PPCAsmPrinter.cpp updated: 1.234 - 1.235
---
Log message:

Emit low/high immediate loads properly for Linux/PPC.


---
Diffs of the changes:  (+10 -6)

 PPCAsmPrinter.cpp |   16 ++--
 1 files changed, 10 insertions(+), 6 deletions(-)


Index: llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
diff -u llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp:1.234 
llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp:1.235
--- llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp:1.234 Wed Feb 21 16:47:38 2007
+++ llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp   Fri Mar  2 23:29:51 2007
@@ -215,24 +215,28 @@
   if (MI-getOperand(OpNo).isImmediate()) {
 printS16ImmOperand(MI, OpNo);
   } else {
-O  ha16(;
+if (Subtarget.isDarwin()) O  ha16(;
 printOp(MI-getOperand(OpNo));
 if (TM.getRelocationModel() == Reloc::PIC_)
-  O  -\L  getFunctionNumber()  $pb\);
-else
+  O  -\L  getFunctionNumber()  $pb\;
+if (Subtarget.isDarwin())
   O  ')';
+else
+  O  @ha;
   }
 }
 void printSymbolLo(const MachineInstr *MI, unsigned OpNo) {
   if (MI-getOperand(OpNo).isImmediate()) {
 printS16ImmOperand(MI, OpNo);
   } else {
-O  lo16(;
+if (Subtarget.isDarwin()) O  lo16(;
 printOp(MI-getOperand(OpNo));
 if (TM.getRelocationModel() == Reloc::PIC_)
-  O  -\L  getFunctionNumber()  $pb\);
-else
+  O  -\L  getFunctionNumber()  $pb\;
+if (Subtarget.isDarwin())
   O  ')';
+else
+  O  @l;
   }
 }
 void printcrbitm(const MachineInstr *MI, unsigned OpNo) {



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [124495] disable EH support until someone has a chance to finish it.

2007-03-02 Thread clattner
Revision: 124495
Author:   clattner
Date: 2007-03-02 21:32:18 -0800 (Fri, 02 Mar 2007)

Log Message:
---
disable EH support until someone has a chance to finish it.  This fixes
Benchmarks/Prolangs-C++/deriv1

Modified Paths:
--
apple-local/branches/llvm/gcc/llvm-convert.cpp

Modified: apple-local/branches/llvm/gcc/llvm-convert.cpp
===
--- apple-local/branches/llvm/gcc/llvm-convert.cpp  2007-03-03 05:17:25 UTC 
(rev 124494)
+++ apple-local/branches/llvm/gcc/llvm-convert.cpp  2007-03-03 05:32:18 UTC 
(rev 124495)
@@ -63,7 +63,7 @@
 extern int get_pointer_alignment (tree exp, unsigned int max_align);
 }
 
-#define ITANIUM_STYLE_EXCEPTIONS
+//#define ITANIUM_STYLE_EXCEPTIONS
 
 
//===--===//
 //   Matching LLVM Values with GCC DECL trees


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/include/llvm/ADT/APInt.h

2007-03-02 Thread Reid Spencer


Changes in directory llvm/include/llvm/ADT:

APInt.h updated: 1.36 - 1.37
---
Log message:

Add names for some of the operators. This is needed for the macros in
the Interpreter.


---
Diffs of the changes:  (+9 -0)

 APInt.h |9 +
 1 files changed, 9 insertions(+)


Index: llvm/include/llvm/ADT/APInt.h
diff -u llvm/include/llvm/ADT/APInt.h:1.36 llvm/include/llvm/ADT/APInt.h:1.37
--- llvm/include/llvm/ADT/APInt.h:1.36  Fri Mar  2 18:24:39 2007
+++ llvm/include/llvm/ADT/APInt.h   Fri Mar  2 23:37:23 2007
@@ -248,14 +248,23 @@
   /// the given APInt RHS.
   /// @brief Bitwise AND operator. 
   APInt operator(const APInt RHS) const;
+  APInt And(const APInt RHS) const {
+return this-operator(RHS);
+  }
 
   /// Performs bitwise OR operation on this APInt and the given APInt RHS.
   /// @brief Bitwise OR operator. 
   APInt operator|(const APInt RHS) const;
+  APInt Or(const APInt RHS) const {
+return this-operator|(RHS);
+  }
 
   /// Performs bitwise XOR operation on this APInt and the given APInt RHS.
   /// @brief Bitwise XOR operator. 
   APInt operator^(const APInt RHS) const;
+  APInt Xor(const APInt RHS) const {
+return this-operator^(RHS);
+  }
 
   /// Performs logical negation operation on this APInt.
   /// @brief Logical negation operator. 



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/include/llvm/ADT/APInt.h

2007-03-02 Thread Reid Spencer


Changes in directory llvm/include/llvm/ADT:

APInt.h updated: 1.37 - 1.38
---
Log message:

Make getNumWords public so that those using getRawData stand a chance of
not reading beyond the end of the buffer returned.


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

 APInt.h |   14 +++---
 1 files changed, 7 insertions(+), 7 deletions(-)


Index: llvm/include/llvm/ADT/APInt.h
diff -u llvm/include/llvm/ADT/APInt.h:1.37 llvm/include/llvm/ADT/APInt.h:1.38
--- llvm/include/llvm/ADT/APInt.h:1.37  Fri Mar  2 23:37:23 2007
+++ llvm/include/llvm/ADT/APInt.h   Sat Mar  3 00:17:23 2007
@@ -79,13 +79,6 @@
   // Fast internal constructor
   APInt(uint64_t* val, uint32_t bits) : BitWidth(bits), pVal(val) { }
 
-  /// Here one word's bitwidth equals to that of uint64_t.
-  /// @returns the number of words to hold the integer value of this APInt.
-  /// @brief Get the number of words.
-  inline uint32_t getNumWords() const {
-return (BitWidth + APINT_BITS_PER_WORD - 1) / APINT_BITS_PER_WORD;
-  }
-
   /// @returns true if the number of bits = 64, false otherwise.
   /// @brief Determine if this APInt just has one word to store value.
   inline bool isSingleWord() const { 
@@ -486,6 +479,13 @@
 return whichWord(getActiveBits()-1) + 1;
   }
 
+  /// Here one word's bitwidth equals to that of uint64_t.
+  /// @returns the number of words to hold the integer value of this APInt.
+  /// @brief Get the number of words.
+  inline uint32_t getNumWords() const {
+return (BitWidth + APINT_BITS_PER_WORD - 1) / APINT_BITS_PER_WORD;
+  }
+
   /// This function returns a pointer to the internal storage of the APInt. 
   /// This is useful for writing out the APInt in binary form without any
   /// conversions.



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/lib/ExecutionEngine/ExecutionEngine.cpp

2007-03-02 Thread Reid Spencer


Changes in directory llvm/lib/ExecutionEngine:

ExecutionEngine.cpp updated: 1.107 - 1.108
---
Log message:

Implement loading and storing of APInt values from memory.


---
Diffs of the changes:  (+16 -8)

 ExecutionEngine.cpp |   24 
 1 files changed, 16 insertions(+), 8 deletions(-)


Index: llvm/lib/ExecutionEngine/ExecutionEngine.cpp
diff -u llvm/lib/ExecutionEngine/ExecutionEngine.cpp:1.107 
llvm/lib/ExecutionEngine/ExecutionEngine.cpp:1.108
--- llvm/lib/ExecutionEngine/ExecutionEngine.cpp:1.107  Wed Feb 14 20:26:10 2007
+++ llvm/lib/ExecutionEngine/ExecutionEngine.cppSat Mar  3 00:18:03 2007
@@ -425,7 +425,7 @@
 else if (BitWidth = 64)
   Result.Int64Val = (uint64_t )castConstantInt(C)-getZExtValue();
 else
-  assert(0  Integers with  64-bits not implemented);
+  Result.APIntVal = const_castAPInt*(castConstantInt(C)-getValue());
 break;
   }
 
@@ -481,8 +481,12 @@
 Ptr-Untyped[5] = (unsigned char)(TmpVal.Int64Val  40);
 Ptr-Untyped[6] = (unsigned char)(TmpVal.Int64Val  48);
 Ptr-Untyped[7] = (unsigned char)(TmpVal.Int64Val  56);
-  } else
-assert(0  Integer types  64 bits not supported);
+  } else {
+uint64_t *Dest = (uint64_t*)Ptr;
+const uint64_t *Src = Val.APIntVal-getRawData();
+for (uint32_t i = 0; i  Val.APIntVal-getNumWords(); ++i)
+  Dest[i] = Src[i];
+  }
   break;
 }
 Store4BytesLittleEndian:
@@ -537,8 +541,12 @@
 Ptr-Untyped[2] = (unsigned char)(TmpVal.Int64Val  40);
 Ptr-Untyped[1] = (unsigned char)(TmpVal.Int64Val  48);
 Ptr-Untyped[0] = (unsigned char)(TmpVal.Int64Val  56);
-  } else
-assert(0  Integer types  64 bits not supported);
+  } else {
+uint64_t *Dest = (uint64_t*)Ptr;
+const uint64_t *Src = Val.APIntVal-getRawData();
+for (uint32_t i = 0; i  Val.APIntVal-getNumWords(); ++i)
+  Dest[i] = Src[i];
+  }
   break;
 }
 Store4BytesBigEndian:
@@ -597,7 +605,7 @@
   ((uint64_t)Ptr-Untyped[6]  48) |
   ((uint64_t)Ptr-Untyped[7]  56);
   } else
-assert(0  Integer types  64 bits not supported);
+Result.APIntVal = new APInt(BitWidth, BitWidth/64, (uint64_t*)Ptr);
   break;
 }
 Load4BytesLittleEndian:
@@ -628,7 +636,7 @@
   } else {
 switch (Ty-getTypeID()) {
 case Type::IntegerTyID: {
-  unsigned BitWidth = castIntegerType(Ty)-getBitWidth();
+  uint32_t BitWidth = castIntegerType(Ty)-getBitWidth();
   if (BitWidth = 8)
 Result.Int8Val  = Ptr-Untyped[0];
   else if (BitWidth = 16) {
@@ -649,7 +657,7 @@
   ((uint64_t)Ptr-Untyped[1]  48) |
   ((uint64_t)Ptr-Untyped[0]  56);
   } else
-assert(0  Integer types  64 bits not supported);
+Result.APIntVal = new APInt(BitWidth, BitWidth/64, (uint64_t*)Ptr);
   break;
 }
 Load4BytesBigEndian:



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/lib/CodeGen/MachOWriter.cpp

2007-03-02 Thread Nate Begeman


Changes in directory llvm/lib/CodeGen:

MachOWriter.cpp updated: 1.30 - 1.31
---
Log message:

http://llvm.org/bugs/show_bug.cgi?id=1237


---
Diffs of the changes:  (+10 -5)

 MachOWriter.cpp |   15 ++-
 1 files changed, 10 insertions(+), 5 deletions(-)


Index: llvm/lib/CodeGen/MachOWriter.cpp
diff -u llvm/lib/CodeGen/MachOWriter.cpp:1.30 
llvm/lib/CodeGen/MachOWriter.cpp:1.31
--- llvm/lib/CodeGen/MachOWriter.cpp:1.30   Wed Feb 28 03:16:38 2007
+++ llvm/lib/CodeGen/MachOWriter.cppSat Mar  3 00:18:18 2007
@@ -736,14 +736,14 @@
   for (unsigned i = 0, e = MOS.Relocations.size(); i != e; ++i) {
 MachineRelocation MR = MOS.Relocations[i];
 unsigned TargetSection = MR.getConstantVal();
-unsigned TargetAddr;
-unsigned TargetIndex;
+unsigned TargetAddr = 0;
+unsigned TargetIndex = 0;
 
 // This is a scattered relocation entry if it points to a global value with
 // a non-zero offset.
 bool Scattered = false;
 bool Extern = false;
-
+
 // Since we may not have seen the GlobalValue we were interested in yet at
 // the time we emitted the relocation for it, fix it up now so that it
 // points to the offset into the correct section.
@@ -762,11 +762,16 @@
   } else {
 Scattered = TargetSection != 0;
 TargetSection = MOSPtr-Index;
+  }
+  MR.setResultPointer((void*)Offset);
+}
+
+// If the symbol is locally defined, pass in the address of the section and
+// the section index to the code which will generate the target relocation.
+if (!Extern) {
 MachOSection To = *SectionList[TargetSection - 1];
 TargetAddr = To.addr;
 TargetIndex = To.Index;
-  }
-  MR.setResultPointer((void*)Offset);
 }
 
 OutputBuffer RelocOut(MOS.RelocBuffer, is64Bit, isLittleEndian);



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/lib/ExecutionEngine/Interpreter/Interpreter.h

2007-03-02 Thread Reid Spencer


Changes in directory llvm/lib/ExecutionEngine/Interpreter:

Interpreter.h updated: 1.83 - 1.84
---
Log message:

1. Have the ExecutionContext keep track of the APInt's allocated and 
   ensure they are cleaned up when the stack frame exits.
2. Move a function to the Execution.cpp file where it belongs.


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

 Interpreter.h |   24 +---
 1 files changed, 13 insertions(+), 11 deletions(-)


Index: llvm/lib/ExecutionEngine/Interpreter/Interpreter.h
diff -u llvm/lib/ExecutionEngine/Interpreter/Interpreter.h:1.83 
llvm/lib/ExecutionEngine/Interpreter/Interpreter.h:1.84
--- llvm/lib/ExecutionEngine/Interpreter/Interpreter.h:1.83 Wed Feb  7 
18:29:31 2007
+++ llvm/lib/ExecutionEngine/Interpreter/Interpreter.h  Sat Mar  3 00:19:55 2007
@@ -17,6 +17,7 @@
 #include llvm/Function.h
 #include llvm/ExecutionEngine/ExecutionEngine.h
 #include llvm/ExecutionEngine/GenericValue.h
+#include llvm/ADT/APInt.h
 #include llvm/Support/InstVisitor.h
 #include llvm/Support/CallSite.h
 #include llvm/Target/TargetData.h
@@ -75,6 +76,18 @@
   CallSite Caller; // Holds the call that called subframes.
// NULL if main func or debugger invoked fn
   AllocaHolderHandleAllocas;// Track memory allocated by alloca
+  std::vectorAPInt*   APInts; // Track memory allocated for APInts
+  APInt* getAPInt(uint32_t BitWidth) {
+APInt* Result = new APInt(BitWidth, 0);
+APInts.push_back(Result);
+return Result;
+  }
+  ~ExecutionContext() {
+while (!APInts.empty()) {
+  delete APInts.back();
+  APInts.pop_back();
+}
+  }
 };
 
 // Interpreter - This class represents the entirety of the interpreter.
@@ -235,17 +248,6 @@
 
 };
 
-inline void maskToBitWidth(GenericValue GV, unsigned BitWidth) {
-  uint64_t BitMask = ~(uint64_t)(0ull)  (64-BitWidth);
-  if (BitWidth = 8)
-GV.Int8Val = BitMask;
-  else if (BitWidth = 16)
-GV.Int16Val = BitMask;
-  else if (BitWidth = 32)
-GV.Int32Val = BitMask;
-  else 
-GV.Int64Val = BitMask;
-}
 } // End llvm namespace
 
 #endif



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/lib/ExecutionEngine/Interpreter/Execution.cpp

2007-03-02 Thread Reid Spencer


Changes in directory llvm/lib/ExecutionEngine/Interpreter:

Execution.cpp updated: 1.170 - 1.171
---
Log message:

Implement APInt support for the binary operators. 
Move the getConstantExpr function towards the end of the file so we don't 
need a dozen forward declarations.


---
Diffs of the changes:  (+240 -254)

 Execution.cpp |  494 --
 1 files changed, 240 insertions(+), 254 deletions(-)


Index: llvm/lib/ExecutionEngine/Interpreter/Execution.cpp
diff -u llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.170 
llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.171
--- llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.170Wed Feb 14 
00:20:04 2007
+++ llvm/lib/ExecutionEngine/Interpreter/Execution.cpp  Sat Mar  3 00:22:22 2007
@@ -18,6 +18,7 @@
 #include llvm/Instructions.h
 #include llvm/CodeGen/IntrinsicLowering.h
 #include llvm/Support/GetElementPtrTypeIterator.h
+#include llvm/ADT/APInt.h
 #include llvm/ADT/Statistic.h
 #include llvm/Support/Debug.h
 #include llvm/Support/MathExtras.h
@@ -27,47 +28,17 @@
 STATISTIC(NumDynamicInsts, Number of dynamic instructions executed);
 static Interpreter *TheEE = 0;
 
-
 
//===--===//
-// Value Manipulation code
+// Various Helper Functions
 
//===--===//
 
-static GenericValue executeAddInst(GenericValue Src1, GenericValue Src2,
-   const Type *Ty);
-static GenericValue executeSubInst(GenericValue Src1, GenericValue Src2,
-   const Type *Ty);
-static GenericValue executeMulInst(GenericValue Src1, GenericValue Src2,
-   const Type *Ty);
-static GenericValue executeUDivInst(GenericValue Src1, GenericValue Src2,
-const Type *Ty);
-static GenericValue executeSDivInst(GenericValue Src1, GenericValue Src2,
-const Type *Ty);
-static GenericValue executeFDivInst(GenericValue Src1, GenericValue Src2,
-const Type *Ty);
-static GenericValue executeURemInst(GenericValue Src1, GenericValue Src2,
-const Type *Ty);
-static GenericValue executeSRemInst(GenericValue Src1, GenericValue Src2,
-const Type *Ty);
-static GenericValue executeFRemInst(GenericValue Src1, GenericValue Src2,
-const Type *Ty);
-static GenericValue executeAndInst(GenericValue Src1, GenericValue Src2,
-   const Type *Ty);
-static GenericValue executeOrInst(GenericValue Src1, GenericValue Src2,
-   const Type *Ty);
-static GenericValue executeXorInst(GenericValue Src1, GenericValue Src2,
-   const Type *Ty);
-static GenericValue executeCmpInst(unsigned predicate, GenericValue Src1, 
-   GenericValue Src2, const Type *Ty);
-static GenericValue executeShlInst(GenericValue Src1, GenericValue Src2,
-   const Type *Ty);
-static GenericValue executeLShrInst(GenericValue Src1, GenericValue Src2,
-const Type *Ty);
-static GenericValue executeAShrInst(GenericValue Src1, GenericValue Src2,
-const Type *Ty);
-static GenericValue executeSelectInst(GenericValue Src1, GenericValue Src2,
-  GenericValue Src3);
+inline void initializeAPInt(GenericValue GV, const Type* Ty, 
+ ExecutionContext SF) {
+  if (const IntegerType *ITy = dyn_castIntegerType(Ty)) 
+GV.APIntVal = SF.getAPInt(ITy-getBitWidth());
+}
 
-inline uint64_t doSignExtension(uint64_t Val, const IntegerType* ITy) {
+static inline uint64_t doSignExtension(uint64_t Val, const IntegerType* ITy) {
   // Determine if the value is signed or not
   bool isSigned = (Val  (1  (ITy-getBitWidth()-1))) != 0;
   // If its signed, extend the sign bits
@@ -76,122 +47,19 @@
   return Val;
 }
 
-GenericValue Interpreter::getConstantExprValue (ConstantExpr *CE,
-ExecutionContext SF) {
-  switch (CE-getOpcode()) {
-  case Instruction::Trunc:   
-  return executeTruncInst(CE-getOperand(0), CE-getType(), SF);
-  case Instruction::ZExt:
-  return executeZExtInst(CE-getOperand(0), CE-getType(), SF);
-  case Instruction::SExt:
-  return executeSExtInst(CE-getOperand(0), CE-getType(), SF);
-  case Instruction::FPTrunc:
-  return executeFPTruncInst(CE-getOperand(0), CE-getType(), SF);
-  case Instruction::FPExt:
-  return executeFPExtInst(CE-getOperand(0), CE-getType(), SF);
-  case Instruction::UIToFP:
-  return executeUIToFPInst(CE-getOperand(0), CE-getType(), SF);
-  case 

[llvm-commits] CVS: llvm/lib/CodeGen/VirtRegMap.cpp

2007-03-02 Thread Evan Cheng


Changes in directory llvm/lib/CodeGen:

VirtRegMap.cpp updated: 1.103 - 1.104
---
Log message:

Only propagate IsKill if the last use is a kill.

---
Diffs of the changes:  (+22 -8)

 VirtRegMap.cpp |   30 ++
 1 files changed, 22 insertions(+), 8 deletions(-)


Index: llvm/lib/CodeGen/VirtRegMap.cpp
diff -u llvm/lib/CodeGen/VirtRegMap.cpp:1.103 
llvm/lib/CodeGen/VirtRegMap.cpp:1.104
--- llvm/lib/CodeGen/VirtRegMap.cpp:1.103   Fri Mar  2 02:52:00 2007
+++ llvm/lib/CodeGen/VirtRegMap.cpp Sat Mar  3 00:32:37 2007
@@ -703,15 +703,19 @@
 
   // Extend the live range of the MI that last kill the register if
   // necessary.
+  bool WasKill = false;
   if (SSMI) {
 MachineOperand *MOK = SSMI-findRegisterUseOperand(PhysReg, true);
-if (MOK)
+if (MOK) {
+  WasKill = MOK-isKill();
   MOK-unsetIsKill();
+}
   }
   if (ti == -1) {
 // Unless it's the use of a two-address code, transfer the kill
 // of the reused register to this use.
-MI.getOperand(i).setIsKill();
+if (WasKill)
+  MI.getOperand(i).setIsKill();
 Spills.addLastUse(PhysReg, MI);
   }
 
@@ -782,15 +786,21 @@
 
 // Extend the live range of the MI that last kill the register if
 // necessary.
+bool WasKill = false;
 if (SSMI) {
   MachineOperand *MOK = SSMI-findRegisterUseOperand(PhysReg, true);
-  if (MOK)
+  if (MOK) {
+WasKill = MOK-isKill();
 MOK-unsetIsKill();
+  }
 }
 MachineInstr *CopyMI = prior(MII);
-MachineOperand *MOU = CopyMI-findRegisterUseOperand(PhysReg);
-MOU-setIsKill();
-Spills.addLastUse(PhysReg, MI);
+if (WasKill) {
+  // Transfer kill to the next use.
+  MachineOperand *MOU = CopyMI-findRegisterUseOperand(PhysReg);
+  MOU-setIsKill();
+}
+Spills.addLastUse(PhysReg, CopyMI);
 
 // This invalidates DesignatedReg.
 Spills.ClobberPhysReg(DesignatedReg);
@@ -877,16 +887,20 @@
 
   // Either way, the live range of the last kill of InReg has been
   // extended. Remove its kill.
+  bool WasKill = false;
   if (SSMI) {
 MachineOperand *MOK = SSMI-findRegisterUseOperand(InReg, 
true);
-if (MOK)
+if (MOK) {
+  WasKill = MOK-isKill();
   MOK-unsetIsKill();
+}
   }
   if (NextMII != MBB.end()) {
 // If NextMII uses InReg (must be the copy?), mark it killed.
 MachineOperand *MOU = NextMII-findRegisterUseOperand(InReg);
 if (MOU) {
-  MOU-setIsKill();
+  if (WasKill)
+MOU-setIsKill();
   Spills.addLastUse(InReg, (*NextMII));
 }
   }



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/include/llvm/ExecutionEngine/GenericValue.h

2007-03-02 Thread Reid Spencer


Changes in directory llvm/include/llvm/ExecutionEngine:

GenericValue.h updated: 1.9 - 1.10
---
Log message:

Add APIntVal as a possible GenericeValue.


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

 GenericValue.h |3 +++
 1 files changed, 3 insertions(+)


Index: llvm/include/llvm/ExecutionEngine/GenericValue.h
diff -u llvm/include/llvm/ExecutionEngine/GenericValue.h:1.9 
llvm/include/llvm/ExecutionEngine/GenericValue.h:1.10
--- llvm/include/llvm/ExecutionEngine/GenericValue.h:1.9Thu Jan 11 
12:21:28 2007
+++ llvm/include/llvm/ExecutionEngine/GenericValue.hSat Mar  3 01:36:44 2007
@@ -20,6 +20,8 @@
 namespace llvm {
 
 typedef uintptr_t PointerTy;
+class APInt;
+class Type;
 
 union GenericValue {
   boolInt1Val;
@@ -27,6 +29,7 @@
   unsigned short  Int16Val;
   unsigned intInt32Val;
   uint64_tInt64Val;
+  APInt  *APIntVal;
   double  DoubleVal;
   float   FloatVal;
   struct { unsigned int first; unsigned int second; } UIntPairVal;



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits