[llvm-commits] CVS: llvm/lib/Target/X86/README-MMX.txt

2007-03-25 Thread Bill Wendling


Changes in directory llvm/lib/Target/X86:

README-MMX.txt updated: 1.1 -> 1.2
---
Log message:

Updated.


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

 README-MMX.txt |   54 --
 1 files changed, 54 deletions(-)


Index: llvm/lib/Target/X86/README-MMX.txt
diff -u llvm/lib/Target/X86/README-MMX.txt:1.1 
llvm/lib/Target/X86/README-MMX.txt:1.2
--- llvm/lib/Target/X86/README-MMX.txt:1.1  Thu Mar 22 13:42:45 2007
+++ llvm/lib/Target/X86/README-MMX.txt  Mon Mar 26 02:55:58 2007
@@ -3,57 +3,3 @@
 //===-===//
 
 //===-===//
-
-We should compile 
-
-#include 
-
-extern __m64 C;
-
-void baz(__v2si *A, __v2si *B)
-{
-  *A = __builtin_ia32_psllq(*B, C);
-  _mm_empty();
-}
-
-to:
-
-.globl _baz
-_baz:
-   callL3
-"L001$pb":
-L3:
-   popl%ecx
-   subl$12, %esp
-   movl20(%esp), %eax
-   movq(%eax), %mm0
-   movlL_C$non_lazy_ptr-"L001$pb"(%ecx), %eax
-   movq(%eax), %mm1
-   movl16(%esp), %eax
-   psllq   %mm1, %mm0
-   movq%mm0, (%eax)
-   emms
-   addl$12, %esp
-   ret
-
-not:
-
-_baz:
-   subl $12, %esp
-   call "L1$pb"
-"L1$pb":
-   popl %eax
-   movl L_C$non_lazy_ptr-"L1$pb"(%eax), %eax
-   movl (%eax), %ecx
-   movl %ecx, (%esp)
-   movl 4(%eax), %eax
-   movl %eax, 4(%esp)
-   movl 20(%esp), %eax
-   movq (%eax), %mm0
-   movq (%esp), %mm1
-   psllq %mm1, %mm0
-   movl 16(%esp), %eax
-   movq %mm0, (%eax)
-   emms
-   addl $12, %esp
-   ret



___
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 X86InstrMMX.td X86RegisterInfo.td

2007-03-25 Thread Bill Wendling


Changes in directory llvm/lib/Target/X86:

X86ISelLowering.cpp updated: 1.377 -> 1.378
X86InstrMMX.td updated: 1.24 -> 1.25
X86RegisterInfo.td updated: 1.40 -> 1.41
---
Log message:

Add support for the v1i64 type. This makes better code for this:

#include 

extern __m64 C;

void baz(__v2si *A, __v2si *B)
{
  *A = C;
  _mm_empty();
}

We get this:

_baz:
call "L1$pb"
"L1$pb":
popl %eax
movl L_C$non_lazy_ptr-"L1$pb"(%eax), %eax
movq (%eax), %mm0
movl 4(%esp), %eax
movq %mm0, (%eax)
emms
ret

GCC gives us this:

_baz:
pushl   %ebx
callL3
"L001$pb":
L3:
popl%ebx
subl$8, %esp
movlL_C$non_lazy_ptr-"L001$pb"(%ebx), %eax
movl(%eax), %edx
movl4(%eax), %ecx
movl16(%esp), %eax
movl%edx, (%eax)
movl%ecx, 4(%eax)
emms
addl$8, %esp
popl%ebx
ret


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

 X86ISelLowering.cpp |9 --
 X86InstrMMX.td  |   75 +++-
 X86RegisterInfo.td  |2 -
 3 files changed, 58 insertions(+), 28 deletions(-)


Index: llvm/lib/Target/X86/X86ISelLowering.cpp
diff -u llvm/lib/Target/X86/X86ISelLowering.cpp:1.377 
llvm/lib/Target/X86/X86ISelLowering.cpp:1.378
--- llvm/lib/Target/X86/X86ISelLowering.cpp:1.377   Sat Mar 24 21:14:49 2007
+++ llvm/lib/Target/X86/X86ISelLowering.cpp Mon Mar 26 02:53:08 2007
@@ -314,6 +314,7 @@
 addRegisterClass(MVT::v8i8,  X86::VR64RegisterClass);
 addRegisterClass(MVT::v4i16, X86::VR64RegisterClass);
 addRegisterClass(MVT::v2i32, X86::VR64RegisterClass);
+addRegisterClass(MVT::v1i64, X86::VR64RegisterClass);
 
 // FIXME: add MMX packed arithmetics
 
@@ -347,10 +348,12 @@
 setOperationAction(ISD::XOR,MVT::v2i32, Legal);
 
 setOperationAction(ISD::LOAD,   MVT::v8i8,  Promote);
-AddPromotedToType (ISD::LOAD,   MVT::v8i8,  MVT::v2i32);
+AddPromotedToType (ISD::LOAD,   MVT::v8i8,  MVT::v1i64);
 setOperationAction(ISD::LOAD,   MVT::v4i16, Promote);
-AddPromotedToType (ISD::LOAD,   MVT::v4i16, MVT::v2i32);
-setOperationAction(ISD::LOAD,   MVT::v2i32, Legal);
+AddPromotedToType (ISD::LOAD,   MVT::v4i16, MVT::v1i64);
+setOperationAction(ISD::LOAD,   MVT::v2i32, Promote);
+AddPromotedToType (ISD::LOAD,   MVT::v2i32, MVT::v1i64);
+setOperationAction(ISD::LOAD,   MVT::v1i64, Legal);
 
 setOperationAction(ISD::BUILD_VECTOR,   MVT::v8i8,  Expand);
 setOperationAction(ISD::BUILD_VECTOR,   MVT::v4i16, Expand);


Index: llvm/lib/Target/X86/X86InstrMMX.td
diff -u llvm/lib/Target/X86/X86InstrMMX.td:1.24 
llvm/lib/Target/X86/X86InstrMMX.td:1.25
--- llvm/lib/Target/X86/X86InstrMMX.td:1.24 Fri Mar 23 17:35:46 2007
+++ llvm/lib/Target/X86/X86InstrMMX.td  Mon Mar 26 02:53:08 2007
@@ -37,12 +37,13 @@
 def : Pat<(v8i8  (undef)), (IMPLICIT_DEF_VR64)>;
 def : Pat<(v4i16 (undef)), (IMPLICIT_DEF_VR64)>;
 def : Pat<(v2i32 (undef)), (IMPLICIT_DEF_VR64)>;
+def : Pat<(v1i64 (undef)), (IMPLICIT_DEF_VR64)>;
 
 
//===--===//
 // MMX Pattern Fragments
 
//===--===//
 
-def loadv2i32 : PatFrag<(ops node:$ptr), (v2i32 (load node:$ptr))>;
+def loadv1i64 : PatFrag<(ops node:$ptr), (v1i64 (load node:$ptr))>;
 
 def bc_v8i8  : PatFrag<(ops node:$in), (v8i8  (bitconvert node:$in))>;
 def bc_v4i16 : PatFrag<(ops node:$in), (v4i16 (bitconvert node:$in))>;
