[llvm-commits] CVS: llvm-www/pubs/2006-06-15-VEE-VectorLLVA.html 2006-06-15-VEE-VectorLLVA.html~ 2006-06-15-VEE-VectorLLVA.pdf index.html

2006-04-28 Thread Robert L. Bocchino Jr.


Changes in directory llvm-www/pubs:

2006-06-15-VEE-VectorLLVA.html added (r1.1)
2006-06-15-VEE-VectorLLVA.html~ added (r1.1)
2006-06-15-VEE-VectorLLVA.pdf added (r1.1)
index.html updated: 1.37 - 1.38
---
Log message:

Added VEE Vector LLVA paper to the pubs list.


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

 2006-06-15-VEE-VectorLLVA.html  |   50 
 2006-06-15-VEE-VectorLLVA.html~ |   50 
 index.html  |3 ++
 3 files changed, 103 insertions(+)


Index: llvm-www/pubs/2006-06-15-VEE-VectorLLVA.html
diff -c /dev/null llvm-www/pubs/2006-06-15-VEE-VectorLLVA.html:1.1
*** /dev/null   Fri Apr 28 12:16:32 2006
--- llvm-www/pubs/2006-06-15-VEE-VectorLLVA.htmlFri Apr 28 12:16:21 2006
***
*** 0 
--- 1,50 
+ !DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN
+ html
+ head
+   meta http-equiv=Content-Type content=text/html; charset=UTF-8 /
+   link rel=stylesheet href=../llvm.css type=text/css media=screen /
+   titleVector LLVA:  A Virtual Vector Instruction Set for Media 
Processing/title
+ /head
+ body
+ 
+ div class=pub_title
+   Vector LLVA:  A Virtual Vector Instruction Set for Media Processing
+ /div
+ div class=pub_author
+   Robert L. Bocchino Jr. and Vikram S. Adve
+ /div
+ 
+ h2Abstract:/h2
+ blockquote
+ We present Vector LLVA, a virtual instruction set architecture (V-ISA)
+ that exposes extensive static information about vector parallelism
+ while avoiding the use of hardware-specific parameters.  We provide
+ both arbitrary-length vectors (for targets that allow vectors of
+ arbitrary length, or where the target length is not known) and
+ fixed-length vectors (for targets that have a fixed vector length,
+ such as subword SIMD extensions), together with a rich set of
+ operations on both vector types.  We have implemented translators that
+ compile (1) Vector LLVA written with arbitrary-length vectors to the
+ Motorola RSVP architecture and (2) Vector LLVA written with
+ fixed-length vectors to both AltiVec and Intel SSE2.  Our
+ translator-generated code achieves speedups competitive with
+ handwritten native code versions of several benchmarks on all three
+ architectures.  These experiments show that our V-ISA design captures
+ vector parallelism for two quite different classes of architectures
+ and provides virtual object code portability within the class of
+ subword SIMD architectures.
+ /blockquote
+ 
+ h2Published:/h2
+ blockquote
+   Vector LLVA:  A Virtual Vector Instruction Set for Media Processing, 
Robert L. Bocchino Jr. and Vikram S. Adve.br
+   Proceedings of the Second International Conference on Virtual Execution 
Environments (VEE '06), Ottawa, Canada, 2006.
+ /blockquote
+ 
+ h2Download:/h2
+ ul
+   lia href=2006-06-15-VEE-VectorLLVA.pdfVector LLVA:  A Virtual Vector 
Instruction Set for Media Processing/a (PDF)/li
+ /ul
+ 
+ /body
+ /html


Index: llvm-www/pubs/2006-06-15-VEE-VectorLLVA.html~
diff -c /dev/null llvm-www/pubs/2006-06-15-VEE-VectorLLVA.html~:1.1
*** /dev/null   Fri Apr 28 12:16:53 2006
--- llvm-www/pubs/2006-06-15-VEE-VectorLLVA.html~   Fri Apr 28 12:16:21 2006
***
*** 0 
--- 1,50 
+ !DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN
+ html
+ head
+   meta http-equiv=Content-Type content=text/html; charset=UTF-8 /
+   link rel=stylesheet href=../llvm.css type=text/css media=screen /
+   titleVector LLVA:  A Virtual Vector Instruction Set for Media 
Processing/title
+ /head
+ body
+ 
+ div class=pub_title
+   Vector LLVA:  A Virtual Vector Instruction Set for Media Processing
+ /div
+ div class=pub_author
+   Robert L. Bocchino Jr. and Vikram S. Adve
+ /div
+ 
+ h2Abstract:/h2
+ blockquote
+ We present Vector LLVA, a virtual instruction set architecture (V-ISA)
+ that exposes extensive static information about vector parallelism
+ while avoiding the use of hardware-specific parameters.  We provide
+ both arbitrary-length vectors (for targets that allow vectors of
+ arbitrary length, or where the target length is not known) and
+ fixed-length vectors (for targets that have a fixed vector length,
+ such as subword SIMD extensions), together with a rich set of
+ operations on both vector types.  We have implemented translators that
+ compile (1) Vector LLVA written with arbitrary-length vectors to the
+ Motorola RSVP architecture and (2) Vector LLVA written with
+ fixed-length vectors to both AltiVec and Intel SSE2.  Our
+ translator-generated code achieves speedups competitive with
+ handwritten native code versions of several benchmarks on all three
+ architectures.  These experiments show that our V-ISA design captures
+ vector parallelism for two quite different classes of architectures
+ and provides virtual object code portability within the class of
+ subword SIMD architectures.
+ /blockquote
+ 
+ h2Published:/h2
+ blockquote
+   Vector LLVA:  A Virtual Vector Instruction Set for Media Processing

[llvm-commits] CVS: llvm/docs/LangRef.html

2006-03-14 Thread Robert L. Bocchino Jr.


Changes in directory llvm/docs:

LangRef.html updated: 1.140 - 1.141
---
Log message:

Split the 'vset' instruction into two instructions, 'vsetint' and
'vsetfp', to reflect the fact that the semantics are different for
integer and fp values.


---
Diffs of the changes:  (+74 -39)

 LangRef.html |  113 ++-
 1 files changed, 74 insertions(+), 39 deletions(-)


Index: llvm/docs/LangRef.html
diff -u llvm/docs/LangRef.html:1.140 llvm/docs/LangRef.html:1.141
--- llvm/docs/LangRef.html:1.140Tue Mar 14 14:02:51 2006
+++ llvm/docs/LangRef.html  Tue Mar 14 14:55:28 2006
@@ -106,7 +106,8 @@
   lia href=#i_phi'ttphi/tt'   Instruction/a/li
   lia href=#i_cast'ttcast .. to/tt' Instruction/a/li
   lia href=#i_select'ttselect/tt' Instruction/a/li
-  lia href=#i_vset'ttvset/tt' Instruction/a/li
+  lia href=#i_vsetint'ttvsetint/tt' Instruction/a/li
+  lia href=#i_vsetfp'ttvsetfp/tt' Instruction/a/li
   lia href=#i_vselect'ttvselect/tt' Instruction/a/li
   lia href=#i_extractelement'ttextractelement/tt' 
Instruction/a/li
   lia href=#i_insertelement'ttinsertelement/tt' 
Instruction/a/li
@@ -2331,56 +2332,50 @@
 /div
 
 !-- ___ 
--
-div class=doc_subsubsection a name=i_vset'ttvset/tt'
+div class=doc_subsubsection a name=i_vsetint'ttvsetint/tt'
 Instruction/a /div
 div class=doc_text
 h5Syntax:/h5
-prelt;resultgt; = vset lt;opgt;, lt;n x lt;tygt;gt; lt;var1gt;, 
lt;var2gt;   i; yields lt;n x boolgt;/i
+prelt;resultgt; = vsetint lt;opgt;, lt;n x lt;tygt;gt; lt;var1gt;, 
lt;var2gt;   i; yields lt;n x boolgt;/i
 /pre
 
 h5Overview:/h5
 
-pThe 'ttvset/tt' instruction returns a vector of boolean
-values representing, at each position, the result of the comparison
-between the values at that position in the two operands./p
+pThe 'ttvsetint/tt' instruction takes two integer vectors and
+returns a vector of boolean values representing, at each position, the
+result of the comparison between the values at that position in the
+two operands./p
 
 h5Arguments:/h5
 
-pThe arguments to a 'ttvset/tt' instruction are a comparison
+pThe arguments to a 'ttvsetint/tt' instruction are a comparison
 operation and two value arguments.  The value arguments must be of a
-href=#t_packedpacked/a type, and they must have identical types.
-For value arguments of integral element type, the operation argument
-must be one of tteq/tt, ttne/tt, ttlt/tt, ttgt/tt,
-ttle/tt, ttge/tt, ttult/tt, ttugt/tt, ttule/tt,
-ttuge/tt, tttrue/tt, and ttfalse/tt.  For value arguments
-of floating point element type, the operation argument must be one of
-tteq/tt, ttne/tt, ttlt/tt, ttgt/tt, ttle/tt,
-ttge/tt, ttoeq/tt, ttone/tt, ttolt/tt, ttogt/tt,
-ttole/tt, ttoge/tt, ttueq/tt, ttune/tt, ttult/tt,
-ttugt/tt, ttule/tt, ttuge/tt, tto/tt, ttu/tt,
-tttrue/tt, and ttfalse/tt.  The result is a packed
-ttbool/tt value with the same length as each operand./p
+href=#t_integralintegral/a a href=#t_packedpacked/a type,
+and they must have identical types.  The operation argument must be
+one of tteq/tt, ttne/tt, ttslt/tt, ttsgt/tt,
+ttsle/tt, ttsge/tt, ttult/tt, ttugt/tt, ttule/tt,
+ttuge/tt, tttrue/tt, and ttfalse/tt.  The result is a
+packed ttbool/tt value with the same length as each operand./p
 
 h5Semantics:/h5
 
-pThe following table shows the semantics of 'ttvset/tt' for
-integral value arguments.  For each position of the result, the
-comparison is done on the corresponding positions of the two value
-arguments.  Note that the signedness of the comparison depends on the
-comparison opcode and inot/i on the signedness of the value
-operands.  E.g., ttvset lt 4 x unsigned %x, %y/tt does an
-elementwise isigned/i comparison of tt%x/tt and
-tt%y/tt./p
+pThe following table shows the semantics of 'ttvsetint/tt'.  For
+each position of the result, the comparison is done on the
+corresponding positions of the two value arguments.  Note that the
+signedness of the comparison depends on the comparison opcode and
+inot/i on the signedness of the value operands.  E.g., ttvsetint
+slt 4 x unsigned %x, %y/tt does an elementwise isigned/i
+comparison of tt%x/tt and tt%y/tt./p
 
 table  border=1 cellspacing=0 cellpadding=4
   tbody
 trthOperation/ththResult is true iff/ththComparison 
is/th/tr
 trtdtteq/tt/tdtdvar1 == var2/tdtd--/td/tr
 trtdttne/tt/tdtdvar1 != var2/tdtd--/td/tr
-trtdttlt/tt/tdtdvar1 lt; var2/tdtdsigned/td/tr
-trtdttgt/tt/tdtdvar1 gt; var2/tdtdsigned/td/tr
-trtdttle/tt/tdtdvar1 lt;= var2/tdtdsigned/td/tr
-trtdttge/tt/tdtdvar1 gt;= var2/tdtdsigned/td/tr
+trtdttslt/tt/tdtdvar1 lt; var2/tdtdsigned/td/tr
+trtdttsgt/tt/tdtdvar1 gt; var2/tdtdsigned/td/tr
+trtdttsle/tt/tdtdvar1 lt;= var2/tdtdsigned/td/tr
+trtdttsge/tt/tdtdvar1 gt;= var2/tdtdsigned/td/tr
 trtdttult/tt/tdtdvar1 lt; var2/tdtdunsigned/td/tr
 

[llvm-commits] CVS: llvm-www/developers.txt

2006-02-17 Thread Robert L. Bocchino Jr.


Changes in directory llvm-www:

developers.txt updated: 1.5 - 1.6
---
Log message:

Added a link to my web page on the Developers list.


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

 developers.txt |2 +-
 1 files changed, 1 insertion(+), 1 deletion(-)


Index: llvm-www/developers.txt
diff -u llvm-www/developers.txt:1.5 llvm-www/developers.txt:1.6
--- llvm-www/developers.txt:1.5 Sat Dec 17 00:49:45 2005
+++ llvm-www/developers.txt Fri Feb 17 11:57:35 2006
@@ -1,7 +1,7 @@
 Vikram Advehref=http://www-sal.cs.uiuc.edu/~vadve/ img=PhotoVikram.jpg 
width=120   height=120  alt=vadve
 Henrik Bachhref=mailto:[EMAIL PROTECTED]   img=PhotoHenrik.jpg 
width=156   height=178  alt=Henrik
 Nate   Begeman href=http://sampo.lasthome.net/ img=PhotoNate.jpg   
width=160   height=130  alt=Sampo
-RobBocchinoimg=PhotoRob.jpgwidth=140   height=187  
alt=Rob
+RobBocchino href=http://llvm.cs.uiuc.edu/~bocchino img=PhotoRob.jpg
width=140   height=187  alt=Rob
 Misha  Brukman href=http://misha.brukman.net/code/llvm/
img=PhotoMisha.png  width=175   height=198  alt=Misha
 Evan   Cheng   href=mailto:[EMAIL PROTECTED]   img=PhotoEvan.jpg   
width=152   height=198  alt=Grawp
 Jeff   Cohen   href=http://jolt-lang.org/  img=PhotoJeffCohen.jpg  
width=165   height=134  alt=jeffc



___
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

2006-01-20 Thread Robert L. Bocchino Jr.


Changes in directory llvm/lib/ExecutionEngine:

ExecutionEngine.cpp updated: 1.72 - 1.73
---
Log message:

Fixed InitializeMemory to handle ConstantPacked.



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

 ExecutionEngine.cpp |6 ++
 1 files changed, 6 insertions(+)


Index: llvm/lib/ExecutionEngine/ExecutionEngine.cpp
diff -u llvm/lib/ExecutionEngine/ExecutionEngine.cpp:1.72 
llvm/lib/ExecutionEngine/ExecutionEngine.cpp:1.73
--- llvm/lib/ExecutionEngine/ExecutionEngine.cpp:1.72   Sun Oct 23 18:54:56 2005
+++ llvm/lib/ExecutionEngine/ExecutionEngine.cppFri Jan 20 12:18:40 2006
@@ -457,6 +457,12 @@
 void ExecutionEngine::InitializeMemory(const Constant *Init, void *Addr) {
   if (isaUndefValue(Init)) {
 return;
+  } else if (const ConstantPacked *CP = dyn_castConstantPacked(Init)) {
+unsigned ElementSize =
+  getTargetData().getTypeSize(CP-getType()-getElementType());
+for (unsigned i = 0, e = CP-getNumOperands(); i != e; ++i)
+  InitializeMemory(CP-getOperand(i), (char*)Addr+i*ElementSize);
+return;
   } else if (Init-getType()-isFirstClassType()) {
 GenericValue Val = getConstantValue(Init);
 StoreValueToMemory(Val, (GenericValue*)Addr, Init-getType());



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


[llvm-commits] CVS: llvm/lib/Target/CBackend/Writer.cpp

2006-01-20 Thread Robert L. Bocchino Jr.


Changes in directory llvm/lib/Target/CBackend:

Writer.cpp updated: 1.251 - 1.252
---
Log message:

Make the C writer work with packed types.  printContainedStructs is
still not quite right and will be fixed later.



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

 Writer.cpp |   53 +
 1 files changed, 49 insertions(+), 4 deletions(-)


Index: llvm/lib/Target/CBackend/Writer.cpp
diff -u llvm/lib/Target/CBackend/Writer.cpp:1.251 
llvm/lib/Target/CBackend/Writer.cpp:1.252
--- llvm/lib/Target/CBackend/Writer.cpp:1.251   Fri Jan 20 12:57:03 2006
+++ llvm/lib/Target/CBackend/Writer.cpp Fri Jan 20 14:43:57 2006
@@ -132,6 +132,7 @@
 
 void printConstant(Constant *CPV);
 void printConstantArray(ConstantArray *CPA);
+void printConstantPacked(ConstantPacked *CP);
 
 // isInlinableInst - Attempt to inline instructions into their uses to 
build
 // trees as much as possible.  To do this, we have to consistently decide
@@ -329,7 +330,8 @@
 const PointerType *PTy = castPointerType(Ty);
 std::string ptrName = * + NameSoFar;
 
-if (isaArrayType(PTy-getElementType()))
+if (isaArrayType(PTy-getElementType()) ||
+isaPackedType(PTy-getElementType()))
   ptrName = ( + ptrName + );
 
 return printType(Out, PTy-getElementType(), ptrName);
@@ -343,6 +345,14 @@
  NameSoFar + [ + utostr(NumElements) + ]);
   }
 
+  case Type::PackedTyID: {
+const PackedType *PTy = castPackedType(Ty);
+unsigned NumElements = PTy-getNumElements();
+if (NumElements == 0) NumElements = 1;
+return printType(Out, PTy-getElementType(),
+ NameSoFar + [ + utostr(NumElements) + ]);
+  }
+
   case Type::OpaqueTyID: {
 static int Count = 0;
 std::string TyName = struct opaque_ + itostr(Count++);
@@ -426,6 +436,19 @@
   }
 }
 
+void CWriter::printConstantPacked(ConstantPacked *CP) {
+  Out  '{';
+  if (CP-getNumOperands()) {
+Out  ' ';
+printConstant(castConstant(CP-getOperand(0)));
+for (unsigned i = 1, e = CP-getNumOperands(); i != e; ++i) {
+  Out  , ;
+  printConstant(castConstant(CP-getOperand(i)));
+}
+  }
+  Out   };
+}
+
 // isFPCSafeToPrint - Returns true if we may assume that CFP may be written out
 // textually as a double (rather than as a reference to a stack-allocated
 // variable). We decide this by converting CFP to a string and back into a
@@ -641,6 +664,25 @@
 }
 break;
 
+  case Type::PackedTyID:
+if (isaConstantAggregateZero(CPV) || isaUndefValue(CPV)) {
+  const PackedType *AT = castPackedType(CPV-getType());
+  Out  '{';
+  if (AT-getNumElements()) {
+Out  ' ';
+Constant *CZ = Constant::getNullValue(AT-getElementType());
+printConstant(CZ);
+for (unsigned i = 1, e = AT-getNumElements(); i != e; ++i) {
+  Out  , ;
+  printConstant(CZ);
+}
+  }
+  Out   };
+} else {
+  printConstantPacked(castConstantPacked(CPV));
+}
+break;
+
   case Type::StructTyID:
 if (isaConstantAggregateZero(CPV) || isaUndefValue(CPV)) {
   const StructType *ST = castStructType(CPV-getType());
@@ -936,7 +978,8 @@
   // the compiler figure out the rest of the zeros.
   Out   =  ;
   if (isaStructType(I-getInitializer()-getType()) ||
-  isaArrayType(I-getInitializer()-getType())) {
+  isaArrayType(I-getInitializer()-getType()) ||
+  isaPackedType(I-getInitializer()-getType())) {
 Out  { 0 };
   } else {
 // Just print it out normally.
@@ -987,7 +1030,7 @@
 
 
 /// printSymbolTable - Run through symbol table looking for type names.  If a
-/// type name is found, emit it's declaration...
+/// type name is found, emit its declaration...
 ///
 void CWriter::printModuleTypes(const SymbolTable ST) {
   // We are only interested in the type plane of the symbol table.
@@ -1035,6 +1078,9 @@
 
 // Push the struct onto the stack and recursively push all structs
 // this one depends on.
+//
+// TODO:  Make this work properly with packed types
+//
 void CWriter::printContainedStructs(const Type *Ty,
 std::setconst StructType* 
StructPrinted){
   // Don't walk through pointers.
@@ -1055,7 +1101,6 @@
 }
   }
 }
-
 
 void CWriter::printFunctionSignature(const Function *F, bool Prototype) {
   if (F-hasInternalLinkage()) Out  static ;



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

2006-01-19 Thread Robert L. Bocchino Jr.


Changes in directory llvm/lib/Transforms/Utils:

Local.cpp updated: 1.51 - 1.52
---
Log message:

ConstantFoldLoadThroughGEPConstantExpr wasn't handling pointers to
packed types correctly.



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

 Local.cpp |   31 ++-
 1 files changed, 22 insertions(+), 9 deletions(-)


Index: llvm/lib/Transforms/Utils/Local.cpp
diff -u llvm/lib/Transforms/Utils/Local.cpp:1.51 
llvm/lib/Transforms/Utils/Local.cpp:1.52
--- llvm/lib/Transforms/Utils/Local.cpp:1.51Tue Jan 17 14:07:07 2006
+++ llvm/lib/Transforms/Utils/Local.cpp Thu Jan 19 17:53:23 2006
@@ -267,16 +267,29 @@
 return 0;
   }
 } else if (ConstantInt *CI = dyn_castConstantInt(I.getOperand())) {
-  const ArrayType *ATy = castArrayType(*I);
-  if ((uint64_t)CI-getRawValue() = ATy-getNumElements()) return 0;
-  if (ConstantArray *CA = dyn_castConstantArray(C))
-C = CA-getOperand((unsigned)CI-getRawValue());
-  else if (isaConstantAggregateZero(C))
-C = Constant::getNullValue(ATy-getElementType());
-  else if (isaUndefValue(C))
-C = UndefValue::get(ATy-getElementType());
-  else
+  if (const ArrayType *ATy = dyn_castArrayType(*I)) {
+if ((uint64_t)CI-getRawValue() = ATy-getNumElements()) return 0;
+if (ConstantArray *CA = dyn_castConstantArray(C))
+  C = CA-getOperand((unsigned)CI-getRawValue());
+else if (isaConstantAggregateZero(C))
+  C = Constant::getNullValue(ATy-getElementType());
+else if (isaUndefValue(C))
+  C = UndefValue::get(ATy-getElementType());
+else
+  return 0;
+  } else if (const PackedType *PTy = dyn_castPackedType(*I)) {
+if ((uint64_t)CI-getRawValue() = PTy-getNumElements()) return 0;
+if (ConstantPacked *CP = dyn_castConstantPacked(C))
+  C = CP-getOperand((unsigned)CI-getRawValue());
+else if (isaConstantAggregateZero(C))
+  C = Constant::getNullValue(PTy-getElementType());
+else if (isaUndefValue(C))
+  C = UndefValue::get(PTy-getElementType());
+else
+  return 0;
+  } else {
 return 0;
+  }
 } else {
   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/VMCore/ConstantFolding.cpp ConstantFolding.h Constants.cpp Instruction.cpp Instructions.cpp Verifier.cpp

2006-01-17 Thread Robert L. Bocchino Jr.


Changes in directory llvm/lib/VMCore:

ConstantFolding.cpp updated: 1.82 - 1.83
ConstantFolding.h updated: 1.46 - 1.47
Constants.cpp updated: 1.144 - 1.145
Instruction.cpp updated: 1.49 - 1.50
Instructions.cpp updated: 1.30 - 1.31
Verifier.cpp updated: 1.143 - 1.144
---
Log message:

VMCore support for the insertelement operation.



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

 ConstantFolding.cpp |   57 
 ConstantFolding.h   |3 ++
 Constants.cpp   |   49 +---
 Instruction.cpp |1 
 Instructions.cpp|   25 --
 Verifier.cpp|   21 +++
 6 files changed, 147 insertions(+), 9 deletions(-)


Index: llvm/lib/VMCore/ConstantFolding.cpp
diff -u llvm/lib/VMCore/ConstantFolding.cpp:1.82 
llvm/lib/VMCore/ConstantFolding.cpp:1.83
--- llvm/lib/VMCore/ConstantFolding.cpp:1.82Tue Jan 10 14:03:46 2006
+++ llvm/lib/VMCore/ConstantFolding.cpp Tue Jan 17 14:07:22 2006
@@ -734,6 +734,63 @@
   return 0;
 }
 