@@ -65,7 +66,7 @@
   !strconcat(OpcodeStr, " {$src2, $dst|$dst, $src2}"),
   [(set VR64:$dst, (OpVT (OpNode VR64:$src1,
  (bitconvert
-  (loadv2i32 addr:$src2)]>;
+  (loadv1i64 addr:$src2)]>;
   }
 
   multiclass MMXI_binop_rm_int opc, string OpcodeStr, Intrinsic IntId,
@@ -78,25 +79,25 @@
 def rm : MMXI;
+   (bitconvert (loadv1i64 addr:$src2]>;
   }
 
-  // MMXI_binop_rm_v2i32 - Simple MMX binary operator whose type is v2i32.
+  // MMXI_binop_rm_v1i64 - Simple MMX binary operator whose type is v1i64.
   //
   // FIXME: we could eliminate this and use MMXI_binop_rm instead if tblgen 
knew
   // to collapse (bitconvert VT to VT) into its operand.
   //
-  multiclass MMXI_binop_rm_v2i32 opc, string OpcodeStr, SDNode OpNode,
+  multiclass MMXI_binop_rm_v1i64 opc, string OpcodeStr, SDNode OpNode,
  bit Commutable = 0> {
 def rr : MMXI {
+  [(set VR64:$dst, (v1i64 (OpNode VR64:$src1, VR64:$src2)))]> {
   let isCommutable = Commutable;
 }
 def rm : MMXI;
+   

[llvm-commits] CVS: llvm/include/llvm/Intrinsics.td

2007-03-25 Thread Bill Wendling


Changes in directory llvm/include/llvm:

Intrinsics.td updated: 1.50 -> 1.51
---
Log message:

Add support for the v1i64 type. This makes better code for this:

#include 

extern __m64 C;

void baz(__v2si *A, __v2si *B)
{
  *A = C;
  _mm_empty();
}

We get this:

_baz:
call "L1$pb"
"L1$pb":
popl %eax
movl L_C$non_lazy_ptr-"L1$pb"(%eax), %eax
movq (%eax), %mm0
movl 4(%esp), %eax
movq %mm0, (%eax)
emms
ret

GCC gives us this:

_baz:
pushl   %ebx
callL3
"L001$pb":
L3:
popl%ebx
subl$8, %esp
movlL_C$non_lazy_ptr-"L001$pb"(%ebx), %eax
movl(%eax), %edx
movl4(%eax), %ecx
movl16(%esp), %eax
movl%edx, (%eax)
movl%ecx, 4(%eax)
emms
addl$8, %esp
popl%ebx
ret


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

 Intrinsics.td |1 +
 1 files changed, 1 insertion(+)


Index: llvm/include/llvm/Intrinsics.td
diff -u llvm/include/llvm/Intrinsics.td:1.50 
llvm/include/llvm/Intrinsics.td:1.51
--- llvm/include/llvm/Intrinsics.td:1.50Thu Mar  8 16:09:11 2007
+++ llvm/include/llvm/Intrinsics.td Mon Mar 26 02:53:08 2007
@@ -94,6 +94,7 @@
 def llvm_v8i16_ty  : LLVMVectorType;   //  8 x i16
 def llvm_v2i64_ty  : LLVMVectorType;   //  2 x i64
 def llvm_v2i32_ty  : LLVMVectorType;   //  2 x i32
+def llvm_v1i64_ty  : LLVMVectorType;   //  1 x i64
 def llvm_v4i32_ty  : LLVMVectorType;   //  4 x i32
 def llvm_v4f32_ty  : LLVMVectorType; //  4 x float
 def llvm_v2f64_ty  : LLVMVectorType;//  2 x 
double



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


[llvm-commits] CVS: llvm/utils/TableGen/CodeGenTarget.cpp

2007-03-25 Thread Bill Wendling


Changes in directory llvm/utils/TableGen:

CodeGenTarget.cpp updated: 1.86 -> 1.87
---
Log message:

Add support for the v1i64 type. This makes better code for this:

#include 

extern __m64 C;

void baz(__v2si *A, __v2si *B)
{
  *A = C;
  _mm_empty();
}

We get this:

_baz:
call "L1$pb"
"L1$pb":
popl %eax
movl L_C$non_lazy_ptr-"L1$pb"(%eax), %eax
movq (%eax), %mm0
movl 4(%esp), %eax
movq %mm0, (%eax)
emms
ret

GCC gives us this:

_baz:
pushl   %ebx
callL3
"L001$pb":
L3:
popl%ebx
subl$8, %esp
movlL_C$non_lazy_ptr-"L001$pb"(%ebx), %eax
movl(%eax), %edx
movl4(%eax), %ecx
movl16(%esp), %eax
movl%edx, (%eax)
movl%ecx, 4(%eax)
emms
addl$8, %esp
popl%ebx
ret


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

 CodeGenTarget.cpp |2 ++
 1 files changed, 2 insertions(+)


Index: llvm/utils/TableGen/CodeGenTarget.cpp
diff -u llvm/utils/TableGen/CodeGenTarget.cpp:1.86 
llvm/utils/TableGen/CodeGenTarget.cpp:1.87
--- llvm/utils/TableGen/CodeGenTarget.cpp:1.86  Mon Mar 19 01:20:37 2007
+++ llvm/utils/TableGen/CodeGenTarget.cpp   Mon Mar 26 02:53:08 2007
@@ -52,6 +52,7 @@
   case MVT::v8i8:  return "MVT::v8i8";
   case MVT::v4i16: return "MVT::v4i16";
   case MVT::v2i32: return "MVT::v2i32";
+  case MVT::v1i64: return "MVT::v1i64";
   case MVT::v16i8: return "MVT::v16i8";
   case MVT::v8i16: return "MVT::v8i16";
   case MVT::v4i32: return "MVT::v4i32";
@@ -82,6 +83,7 @@
   case MVT::v8i8:  return "MVT::v8i8";
   case MVT::v4i16: return "MVT::v4i16";
   case MVT::v2i32: return "MVT::v2i32";
+  case MVT::v1i64: return "MVT::v1i64";
   case MVT::v16i8: return "MVT::v16i8";
   case MVT::v8i16: return "MVT::v8i16";
   case MVT::v4i32: return "MVT::v4i32";



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


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

2007-03-25 Thread Evan Cheng


Changes in directory llvm/lib/CodeGen/SelectionDAG:

DAGCombiner.cpp updated: 1.281 -> 1.282
---
Log message:

SIGN_EXTEND_INREG requires one extra operand, a ValueType node.

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

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


Index: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
diff -u llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:1.281 
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:1.282
--- llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:1.281 Fri Mar 23 19:02:43 2007
+++ llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp   Mon Mar 26 02:12:51 2007
@@ -2327,8 +2327,12 @@
   CombineTo(N->getOperand(0).Val, Load);
 } else
   CombineTo(N0.Val, Load, Load.getValue(1));
-if (ShAmt)
-  return DAG.getNode(N->getOpcode(), VT, Load);
+if (ShAmt) {
+  if (Opc == ISD::SIGN_EXTEND_INREG)
+return DAG.getNode(Opc, VT, Load, N->getOperand(1));
+  else
+return DAG.getNode(Opc, VT, Load);
+}
 return SDOperand(N, 0);   // Return N so it doesn't get rechecked!
   }
 



___
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/2007-03-25-BadShiftMask.ll

2007-03-25 Thread Reid Spencer


Changes in directory llvm/test/Transforms/InstCombine:

2007-03-25-BadShiftMask.ll added (r1.1)
---
Log message:

Test case for PR1271: http://llvm.org/PR1271  involving construction of a bad 
mask to replace a 
shift instruction.


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

 2007-03-25-BadShiftMask.ll |   28 
 1 files changed, 28 insertions(+)


Index: llvm/test/Transforms/InstCombine/2007-03-25-BadShiftMask.ll
diff -c /dev/null 
llvm/test/Transforms/InstCombine/2007-03-25-BadShiftMask.ll:1.1
*** /dev/null   Mon Mar 26 00:32:26 2007
--- llvm/test/Transforms/InstCombine/2007-03-25-BadShiftMask.ll Mon Mar 26 
00:32:16 2007
***
*** 0 
--- 1,28 
+ ; PR1271
+ ; RUN: llvm-as < %s | opt -instcombine | llvm-dis | grep 'br i1 %1'
+ %struct..0anon = type { i32, i32 }
+ %struct..1anon = type { double }
+ 
+ define i32 @main() {
+ entry:
+   %u = alloca %struct..1anon, align 8 ; <%struct..1anon*> 
[#uses=4]
+   %tmp1 = getelementptr %struct..1anon* %u, i32 0, i32 0  ; 
 [#uses=1]
+   store double 0x7FF0, double* %tmp1
+   %tmp3 = getelementptr %struct..1anon* %u, i32 0, i32 0  ; 
 [#uses=1]
+   %tmp34 = bitcast double* %tmp3 to %struct..0anon*   ; 
<%struct..0anon*> [#uses=1]
+   %tmp5 = getelementptr %struct..0anon* %tmp34, i32 0, i32 1  
;  [#uses=1]
+   %tmp6 = load i32* %tmp5 ;  [#uses=1]
+   %tmp7 = shl i32 %tmp6, 1;  [#uses=1]
+   %tmp8 = lshr i32 %tmp7, 21  ;  [#uses=1]
+   %tmp89 = trunc i32 %tmp8 to i16 ;  [#uses=1]
+   icmp ne i16 %tmp89, 2047; :0 [#uses=1]
+   zext i1 %0 to i8; :1 [#uses=1]
+   icmp ne i8 %1, 0; :2 [#uses=1]
+   br i1 %2, label %cond_true, label %cond_false
+ 
+ cond_true:; preds = %entry
+   ret i32 0
+ 
+ cond_false:   ; preds = %entry
+ ret i32 1
+ }



___
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-25 Thread Reid Spencer


Changes in directory llvm/lib/Transforms/Scalar:

InstructionCombining.cpp updated: 1.691 -> 1.692
---
Log message:

For PR1271: http://llvm.org/PR1271 :
Fix SingleSource/Regression/C/2003-05-21-UnionBitFields.c by changing a
getHighBitsSet call to getLowBitsSet call that was incorrectly converted
from the original lshr constant expression.


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

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


Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp
diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.691 
llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.692
--- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.691   Sun Mar 25 
16:11:44 2007
+++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp Mon Mar 26 00:25:00 2007
@@ -5858,7 +5858,7 @@
   BinaryOperator::createLShr(X, ConstantInt::get(Ty, ShiftDiff));
 InsertNewInstBefore(Shift, I);
 
-APInt Mask(APInt::getHighBitsSet(TypeBits, TypeBits - ShiftAmt2));
+APInt Mask(APInt::getLowBitsSet(TypeBits, ShiftAmt2));
 return BinaryOperator::createAnd(Shift, ConstantInt::get(Mask));
   }
   



___
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-25 Thread Dale Johannesen


Changes in directory llvm/lib/Transforms/Scalar:

LoopStrengthReduce.cpp updated: 1.121 -> 1.122
---
Log message:

Look through bitcast when finding IVs.  (Chris' patch really.)


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

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


Index: llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
diff -u llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp:1.121 
llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp:1.122
--- llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp:1.121 Tue Mar 20 
16:54:54 2007
+++ llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp   Sun Mar 25 22:01:27 2007
@@ -235,6 +235,16 @@
 /// GetExpressionSCEV - Compute and return the SCEV for the specified
 /// instruction.
 SCEVHandle LoopStrengthReduce::GetExpressionSCEV(Instruction *Exp, Loop *L) {
+  // Pointer to pointer bitcast instructions return the same value as their
+  // operand.
+  if (BitCastInst *BCI = dyn_cast(Exp)) {
+if (SE->hasSCEV(BCI) || !isa(BCI->getOperand(0)))
+  return SE->getSCEV(BCI);
+SCEVHandle R = GetExpressionSCEV(cast(BCI->getOperand(0)), L);
+SE->setSCEV(BCI, R);
+return R;
+  }
+
   // Scalar Evolutions doesn't know how to compute SCEV's for GEP instructions.
   // If this is a GEP that SE doesn't know about, compute it now and insert it.
   // If this is not a GEP, or if we have already done this computation, just 
let



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


[llvm-commits] CVS: llvm/include/llvm/ValueSymbolTable.h

2007-03-25 Thread Chris Lattner


Changes in directory llvm/include/llvm:

ValueSymbolTable.h updated: 1.8 -> 1.9
---
Log message:

Start value symbol tables out small (space for 16 elts), not huge (space for 
512).

This is particularly useful for the JIT, which lazily deserializes functions.


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

 ValueSymbolTable.h |2 +-
 1 files changed, 1 insertion(+), 1 deletion(-)


Index: llvm/include/llvm/ValueSymbolTable.h
diff -u llvm/include/llvm/ValueSymbolTable.h:1.8 
llvm/include/llvm/ValueSymbolTable.h:1.9
--- llvm/include/llvm/ValueSymbolTable.h:1.8Sun Feb 11 23:18:08 2007
+++ llvm/include/llvm/ValueSymbolTable.hSun Mar 25 20:45:35 2007
@@ -61,7 +61,7 @@
 /// @{
 public:
 
-  ValueSymbolTable() : LastUnique(0) {}
+  ValueSymbolTable() : vmap(16), LastUnique(0) {}
   ~ValueSymbolTable();
 
 /// @}



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


[llvm-commits] CVS: llvm/test/CodeGen/Generic/switch-lower-feature.ll

2007-03-25 Thread Anton Korobeynikov


Changes in directory llvm/test/CodeGen/Generic:

switch-lower-feature.ll added (r1.1)
---
Log message:

Add "feature" testcase for new switch lowering code


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

 switch-lower-feature.ll |   32 
 1 files changed, 32 insertions(+)


Index: llvm/test/CodeGen/Generic/switch-lower-feature.ll
diff -c /dev/null llvm/test/CodeGen/Generic/switch-lower-feature.ll:1.1
*** /dev/null   Sun Mar 25 17:01:24 2007
--- llvm/test/CodeGen/Generic/switch-lower-feature.ll   Sun Mar 25 17:01:14 2007
***
*** 0 
--- 1,32 
+ ; RUN: llvm-as < %s | llc -march=x86 -o - | grep \$5 | wc -l | grep 1 &&
+ ; RUN: llvm-as < %s | llc -march=x86 -o - | grep \$6 | wc -l | grep 1 &&
+ ; RUN: llvm-as < %s | llc -march=x86 -o - | grep 1024 | wc -l | grep 1 &&
+ ; RUN: llvm-as < %s | llc -march=x86 -o - | grep 1023 | wc -l | grep 1 &&
+ ; RUN: llvm-as < %s | llc -march=x86 -o - | grep 1024 | wc -l | grep 1 &&
+ ; RUN: llvm-as < %s | llc -march=x86 -o - | grep jg | wc -l | grep 2 &&
+ ; RUN: llvm-as < %s | llc -march=x86 -o - | grep ja | wc -l | grep 2 &&
+ ; RUN: llvm-as < %s | llc -march=x86 -o - | grep je | wc -l | grep 1
+ 
+ define i32 @main(i32 %tmp158) {
+ entry:
+ switch i32 %tmp158, label %bb336 [
+i32 120, label %bb338
+i32 121, label %bb338
+  i32 122, label %bb338
+  i32 123, label %bb338
+  i32 124, label %bb338
+  i32 125, label %bb338
+  i32 126, label %bb338
+i32 1024, label %bb338
+  i32 0, label %bb338
+  i32 1, label %bb338
+  i32 2, label %bb338
+  i32 3, label %bb338
+  i32 4, label %bb338
+i32 5, label %bb338
+ ]
+ bb336:
+   ret i32 10
+ bb338:
+   ret i32 11
+ }



___
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-25 Thread Reid Spencer


Changes in directory llvm/include/llvm/ADT:

APInt.h updated: 1.57 -> 1.58
---
Log message:

Compute getLowBitsSet correctly. Using the complement of a 64-bit value
and shifting down without regard for the bitwidth of the APInt can lead
to incorrect initialization values. Instead, check for the word size case
(to avoid undef results from shift) and then do (1 << loBitsSet) - 1


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

 APInt.h |9 +
 1 files changed, 5 insertions(+), 4 deletions(-)


Index: llvm/include/llvm/ADT/APInt.h
diff -u llvm/include/llvm/ADT/APInt.h:1.57 llvm/include/llvm/ADT/APInt.h:1.58
--- llvm/include/llvm/ADT/APInt.h:1.57  Sat Mar 24 20:13:46 2007
+++ llvm/include/llvm/ADT/APInt.h   Sun Mar 25 16:58:42 2007
@@ -374,11 +374,12 @@
 // Handle a degenerate case, to avoid shifting by word size
 if (loBitsSet == 0)
   return APInt(numBits, 0);
-uint32_t shiftAmt = numBits - loBitsSet;
+if (loBitsSet == APINT_BITS_PER_WORD)
+  return APInt(numBits, -1ULL);
 // For small values, return quickly
-if (numBits <= APINT_BITS_PER_WORD)
-  return APInt(numBits, ~0ULL >> shiftAmt);
-return (~APInt(numBits, 0)).lshr(shiftAmt);
+if (numBits < APINT_BITS_PER_WORD)
+  return APInt(numBits, (1ULL << loBitsSet) - 1);
+return (~APInt(numBits, 0)).lshr(numBits - loBitsSet);
   }
 
   /// The hash value is computed as the sum of the words and the bit width.



___
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/2007-03-25-DoubleShift.ll

2007-03-25 Thread Reid Spencer


Changes in directory llvm/test/Transforms/InstCombine:

2007-03-25-DoubleShift.ll added (r1.1)
---
Log message:

Add a test case for PR1271: http://llvm.org/PR1271  (necessary, but not 
sufficient).


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

 2007-03-25-DoubleShift.ll |9 +
 1 files changed, 9 insertions(+)


Index: llvm/test/Transforms/InstCombine/2007-03-25-DoubleShift.ll
diff -c /dev/null llvm/test/Transforms/InstCombine/2007-03-25-DoubleShift.ll:1.1
*** /dev/null   Sun Mar 25 16:30:51 2007
--- llvm/test/Transforms/InstCombine/2007-03-25-DoubleShift.ll  Sun Mar 25 
16:30:41 2007
***
*** 0 
--- 1,9 
+ ; PR1271
+ ; RUN: llvm-as < %s | opt -instcombine | llvm-dis | grep and
+ define i1 @test(i32 %tmp13) {
+ entry:
+   %tmp14 = shl i32 %tmp13, 12 ;  [#uses=1]
+   %tmp15 = lshr i32 %tmp14, 12;  [#uses=1]
+   %res = icmp ne i32 %tmp15, 0; :3 [#uses=1]
+ ret i1 %res
+ }



___
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-25 Thread Reid Spencer


Changes in directory llvm/lib/Transforms/Scalar:

InstructionCombining.cpp updated: 1.690 -> 1.691
---
Log message:

For PR1271: http://llvm.org/PR1271 :
Remove a use of getLowBitsSet that caused the mask used for replacement of
shl/lshr pairs with an AND instruction to be computed incorrectly. Its not
clear exactly why this is the case. This solves the disappearing shifts
problem, but it doesn't fix Regression/C/2003-05-21-UnionBitFields. It 
seems there is more going on.


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

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


Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp
diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.690 
llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.691
--- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.690   Sun Mar 25 
15:43:09 2007
+++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp Sun Mar 25 16:11:44 2007
@@ -595,7 +595,7 @@
 /// optimized based on the contradictory assumption that it is non-zero.
 /// Because instcombine aggressively folds operations with undef args anyway,
 /// this won't lose us code quality.
-static void ComputeMaskedBits(Value *V, const APInt& Mask, APInt& KnownZero, 
+static void ComputeMaskedBits(Value *V, const APInt &Mask, APInt& KnownZero, 
   APInt& KnownOne, unsigned Depth = 0) {
   assert(V && "No Value?");
   assert(Depth <= 6 && "Limit Search Depth");
@@ -1200,7 +1200,7 @@
 // Figure out what the input bits are.  If the top bits of the and result
 // are not demanded, then the add doesn't demand them from its input
 // either.
-unsigned NLZ = DemandedMask.countLeadingZeros();
+uint32_t NLZ = DemandedMask.countLeadingZeros();
   
 // If there is a constant on the RHS, there are a variety of xformations
 // we can do.
@@ -1296,7 +1296,7 @@
 if ((DemandedMask & APInt::getSignBit(BitWidth)) == 0) {
   // Right fill the mask of bits for this SUB to demand the most
   // significant bit and all those below it.
-  uint32_t NLZ = DemandedMask.countLeadingZeros();
+  unsigned NLZ = DemandedMask.countLeadingZeros();
   APInt DemandedFromOps(APInt::getAllOnesValue(BitWidth).lshr(NLZ));
   if (SimplifyDemandedBits(I->getOperand(0), DemandedFromOps,
LHSKnownZero, LHSKnownOne, Depth+1))
@@ -4877,8 +4877,8 @@
 if (LHSI->hasOneUse()) {
   // Otherwise strength reduce the shift into an and.
   unsigned ShAmtVal = (unsigned)ShAmt->getZExtValue();
-  Constant *Mask = ConstantInt::get(APInt::getLowBitsSet(TypeBits, 
-  TypeBits - 
ShAmtVal));
+  uint64_t Val = (1ULL << (TypeBits-ShAmtVal))-1;
+  Constant *Mask = ConstantInt::get(CI->getType(), Val);
 
   Instruction *AndI =
 BinaryOperator::createAnd(LHSI->getOperand(0),
@@ -5809,7 +5809,7 @@
 if (ShiftAmt1 == ShiftAmt2) {
   // If we have ((X >>? C) << C), turn this into X & (-1 << C).
   if (I.getOpcode() == Instruction::Shl) {
-APInt Mask(Ty->getMask().shl(ShiftAmt1));
+APInt Mask(APInt::getHighBitsSet(TypeBits, TypeBits - ShiftAmt1));
 return BinaryOperator::createAnd(X, ConstantInt::get(Mask));
   }
   // If we have ((X << C) >>u C), turn this into X & (-1 >>u C).
@@ -5847,9 +5847,8 @@
   BinaryOperator::createShl(X, ConstantInt::get(Ty, ShiftDiff));
 InsertNewInstBefore(Shift, I);
 
-ConstantInt *Mask = ConstantInt::get(
-APInt::getHighBitsSet(TypeBits, TypeBits - ShiftAmt2));
-return BinaryOperator::createAnd(Shift, Mask);
+APInt Mask(APInt::getHighBitsSet(TypeBits, TypeBits - ShiftAmt2));
+return BinaryOperator::createAnd(Shift, ConstantInt::get(Mask));
   }
   
   // (X << C1) >>u C2  --> X >>u (C2-C1) & (-1 >> C2)
@@ -5859,7 +5858,7 @@
   BinaryOperator::createLShr(X, ConstantInt::get(Ty, ShiftDiff));
 InsertNewInstBefore(Shift, I);
 
-APInt Mask(Ty->getMask().lshr(ShiftAmt2));
+APInt Mask(APInt::getHighBitsSet(TypeBits, TypeBits - ShiftAmt2));
 return BinaryOperator::createAnd(Shift, ConstantInt::get(Mask));
   }
   
@@ -5877,7 +5876,7 @@
  ConstantInt::get(Ty, ShiftDiff));
 InsertNewInstBefore(Shift, I);
 
-APInt Mask(Ty->getMask().shl(ShiftAmt2));
+APInt Mask(APInt::getHighBitsSet(TypeBits, TypeBits - ShiftAmt2));
 return BinaryOperator::createAnd(Shift, ConstantInt::get(Mask));
   }
   
@@ -5888,7 +5887,7 @@
   BinaryOperator::createShl(X, ConstantInt::get(Ty, ShiftDiff));
 InsertNewInstBefore(Shift, I);
 
-APInt Mask(Ty->getMask().lshr(ShiftAmt2));
+APInt Mask(APInt::getHighBitsSet(TypeBits, TypeBit

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

2007-03-25 Thread Chris Lattner


Changes in directory llvm/lib/Transforms/Scalar:

InstructionCombining.cpp updated: 1.689 -> 1.690
---
Log message:

implement Transforms/InstCombine/cast2.ll:test3 and PR1263: 
http://llvm.org/PR1263 


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

 InstructionCombining.cpp |   22 +-
 1 files changed, 21 insertions(+), 1 deletion(-)


Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp
diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.689 
llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.690
--- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.689   Sun Mar 25 
14:55:33 2007
+++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp Sun Mar 25 15:43:09 2007
@@ -7896,10 +7896,22 @@
   if (GEP.getNumOperands() == 2 && HasZeroPointerIndex)
 return ReplaceInstUsesWith(GEP, PtrOp);
 
+  // Keep track of whether all indices are zero constants integers.
+  bool AllZeroIndices = true;
+  
   // Eliminate unneeded casts for indices.
   bool MadeChange = false;
+  
   gep_type_iterator GTI = gep_type_begin(GEP);
-  for (unsigned i = 1, e = GEP.getNumOperands(); i != e; ++i, ++GTI)
+  for (unsigned i = 1, e = GEP.getNumOperands(); i != e; ++i, ++GTI) {
+// Track whether this GEP has all zero indices, if so, it doesn't move the
+// input pointer, it just changes its type.
+if (AllZeroIndices) {
+  if (ConstantInt *CI = dyn_cast(GEP.getOperand(i)))
+AllZeroIndices = CI->isNullValue();
+  else
+AllZeroIndices = false;
+}
 if (isa(*GTI)) {
   if (CastInst *CI = dyn_cast(GEP.getOperand(i))) {
 if (CI->getOpcode() == Instruction::ZExt ||
@@ -7929,8 +7941,16 @@
   MadeChange = true;
 }
 }
+  }
   if (MadeChange) return &GEP;
 
+  // If this GEP instruction doesn't move the pointer, and if the input operand
+  // is a bitcast of another pointer, just replace the GEP with a bitcast of 
the
+  // real input to the dest type.
+  if (AllZeroIndices && isa(GEP.getOperand(0)))
+return new BitCastInst(cast(GEP.getOperand(0))->getOperand(0),
+   GEP.getType());
+
   // Combine Indices - If the source pointer to this getelementptr instruction
   // is a getelementptr instruction, combine the indices of the two
   // getelementptr instructions into a single instruction.



___
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 getelementptr.ll

2007-03-25 Thread Chris Lattner


Changes in directory llvm/test/Transforms/InstCombine:

cast2.ll updated: 1.1 -> 1.2
getelementptr.ll updated: 1.19 -> 1.20
---
Log message:

new testcase


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

 cast2.ll |6 ++
 getelementptr.ll |3 ++-
 2 files changed, 8 insertions(+), 1 deletion(-)


Index: llvm/test/Transforms/InstCombine/cast2.ll
diff -u llvm/test/Transforms/InstCombine/cast2.ll:1.1 
llvm/test/Transforms/InstCombine/cast2.ll:1.2
--- llvm/test/Transforms/InstCombine/cast2.ll:1.1   Fri Mar  2 23:24:06 2007
+++ llvm/test/Transforms/InstCombine/cast2.ll   Sun Mar 25 15:42:40 2007
@@ -20,5 +20,11 @@
 ret i16 %tmp.upgrd.3
 }
 
+; PR1263
+define i32* @test3(i32* %tmp1) {
+%tmp64 = bitcast i32* %tmp1 to { i32 }* ; <{ i32 }*> [#uses=1]
+%tmp65 = getelementptr { i32 }* %tmp64, i32 0, i32 0; 
 [#uses=1]
+ret i32* %tmp65
+}
 
 


Index: llvm/test/Transforms/InstCombine/getelementptr.ll
diff -u llvm/test/Transforms/InstCombine/getelementptr.ll:1.19 
llvm/test/Transforms/InstCombine/getelementptr.ll:1.20
--- llvm/test/Transforms/InstCombine/getelementptr.ll:1.19  Fri Dec  1 
22:23:09 2006
+++ llvm/test/Transforms/InstCombine/getelementptr.ll   Sun Mar 25 15:42:40 2007
@@ -1,6 +1,7 @@
 ; The %A getelementptr instruction should be eliminated here
 
-; RUN: llvm-upgrade < %s | llvm-as | opt -instcombine | llvm-dis | grep -v 
'%B' | not grep getelementptr
+; RUN: llvm-upgrade < %s | llvm-as | opt -instcombine | llvm-dis | grep -v 
'%B' | not grep getelementptr &&
+; RUN: llvm-upgrade < %s | llvm-as | opt -instcombine | llvm-dis | grep foo1
 
 %Global = constant [10 x sbyte] c"helloworld"
 



___
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/InstructionCombining.cpp

2007-03-25 Thread Chris Lattner
> Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp
> diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.688  
> llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.689
> --- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.688 Sun  
> Mar 25 00:33:51 2007
> +++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp   Sun Mar 25  
> 14:55:33 2007
> @@ -540,9 +540,8 @@
>if (I->getOpcode() == Instruction::Shl)
>  if ((CST = dyn_cast(I->getOperand(1 {
>// The multiplier is really 1 << CST.
> -  APInt Multiplier(V->getType()->getPrimitiveSizeInBits(),  
> 0);
> -  Multiplier.set(CST->getZExtValue()); // set bit is == 1  
> << CST
> -  CST = ConstantInt::get(Multiplier);
> +  Constant *One = ConstantInt::get(V->getType(), 1);
> +  CST = cast(ConstantExpr::getShl(One, CST));

This is doing arithmetic with constant expr :(.  Why not something like:

ConstantInt::get(APInt(bitwidth, 1).shl(CST->getValue()))

or something?

-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/InstructionCombining.cpp

2007-03-25 Thread Reid Spencer


Changes in directory llvm/lib/Transforms/Scalar:

InstructionCombining.cpp updated: 1.688 -> 1.689
---
Log message:

Some cleanup from review:
* Don't assume shift amounts are <= 64 bits
* Avoid creating an extra APInt in SubOne and AddOne by using -- and ++
* Add another use of getLowBitsSet
* Convert a series of if statements to a switch


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

 InstructionCombining.cpp |   34 ++
 1 files changed, 18 insertions(+), 16 deletions(-)


Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp
diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.688 
llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.689
--- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.688   Sun Mar 25 
00:33:51 2007
+++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp Sun Mar 25 14:55:33 2007
@@ -540,9 +540,8 @@
   if (I->getOpcode() == Instruction::Shl)
 if ((CST = dyn_cast(I->getOperand(1 {
   // The multiplier is really 1 << CST.
-  APInt Multiplier(V->getType()->getPrimitiveSizeInBits(), 0);
-  Multiplier.set(CST->getZExtValue()); // set bit is == 1 << CST
-  CST = ConstantInt::get(Multiplier);
+  Constant *One = ConstantInt::get(V->getType(), 1);
+  CST = cast(ConstantExpr::getShl(One, CST));
   return I->getOperand(0);
 }
 }
@@ -561,13 +560,13 @@
 
 /// AddOne - Add one to a ConstantInt
 static ConstantInt *AddOne(ConstantInt *C) {
-  APInt One(C->getType()->getPrimitiveSizeInBits(),1);
-  return ConstantInt::get(C->getValue() + One);
+  APInt Val(C->getValue());
+  return ConstantInt::get(++Val);
 }
 /// SubOne - Subtract one from a ConstantInt
 static ConstantInt *SubOne(ConstantInt *C) {
-  APInt One(C->getType()->getPrimitiveSizeInBits(),1);
-  return ConstantInt::get(C->getValue() - One);
+  APInt Val(C->getValue());
+  return ConstantInt::get(--Val);
 }
 /// Add - Add two ConstantInts together
 static ConstantInt *Add(ConstantInt *C1, ConstantInt *C2) {
@@ -752,7 +751,7 @@
   assert((KnownZero & KnownOne) == 0 && "Bits known to be one AND zero?"); 
   KnownZero <<= ShiftAmt;
   KnownOne  <<= ShiftAmt;
-  KnownZero |= APInt(BitWidth, 1ULL).shl(ShiftAmt)-1;  // low bits known 0
+  KnownZero |= APInt::getLowBitsSet(BitWidth, ShiftAmt); // low bits known 0
   return;
 }
 break;
@@ -4654,14 +4653,17 @@
 // appropriate icmp lt or icmp gt instruction.  Since the border cases have
 // already been handled above, this requires little checking.
 //
-if (I.getPredicate() == ICmpInst::ICMP_ULE)
-  return new ICmpInst(ICmpInst::ICMP_ULT, Op0, AddOne(CI));
-if (I.getPredicate() == ICmpInst::ICMP_SLE)
-  return new ICmpInst(ICmpInst::ICMP_SLT, Op0, AddOne(CI));
-if (I.getPredicate() == ICmpInst::ICMP_UGE)
-  return new ICmpInst( ICmpInst::ICMP_UGT, Op0, SubOne(CI));
-if (I.getPredicate() == ICmpInst::ICMP_SGE)
-  return new ICmpInst(ICmpInst::ICMP_SGT, Op0, SubOne(CI));
+switch (I.getPredicate()) {
+  default: break;
+  case ICmpInst::ICMP_ULE: 
+return new ICmpInst(ICmpInst::ICMP_ULT, Op0, AddOne(CI));
+  case ICmpInst::ICMP_SLE:
+return new ICmpInst(ICmpInst::ICMP_SLT, Op0, AddOne(CI));
+  case ICmpInst::ICMP_UGE:
+return new ICmpInst( ICmpInst::ICMP_UGT, Op0, SubOne(CI));
+  case ICmpInst::ICMP_SGE:
+return new ICmpInst(ICmpInst::ICMP_SGT, Op0, SubOne(CI));
+}
 
 // See if we can fold the comparison based on bits known to be zero or one
 // in the input.



___
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/InstructionCombining.cpp

2007-03-25 Thread Chris Lattner
>> Right.  ConstantInt's are immutable, so it doesn't really need to be
>> marked const.  I'm saying that the implementation of these methods
>> shouldn't build a "1" apint, then add it.  Instead, it should just
>> increment an apint with ++.
>
> Yup. I've already changed it to:
>
> static ConstantInt *AddOne(ConstantInt *C) {
>   APInt Val(C->getValue());
>   return ConstantInt::get(++Val);
> }

Beautiful,

-Chris
___
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/InstructionCombining.cpp

2007-03-25 Thread Reid Spencer
On Sun, 2007-03-25 at 12:25 -0700, Chris Lattner wrote:
> >
> >>> +/// SubOne - Subtract one from a ConstantInt
> >>>  static ConstantInt *SubOne(ConstantInt *C) {
> >>
> >> Shouldn't these use ++/-- on APInt?  That seems more efficient.
> >
> > I should really have these functions declare the parameter  
> > constant. We
> > don't want to increment the APInt inside C. Either way, a copy of the
> > value is being made.
> 
> Right.  ConstantInt's are immutable, so it doesn't really need to be  
> marked const.  I'm saying that the implementation of these methods  
> shouldn't build a "1" apint, then add it.  Instead, it should just  
> increment an apint with ++.

Yup. I've already changed it to:

static ConstantInt *AddOne(ConstantInt *C) {
  APInt Val(C->getValue());
  return ConstantInt::get(++Val);
}

Reid.



signature.asc
Description: This is a digitally signed message part
___
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/InstructionCombining.cpp

2007-03-25 Thread Chris Lattner

On Mar 25, 2007, at 12:10 PM, Reid Spencer wrote:

> On Sun, 2007-03-25 at 11:55 -0700, Chris Lattner wrote:
>>> Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp
>>> diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.687
>>> llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.688
>>> --- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.687   Sun
>>> Mar 25 00:01:29 2007
>>> +++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp Sun Mar 25
>>> 00:33:51 2007
>>> @@ -540,8 +540,9 @@
>>>if (I->getOpcode() == Instruction::Shl)
>>>  if ((CST = dyn_cast(I->getOperand(1 {
>>>// The multiplier is really 1 << CST.
>>> -  Constant *One = ConstantInt::get(V->getType(), 1);
>>> -  CST = cast(ConstantExpr::getShl(One, CST));
>>> +  APInt Multiplier(V->getType()->getPrimitiveSizeInBits(),
>>> 0);
>>> +  Multiplier.set(CST->getZExtValue()); // set bit is == 1
>>> << CST
>>
>> This doesn't seem safe.  Won't getZextValue assert if CST is > 64  
>> bits?
>
> The same comment you made about huge shift values applies here. I was
> assuming the shift amount would always fit in 64-bits (32, really),  
> but
> as you mentioned before, it could be some huge value. Will fix.  In
> practice, this is quite unlikely to cause a problem.

Right.

>> Also, I don't understand the gymnastics you're doing with Multiplier.
>
> Just trying to get rid of an expensive ConstantExpr::getShl. In  
> addition
> to the ConstantExpr overhead, the resulting Shl on an APInt isn't  
> super
> cheap, even for the <= 64 bits case. Setting a bit is pretty cheap.  
> But,
> I'll probably just revert to get over the "huge value" issue.

k

>
>>> +/// SubOne - Subtract one from a ConstantInt
>>>  static ConstantInt *SubOne(ConstantInt *C) {
>>
>> Shouldn't these use ++/-- on APInt?  That seems more efficient.
>
> I should really have these functions declare the parameter  
> constant. We
> don't want to increment the APInt inside C. Either way, a copy of the
> value is being made.

Right.  ConstantInt's are immutable, so it doesn't really need to be  
marked const.  I'm saying that the implementation of these methods  
shouldn't build a "1" apint, then add it.  Instead, it should just  
increment an apint with ++.


>>
>>> @@ -2188,14 +2203,12 @@
>>>
>>>ConstantInt *C1;
>>>if (Value *X = dyn_castFoldableMul(Op0, C1)) {
>>> -if (X == Op1) { // X*C - X --> X * (C-1)
>>> -  Constant *CP1 = ConstantExpr::getSub(C1, ConstantInt::get
>>> (I.getType(),1));
>>> -  return BinaryOperator::createMul(Op1, CP1);
>>> -}
>>> +if (X == Op1)  // X*C - X --> X * (C-1)
>>> +  return BinaryOperator::createMul(Op1, SubOne(C1));
>>
>> I like this set of changes, much cleaner.
>
> This was the real intent .. makes the code more readable and a little
> bit faster too.

Yep, thanks again,

-Chris
___
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/InstructionCombining.cpp

2007-03-25 Thread Reid Spencer
On Sun, 2007-03-25 at 11:55 -0700, Chris Lattner wrote:
> > Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp
> > diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.687  
> > llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.688
> > --- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.687   Sun  
> > Mar 25 00:01:29 2007
> > +++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp Sun Mar 25  
> > 00:33:51 2007
> > @@ -540,8 +540,9 @@
> >if (I->getOpcode() == Instruction::Shl)
> >  if ((CST = dyn_cast(I->getOperand(1 {
> >// The multiplier is really 1 << CST.
> > -  Constant *One = ConstantInt::get(V->getType(), 1);
> > -  CST = cast(ConstantExpr::getShl(One, CST));
> > +  APInt Multiplier(V->getType()->getPrimitiveSizeInBits(),  
> > 0);
> > +  Multiplier.set(CST->getZExtValue()); // set bit is == 1  
> > << CST
> 
> This doesn't seem safe.  Won't getZextValue assert if CST is > 64 bits?

The same comment you made about huge shift values applies here. I was
assuming the shift amount would always fit in 64-bits (32, really), but
as you mentioned before, it could be some huge value. Will fix.  In
practice, this is quite unlikely to cause a problem.

> 
> Also, I don't understand the gymnastics you're doing with Multiplier.

Just trying to get rid of an expensive ConstantExpr::getShl. In addition
to the ConstantExpr overhead, the resulting Shl on an APInt isn't super
cheap, even for the <= 64 bits case. Setting a bit is pretty cheap. But,
I'll probably just revert to get over the "huge value" issue.

> 
> > +  CST = ConstantInt::get(Multiplier);
> >return I->getOperand(0);
> >  }
> >  }
> > @@ -558,14 +559,31 @@
> >return false;
> >  }
> >
> > +/// AddOne - Add one to a ConstantInt
> >  static ConstantInt *AddOne(ConstantInt *C) {
> > +  APInt One(C->getType()->getPrimitiveSizeInBits(),1);
> > +  return ConstantInt::get(C->getValue() + One);
> >  }
> > +/// SubOne - Subtract one from a ConstantInt
> >  static ConstantInt *SubOne(ConstantInt *C) {
> 
> Shouldn't these use ++/-- on APInt?  That seems more efficient.

I should really have these functions declare the parameter constant. We
don't want to increment the APInt inside C. Either way, a copy of the
value is being made.

> 
> > @@ -2188,14 +2203,12 @@
> >
> >ConstantInt *C1;
> >if (Value *X = dyn_castFoldableMul(Op0, C1)) {
> > -if (X == Op1) { // X*C - X --> X * (C-1)
> > -  Constant *CP1 = ConstantExpr::getSub(C1, ConstantInt::get 
> > (I.getType(),1));
> > -  return BinaryOperator::createMul(Op1, CP1);
> > -}
> > +if (X == Op1)  // X*C - X --> X * (C-1)
> > +  return BinaryOperator::createMul(Op1, SubOne(C1));
> 
> I like this set of changes, much cleaner.

This was the real intent .. makes the code more readable and a little
bit faster too.

Reid.
> 
> -Chris


signature.asc
Description: This is a digitally signed message part
___
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/InstructionCombining.cpp

2007-03-25 Thread Chris Lattner
> Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp
> diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.687  
> llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.688
> --- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.687 Sun  
> Mar 25 00:01:29 2007
> +++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp   Sun Mar 25  
> 00:33:51 2007
> @@ -540,8 +540,9 @@
>if (I->getOpcode() == Instruction::Shl)
>  if ((CST = dyn_cast(I->getOperand(1 {
>// The multiplier is really 1 << CST.
> -  Constant *One = ConstantInt::get(V->getType(), 1);
> -  CST = cast(ConstantExpr::getShl(One, CST));
> +  APInt Multiplier(V->getType()->getPrimitiveSizeInBits(),  
> 0);
> +  Multiplier.set(CST->getZExtValue()); // set bit is == 1  
> << CST

This doesn't seem safe.  Won't getZextValue assert if CST is > 64 bits?

Also, I don't understand the gymnastics you're doing with Multiplier.

> +  CST = ConstantInt::get(Multiplier);
>return I->getOperand(0);
>  }
>  }
> @@ -558,14 +559,31 @@
>return false;
>  }
>
> +/// AddOne - Add one to a ConstantInt
>  static ConstantInt *AddOne(ConstantInt *C) {
> +  APInt One(C->getType()->getPrimitiveSizeInBits(),1);
> +  return ConstantInt::get(C->getValue() + One);
>  }
> +/// SubOne - Subtract one from a ConstantInt
>  static ConstantInt *SubOne(ConstantInt *C) {

Shouldn't these use ++/-- on APInt?  That seems more efficient.

> @@ -2188,14 +2203,12 @@
>
>ConstantInt *C1;
>if (Value *X = dyn_castFoldableMul(Op0, C1)) {
> -if (X == Op1) { // X*C - X --> X * (C-1)
> -  Constant *CP1 = ConstantExpr::getSub(C1, ConstantInt::get 
> (I.getType(),1));
> -  return BinaryOperator::createMul(Op1, CP1);
> -}
> +if (X == Op1)  // X*C - X --> X * (C-1)
> +  return BinaryOperator::createMul(Op1, SubOne(C1));

I like this set of changes, much cleaner.

-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/SelectionDAG/SelectionDAGISel.cpp

2007-03-25 Thread Anton Korobeynikov


Changes in directory llvm/lib/CodeGen/SelectionDAG:

SelectionDAGISel.cpp updated: 1.393 -> 1.394
---
Log message:

First step of switch lowering refactoring: perform worklist-driven 
strategy, emit JT's where possible.


---
Diffs of the changes:  (+253 -180)

 SelectionDAGISel.cpp |  433 +--
 1 files changed, 253 insertions(+), 180 deletions(-)


Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
diff -u llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.393 
llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.394
--- llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.393Sun Mar 25 
00:00:54 2007
+++ llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp  Sun Mar 25 10:07:15 2007
@@ -405,7 +405,9 @@
   /// SwitchCases - Vector of CaseBlock structures used to communicate
   /// SwitchInst code generation information.
   std::vector SwitchCases;
-  SelectionDAGISel::JumpTable JT;
+  /// JTCases - Vector of JumpTable structures used to communicate
+  /// SwitchInst code generation information.
+  std::vector JTCases;
   
   /// FuncInfo - Information about the function as a whole.
   ///
@@ -414,7 +416,7 @@
   SelectionDAGLowering(SelectionDAG &dag, TargetLowering &tli,
FunctionLoweringInfo &funcinfo)
 : TLI(tli), DAG(dag), TD(DAG.getTarget().getTargetData()),
-  JT(0,0,0,0), FuncInfo(funcinfo) {
+  FuncInfo(funcinfo) {
   }
 
   /// getRoot - Return the current virtual root of the Selection DAG.
@@ -497,6 +499,8 @@
   // Helper for visitSwitch
   void visitSwitchCase(SelectionDAGISel::CaseBlock &CB);
   void visitJumpTable(SelectionDAGISel::JumpTable &JT);
+  void visitJumpTableHeader(SelectionDAGISel::JumpTable &JT,
+SelectionDAGISel::JumpTableHeader &JTH);
   
   // These all get lowered before this pass.
   void visitInvoke(InvokeInst &I);
@@ -1065,7 +1069,7 @@
 Cond = DAG.getNode(ISD::XOR, CondLHS.getValueType(), CondLHS, True);
   } else
 Cond = DAG.getSetCC(MVT::i1, CondLHS, getValue(CB.CmpRHS), CB.CC);
-  
+
   // Set NextBlock to be the MBB immediately after the current one, if any.
   // This is used to avoid emitting unnecessary branches to the next block.
   MachineBasicBlock *NextBlock = 0;
@@ -1092,8 +1096,10 @@
   CurMBB->addSuccessor(CB.FalseBB);
 }
 
+/// visitJumpTable - Emit JumpTable node in the current MBB
 void SelectionDAGLowering::visitJumpTable(SelectionDAGISel::JumpTable &JT) {
   // Emit the code for the jump table
+  assert(JT.Reg != -1UL && "Should lower JT Header first!");
   MVT::ValueType PTy = TLI.getPointerTy();
   SDOperand Index = DAG.getCopyFromReg(getRoot(), JT.Reg, PTy);
   SDOperand Table = DAG.getJumpTable(JT.JTI, PTy);
@@ -1102,6 +1108,57 @@
   return;
 }
 
+/// visitJumpTableHeader - This function emits necessary code to produce index
+/// in the JumpTable from switch case.
+void SelectionDAGLowering::visitJumpTableHeader(SelectionDAGISel::JumpTable 
&JT,
+ SelectionDAGISel::JumpTableHeader 
&JTH) {
+  // Subtract the lowest switch case value from the value being switched on
+  // and conditional branch to default mbb if the result is greater than the
+  // difference between smallest and largest cases.
+  SDOperand SwitchOp = getValue(JTH.SValue);
+  MVT::ValueType VT = SwitchOp.getValueType();
+  SDOperand SUB = DAG.getNode(ISD::SUB, VT, SwitchOp,
+  DAG.getConstant(JTH.First, VT));
+  
+  // The SDNode we just created, which holds the value being switched on
+  // minus the the smallest case value, needs to be copied to a virtual
+  // register so it can be used as an index into the jump table in a 
+  // subsequent basic block.  This value may be smaller or larger than the
+  // target's pointer type, and therefore require extension or truncating.
+  if (VT > TLI.getPointerTy())
+SwitchOp = DAG.getNode(ISD::TRUNCATE, TLI.getPointerTy(), SUB);
+  else
+SwitchOp = DAG.getNode(ISD::ZERO_EXTEND, TLI.getPointerTy(), SUB);
+  
+  unsigned JumpTableReg = FuncInfo.MakeReg(TLI.getPointerTy());
+  SDOperand CopyTo = DAG.getCopyToReg(getRoot(), JumpTableReg, SwitchOp);
+  JT.Reg = JumpTableReg;
+
+  // Emit the range check for the jump table, and branch to the default
+  // block for the switch statement if the value being switched on exceeds
+  // the largest case in the switch.
+  SDOperand CMP = DAG.getSetCC(TLI.getSetCCResultTy(), SUB,
+   DAG.getConstant(JTH.Last-JTH.First,VT),
+   ISD::SETUGT);
+
+  // Set NextBlock to be the MBB immediately after the current one, if any.
+  // This is used to avoid emitting unnecessary branches to the next block.
+  MachineBasicBlock *NextBlock = 0;
+  MachineFunction::iterator BBI = CurMBB;
+  if (++BBI != CurMBB->getParent()->end())
+NextBlock = BBI;
+
+  SDOperand BrCond = DAG.getNode(ISD::BRCOND, MVT::Other, CopyTo, CMP,
+ DAG.getB

[llvm-commits] CVS: llvm/include/llvm/CodeGen/SelectionDAGISel.h

2007-03-25 Thread Anton Korobeynikov


Changes in directory llvm/include/llvm/CodeGen:

SelectionDAGISel.h updated: 1.34 -> 1.35
---
Log message:

First step of switch lowering refactoring: perform worklist-driven 
strategy, emit JT's where possible.


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

 SelectionDAGISel.h |   36 
 1 files changed, 24 insertions(+), 12 deletions(-)


Index: llvm/include/llvm/CodeGen/SelectionDAGISel.h
diff -u llvm/include/llvm/CodeGen/SelectionDAGISel.h:1.34 
llvm/include/llvm/CodeGen/SelectionDAGISel.h:1.35
--- llvm/include/llvm/CodeGen/SelectionDAGISel.h:1.34   Fri Mar 23 13:44:11 2007
+++ llvm/include/llvm/CodeGen/SelectionDAGISel.hSun Mar 25 10:07:15 2007
@@ -42,8 +42,7 @@
   std::vector TopOrder;
   unsigned DAGSize;
 
-  explicit SelectionDAGISel(TargetLowering &tli)
-  : TLI(tli), DAGSize(0), JT(0,0,0,0) {}
+  explicit SelectionDAGISel(TargetLowering &tli) : TLI(tli), DAGSize(0) {}
   
   TargetLowering &getTargetLowering() { return TLI; }
 
@@ -99,19 +98,31 @@
   };
   struct JumpTable {
 JumpTable(unsigned R, unsigned J, MachineBasicBlock *M,
-  MachineBasicBlock *D) : Reg(R), JTI(J), MBB(M), Default(D) {}
-// Reg - the virtual register containing the index of the jump table entry
-// to jump to.
+  MachineBasicBlock *D): Reg(R), JTI(J), MBB(M), Default(D) {};
+
+/// Reg - the virtual register containing the index of the jump table entry
+//. to jump to.
 unsigned Reg;
-// JTI - the JumpTableIndex for this jump table in the function.
+/// JTI - the JumpTableIndex for this jump table in the function.
 unsigned JTI;
-// MBB - the MBB into which to emit the code for the indirect jump.
+/// MBB - the MBB into which to emit the code for the indirect jump.
 MachineBasicBlock *MBB;
-// Default - the MBB of the default bb, which is a successor of the range
-// check MBB.  This is when updating PHI nodes in successors.
+/// Default - the MBB of the default bb, which is a successor of the range
+/// check MBB.  This is when updating PHI nodes in successors.
 MachineBasicBlock *Default;
   };
-  
+  struct JumpTableHeader {
+JumpTableHeader(uint64_t F, uint64_t L, Value* SV, MachineBasicBlock* H,
+bool E = false):
+  First(F), Last(L), SValue(SV), HeaderBB(H), Emitted(E) {};
+uint64_t First;
+uint64_t Last;
+Value *SValue;
+MachineBasicBlock *HeaderBB;
+bool Emitted;
+  };
+  typedef std::pair JumpTableBlock;
+ 
 protected:
   /// Pick a safe ordering and emit instructions for each target node in the
   /// graph.
@@ -141,8 +152,9 @@
   /// SwitchInst code generation information.
   std::vector SwitchCases;
 
-  /// JT - Record which holds necessary information for emitting a jump table
-  JumpTable JT;
+  /// JTCases - Vector of JumpTable structures which holds necessary 
information
+  /// for emitting a jump tables during SwitchInst code generation.
+  std::vector JTCases;
 };
 
 }



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


[llvm-commits] CVS: llvm/lib/Target/MSIL/Makefile

2007-03-25 Thread Anton Korobeynikov


Changes in directory llvm/lib/Target/MSIL:

Makefile updated: 1.1 -> 1.2
---
Log message:

Fix authorship


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

 Makefile |2 +-
 1 files changed, 1 insertion(+), 1 deletion(-)


Index: llvm/lib/Target/MSIL/Makefile
diff -u llvm/lib/Target/MSIL/Makefile:1.1 llvm/lib/Target/MSIL/Makefile:1.2
--- llvm/lib/Target/MSIL/Makefile:1.1   Wed Mar 21 16:38:25 2007
+++ llvm/lib/Target/MSIL/Makefile   Sun Mar 25 08:44:26 2007
@@ -2,7 +2,7 @@
 #
 #The LLVM Compiler Infrastructure
 #
-# This file was developed by the LLVM research group and is distributed under
+# This file was developed by Roman Samoilov and is distributed under
 # the University of Illinois Open Source License. See LICENSE.TXT for details.
 #
 
##===--===##



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


Re: [llvm-commits] [125160] Better support for variable size struct fields.

2007-03-25 Thread Duncan Sands
> Is this already fixed?

I am testing a fix.

Ciao,

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