+Constant *llvm::ConstantFoldInsertElementInstruction(const Constant *Val,
+ const Constant *Elt,
+ const Constant *Idx) {
+  const ConstantUInt *CIdx = dyn_castConstantUInt(Idx);
+  if (!CIdx) return 0;
+  unsigned idxVal = CIdx-getValue();
+  if (const UndefValue *UVal = dyn_castUndefValue(Val)) {
+// Insertion of scalar constant into packed undef
+// Optimize away insertion of undef
+if (isaUndefValue(Elt))
+  return const_castConstant*(Val);
+// Otherwise break the aggregate undef into multiple undefs and do
+// the insertion
+unsigned numOps = 
+  castPackedType(Val-getType())-getNumElements();
+std::vectorConstant* Ops; 
+Ops.reserve(numOps);
+for (unsigned i = 0; i  numOps; ++i) {
+  const Constant *Op =
+(i == idxVal) ? Elt : UndefValue::get(Elt-getType());
+  Ops.push_back(const_castConstant*(Op));
+}
+return ConstantPacked::get(Ops);
+  }
+  if (const ConstantAggregateZero *CVal =
+  dyn_castConstantAggregateZero(Val)) {
+// Insertion of scalar constant into packed aggregate zero
+// Optimize away insertion of zero
+if (Elt-isNullValue())
+  return const_castConstant*(Val);
+// Otherwise break the aggregate zero into multiple zeros and do
+// the insertion
+unsigned numOps = 
+  castPackedType(Val-getType())-getNumElements();
+std::vectorConstant* Ops; 
+Ops.reserve(numOps);
+for (unsigned i = 0; i  numOps; ++i) {
+  const Constant *Op =
+(i == idxVal) ? Elt : Constant::getNullValue(Elt-getType());
+  Ops.push_back(const_castConstant*(Op));
+}
+return ConstantPacked::get(Ops);
+  }
+  if (const ConstantPacked *CVal = dyn_castConstantPacked(Val)) {
+// Insertion of scalar constant into packed constant
+std::vectorConstant* Ops; 
+Ops.reserve(CVal-getNumOperands());
+for (unsigned i = 0; i  CVal-getNumOperands(); ++i) {
+  const Constant *Op =
+(i == idxVal) ? Elt : castConstant(CVal-getOperand(i));
+  Ops.push_back(const_castConstant*(Op));
+}
+return ConstantPacked::get(Ops);
+  }
+  return 0;
+}
+
 /// isZeroSizedType - This type is zero sized if its an array or structure of
 /// zero sized types.  The only leaf zero sized type is an empty structure.
 static bool isMaybeZeroSizedType(const Type *Ty) {


Index: llvm/lib/VMCore/ConstantFolding.h
diff -u llvm/lib/VMCore/ConstantFolding.h:1.46 
llvm/lib/VMCore/ConstantFolding.h:1.47
--- llvm/lib/VMCore/ConstantFolding.h:1.46  Tue Jan 10 14:03:46 2006
+++ llvm/lib/VMCore/ConstantFolding.h   Tue Jan 17 14:07:22 2006
@@ -33,6 +33,9 @@
   const Constant *V2);
   Constant *ConstantFoldExtractElementInstruction(const Constant *Val,
   const Constant *Idx);
+  Constant *ConstantFoldInsertElementInstruction(const Constant *Val,
+ const Constant *Elt,
+ const Constant *Idx);
   Constant *ConstantFoldBinaryInstruction(unsigned Opcode, const Constant *V1,
   const Constant *V2);
   Constant *ConstantFoldGetElementPtr(const Constant *C,


Index: llvm/lib/VMCore/Constants.cpp
diff -u llvm/lib/VMCore/Constants.cpp:1.144 llvm/lib/VMCore/Constants.cpp:1.145
--- llvm/lib/VMCore/Constants.cpp:1.144 Tue Jan 10 14:03:46 2006
+++ llvm/lib/VMCore/Constants.cpp   Tue Jan 17 14:07:22 2006
@@ -347,8 +347,9 @@
   }
 };
 
-/// ExtractElementConstantExpr - This class is private to Constants.cpp, and 
is used
-/// behind the scenes to implement extractelement constant exprs.
+/// ExtractElementConstantExpr - This class is private to
+/// Constants.cpp, and is used behind the scenes to implement
+/// extractelement constant exprs.
 class 

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

2006-01-17 Thread Robert L. Bocchino Jr.


Changes in directory llvm/lib/Transforms/Scalar:

LowerPacked.cpp updated: 1.7 - 1.8
SCCP.cpp updated: 1.126 - 1.127
---
Log message:

Lowerpacked and SCCP support for the insertelement operation.



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

 LowerPacked.cpp |   53 +
 SCCP.cpp|   21 +
 2 files changed, 66 insertions(+), 8 deletions(-)


Index: llvm/lib/Transforms/Scalar/LowerPacked.cpp
diff -u llvm/lib/Transforms/Scalar/LowerPacked.cpp:1.7 
llvm/lib/Transforms/Scalar/LowerPacked.cpp:1.8
--- llvm/lib/Transforms/Scalar/LowerPacked.cpp:1.7  Tue Jan 10 13:05:05 2006
+++ llvm/lib/Transforms/Scalar/LowerPacked.cpp  Tue Jan 17 14:06:55 2006
@@ -61,8 +61,12 @@
 
/// @brief Lowers packed extractelement instructions.
/// @param EI the extractelement operator to convert
-   void visitExtractElementInst(ExtractElementInst EI);
+   void visitExtractElementInst(ExtractElementInst EE);
 
+   /// @brief Lowers packed insertelement instructions.
+   /// @param EI the insertelement operator to convert
+   void visitInsertElementInst(InsertElementInst IE);
+
/// This function asserts if the instruction is a PackedType but
/// is handled by another function.
///
@@ -345,22 +349,55 @@
   if (ConstantUInt *C = dyn_castConstantUInt(op1)) {
 EI.replaceAllUsesWith(op0Vals[C-getValue()]);
   } else {
-AllocaInst *alloca = new AllocaInst(PTy-getElementType(),
-   ConstantUInt::get(Type::UIntTy, 
PTy-getNumElements()),
-   EI.getName() + .alloca, 
(EI.getParent()-getParent()-getEntryBlock().front()));
+AllocaInst *alloca = 
+  new AllocaInst(PTy-getElementType(),
+ ConstantUInt::get(Type::UIntTy, PTy-getNumElements()),
+ EI.getName() + .alloca, 
+EI.getParent()-getParent()-getEntryBlock().begin());
 for (unsigned i = 0; i  PTy-getNumElements(); ++i) {
-  GetElementPtrInst *GEP = new GetElementPtrInst(alloca, 
ConstantUInt::get(Type::UIntTy, i),
-store.ge, EI);
+  GetElementPtrInst *GEP = 
+new GetElementPtrInst(alloca, ConstantUInt::get(Type::UIntTy, i),
+  store.ge, EI);
   new StoreInst(op0Vals[i], GEP, EI);
 }
-GetElementPtrInst *GEP = new GetElementPtrInst(alloca, op1,
-  EI.getName() + .ge, EI);
+GetElementPtrInst *GEP = 
+  new GetElementPtrInst(alloca, op1, EI.getName() + .ge, EI);
 LoadInst *load = new LoadInst(GEP, EI.getName() + .load, EI);
 EI.replaceAllUsesWith(load);
   }
 
   Changed = true;
   instrsToRemove.push_back(EI);
+}
+
+void LowerPacked::visitInsertElementInst(InsertElementInst IE)
+{
+  std::vectorValue* Vals = getValues(IE.getOperand(0));
+  Value *Elt = IE.getOperand(1);
+  Value *Idx = IE.getOperand(2);
+  std::vectorValue* result;
+  result.reserve(Vals.size());
+
+  if (ConstantUInt *C = dyn_castConstantUInt(Idx)) {
+unsigned idxVal = C-getValue();
+for (unsigned i = 0; i != Vals.size(); ++i) {
+  result.push_back(i == idxVal ? Elt : Vals[i]);
+}
+  } else {
+for (unsigned i = 0; i != Vals.size(); ++i) {
+  SetCondInst *setcc =
+new SetCondInst(Instruction::SetEQ, Idx, 
+ConstantUInt::get(Type::UIntTy, i),
+setcc, IE);
+  SelectInst *select =
+new SelectInst(setcc, Elt, Vals[i], select, IE);
+  result.push_back(select);
+}
+  }
+
+  setValues(IE, result);
+  Changed = true;
+  instrsToRemove.push_back(IE);
 }
 
 bool LowerPacked::runOnFunction(Function F)


Index: llvm/lib/Transforms/Scalar/SCCP.cpp
diff -u llvm/lib/Transforms/Scalar/SCCP.cpp:1.126 
llvm/lib/Transforms/Scalar/SCCP.cpp:1.127
--- llvm/lib/Transforms/Scalar/SCCP.cpp:1.126   Tue Jan 10 13:05:05 2006
+++ llvm/lib/Transforms/Scalar/SCCP.cpp Tue Jan 17 14:06:55 2006
@@ -323,6 +323,7 @@
   void visitBinaryOperator(Instruction I);
   void visitShiftInst(ShiftInst I) { visitBinaryOperator(I); }
   void visitExtractElementInst(ExtractElementInst I);
+  void visitInsertElementInst(InsertElementInst I);
 
   // Instructions that cannot be folded away...
   void visitStoreInst (Instruction I);
@@ -738,6 +739,26 @@
   else if(ValState.isConstant()  IdxState.isConstant())
 markConstant(I, ConstantExpr::getExtractElement(ValState.getConstant(),
  IdxState.getConstant()));
+}
+
+void SCCPSolver::visitInsertElementInst(InsertElementInst I) {
+  LatticeVal ValState = getValueState(I.getOperand(0));
+  LatticeVal EltState = getValueState(I.getOperand(1));
+  LatticeVal IdxState = getValueState(I.getOperand(2));
+
+  if (ValState.isOverdefined() || EltState.isOverdefined() ||
+  IdxState.isOverdefined())
+markOverdefined(I);
+  else if(ValState.isConstant()  

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

2006-01-17 Thread Robert L. Bocchino Jr.


Changes in directory llvm/lib/Transforms/Utils:

Local.cpp updated: 1.50 - 1.51
---
Log message:

Constant folding support for the insertelement operation.



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

 Local.cpp |3 +++
 1 files changed, 3 insertions(+)


Index: llvm/lib/Transforms/Utils/Local.cpp
diff -u llvm/lib/Transforms/Utils/Local.cpp:1.50 
llvm/lib/Transforms/Utils/Local.cpp:1.51
--- llvm/lib/Transforms/Utils/Local.cpp:1.50Mon Jan 16 15:12:35 2006
+++ llvm/lib/Transforms/Utils/Local.cpp Tue Jan 17 14:07:07 2006
@@ -104,6 +104,9 @@
 return 0;
   case Instruction::ExtractElement:
 return ConstantExpr::getExtractElement(Op0, Op1);
+  case Instruction::InsertElement:
+if (Constant *Op2 = dyn_castConstant(I-getOperand(2)))
+  return ConstantExpr::getInsertElement(Op0, Op1, Op2);
   case Instruction::GetElementPtr:
 std::vectorConstant* IdxList;
 IdxList.reserve(I-getNumOperands()-1);



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


[llvm-commits] CVS: llvm/docs/LangRef.html

2006-01-15 Thread Robert L. Bocchino Jr.


Changes in directory llvm/docs:

LangRef.html updated: 1.126 - 1.127
---
Log message:

Added spec for insertelement operation.


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

 LangRef.html |   57 +++--
 1 files changed, 55 insertions(+), 2 deletions(-)


Index: llvm/docs/LangRef.html
diff -u llvm/docs/LangRef.html:1.126 llvm/docs/LangRef.html:1.127
--- llvm/docs/LangRef.html:1.126Fri Jan 13 17:26:38 2006
+++ llvm/docs/LangRef.html  Sun Jan 15 14:48:27 2006
@@ -101,6 +101,7 @@
   lia href=#i_cast'ttcast .. to/tt' Instruction/a/li
   lia href=#i_select'ttselect/tt' Instruction/a/li
   lia href=#i_extractelement'ttextractelement/tt' 
Instruction/a/li
+  lia href=#i_insertelement'ttinsertelement/tt' 
Instruction/a/li
   lia href=#i_call'ttcall/tt'  Instruction/a/li
   lia href=#i_va_arg'ttva_arg/tt'  Instruction/a/li
 /ol
@@ -1099,6 +1100,11 @@
   ddPerform the a href=#i_extractelementextractelement
   operation/a on constants.
 
+  dtbttinsertelement ( VAL, ELT, IDX )/tt/b/dt
+
+  ddPerform the a href=#i_insertelementinsertelement
+  operation/a on constants.
+
   dtbttOPCODE ( LHS, RHS )/tt/b/dt
 
   ddPerform the specified operation of the LHS and RHS constants. OPCODE may 
@@ -2261,7 +2267,7 @@
 
 p
 The 'ttextractelement/tt' instruction extracts a single scalar
-element from a vector at a specified index.
+element from a packed vector at a specified index.
 /p
 
 
@@ -2292,6 +2298,53 @@
 
 !-- ___ 
--
 div class=doc_subsubsection
+   a name=i_insertelement'ttinsertelement/tt' Instruction/a
+/div
+
+div class=doc_text
+
+h5Syntax:/h5
+
+pre
+  lt;resultgt; = insertelement lt;n x lt;tygt;gt; lt;valgt;, 
lt;tygt; lt;eltgt, uint lt;idxgt;i; yields lt;n x 
lt;tygt;gt;/i
+/pre
+
+h5Overview:/h5
+
+p
+The 'ttinsertelement/tt' instruction inserts a scalar
+element into a packed vector at a specified index.
+/p
+
+
+h5Arguments:/h5
+
+p
+The first operand of an 'ttinsertelement/tt' instruction is a
+value of a href=#t_packedpacked/a type.  The second operand is a
+scalar value whose type must equal the element type of the first
+operand.  The third operand is an index indicating the position at
+which to insert the value.  The index may be a variable./p
+
+h5Semantics:/h5
+
+p
+The result is a packed vector of the same type as ttval/tt.  Its
+element values are those of ttval/tt except at position
+ttidx/tt, where it gets the value ttelt/tt.  If ttidx/tt
+exceeds the length of ttval/tt, the results are undefined.
+/p
+
+h5Example:/h5
+
+pre
+  %result = insertelement lt;4 x intgt; %vec, int 1, uint 0i; yields 
lt;4 x intgt;/i
+/pre
+/div
+
+
+!-- ___ 
--
+div class=doc_subsubsection
   a name=i_call'ttcall/tt' Instruction/a
 /div
 
@@ -3585,7 +3638,7 @@
 
   a href=mailto:[EMAIL PROTECTED]Chris Lattner/abr
   a href=http://llvm.cs.uiuc.edu;The LLVM Compiler Infrastructure/abr
-  Last modified: $Date: 2006/01/13 23:26:38 $
+  Last modified: $Date: 2006/01/15 20:48:27 $
 /address
 /body
 /html



___
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

2006-01-13 Thread Robert L. Bocchino Jr.


Changes in directory llvm/lib/Transforms/Scalar:

InstructionCombining.cpp updated: 1.413 - 1.414
---
Log message:

Added instcombine support for extractelement.


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

 InstructionCombining.cpp |   55 ++-
 1 files changed, 54 insertions(+), 1 deletion(-)


Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp
diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.413 
llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.414
--- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.413   Fri Jan 13 
15:28:09 2006
+++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp Fri Jan 13 16:48:06 2006
@@ -135,6 +135,7 @@
 Instruction *visitStoreInst(StoreInst SI);
 Instruction *visitBranchInst(BranchInst BI);
 Instruction *visitSwitchInst(SwitchInst SI);
+Instruction *visitExtractElementInst(ExtractElementInst EI);
 
 // visitInstruction - Specify what to return for unhandled instructions...
 Instruction *visitInstruction(Instruction I) { return 0; }
@@ -5877,6 +5878,58 @@
   return 0;
 }
 
+Instruction *InstCombiner::visitExtractElementInst(ExtractElementInst EI) {
+  if (ConstantAggregateZero *C = 
+  dyn_castConstantAggregateZero(EI.getOperand(0))) {
+// If packed val is constant 0, replace extract with scalar 0
+const Type *Ty = castPackedType(C-getType())-getElementType();
+EI.replaceAllUsesWith(Constant::getNullValue(Ty));
+return ReplaceInstUsesWith(EI, Constant::getNullValue(Ty));
+  }
+  if (ConstantPacked *C = dyn_castConstantPacked(EI.getOperand(0))) {
+// If packed val is constant with uniform operands, replace EI
+// with that operand
+Constant *op0 = castConstant(C-getOperand(0));
+for (unsigned i = 1; i  C-getNumOperands(); ++i)
+  if (C-getOperand(i) != op0) return 0;
+return ReplaceInstUsesWith(EI, op0);
+  }
+  if (Instruction *I = dyn_castInstruction(EI.getOperand(0)))
+if (I-hasOneUse()) {
+  // Push extractelement into predecessor operation if legal and
+  // profitable to do so
+  if (BinaryOperator *BO = dyn_castBinaryOperator(I)) {
+if (!isaConstant(BO-getOperand(0)) 
+!isaConstant(BO-getOperand(1)))
+  return 0;
+ExtractElementInst *newEI0 = 
+  new ExtractElementInst(BO-getOperand(0), EI.getOperand(1),
+ EI.getName());
+ExtractElementInst *newEI1 =
+  new ExtractElementInst(BO-getOperand(1), EI.getOperand(1),
+ EI.getName());
+InsertNewInstBefore(newEI0, EI);
+InsertNewInstBefore(newEI1, EI);
+return BinaryOperator::create(BO-getOpcode(), newEI0, newEI1);
+  }
+  switch(I-getOpcode()) {
+  case Instruction::Load: {
+Value *Ptr = InsertCastBefore(I-getOperand(0),
+  PointerType::get(EI.getType()), EI);
+GetElementPtrInst *GEP = 
+  new GetElementPtrInst(Ptr, EI.getOperand(1),
+I-getName() + .gep);
+InsertNewInstBefore(GEP, EI);
+return new LoadInst(GEP);
+  }
+  default:
+return 0;
+  }
+}
+  return 0;
+}
+
+
 void InstCombiner::removeFromWorkList(Instruction *I) {
   WorkList.erase(std::remove(WorkList.begin(), WorkList.end(), I),
  WorkList.end());
@@ -6075,7 +6128,7 @@
   WorkList.push_back(OpI);
 
   // Instructions may end up in the worklist more than once.  Erase all
-  // occurrances of this instruction.
+  // occurrences of this instruction.
   removeFromWorkList(I);
   I-eraseFromParent();
 } else {



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


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

2006-01-10 Thread Robert L. Bocchino Jr.


Changes in directory llvm/lib/Bytecode/Reader:

Reader.cpp updated: 1.175 - 1.176
---
Log message:

Added bytecode support for the extractelement operation.



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

 Reader.cpp |   13 +
 1 files changed, 13 insertions(+)


Index: llvm/lib/Bytecode/Reader/Reader.cpp
diff -u llvm/lib/Bytecode/Reader/Reader.cpp:1.175 
llvm/lib/Bytecode/Reader/Reader.cpp:1.176
--- llvm/lib/Bytecode/Reader/Reader.cpp:1.175   Sat Nov 12 12:31:54 2005
+++ llvm/lib/Bytecode/Reader/Reader.cpp Tue Jan 10 13:04:39 2006
@@ -717,6 +717,13 @@
 Result = new VAArgInst(foo, getSanitizedType(Oprnds[1]));
 break;
   }
+  case Instruction::ExtractElement: {
+if (Oprnds.size() != 2)
+  throw std::string(Invalid extractelement instruction!);
+Result = new ExtractElementInst(getValue(iType, Oprnds[0]), 
+getValue(Type::UIntTyID, Oprnds[1]));
+break;
+  }
   case Instruction::Cast:
 Result = new CastInst(getValue(iType, Oprnds[0]),
   getSanitizedType(Oprnds[1]));
@@ -1439,6 +1446,12 @@
 error(Select instruction must have three arguments.);
   Constant* Result = ConstantExpr::getSelect(ArgVec[0], ArgVec[1],
  ArgVec[2]);
+  if (Handler) Handler-handleConstantExpression(Opcode, ArgVec, Result);
+  return Result;
+} else if (Opcode == Instruction::ExtractElement) {
+  if (ArgVec.size() != 2)
+error(ExtractElement instruction must have two arguments.);
+  Constant* Result = ConstantExpr::getExtractElement(ArgVec[0], ArgVec[1]);
   if (Handler) Handler-handleConstantExpression(Opcode, ArgVec, Result);
   return Result;
 } else {// All other 2-operand expressions



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

2006-01-10 Thread Robert L. Bocchino Jr.


Changes in directory llvm/lib/Transforms/Scalar:

LowerPacked.cpp updated: 1.6 - 1.7
SCCP.cpp updated: 1.125 - 1.126
---
Log message:

Added lower packed support for the extractelement operation.



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

 LowerPacked.cpp |   31 +++
 SCCP.cpp|   12 
 2 files changed, 43 insertions(+)


Index: llvm/lib/Transforms/Scalar/LowerPacked.cpp
diff -u llvm/lib/Transforms/Scalar/LowerPacked.cpp:1.6 
llvm/lib/Transforms/Scalar/LowerPacked.cpp:1.7
--- llvm/lib/Transforms/Scalar/LowerPacked.cpp:1.6  Mon Dec 26 07:48:44 2005
+++ llvm/lib/Transforms/Scalar/LowerPacked.cpp  Tue Jan 10 13:05:05 2006
@@ -59,6 +59,10 @@
/// @param SELI the select operator to convert
void visitSelectInst(SelectInst SELI);
 
+   /// @brief Lowers packed extractelement instructions.
+   /// @param EI the extractelement operator to convert
+   void visitExtractElementInst(ExtractElementInst EI);
+
/// This function asserts if the instruction is a PackedType but
/// is handled by another function.
///
@@ -330,6 +334,33 @@
   Changed = true;
   instrsToRemove.push_back(SELI);
}
+}
+
+void LowerPacked::visitExtractElementInst(ExtractElementInst EI)
+{
+  std::vectorValue* op0Vals = getValues(EI.getOperand(0));
+  const PackedType *PTy = castPackedType(EI.getOperand(0)-getType());
+  Value *op1 = EI.getOperand(1);
+
+  if (ConstantUInt *C = dyn_castConstantUInt(op1)) {
+EI.replaceAllUsesWith(op0Vals[C-getValue()]);
+  } else {
+AllocaInst *alloca = new AllocaInst(PTy-getElementType(),
+   ConstantUInt::get(Type::UIntTy, 
PTy-getNumElements()),
+   EI.getName() + .alloca, 
(EI.getParent()-getParent()-getEntryBlock().front()));
+for (unsigned i = 0; i  PTy-getNumElements(); ++i) {
+  GetElementPtrInst *GEP = new GetElementPtrInst(alloca, 
ConstantUInt::get(Type::UIntTy, i),
+store.ge, EI);
+  new StoreInst(op0Vals[i], GEP, EI);
+}
+GetElementPtrInst *GEP = new GetElementPtrInst(alloca, op1,
+  EI.getName() + .ge, EI);
+LoadInst *load = new LoadInst(GEP, EI.getName() + .load, EI);
+EI.replaceAllUsesWith(load);
+  }
+
+  Changed = true;
+  instrsToRemove.push_back(EI);
 }
 
 bool LowerPacked::runOnFunction(Function F)


Index: llvm/lib/Transforms/Scalar/SCCP.cpp
diff -u llvm/lib/Transforms/Scalar/SCCP.cpp:1.125 
llvm/lib/Transforms/Scalar/SCCP.cpp:1.126
--- llvm/lib/Transforms/Scalar/SCCP.cpp:1.125   Mon Sep 26 00:28:52 2005
+++ llvm/lib/Transforms/Scalar/SCCP.cpp Tue Jan 10 13:05:05 2006
@@ -322,6 +322,7 @@
   void visitSelectInst(SelectInst I);
   void visitBinaryOperator(Instruction I);
   void visitShiftInst(ShiftInst I) { visitBinaryOperator(I); }
+  void visitExtractElementInst(ExtractElementInst I);
 
   // Instructions that cannot be folded away...
   void visitStoreInst (Instruction I);
@@ -726,6 +727,17 @@
 markConstant(IV, I, ConstantExpr::get(I.getOpcode(), 
V1State.getConstant(),
V2State.getConstant()));
   }
+}
+
+void SCCPSolver::visitExtractElementInst(ExtractElementInst I) {
+  LatticeVal ValState = getValueState(I.getOperand(0));
+  LatticeVal IdxState = getValueState(I.getOperand(1));
+
+  if (ValState.isOverdefined() || IdxState.isOverdefined())
+markOverdefined(I);
+  else if(ValState.isConstant()  IdxState.isConstant())
+markConstant(I, ConstantExpr::getExtractElement(ValState.getConstant(),
+ IdxState.getConstant()));
 }
 
 // Handle getelementptr instructions... if all operands are constants then we



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


[llvm-commits] CVS: llvm/include/llvm/Constants.h Instruction.def Instructions.h

2006-01-10 Thread Robert L. Bocchino Jr.


Changes in directory llvm/include/llvm:

Constants.h updated: 1.75 - 1.76
Instruction.def updated: 1.16 - 1.17
Instructions.h updated: 1.29 - 1.30
---
Log message:

Added an instruction and constant expression for the extractelement
operation.


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

 Constants.h |6 ++
 Instruction.def |3 ++-
 Instructions.h  |   46 ++
 3 files changed, 54 insertions(+), 1 deletion(-)


Index: llvm/include/llvm/Constants.h
diff -u llvm/include/llvm/Constants.h:1.75 llvm/include/llvm/Constants.h:1.76
--- llvm/include/llvm/Constants.h:1.75  Tue Oct  4 13:12:13 2005
+++ llvm/include/llvm/Constants.h   Tue Jan 10 13:03:58 2006
@@ -521,6 +521,8 @@
Constant *C1, Constant *C2, Constant *C3);
   static Constant *getGetElementPtrTy(const Type *Ty, Constant *C,
   const std::vectorValue* IdxList);
+  static Constant *getExtractElementTy(const Type *Ty, Constant *Val,
+   Constant *Idx);
 
 public:
   // Static methods to construct a ConstantExpr of different kinds.  Note that
@@ -587,6 +589,10 @@
 const std::vectorConstant* IdxList);
   static Constant *getGetElementPtr(Constant *C,
 const std::vectorValue* IdxList);
+
+  /// Extractelement form.
+  ///
+  static Constant *getExtractElement(Constant *Val, Constant *Idx);
 
   /// isNullValue - Return true if this is the value that would be returned by
   /// getNullValue.


Index: llvm/include/llvm/Instruction.def
diff -u llvm/include/llvm/Instruction.def:1.16 
llvm/include/llvm/Instruction.def:1.17
--- llvm/include/llvm/Instruction.def:1.16  Fri Jun 24 13:17:33 2005
+++ llvm/include/llvm/Instruction.def   Tue Jan 10 13:03:58 2006
@@ -135,7 +135,8 @@
 HANDLE_OTHER_INST(35, UserOp1, Instruction)  // May be used internally in a 
pass
 HANDLE_OTHER_INST(36, UserOp2, Instruction)
 HANDLE_OTHER_INST(37, VAArg  , VAArgInst  )  // vaarg instruction
-  LAST_OTHER_INST(37)
+HANDLE_OTHER_INST(38, ExtractElement, ExtractElementInst)  // extract packed 
element
+  LAST_OTHER_INST(38)
 
 #undef  FIRST_TERM_INST
 #undef HANDLE_TERM_INST


Index: llvm/include/llvm/Instructions.h
diff -u llvm/include/llvm/Instructions.h:1.29 
llvm/include/llvm/Instructions.h:1.30
--- llvm/include/llvm/Instructions.h:1.29   Sat Nov  5 15:58:30 2005
+++ llvm/include/llvm/Instructions.hTue Jan 10 13:03:58 2006
@@ -718,6 +718,52 @@
 };
 
 
//===--===//
+//ExtractElementInst Class
+//===--===//
+
+/// ExtractElementInst - This instruction extracts a single (scalar)
+/// element from a PackedType value
+///
+class ExtractElementInst : public Instruction {
+  Use Ops[2];
+  ExtractElementInst(const ExtractElementInst EI) : 
+Instruction(EI.getType(), ExtractElement, Ops, 2) {
+Ops[0].init(EI.Ops[0], this);
+Ops[1].init(EI.Ops[1], this);
+  }
+
+public:
+  ExtractElementInst(Value *Val, Value *Index,
+   const std::string Name = , Instruction *InsertBefore = 0);
+  ExtractElementInst(Value *Val, Value *Index,
+   const std::string Name, BasicBlock *InsertAtEnd);
+
+  virtual ExtractElementInst *clone() const;
+
+  virtual bool mayWriteToMemory() const { return false; }
+
+  /// Transparently provide more efficient getOperand methods.
+  Value *getOperand(unsigned i) const {
+assert(i  2  getOperand() out of range!);
+return Ops[i];
+  }
+  void setOperand(unsigned i, Value *Val) {
+assert(i  2  setOperand() out of range!);
+Ops[i] = Val;
+  }
+  unsigned getNumOperands() const { return 2; }
+
+  // Methods for support type inquiry through isa, cast, and dyn_cast:
+  static inline bool classof(const ExtractElementInst *) { return true; }
+  static inline bool classof(const Instruction *I) {
+return I-getOpcode() == Instruction::ExtractElement;
+  }
+  static inline bool classof(const Value *V) {
+return isaInstruction(V)  classof(castInstruction(V));
+  }
+};
+
+//===--===//
 //   PHINode Class
 
//===--===//
 



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


[llvm-commits] CVS: llvm/lib/VMCore/Constants.cpp Instruction.cpp Instructions.cpp Verifier.cpp

2006-01-10 Thread Robert L. Bocchino Jr.


Changes in directory llvm/lib/VMCore:

Constants.cpp updated: 1.142 - 1.143
Instruction.cpp updated: 1.48 - 1.49
Instructions.cpp updated: 1.29 - 1.30
Verifier.cpp updated: 1.136 - 1.137
---
Log message:

Added support for the extractelement operation.



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

 Constants.cpp|   38 ++
 Instruction.cpp  |1 +
 Instructions.cpp |   21 +
 Verifier.cpp |   13 +
 4 files changed, 73 insertions(+)


Index: llvm/lib/VMCore/Constants.cpp
diff -u llvm/lib/VMCore/Constants.cpp:1.142 llvm/lib/VMCore/Constants.cpp:1.143
--- llvm/lib/VMCore/Constants.cpp:1.142 Tue Jan  3 19:01:04 2006
+++ llvm/lib/VMCore/Constants.cpp   Tue Jan 10 13:05:24 2006
@@ -347,6 +347,19 @@
   }
 };
 
+/// ExtractElementConstantExpr - This class is private to Constants.cpp, and 
is used
+/// behind the scenes to implement extractelement constant exprs.
+class ExtractElementConstantExpr : public ConstantExpr {
+  Use Ops[2];
+public:
+  ExtractElementConstantExpr(Constant *C1, Constant *C2)
+: ConstantExpr(castPackedType(C1-getType())-getElementType(), 
+   Instruction::ExtractElement, Ops, 2) {
+Ops[0].init(C1, this);
+Ops[1].init(C2, this);
+  }
+};
+
 /// GetElementPtrConstantExpr - This class is private to Constants.cpp, and is
 /// used behind the scenes to implement getelementpr constant exprs.
 struct GetElementPtrConstantExpr : public ConstantExpr {
@@ -1141,6 +1154,8 @@
 return new BinaryConstantExpr(V.first, V.second[0], V.second[1]);
   if (V.first == Instruction::Select)
 return new SelectConstantExpr(V.second[0], V.second[1], V.second[2]);
+  if (V.first == Instruction::ExtractElement)
+return new ExtractElementConstantExpr(V.second[0], V.second[1]);
 
   assert(V.first == Instruction::GetElementPtr  Invalid ConstantExpr!);
 
@@ -1386,7 +1401,24 @@
   return getGetElementPtrTy(PointerType::get(Ty), C, IdxList);
 }
 
+Constant *ConstantExpr::getExtractElementTy(const Type *ReqTy, Constant *Val,
+Constant *Idx) {
+  // Look up the constant in the table first to ensure uniqueness
+  std::vectorConstant* ArgVec(1, Val);
+  ArgVec.push_back(Idx);
+  const ExprMapKeyType Key = 
std::make_pair(Instruction::ExtractElement,ArgVec);
+  return ExprConstants.getOrCreate(ReqTy, Key);
+}
 
+Constant *ConstantExpr::getExtractElement(Constant *Val, Constant *Idx) {
+  assert(isaPackedType(Val-getType()) 
+ Tried to create extractelement operation on non-packed type!);
+  assert(Idx-getType() == Type::UIntTy 
+ Index must be uint type!);
+  return 
getExtractElementTy(castPackedType(Val-getType())-getElementType(),
+ Val, Idx);
+}
+
 // destroyConstant - Remove the constant from the constant table...
 //
 void ConstantExpr::destroyConstant() {
@@ -1581,6 +1613,12 @@
 if (C2 == From) C2 = To;
 if (C3 == From) C3 = To;
 Replacement = ConstantExpr::getSelect(C1, C2, C3);
+  } else if (getOpcode() == Instruction::ExtractElement) {
+Constant *C1 = getOperand(0);
+Constant *C2 = getOperand(1);
+if (C1 == From) C1 = To;
+if (C2 == From) C2 = To;
+Replacement = ConstantExpr::getExtractElement(C1, C2);
   } else if (getNumOperands() == 2) {
 Constant *C1 = getOperand(0);
 Constant *C2 = getOperand(1);


Index: llvm/lib/VMCore/Instruction.cpp
diff -u llvm/lib/VMCore/Instruction.cpp:1.48 
llvm/lib/VMCore/Instruction.cpp:1.49
--- llvm/lib/VMCore/Instruction.cpp:1.48Mon Aug  8 00:21:50 2005
+++ llvm/lib/VMCore/Instruction.cpp Tue Jan 10 13:05:24 2006
@@ -120,6 +120,7 @@
   case Shl: return shl;
   case Shr: return shr;
   case VAArg:   return va_arg;
+  case ExtractElement: return extractelement;
 
   default: return Invalid operator ;
   }


Index: llvm/lib/VMCore/Instructions.cpp
diff -u llvm/lib/VMCore/Instructions.cpp:1.29 
llvm/lib/VMCore/Instructions.cpp:1.30
--- llvm/lib/VMCore/Instructions.cpp:1.29   Wed Dec 21 12:22:19 2005
+++ llvm/lib/VMCore/Instructions.cppTue Jan 10 13:05:24 2006
@@ -796,6 +796,26 @@
 }
 
 
//===--===//
+//   ExtractElementInst Implementation
+//===--===//
+
+ExtractElementInst::ExtractElementInst(Value *Val, Value *Index,
+ const std::string Name, Instruction *InsertBef)
+  : Instruction(castPackedType(Val-getType())-getElementType(),
+ExtractElement, Ops, 2, Name, InsertBef) {
+  Ops[0].init(Val, this);
+  Ops[1].init(Index, this);
+}
+
+ExtractElementInst::ExtractElementInst(Value *Val, Value *Index,
+ const std::string Name, BasicBlock *InsertAE)
+  : Instruction(castPackedType(Val-getType())-getElementType(),
+ExtractElement, Ops, 2, Name, InsertAE) {
+  

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

2006-01-10 Thread Robert L. Bocchino Jr.


Changes in directory llvm/utils/TableGen:

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

Added support for the extractelement operation.



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

 FileParser.cpp |  162 -
 1 files changed, 81 insertions(+), 81 deletions(-)


Index: llvm/utils/TableGen/FileParser.cpp
diff -u llvm/utils/TableGen/FileParser.cpp:1.9 
llvm/utils/TableGen/FileParser.cpp:1.10
--- llvm/utils/TableGen/FileParser.cpp:1.9  Fri Sep 30 01:09:50 2005
+++ llvm/utils/TableGen/FileParser.cpp  Tue Jan 10 13:05:34 2006
@@ -1,5 +1,5 @@
 
-/*  A Bison parser, made from /Users/sabre/llvm/utils/TableGen/FileParser.y
+/*  A Bison parser, made from 
/Users/bocchino/vllvm-checkin/src/utils/TableGen/FileParser.y
 by GNU Bison version 1.28  */
 
 #define YYBISON 1  /* Identify Bison output.  */
@@ -32,7 +32,7 @@
 #defineSTRVAL  275
 #defineCODEFRAGMENT276
 
-#line 14 /Users/sabre/llvm/utils/TableGen/FileParser.y
+#line 14 /Users/bocchino/vllvm-checkin/src/utils/TableGen/FileParser.y
 
 #include Record.h
 #include llvm/ADT/StringExtras.h
@@ -207,7 +207,7 @@
 using namespace llvm;
 
 
-#line 189 /Users/sabre/llvm/utils/TableGen/FileParser.y
+#line 189 /Users/bocchino/vllvm-checkin/src/utils/TableGen/FileParser.y
 typedef union {
   std::string*StrVal;
   int IntVal;
@@ -1005,7 +1005,7 @@
   switch (yyn) {
 
 case 1:
-#line 223 /Users/sabre/llvm/utils/TableGen/FileParser.y
+#line 223 /Users/bocchino/vllvm-checkin/src/utils/TableGen/FileParser.y
 {
 yyval.Rec = Records.getClass(*yyvsp[0].StrVal);
 if (yyval.Rec == 0) {
@@ -1016,97 +1016,97 @@
   ;
 break;}
 case 2:
-#line 234 /Users/sabre/llvm/utils/TableGen/FileParser.y
+#line 234 /Users/bocchino/vllvm-checkin/src/utils/TableGen/FileParser.y
 {   // string type
 yyval.Ty = new StringRecTy();
   ;
 break;}
 case 3:
-#line 236 /Users/sabre/llvm/utils/TableGen/FileParser.y
+#line 236 /Users/bocchino/vllvm-checkin/src/utils/TableGen/FileParser.y
 {   // bit type
 yyval.Ty = new BitRecTy();
   ;
 break;}
 case 4:
-#line 238 /Users/sabre/llvm/utils/TableGen/FileParser.y
+#line 238 /Users/bocchino/vllvm-checkin/src/utils/TableGen/FileParser.y
 {   // bitsx type
 yyval.Ty = new BitsRecTy(yyvsp[-1].IntVal);
   ;
 break;}
 case 5:
-#line 240 /Users/sabre/llvm/utils/TableGen/FileParser.y
+#line 240 /Users/bocchino/vllvm-checkin/src/utils/TableGen/FileParser.y
 {   // int type
 yyval.Ty = new IntRecTy();
   ;
 break;}
 case 6:
-#line 242 /Users/sabre/llvm/utils/TableGen/FileParser.y
+#line 242 /Users/bocchino/vllvm-checkin/src/utils/TableGen/FileParser.y
 {  // listx type
 yyval.Ty = new ListRecTy(yyvsp[-1].Ty);
   ;
 break;}
 case 7:
-#line 244 /Users/sabre/llvm/utils/TableGen/FileParser.y
+#line 244 /Users/bocchino/vllvm-checkin/src/utils/TableGen/FileParser.y
 {  // code type
 yyval.Ty = new CodeRecTy();
   ;
 break;}
 case 8:
-#line 246 /Users/sabre/llvm/utils/TableGen/FileParser.y
+#line 246 /Users/bocchino/vllvm-checkin/src/utils/TableGen/FileParser.y
 {   // dag type
 yyval.Ty = new DagRecTy();
   ;
 break;}
 case 9:
-#line 248 /Users/sabre/llvm/utils/TableGen/FileParser.y
+#line 248 /Users/bocchino/vllvm-checkin/src/utils/TableGen/FileParser.y
 {   // Record Type
 yyval.Ty = new RecordRecTy(yyvsp[0].Rec);
   ;
 break;}
 case 10:
-#line 252 /Users/sabre/llvm/utils/TableGen/FileParser.y
+#line 252 /Users/bocchino/vllvm-checkin/src/utils/TableGen/FileParser.y
 { yyval.IntVal = 0; ;
 break;}
 case 11:
-#line 252 /Users/sabre/llvm/utils/TableGen/FileParser.y
+#line 252 /Users/bocchino/vllvm-checkin/src/utils/TableGen/FileParser.y
 { yyval.IntVal = 1; ;
 break;}
 case 12:
-#line 254 /Users/sabre/llvm/utils/TableGen/FileParser.y
+#line 254 /Users/bocchino/vllvm-checkin/src/utils/TableGen/FileParser.y
 { yyval.Initializer = 0; ;
 break;}
 case 13:
-#line 254 /Users/sabre/llvm/utils/TableGen/FileParser.y
+#line 254 /Users/bocchino/vllvm-checkin/src/utils/TableGen/FileParser.y
 { yyval.Initializer = yyvsp[0].Initializer; ;
 break;}
 case 14:
-#line 256 /Users/sabre/llvm/utils/TableGen/FileParser.y
+#line 256 /Users/bocchino/vllvm-checkin/src/utils/TableGen/FileParser.y
 {
 yyval.Initializer = new IntInit(yyvsp[0].IntVal);
   ;
 break;}
 case 15:
-#line 258 /Users/sabre/llvm/utils/TableGen/FileParser.y
+#line 258 /Users/bocchino/vllvm-checkin/src/utils/TableGen/FileParser.y
 {
 yyval.Initializer = new StringInit(*yyvsp[0].StrVal);
 delete yyvsp[0].StrVal;
   ;
 break;}
 case 16:
-#line 261 /Users/sabre/llvm/utils/TableGen/FileParser.y
+#line 261 /Users/bocchino/vllvm-checkin/src/utils/TableGen/FileParser.y
 {
 yyval.Initializer = new CodeInit(*yyvsp[0].StrVal);
 delete yyvsp[0].StrVal;
   

[llvm-commits] CVS: llvm/docs/LangRef.html

2006-01-10 Thread Robert L. Bocchino Jr.


Changes in directory llvm/docs:

LangRef.html updated: 1.120 - 1.121
---
Log message:

Expanded the documentation for constant expressions to cover select
and extractelement.



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

 LangRef.html |   12 +++-
 1 files changed, 11 insertions(+), 1 deletion(-)


Index: llvm/docs/LangRef.html
diff -u llvm/docs/LangRef.html:1.120 llvm/docs/LangRef.html:1.121
--- llvm/docs/LangRef.html:1.120Thu Jan  5 11:37:02 2006
+++ llvm/docs/LangRef.html  Tue Jan 10 13:31:34 2006
@@ -1086,6 +1086,16 @@
   instruction, the index list may have zero or more indexes, which are required
   to make sense for the type of CSTPTR./dd
 
+  dtbttselect ( COND, VAL1, VAL2 )/tt/b/dt
+
+  ddPerform the a href=#i_selectselect operation/a on
+  constants.
+
+  dtbttextractelement ( VAL, IDX )/tt/b/dt
+
+  ddPerform the a href=#i_extractelementextractelement
+  operation/a on constants.
+
   dtbttOPCODE ( LHS, RHS )/tt/b/dt
 
   ddPerform the specified operation of the LHS and RHS constants. OPCODE may 
@@ -3473,7 +3483,7 @@
 
   a href=mailto:[EMAIL PROTECTED]Chris Lattner/abr
   a href=http://llvm.cs.uiuc.edu;The LLVM Compiler Infrastructure/abr
-  Last modified: $Date: 2006/01/05 17:37:02 $
+  Last modified: $Date: 2006/01/10 19:31:34 $
 /address
 /body
 /html



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


[llvm-commits] CVS: llvm/lib/VMCore/ConstantFolding.cpp ConstantFolding.h Constants.cpp

2006-01-10 Thread Robert L. Bocchino Jr.


Changes in directory llvm/lib/VMCore:

ConstantFolding.cpp updated: 1.81 - 1.82
ConstantFolding.h updated: 1.45 - 1.46
Constants.cpp updated: 1.143 - 1.144
---
Log message:

Added constant folding support for the extractelement operation.


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

 ConstantFolding.cpp |   10 ++
 ConstantFolding.h   |2 ++
 Constants.cpp   |2 ++
 3 files changed, 14 insertions(+)


Index: llvm/lib/VMCore/ConstantFolding.cpp
diff -u llvm/lib/VMCore/ConstantFolding.cpp:1.81 
llvm/lib/VMCore/ConstantFolding.cpp:1.82
--- llvm/lib/VMCore/ConstantFolding.cpp:1.81Thu Jan  5 01:49:30 2006
+++ llvm/lib/VMCore/ConstantFolding.cpp Tue Jan 10 14:03:46 2006
@@ -724,6 +724,16 @@
   return 0;
 }
 
+Constant *llvm::ConstantFoldExtractElementInstruction(const Constant *Val,
+  const Constant *Idx) {
+  if (const ConstantPacked *CVal = dyn_castConstantPacked(Val)) {
+if (const ConstantUInt *CIdx = dyn_castConstantUInt(Idx)) {
+  return const_castConstant*(CVal-getOperand(CIdx-getValue()));
+}
+  } 
+  return 0;
+}
+
 /// isZeroSizedType - This type is zero sized if its an array or structure of
 /// zero sized types.  The only leaf zero sized type is an empty structure.
 static bool isMaybeZeroSizedType(const Type *Ty) {


Index: llvm/lib/VMCore/ConstantFolding.h
diff -u llvm/lib/VMCore/ConstantFolding.h:1.45 
llvm/lib/VMCore/ConstantFolding.h:1.46
--- llvm/lib/VMCore/ConstantFolding.h:1.45  Thu Apr 21 18:46:51 2005
+++ llvm/lib/VMCore/ConstantFolding.h   Tue Jan 10 14:03:46 2006
@@ -31,6 +31,8 @@
   Constant *ConstantFoldSelectInstruction(const Constant *Cond,
   const Constant *V1,
   const Constant *V2);
+  Constant *ConstantFoldExtractElementInstruction(const Constant *Val,
+  const Constant *Idx);
   Constant *ConstantFoldBinaryInstruction(unsigned Opcode, const Constant *V1,
   const Constant *V2);
   Constant *ConstantFoldGetElementPtr(const Constant *C,


Index: llvm/lib/VMCore/Constants.cpp
diff -u llvm/lib/VMCore/Constants.cpp:1.143 llvm/lib/VMCore/Constants.cpp:1.144
--- llvm/lib/VMCore/Constants.cpp:1.143 Tue Jan 10 13:05:24 2006
+++ llvm/lib/VMCore/Constants.cpp   Tue Jan 10 14:03:46 2006
@@ -1403,6 +1403,8 @@
 
 Constant *ConstantExpr::getExtractElementTy(const Type *ReqTy, Constant *Val,
 Constant *Idx) {
+  if (Constant *FC = ConstantFoldExtractElementInstruction(Val, Idx))
+return FC;  // Fold a few common cases...
   // Look up the constant in the table first to ensure uniqueness
   std::vectorConstant* ArgVec(1, Val);
   ArgVec.push_back(Idx);



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


[llvm-commits] CVS: llvm/docs/WritingAnLLVMPass.html

2006-01-06 Thread Robert L. Bocchino Jr.


Changes in directory llvm/docs:

WritingAnLLVMPass.html updated: 1.42 - 1.43
---
Log message:

Fixed a typo; = 1 was missing.


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

 WritingAnLLVMPass.html |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)


Index: llvm/docs/WritingAnLLVMPass.html
diff -u llvm/docs/WritingAnLLVMPass.html:1.42 
llvm/docs/WritingAnLLVMPass.html:1.43
--- llvm/docs/WritingAnLLVMPass.html:1.42   Mon Nov 28 17:25:41 2005
+++ llvm/docs/WritingAnLLVMPass.htmlFri Jan  6 16:49:23 2006
@@ -177,7 +177,7 @@
 
 # Make the shared library become a loadable module so the tools can 
 # dlopen/dlsym on the resulting library.
-LOADABLE_MODULE
+LOADABLE_MODULE = 1
 
 # Include the makefile implementation stuff
 include $(LEVEL)/Makefile.common
@@ -1593,7 +1593,7 @@
 
   a href=mailto:[EMAIL PROTECTED]Chris Lattner/abr
   a href=http://llvm.cs.uiuc.edu;The LLVM Compiler Infrastructure/abr
-  Last modified: $Date: 2005/11/28 23:25:41 $
+  Last modified: $Date: 2006/01/06 22:49:23 $
 /address
 
 /body



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


[llvm-commits] CVS: llvm/projects/sample/lib/sample/Makefile

2006-01-06 Thread Robert L. Bocchino Jr.


Changes in directory llvm/projects/sample/lib/sample:

Makefile updated: 1.5 - 1.6
---
Log message:

Fixed Makefile so it does, indeed, build a dynamic library.


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

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


Index: llvm/projects/sample/lib/sample/Makefile
diff -u llvm/projects/sample/lib/sample/Makefile:1.5 
llvm/projects/sample/lib/sample/Makefile:1.6
--- llvm/projects/sample/lib/sample/Makefile:1.5Sat Oct 23 10:30:30 2004
+++ llvm/projects/sample/lib/sample/MakefileFri Jan  6 16:51:19 2006
@@ -9,7 +9,8 @@
 # Give the name of a library.  This will build a dynamic version.
 #
 LIBRARYNAME=sample
-#SHARED_LIBRARY=1
+SHARED_LIBRARY=1
+LOADABLE_MODULE=1
 #DONT_BUILD_RELINKED=1
 #ARCHIVE_LIBRARY=1
 



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


[llvm-commits] CVS: llvm/docs/LangRef.html

2006-01-05 Thread Robert L. Bocchino Jr.


Changes in directory llvm/docs:

LangRef.html updated: 1.119 - 1.120
---
Log message:

Added the spec for the new extractelement instruction.


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

 LangRef.html |   46 +-
 1 files changed, 45 insertions(+), 1 deletion(-)


Index: llvm/docs/LangRef.html
diff -u llvm/docs/LangRef.html:1.119 llvm/docs/LangRef.html:1.120
--- llvm/docs/LangRef.html:1.119Tue Nov 15 00:07:55 2005
+++ llvm/docs/LangRef.html  Thu Jan  5 11:37:02 2006
@@ -100,6 +100,7 @@
   lia href=#i_phi'ttphi/tt'   Instruction/a/li
   lia href=#i_cast'ttcast .. to/tt' Instruction/a/li
   lia href=#i_select'ttselect/tt' Instruction/a/li
+  lia href=#i_extractelement'ttextractelement/tt' 
Instruction/a/li
   lia href=#i_call'ttcall/tt'  Instruction/a/li
   lia href=#i_vaarg'ttvaarg/tt'  Instruction/a/li
 /ol
@@ -2230,8 +2231,51 @@
 /div
 
 
+!-- ___ 
--
+div class=doc_subsubsection
+   a name=i_extractelement'ttextractelement/tt' Instruction/a
+/div
+
+div class=doc_text
+
+h5Syntax:/h5
+
+pre
+  lt;resultgt; = extractelement lt;n x lt;tygt;gt; lt;valgt;, uint 
lt;idxgt;i; yields lt;tygt;/i
+/pre
+
+h5Overview:/h5
+
+p
+The 'ttextractelement/tt' instruction extracts a single scalar
+element from a vector at a specified index.
+/p
 
 
+h5Arguments:/h5
+
+p
+The first operand of an 'ttextractelement/tt' instruction is a
+value of a href=#t_packedpacked/a type.  The second operand is
+an index indicating the position from which to extract the element.
+The index may be a variable./p
+
+h5Semantics:/h5
+
+p
+The result is a scalar of the same type as the element type of
+ttval/tt.  Its value is the value at position ttidx/tt of
+ttval/tt.  If ttidx/tt exceeds the length of ttval/tt, the
+results are undefined.
+/p
+
+h5Example:/h5
+
+pre
+  %result = extractelement lt;4 x intgt; %vec, uint 0i; yields int/i
+/pre
+/div
+
 
 !-- ___ 
--
 div class=doc_subsubsection
@@ -3429,7 +3473,7 @@
 
   a href=mailto:[EMAIL PROTECTED]Chris Lattner/abr
   a href=http://llvm.cs.uiuc.edu;The LLVM Compiler Infrastructure/abr
-  Last modified: $Date: 2005/11/15 06:07:55 $
+  Last modified: $Date: 2006/01/05 17:37:02 $
 /address
 /body
 /html



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


[llvm-commits] [vector_llvm] CVS: llvm/Makefile

2005-11-15 Thread Robert L. Bocchino Jr.


Changes in directory llvm:

Makefile updated: 1.51.2.1 - 1.51.2.2
---
Log message:

Added examples to built directories


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

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


Index: llvm/Makefile
diff -u llvm/Makefile:1.51.2.1 llvm/Makefile:1.51.2.2
--- llvm/Makefile:1.51.2.1  Tue Oct 18 14:21:38 2005
+++ llvm/Makefile   Tue Nov 15 14:13:38 2005
@@ -14,7 +14,7 @@
 else
   ifneq ($(MAKECMDGOALS),libs-only)
 DIRS += tools runtime docs
-OPTIONAL_DIRS = #projects
+OPTIONAL_DIRS = examples #projects
   endif
 endif
 



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


[llvm-commits] [vector_llvm] CVS: llvm/include/VectorLLVM/VectorSignificantFunctions.h

2005-11-15 Thread Robert L. Bocchino Jr.


Changes in directory llvm/include/VectorLLVM:

VectorSignificantFunctions.h updated: 1.1.2.1 - 1.1.2.2
---
Log message:

Updated the signature for extract


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

 VectorSignificantFunctions.h |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)


Index: llvm/include/VectorLLVM/VectorSignificantFunctions.h
diff -u llvm/include/VectorLLVM/VectorSignificantFunctions.h:1.1.2.1 
llvm/include/VectorLLVM/VectorSignificantFunctions.h:1.1.2.2
--- llvm/include/VectorLLVM/VectorSignificantFunctions.h:1.1.2.1Tue Oct 
18 14:35:24 2005
+++ llvm/include/VectorLLVM/VectorSignificantFunctions.hTue Nov 15 
14:14:14 2005
@@ -189,13 +189,13 @@
   break;
 case extract:
   // An extract function must have precisely 4 arguments: a value
-  // and 3 unsigned ints
+  // an unsigned int, and int, and an unsigned int
   //
   if (numParams != 4 || isVarArg)
return false;
   if (FTy-getParamType(1) != Type::UIntTy)
return false;
-  if (FTy-getParamType(2) != Type::UIntTy)
+  if (!FTy-getParamType(2)-isIntegral())
return false;
   if (FTy-getParamType(3) != Type::UIntTy)
return false;



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


[llvm-commits] [vector_llvm] CVS: llvm/lib/Transforms/Vector/AltiVec.cpp LowerVectors.cpp RaiseVectors.cpp SSE.cpp

2005-11-15 Thread Robert L. Bocchino Jr.


Changes in directory llvm/lib/Transforms/Vector:

AltiVec.cpp updated: 1.1.2.1 - 1.1.2.2
LowerVectors.cpp updated: 1.1.2.1 - 1.1.2.2
RaiseVectors.cpp updated: 1.1.2.1 - 1.1.2.2
SSE.cpp updated: 1.1.2.1 - 1.1.2.2
---
Log message:

Improved AltiVec code generation support

Changed the signature for extract

Made lowervectors work with fixed vectors


---
Diffs of the changes:  (+108 -131)

 AltiVec.cpp  |  103 +--
 LowerVectors.cpp |   62 -
 RaiseVectors.cpp |9 +++-
 SSE.cpp  |   65 --
 4 files changed, 108 insertions(+), 131 deletions(-)


Index: llvm/lib/Transforms/Vector/AltiVec.cpp
diff -u llvm/lib/Transforms/Vector/AltiVec.cpp:1.1.2.1 
llvm/lib/Transforms/Vector/AltiVec.cpp:1.1.2.2
--- llvm/lib/Transforms/Vector/AltiVec.cpp:1.1.2.1  Tue Oct 18 14:37:03 2005
+++ llvm/lib/Transforms/Vector/AltiVec.cpp  Tue Nov 15 14:15:33 2005
@@ -41,7 +41,6 @@
 
   public:
 bool runOnFunction(Function F);
-void visitCastInst(CastInst );
 void visitVImmInst(VImmInst );
 void visitExtractInst(ExtractInst );
 void visitCombineInst(CombineInst );
@@ -103,7 +102,6 @@
 return altivec_ + baseName + _ + 
VT-getElementType()-getDescription();
   }
 
-
   
//===--===//
   // AltiVec implementation
   
//===--===//
@@ -114,13 +112,15 @@
 instructionsToDelete.clear();
 changed = false;
 for (Function::iterator FI = F.begin(), FE = F.end(); 
-FI != FE; ++FI)
+FI != FE; ++FI) {
   for (BasicBlock::iterator BI = FI-begin(), BE = FI-end(); 
-  BI != BE; ++BI)
+  BI != BE; ++BI) {
if (!instructionsToDelete.count(BI)) {
  DEBUG(std::cerr  Visiting instruction   *BI);
  visit(*BI);
}
+  }
+}
 if (changed) deleteInstructions();
 return changed;
   }
@@ -157,35 +157,6 @@
 changed = true;
   }
 
-  void AltiVec::visitCastInst(CastInst CI) {
-// We need only worry about a cast of a non-constant scalar to a
-// vector; the AltiVec C Backend can handle the other cases
-// directly.
-//
-const VectorType *VT = dyn_castVectorType(CI.getType());
-if (!VT || !isProperType(VT) ||
-   isaVectorType(CI.getOperand(0)-getType()) ||
-   isaConstant(CI.getOperand(0)))
-  return;
-// We need to create a new vector on the stack, store the scalar
-// value into it, and splat the value into a vector register
-//
-AllocaInst *vectorPtr = new AllocaInst(VT, 0, alloca, CI);
-Value *element = CI.getOperand(0); 
-if (element-getType() != VT-getElementType())
-  element = new CastInst(element, VT-getElementType(), cast, CI);
-CastInst *scalarPtr = new CastInst(vectorPtr, 
PointerType::get(VT-getElementType()),
-  cast, CI);
-StoreInst *store = new StoreInst(element, scalarPtr, CI);
-LoadInst *vector = new LoadInst(vectorPtr, load, CI);
-CallInst *call = VectorUtils::getCallInst(VT, getAltiVecName(splat, VT),
- vector, 
ConstantUInt::get(Type::UByteTy, 0),
- splat, CI);
-CI.replaceAllUsesWith(call);
-instructionsToDelete.insert(CI);
-changed = true;
-  }
-  
   // Check whether an extract instruction should be turned into
   // altivec_unpack
   //
@@ -403,7 +374,7 @@
   CastInst *addCast0 = 0, *addCast2 = 0, *shrCast = 0;
   VImmInst *VImm = 0;
   ShiftInst *shr = 0;
-  CallInst *adds;
+  CallInst *adds = 0;
   unsigned offset = 0, shamt = 0;
   if (BO == add-getOperand(0))
addCast0 = dyn_castCastInst(add-getOperand(1));
@@ -427,30 +398,52 @@
   }
   if (shrCast  shrCast-hasOneUse()) {
adds = dyn_castCallInst(*shrCast-use_begin());
-   Function *F = adds-getCalledFunction();
-   if (!F || F-getName().substr(0, 10) != vllvm_adds)
+   if (adds) {
+ Function *F = adds-getCalledFunction();
+ if (!F || F-getName().substr(0, 10) != vllvm_adds)
adds = 0;
+   }
   }
   if (mulCast0  mulCast1  addCast0  VImm 
- offset == 16384  shrCast  shr  shamt == 15  
- adds) {
-   VT = castFixedVectorType(adds-getType());
-   CallInst *mradds = VectorUtils::getCallInst(VT, 
getAltiVecName(mradds, VT),
-   new 
CastInst(mulCast0-getOperand(0), VT, cast, adds), 
-   new 
CastInst(mulCast1-getOperand(0), VT, cast, adds),
-   (shrCast == 
adds-getOperand(1)) ? adds-getOperand(2) : adds-getOperand(1),
-   mradds, adds);
-   

[llvm-commits] [vector_llvm] CVS: llvm/examples/SIMD/Makefile Makefile.common README.txt _malloc.c _malloc.h

2005-10-24 Thread Robert L. Bocchino Jr.


Changes in directory llvm/examples/SIMD:

Makefile added (r1.1.2.1)
Makefile.common added (r1.1.2.1)
README.txt added (r1.1.2.1)
_malloc.c added (r1.1.2.1)
_malloc.h added (r1.1.2.1)
---
Log message:

Examples to illustrate Vector LLVM's SIMD support.


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

 Makefile|   28 ++
 Makefile.common |   85 
 README.txt  |   21 +
 _malloc.c   |   15 +
 _malloc.h   |1 
 5 files changed, 150 insertions


Index: llvm/examples/SIMD/Makefile
diff -c /dev/null llvm/examples/SIMD/Makefile:1.1.2.1
*** /dev/null   Sun Oct 23 17:50:11 2005
--- llvm/examples/SIMD/Makefile Sun Oct 23 17:49:30 2005
***
*** 0 
--- 1,28 
+ all:
+   # Please specify altivec or sse!
+ 
+ altivec:
+   make -C Saxpy altivec
+   make -C InterQuant altivec
+   make -C MADFilter altivec
+   make -C RGB2YUV altivec
+   make -C Transpose altivec
+   make -C DCT altivec
+ 
+ sse:
+   make -C Saxpy sse
+   make -C InterQuant sse
+   make -C MADFilter sse
+ # Note that RGB2YUV doesn't currently work on SSE because of 
+ # SSE's limited support for permute operations
+   make -C Transpose sse
+   make -C DCT sse
+ 
+ clean:
+   make -C Saxpy clean
+   make -C InterQuant clean
+   make -C MADFilter clean
+   make -C RGB2YUV clean
+   make -C Transpose clean
+   make -C DCT clean
+ 


Index: llvm/examples/SIMD/Makefile.common
diff -c /dev/null llvm/examples/SIMD/Makefile.common:1.1.2.1
*** /dev/null   Sun Oct 23 17:50:25 2005
--- llvm/examples/SIMD/Makefile.common  Sun Oct 23 17:49:30 2005
***
*** 0 
--- 1,85 
+ LLVMSRCDIR= $(HOME)/llvm/src
+ LLVMGCCFLAGS += -I$(LLVMSRCDIR)/include/VectorC -I$(LLVMSRCDIR)/include/SIMD 
#-Wa,-unroll-threshold=200
+ SSECFLAGS += -I$(LLVMSRCDIR)/include/SIMD -msse2 -O2
+ ALTIVECCFLAGS += -I$(LLVMSRCDIR)/include/SIMD -faltivec -O2
+ 
+ 
+ # Specify how many runs you want here (for timing). You can also say
+ # NRUNS=n on the command line.
+ #
+ ifndef $(NRUNS)
+ NRUNS= 1
+ endif
+ 
+ all:
+   # Please specify altivec or sse!
+ 
+ altivec: altivec.handwritten altivec.vectorc
+   ./altivec.handwritten
+   ./altivec.vectorc
+ 
+ sse: sse.handwritten sse.vectorc
+   ./sse.handwritten
+   ./sse.vectorc
+ 
+ #
+ # General stuff
+ #
+ main.bc : main.c
+   llvm-gcc $(LLVMGCCFLAGS) -DNRUNS=$(NRUNS) -c -o $@ $
+ 
+ $(NAME).vectorc.bc : $(NAME).vectorc.c
+   llvm-gcc $(LLVMGCCFLAGS) -c $ -o $@
+ 
+ $(NAME).raised.bc : $(NAME).vectorc.bc
+   opt -raisevectors  $  $@
+ 
+ %.ll : %.bc
+   llvm-dis  $  $@
+ 
+ clean:
+   rm -f altivec.handwritten sse.handwritten altivec.vectorc sse.vectorc 
*.o *.s *.bc *.exe *.ll *.cbe.c
+ 
+ #
+ # AltiVec-specific stuff
+ #
+ ../_malloc.bc : ../_malloc.c
+   llvm-gcc $(LLVMGCCFLAGS) -DMEMALIGN=0 -c -o $@ $
+ 
+ altivec.handwritten: $(NAME).altivec.handwritten.c ../_malloc.c main.c
+   gcc $(ALTIVECCFLAGS) -DMEMALIGN=0 -DNRUNS=$(NRUNS) -o $@ $+
+ 
+ $(NAME).altivec.bc : $(NAME).raised.bc
+   opt  $ -altivec  $@
+ 
+ altivec.vectorc.bc: $(NAME).altivec.bc ../_malloc.bc main.bc
+   llvm-gcc $(LLVMGCCFLAGS) $+ -o altivec.vectorc
+ 
+ altivec.vectorc.cbe.c: altivec.vectorc.bc
+   llc -march=altivec-c  $ | sed 's/_2E_/_/g'  $@   
+ 
+ altivec.vectorc: altivec.vectorc.cbe.c
+   gcc $(ALTIVECCFLAGS) -o $@ $
+ 
+ #
+ # SSE-specific stuff
+ #
+ ../_malloc.memalign.bc : ../_malloc.c
+   llvm-gcc $(LLVMGCCFLAGS) -DMEMALIGN=1 -c -o $@ $
+ 
+ sse.handwritten: $(NAME).sse.handwritten.c ../_malloc.c main.c
+   gcc $(SSECFLAGS) -DMEMALIGN=1 -DNRUNS=$(NRUNS) -o $@ $+
+ 
+ $(NAME).sse.bc : $(NAME).raised.bc
+   opt  $ -sse  $@
+ 
+ sse.vectorc.bc: $(NAME).sse.bc ../_malloc.memalign.bc main.bc
+   llvm-gcc $(LLVMGCCFLAGS) $+ -o sse.vectorc
+ 
+ sse.vectorc.cbe.c: sse.vectorc.bc
+   llc -march=sse-c  $ | sed 's/_2E_/_/g'  $@   
+ 
+ sse.vectorc: sse.vectorc.cbe.c
+   gcc $(SSECFLAGS) -o $@ $
+ 
+ 


Index: llvm/examples/SIMD/README.txt
diff -c /dev/null llvm/examples/SIMD/README.txt:1.1.2.1
*** /dev/null   Sun Oct 23 17:50:25 2005
--- llvm/examples/SIMD/README.txt   Sun Oct 23 17:49:30 2005
***
*** 0 
--- 1,21 
+ SIMD Examples
+ =
+ 
+ Rob Bocchino
+ October 23, 2005
+ 
+ This directory illustrates the enhanced support for SIMD operations
+ provided by Vector LLVM.  It provides several benchmarks handcoded in
+ Vector C, AltiVec-C, and SSE-C, together with a build environment for
+ running and timing all three versions.  Except for RGB2YUV (which
+ works only for AltiVec, because of SSE's limited support for permute
+ operations), the same Vector C version compiles to both AltiVec and
+ SSE.
+ 
+ To run the benchmarks on AltiVec, type make altivec in this directory.
+ To run the benchmarks on SSE, type make sse.  To run the benchmarks on
+ 

[llvm-commits] [vector_llvm] CVS: llvm/examples/SIMD/InterQuant/Makefile interquant.altivec.handwritten.c interquant.sse.handwritten.c interquant.vectorc.c main.c

2005-10-23 Thread Robert L. Bocchino Jr.


Changes in directory llvm/examples/SIMD/InterQuant:

Makefile added (r1.1.2.1)
interquant.altivec.handwritten.c added (r1.1.2.1)
interquant.sse.handwritten.c added (r1.1.2.1)
interquant.vectorc.c added (r1.1.2.1)
main.c added (r1.1.2.1)
---
Log message:

Examples to illustrate Vector LLVM's SIMD support.


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

 Makefile |4 +
 interquant.altivec.handwritten.c |1 
 interquant.sse.handwritten.c |   40 +
 interquant.vectorc.c |   44 +++
 main.c   |  112 +++
 5 files changed, 201 insertions


Index: llvm/examples/SIMD/InterQuant/Makefile
diff -c /dev/null llvm/examples/SIMD/InterQuant/Makefile:1.1.2.1
*** /dev/null   Sun Oct 23 17:50:00 2005
--- llvm/examples/SIMD/InterQuant/Makefile  Sun Oct 23 17:49:40 2005
***
*** 0 
--- 1,4 
+ NAME= interquant
+ 
+ include ../Makefile.common
+ 


Index: llvm/examples/SIMD/InterQuant/interquant.altivec.handwritten.c
diff -c /dev/null 
llvm/examples/SIMD/InterQuant/interquant.altivec.handwritten.c:1.1.2.1
*** /dev/null   Sun Oct 23 17:50:17 2005
--- llvm/examples/SIMD/InterQuant/interquant.altivec.handwritten.c  Sun Oct 
23 17:49:40 2005
***
*** 0 
--- 1 
+ /***
 *
 * Copyright:   (c) Copyright Motorola Inc. 1998
 *
 * Date:May 18, 1998
 *
 * Function:INTER_Quantization
 *
 * Description: The INTER_QUANTIZATION routine will quantize
 *  the predictive frames (P-picture). Coefficients
 *  are quantized to the formula:
 * C' = sign(C) * ( abs(C) - QP/2 ) / ( 2 * QP ).
 *  To ensure ( abs(C) - QP/2 ) is positive, saturating
 *  unsigned subtraction is used.
 *
 * Inputs:  input - Pointer to input data (short), which
 *  must be between -2040 and 2040 (as set
 *  up by DCT ). It is assumed that the allocated
 *  array has been 128-bit aligned and contains
 *  8x8 short elements.
 *
 * Outputs: output - Pointer to output area for the transfored
 *   data. The output values are between -127
 *
and 127. It is assumed that a 128-bit
 *   aligned 8x8 array of signed char has been
 *   pre-allocated.
 *
 * QP:  QP (quantization parameter?) ranges from 1 to 31
 *
 **/


#define INTER_CALC( input, output ) \
 t1 = vec_subs( zero, input);\
 u1 = (vector unsigned short ) vec_max( input, t1 ); /*  ( abs(C))   */ 
\
 t2 = (vector signed short ) vec_subs( u1, qpd2 );/*max(0,(abs(C)-QP/2)) */ 
\
 t3 = vec_madds( t2, dtqp.v, zero );   /* ( (abs(C)-QP/2)/(2*QP) )15 ) */ 
\
 t4 = vec_min(maxq,t3);/* peg value at 127 if greater*/ 
\
 msk = vec_cmpgt( zero, input );   /* select to find sign of input   */ 
\
 t5 = vec_subs( zero, t4 );\
 output = vec_sel( t4, t5, msk );  /* ensure result is same sign */

void interquant_vector ( signed short* in,
 signed char* out,
 int QP )
{
  vect
 or signed short* input = (vector signed short*) in;
  vector signed char* output = (vector signed char*) out;

 /* ensure alignment so calculated constant can be
propagated into entire vector for calculations */
 union{
vector signed short v;
signed short s[8];
 } dtqp;

 vector signed short zero, minus1, maxq, parta, partb;
 vector signed short t1, t2, t3, t4, t5; /* used in macros */
 vector unsigned short qpd2, u1;
 vector bool short msk;

 /* load the calculated constant into the vector */
 dtqp.s[0] = (signed short)((int)((32768+QP)/(2*QP)));
 dtqp.s[1] = (signed short)(QP/2);
 qpd2 = (vector unsigned short) vec_splat( dtqp.v, 1);
 dtqp.v = vec_splat( dtqp.v, 0 );

 /* load the static constants used in the macros */
 zero = (vector signed short) (0);
 maxq = (vector signed short) (127);
 minus1 = (vector signed short) (-1);

 /* for all input compute: C' = sign(C) * ( (abs(C)-(QP
 /2) ) / 2*QP ) */
 INTER_CALC( input[0], parta );
 INTER_CALC( input[1], partb );
 output[0] = vec_pack( parta, partb );

 INTER_CALC( input[2], parta );
 INTER_CALC( input[3], partb );
 output[1] = vec_pack( parta, partb );

 INTER_CALC( input[4], parta );
 INTER_CALC( input[5], partb );
 output[2] = vec_pack( parta, partb );

 INTER_CALC( input[6], parta );
 INTER_CALC( input[7], partb );
 output[3] = vec_pack( parta, partb );

}

\ No newline at end of file


Index: llvm/examples/SIMD/InterQuant/interquant.sse.handwritten.c
diff -c /dev/null