[llvm-commits] CVS: llvm/test/Regression/CodeGen/X86/compare_folding.llx

2006-10-25 Thread Chris Lattner


Changes in directory llvm/test/Regression/CodeGen/X86:

compare_folding.llx updated: 1.3 - 1.4
---
Log message:

Modernize the testcase, allow it to pass on ppc


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

 compare_folding.llx |8 
 1 files changed, 4 insertions(+), 4 deletions(-)


Index: llvm/test/Regression/CodeGen/X86/compare_folding.llx
diff -u llvm/test/Regression/CodeGen/X86/compare_folding.llx:1.3 
llvm/test/Regression/CodeGen/X86/compare_folding.llx:1.4
--- llvm/test/Regression/CodeGen/X86/compare_folding.llx:1.3Wed Oct 11 
20:42:03 2006
+++ llvm/test/Regression/CodeGen/X86/compare_folding.llxWed Oct 25 
11:35:10 2006
@@ -1,8 +1,8 @@
-; RUN: llvm-as  %s | llc -march=x86 | grep movsd | wc -l | grep 1 
-; RUN: llvm-as  %s | llc -march=x86 | grep ucomisd
-declare bool %llvm.isunordered(double,double)
+; RUN: llvm-as  %s | llc -march=x86 -mcpu=yonah | grep movsd | wc -l | grep 1 

+; RUN: llvm-as  %s | llc -march=x86 -mcpu=yonah | grep ucomisd
+declare bool %llvm.isunordered.f64(double,double)
 
 bool %test1(double %X, double %Y) {  ;; Returns isunordered(X,Y)
-   %COM = call bool %llvm.isunordered(double %X, double %Y)
+   %COM = call bool %llvm.isunordered.f64(double %X, double %Y)
ret bool %COM
 }



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


[llvm-commits] CVS: llvm/test/Regression/CodeGen/X86/vec_ss_load_fold.ll

2006-10-25 Thread Chris Lattner


Changes in directory llvm/test/Regression/CodeGen/X86:

vec_ss_load_fold.ll updated: 1.1 - 1.2
---
Log message:

Allow this to pass on ppc



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

 vec_ss_load_fold.ll |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)


Index: llvm/test/Regression/CodeGen/X86/vec_ss_load_fold.ll
diff -u llvm/test/Regression/CodeGen/X86/vec_ss_load_fold.ll:1.1 
llvm/test/Regression/CodeGen/X86/vec_ss_load_fold.ll:1.2
--- llvm/test/Regression/CodeGen/X86/vec_ss_load_fold.ll:1.1Wed Oct 11 
17:07:38 2006
+++ llvm/test/Regression/CodeGen/X86/vec_ss_load_fold.llWed Oct 25 
11:37:47 2006
@@ -1,5 +1,5 @@
-; RUN: llvm-as  %s | llc -march=x86 -mattr=+sse | grep minss | grep CPI | wc 
-l | grep 2 
-; RUN: llvm-as  %s | llc -march=x86 -mattr=+sse | grep CPI | not grep movss
+; RUN: llvm-as  %s | llc -march=x86 -mattr=+sse,+sse2 | grep minss | grep CPI 
| wc -l | grep 2 
+; RUN: llvm-as  %s | llc -march=x86 -mattr=+sse,+sse2 | grep CPI | not grep 
movss
 
 target endian = little
 target pointersize = 32



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


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

2006-10-25 Thread Chris Lattner


Changes in directory llvm/lib/CodeGen:

BranchFolding.cpp updated: 1.22 - 1.23
---
Log message:

turn off tail merging for now


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

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


Index: llvm/lib/CodeGen/BranchFolding.cpp
diff -u llvm/lib/CodeGen/BranchFolding.cpp:1.22 
llvm/lib/CodeGen/BranchFolding.cpp:1.23
--- llvm/lib/CodeGen/BranchFolding.cpp:1.22 Mon Oct 23 20:12:32 2006
+++ llvm/lib/CodeGen/BranchFolding.cpp  Wed Oct 25 13:08:50 2006
@@ -206,6 +206,8 @@
 bool BranchFolder::TailMergeBlocks(MachineFunction MF) {
   MadeChange = false;
   
+  return false;
+  
   // Find blocks with no successors.
   std::vectorstd::pairunsigned,MachineBasicBlock*  MergePotentials;
   for (MachineFunction::iterator I = MF.begin(), E = MF.end(); I != E; ++I) {



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


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

2006-10-25 Thread Chris Lattner


Changes in directory llvm/lib/CodeGen:

MachineInstr.cpp updated: 1.126 - 1.127
---
Log message:

be more aggressive about matching identical instructions.


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

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


Index: llvm/lib/CodeGen/MachineInstr.cpp
diff -u llvm/lib/CodeGen/MachineInstr.cpp:1.126 
llvm/lib/CodeGen/MachineInstr.cpp:1.127
--- llvm/lib/CodeGen/MachineInstr.cpp:1.126 Fri Oct 20 17:39:59 2006
+++ llvm/lib/CodeGen/MachineInstr.cpp   Wed Oct 25 13:08:14 2006
@@ -120,7 +120,7 @@
   case MachineOperand::MO_GlobalAddress:
 return getGlobal() == Other.getGlobal()  getOffset() == 
Other.getOffset();
   case MachineOperand::MO_ExternalSymbol:
-return getSymbolName() == Other.getSymbolName() 
+return !strcmp(getSymbolName(), Other.getSymbolName()) 
getOffset() == Other.getOffset();
   }
 }



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


Re: [llvm-commits] Linkage patch for llvm-gcc

2006-10-25 Thread Devang Patel

On Oct 23, 2006, at 1:25 PM, Anton Korobeynikov wrote:

 Hello, Everyone

 Please find patch for llvm-gcc4 attached. It fixes linkage setup at
 least for mingw32 platform as target. However, I'm worrying it's no so
 correct :)

Thanks. I applied this patch today.

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


[llvm-commits] CVS: llvm/tools/lto/lto.cpp

2006-10-25 Thread Devang Patel


Changes in directory llvm/tools/lto:

lto.cpp updated: 1.23 - 1.24
---
Log message:

Supply alignment info to linker through LLVMSymbol.


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

 lto.cpp |   18 --
 1 files changed, 12 insertions(+), 6 deletions(-)


Index: llvm/tools/lto/lto.cpp
diff -u llvm/tools/lto/lto.cpp:1.23 llvm/tools/lto/lto.cpp:1.24
--- llvm/tools/lto/lto.cpp:1.23 Tue Oct 24 13:41:02 2006
+++ llvm/tools/lto/lto.cpp  Wed Oct 25 13:10:07 2006
@@ -36,6 +36,7 @@
 #include llvm/Transforms/IPO.h
 #include llvm/Transforms/Scalar.h
 #include llvm/Analysis/LoadValueNumbering.h
+#include llvm/Support/MathExtras.h
 #include llvm/LinkTimeOptimizer.h
 #include fstream
 #include iostream
@@ -149,8 +150,7 @@
 return LTO_READ_FAILURE;
 
   // Collect Target info
-  if (!Target) 
-getTarget(m);
+  getTarget(m);
 
   if (!Target)
 return LTO_READ_FAILURE;
@@ -166,8 +166,10 @@
 
 if (!f-isExternal()  lt != LTOInternalLinkage
  strncmp (f-getName().c_str(), llvm., 5)) {
+  int alignment = ( 16  f-getAlignment() ? 16 : f-getAlignment());
   LLVMSymbol *newSymbol = new LLVMSymbol(lt, f, f-getName(), 
- mangler.getValueName(f));
+ mangler.getValueName(f),
+ Log2_32(alignment));
   symbols[newSymbol-getMangledName()] = newSymbol;
   allSymbols[newSymbol-getMangledName()] = newSymbol;
 }
@@ -186,8 +188,10 @@
 LTOLinkageTypes lt = getLTOLinkageType(v);
 if (!v-isExternal()  lt != LTOInternalLinkage
  strncmp (v-getName().c_str(), llvm., 5)) {
+  const TargetData *TD = Target-getTargetData();
   LLVMSymbol *newSymbol = new LLVMSymbol(lt, v, v-getName(), 
- mangler.getValueName(v));
+ mangler.getValueName(v),
+ TD-getPreferredAlignmentLog(v));
   symbols[newSymbol-getMangledName()] = newSymbol;
   allSymbols[newSymbol-getMangledName()] = newSymbol;
 
@@ -206,6 +210,9 @@
 void
 LTO::getTarget (Module *M) {
 
+  if (Target)
+return;
+
   std::string Err;
   const TargetMachineRegistry::Entry* March = 
 TargetMachineRegistry::getClosestStaticTargetForModule(*M, Err);
@@ -230,8 +237,7 @@
   PassManager Passes;
   
   // Collect Target info
-  if (!Target) 
-getTarget(M);
+  getTarget(M);
 
   if (!Target)
 return LTO_NO_TARGET;



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


[llvm-commits] CVS: llvm/tools/bugpoint/BugDriver.cpp BugDriver.h CrashDebugger.cpp

2006-10-25 Thread Bill Wendling


Changes in directory llvm/tools/bugpoint:

BugDriver.cpp updated: 1.48 - 1.49
BugDriver.h updated: 1.46 - 1.47
CrashDebugger.cpp updated: 1.49 - 1.50
---
Log message:

Fix for PR960: http://llvm.org/PR960 . Improves bugpoint so that it removes 
global variable
initializers as well. This is only a first pass. It can be slow because
it clones the module for each pass. An obvious improvement is not to do that.


---
Diffs of the changes:  (+110 -23)

 BugDriver.cpp |   10 
 BugDriver.h   |5 ++
 CrashDebugger.cpp |  118 +++---
 3 files changed, 110 insertions(+), 23 deletions(-)


Index: llvm/tools/bugpoint/BugDriver.cpp
diff -u llvm/tools/bugpoint/BugDriver.cpp:1.48 
llvm/tools/bugpoint/BugDriver.cpp:1.49
--- llvm/tools/bugpoint/BugDriver.cpp:1.48  Fri Aug 18 03:43:06 2006
+++ llvm/tools/bugpoint/BugDriver.cpp   Wed Oct 25 13:36:14 2006
@@ -221,3 +221,13 @@
 std::cout  ...   Funcs.size()   total;
   std::cout  std::flush;
 }
+
+void llvm::PrintGlobalVariableList(const std::vectorGlobalVariable* GVs) {
+  unsigned NumPrint = GVs.size();
+  if (NumPrint  10) NumPrint = 10;
+  for (unsigned i = 0; i != NumPrint; ++i)
+std::cout GVs[i]-getName();
+  if (NumPrint  GVs.size())
+std::cout  ...   GVs.size()   total;
+  std::cout  std::flush;
+}


Index: llvm/tools/bugpoint/BugDriver.h
diff -u llvm/tools/bugpoint/BugDriver.h:1.46 
llvm/tools/bugpoint/BugDriver.h:1.47
--- llvm/tools/bugpoint/BugDriver.h:1.46Fri Sep 15 16:29:15 2006
+++ llvm/tools/bugpoint/BugDriver.h Wed Oct 25 13:36:14 2006
@@ -23,6 +23,7 @@
 
 class PassInfo;
 class Module;
+class GlobalVariable;
 class Function;
 class BasicBlock;
 class AbstractInterpreter;
@@ -295,6 +296,10 @@
 ///
 void PrintFunctionList(const std::vectorFunction* Funcs);
 
+/// PrintGlobalVariableList - prints out list of problematic global variables
+///
+void PrintGlobalVariableList(const std::vectorGlobalVariable* GVs);
+
 // DeleteFunctionBody - Remove the function by deleting all of it's basic
 // blocks, making it external.
 //


Index: llvm/tools/bugpoint/CrashDebugger.cpp
diff -u llvm/tools/bugpoint/CrashDebugger.cpp:1.49 
llvm/tools/bugpoint/CrashDebugger.cpp:1.50
--- llvm/tools/bugpoint/CrashDebugger.cpp:1.49  Tue Aug 15 11:40:49 2006
+++ llvm/tools/bugpoint/CrashDebugger.cpp   Wed Oct 25 13:36:14 2006
@@ -15,12 +15,12 @@
 #include ToolRunner.h
 #include ListReducer.h
 #include llvm/Constant.h
+#include llvm/DerivedTypes.h
 #include llvm/Instructions.h
 #include llvm/Module.h
 #include llvm/Pass.h
 #include llvm/PassManager.h
 #include llvm/SymbolTable.h
-#include llvm/Type.h
 #include llvm/Analysis/Verifier.h
 #include llvm/Bytecode/Writer.h
 #include llvm/Support/CFG.h
@@ -94,7 +94,81 @@
   return NoFailure;
 }
 
+namespace {
+  /// ReduceCrashingGlobalVariables - This works by removing the global
+  /// variable's initializer and seeing if the program still crashes. If it
+  /// does, then we keep that program and try again.
+  ///
+  class ReduceCrashingGlobalVariables : public ListReducerGlobalVariable* {
+BugDriver BD;
+bool (*TestFn)(BugDriver , Module *);
+  public:
+ReduceCrashingGlobalVariables(BugDriver bd,
+  bool (*testFn)(BugDriver, Module*))
+  : BD(bd), TestFn(testFn) {}
+
+virtual TestResult doTest(std::vectorGlobalVariable* Prefix,
+  std::vectorGlobalVariable* Kept) {
+  if (!Kept.empty()  TestGlobalVariables(Kept))
+return KeepSuffix;
+
+  if (!Prefix.empty()  TestGlobalVariables(Prefix))
+return KeepPrefix;
+
+  return NoFailure;
+}
+
+bool TestGlobalVariables(std::vectorGlobalVariable* GVs);
+  };
+}
+
+bool
+ReduceCrashingGlobalVariables::TestGlobalVariables(
+  std::vectorGlobalVariable* GVs) {
+  // Clone the program to try hacking it apart...
+  Module *M = CloneModule(BD.getProgram());
+
+  // Convert list to set for fast lookup...
+  std::setGlobalVariable* GVSet;
+
+  for (unsigned i = 0, e = GVs.size(); i != e; ++i) {
+GlobalVariable* CMGV = M-getNamedGlobal(GVs[i]-getName());
+assert(CMGV  Global Variable not in module?!);
+GVSet.insert(CMGV);
+  }
+
+  std::cout  Checking for crash with only these global variables: ;
+  PrintGlobalVariableList(GVs);
+  std::cout  : ;
+
+  // Loop over and delete any global variables which we aren't supposed to be
+  // playing with...
+  for (Module::global_iterator I = M-global_begin(), E = M-global_end();
+   I != E; ++I)
+if (I-hasInitializer()) {
+  I-setInitializer(0);
+  I-setLinkage(GlobalValue::ExternalLinkage);
+}
+
+  // Try running the hacked up program...
+  if (TestFn(BD, M)) {
+BD.setNewProgram(M);// It crashed, keep the trimmed version...
+
+// Make sure to use global variable pointers that point into the 
now-current
+// module.
+GVs.assign(GVSet.begin(), GVSet.end());
+return true;
+  }

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

2006-10-25 Thread Devang Patel


Changes in directory llvm/include/llvm:

LinkTimeOptimizer.h updated: 1.10 - 1.11
---
Log message:

Supply alignment info to linker through LLVMSymbol.


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

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


Index: llvm/include/llvm/LinkTimeOptimizer.h
diff -u llvm/include/llvm/LinkTimeOptimizer.h:1.10 
llvm/include/llvm/LinkTimeOptimizer.h:1.11
--- llvm/include/llvm/LinkTimeOptimizer.h:1.10  Tue Oct 24 13:41:02 2006
+++ llvm/include/llvm/LinkTimeOptimizer.h   Wed Oct 25 13:10:07 2006
@@ -57,17 +57,19 @@
 void mayBeNotUsed();
 
 LLVMSymbol (enum LTOLinkageTypes lt, GlobalValue *g, const std::string n, 
-const std::string m) : linkage(lt), gv(g), name(n), 
-mangledName(m) {}
+const std::string m, int a) : linkage(lt), gv(g), name(n), 
+   mangledName(m), alignment(a) {}
 
 const char *getName() { return name.c_str(); }
 const char *getMangledName() { return mangledName.c_str(); }
+int getAlignment() { return alignment; }
 
   private:
 enum LTOLinkageTypes linkage;
 GlobalValue *gv;
 std::string name;
 std::string mangledName;
+int alignment;
   };
 
   class string_compare {



___
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

2006-10-25 Thread Evan Cheng


Changes in directory llvm/lib/Target/X86:

X86ISelLowering.cpp updated: 1.277 - 1.278
---
Log message:

Remove -disable-x86-shuffle-opti

---
Diffs of the changes:  (+53 -61)

 X86ISelLowering.cpp |  114 
 1 files changed, 53 insertions(+), 61 deletions(-)


Index: llvm/lib/Target/X86/X86ISelLowering.cpp
diff -u llvm/lib/Target/X86/X86ISelLowering.cpp:1.277 
llvm/lib/Target/X86/X86ISelLowering.cpp:1.278
--- llvm/lib/Target/X86/X86ISelLowering.cpp:1.277   Fri Oct 20 12:42:20 2006
+++ llvm/lib/Target/X86/X86ISelLowering.cpp Wed Oct 25 15:48:19 2006
@@ -37,9 +37,6 @@
 // FIXME: temporary.
 static cl::optbool EnableFastCC(enable-x86-fastcc, cl::Hidden,
   cl::desc(Enable fastcc on X86));
-static cl::optbool NoShuffleOpti(disable-x86-shuffle-opti, cl::Hidden,
-   cl::desc(Disable vector shuffle optimizations on 
X86));
-
 X86TargetLowering::X86TargetLowering(TargetMachine TM)
   : TargetLowering(TM) {
   Subtarget = TM.getSubtargetX86Subtarget();
@@ -3310,7 +3307,7 @@
 return SDOperand();
 
   // Special case for single non-zero element.
-  if (!NoShuffleOpti  NumNonZero == 1) {
+  if (NumNonZero == 1) {
 unsigned Idx = CountTrailingZeros_32(NonZeros);
 SDOperand Item = Op.getOperand(Idx);
 Item = DAG.getNode(ISD::SCALAR_TO_VECTOR, VT, Item);
@@ -3389,7 +3386,7 @@
 // FIXME: we can do the same for v4f32 case when we know both parts of
 // the lower half come from scalar_to_vector (loadf32). We should do
 // that in post legalizer dag combiner with target specific hooks.
-if (!NoShuffleOpti  MVT::isInteger(EVT)  (NonZeros  (0x3  2)) == 0)
+if (MVT::isInteger(EVT)  (NonZeros  (0x3  2)) == 0)
   return V[0];
 MVT::ValueType MaskVT = MVT::getIntVectorWithNumElements(NumElems);
 MVT::ValueType EVT = MVT::getVectorBaseType(MaskVT);
@@ -3451,52 +3448,49 @@
   if (isSplatMask(PermMask.Val)) {
 if (NumElems = 4) return Op;
 // Promote it to a v4i32 splat.
-if (!NoShuffleOpti)
-  return PromoteSplat(Op, DAG);
+return PromoteSplat(Op, DAG);
   }
 
-  if (!NoShuffleOpti) {
-if (X86::isMOVLMask(PermMask.Val))
-  return (V1IsUndef) ? V2 : Op;
+  if (X86::isMOVLMask(PermMask.Val))
+return (V1IsUndef) ? V2 : Op;
   
-if (X86::isMOVSHDUPMask(PermMask.Val) ||
-X86::isMOVSLDUPMask(PermMask.Val) ||
-X86::isMOVHLPSMask(PermMask.Val) ||
-X86::isMOVHPMask(PermMask.Val) ||
-X86::isMOVLPMask(PermMask.Val))
-  return Op;
-
-if (ShouldXformToMOVHLPS(PermMask.Val) ||
-ShouldXformToMOVLP(V1.Val, V2.Val, PermMask.Val))
-  return CommuteVectorShuffle(Op, DAG);
-
-V1IsSplat = isSplatVector(V1.Val);
-V2IsSplat = isSplatVector(V2.Val);
-if ((V1IsSplat || V1IsUndef)  !(V2IsSplat || V2IsUndef)) {
-  Op = CommuteVectorShuffle(Op, DAG);
-  V1 = Op.getOperand(0);
-  V2 = Op.getOperand(1);
-  PermMask = Op.getOperand(2);
-  std::swap(V1IsSplat, V2IsSplat);
-  std::swap(V1IsUndef, V2IsUndef);
-}
+  if (X86::isMOVSHDUPMask(PermMask.Val) ||
+  X86::isMOVSLDUPMask(PermMask.Val) ||
+  X86::isMOVHLPSMask(PermMask.Val) ||
+  X86::isMOVHPMask(PermMask.Val) ||
+  X86::isMOVLPMask(PermMask.Val))
+return Op;
 
-if (isCommutedMOVL(PermMask.Val, V2IsSplat, V2IsUndef)) {
-  if (V2IsUndef) return V1;
-  Op = CommuteVectorShuffle(Op, DAG);
-  V1 = Op.getOperand(0);
-  V2 = Op.getOperand(1);
-  PermMask = Op.getOperand(2);
-  if (V2IsSplat) {
-// V2 is a splat, so the mask may be malformed. That is, it may point
-// to any V2 element. The instruction selectior won't like this. Get
-// a corrected mask and commute to form a proper MOVS{S|D}.
-SDOperand NewMask = getMOVLMask(NumElems, DAG);
-if (NewMask.Val != PermMask.Val)
-  Op = DAG.getNode(ISD::VECTOR_SHUFFLE, VT, V1, V2, NewMask);
-  }
-  return Op;
+  if (ShouldXformToMOVHLPS(PermMask.Val) ||
+  ShouldXformToMOVLP(V1.Val, V2.Val, PermMask.Val))
+return CommuteVectorShuffle(Op, DAG);
+
+  V1IsSplat = isSplatVector(V1.Val);
+  V2IsSplat = isSplatVector(V2.Val);
+  if ((V1IsSplat || V1IsUndef)  !(V2IsSplat || V2IsUndef)) {
+Op = CommuteVectorShuffle(Op, DAG);
+V1 = Op.getOperand(0);
+V2 = Op.getOperand(1);
+PermMask = Op.getOperand(2);
+std::swap(V1IsSplat, V2IsSplat);
+std::swap(V1IsUndef, V2IsUndef);
+  }
+
+  if (isCommutedMOVL(PermMask.Val, V2IsSplat, V2IsUndef)) {
+if (V2IsUndef) return V1;
+Op = CommuteVectorShuffle(Op, DAG);
+V1 = Op.getOperand(0);
+V2 = Op.getOperand(1);
+PermMask = Op.getOperand(2);
+if (V2IsSplat) {
+  // V2 is a splat, so the mask may be malformed. That is, it may point
+  // to any V2 element. The instruction selectior won't like this. Get
+  // a corrected mask and commute to form a proper MOVS{S|D}.
+  SDOperand NewMask = 

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

2006-10-25 Thread Chris Lattner


Changes in directory llvm/lib/Transforms/Scalar:

PredicateSimplifier.cpp updated: 1.26 - 1.27
---
Log message:

hide symbols properly


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

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


Index: llvm/lib/Transforms/Scalar/PredicateSimplifier.cpp
diff -u llvm/lib/Transforms/Scalar/PredicateSimplifier.cpp:1.26 
llvm/lib/Transforms/Scalar/PredicateSimplifier.cpp:1.27
--- llvm/lib/Transforms/Scalar/PredicateSimplifier.cpp:1.26 Mon Oct 23 
19:36:21 2006
+++ llvm/lib/Transforms/Scalar/PredicateSimplifier.cpp  Wed Oct 25 16:14:31 2006
@@ -400,7 +400,7 @@
   /// PredicateSimplifier - This class is a simplifier that replaces
   /// one equivalent variable with another. It also tracks what
   /// can't be equal and will solve setcc instructions when possible.
-  class PredicateSimplifier : public FunctionPass {
+  class VISIBILITY_HIDDEN PredicateSimplifier : public FunctionPass {
   public:
 bool runOnFunction(Function F);
 virtual void getAnalysisUsage(AnalysisUsage AU) const;



___
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/X86InstrSSE.td

2006-10-25 Thread Evan Cheng


Changes in directory llvm/lib/Target/X86:

X86InstrSSE.td updated: 1.165 - 1.166
---
Log message:

X86ISD::PEXTRW 3rd operand type is always target pointer type.

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

 X86InstrSSE.td |2 +-
 1 files changed, 1 insertion(+), 1 deletion(-)


Index: llvm/lib/Target/X86/X86InstrSSE.td
diff -u llvm/lib/Target/X86/X86InstrSSE.td:1.165 
llvm/lib/Target/X86/X86InstrSSE.td:1.166
--- llvm/lib/Target/X86/X86InstrSSE.td:1.165Wed Oct 11 16:05:24 2006
+++ llvm/lib/Target/X86/X86InstrSSE.td  Wed Oct 25 16:35:05 2006
@@ -1580,7 +1580,7 @@
 (ops GR32:$dst, VR128:$src1, i32i8imm:$src2),
 pextrw {$src2, $src1, $dst|$dst, $src1, $src2},
 [(set GR32:$dst, (X86pextrw (v8i16 VR128:$src1),
- (i32 imm:$src2)))];
+ (iPTR imm:$src2)))];
 let isTwoAddress = 1 in {
 def PINSRWrri : PDIi80xC4, MRMSrcReg,
  (ops VR128:$dst, VR128:$src1, GR32:$src2, i32i8imm:$src3),



___
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

2006-10-25 Thread Evan Cheng


Changes in directory llvm/lib/Target/X86:

X86ISelLowering.cpp updated: 1.278 - 1.279
---
Log message:

During vector shuffle lowering, we sometimes commute a vector shuffle to try
to match MOVL (movss, movsd, etc.). Don't forget to commute it back and try
unpck* and shufp* if that doesn't pan out.


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

 X86ISelLowering.cpp |   42 +-
 1 files changed, 21 insertions(+), 21 deletions(-)


Index: llvm/lib/Target/X86/X86ISelLowering.cpp
diff -u llvm/lib/Target/X86/X86ISelLowering.cpp:1.278 
llvm/lib/Target/X86/X86ISelLowering.cpp:1.279
--- llvm/lib/Target/X86/X86ISelLowering.cpp:1.278   Wed Oct 25 15:48:19 2006
+++ llvm/lib/Target/X86/X86ISelLowering.cpp Wed Oct 25 16:49:50 2006
@@ -2954,10 +2954,9 @@
 
 /// CommuteVectorShuffle - Swap vector_shuffle operandsas well as
 /// values in ther permute mask.
-static SDOperand CommuteVectorShuffle(SDOperand Op, SelectionDAG DAG) {
-  SDOperand V1 = Op.getOperand(0);
-  SDOperand V2 = Op.getOperand(1);
-  SDOperand Mask = Op.getOperand(2);
+static SDOperand CommuteVectorShuffle(SDOperand Op, SDOperand V1,
+  SDOperand V2, SDOperand Mask,
+  SelectionDAG DAG) {
   MVT::ValueType VT = Op.getValueType();
   MVT::ValueType MaskVT = Mask.getValueType();
   MVT::ValueType EltVT = MVT::getVectorBaseType(MaskVT);
@@ -2978,8 +2977,9 @@
   MaskVec.push_back(DAG.getConstant(Val - NumElems, EltVT));
   }
 
+  std::swap(V1, V2);
   Mask = DAG.getNode(ISD::BUILD_VECTOR, MaskVT, MaskVec[0], MaskVec.size());
-  return DAG.getNode(ISD::VECTOR_SHUFFLE, VT, V2, V1, Mask);
+  return DAG.getNode(ISD::VECTOR_SHUFFLE, VT, V1, V2, Mask);
 }
 
 /// ShouldXformToMOVHLPS - Return true if the node should be transformed to
@@ -3463,25 +3463,21 @@
 
   if (ShouldXformToMOVHLPS(PermMask.Val) ||
   ShouldXformToMOVLP(V1.Val, V2.Val, PermMask.Val))
-return CommuteVectorShuffle(Op, DAG);
+return CommuteVectorShuffle(Op, V1, V2, PermMask, DAG);
 
+  bool Commuted = false;
   V1IsSplat = isSplatVector(V1.Val);
   V2IsSplat = isSplatVector(V2.Val);
   if ((V1IsSplat || V1IsUndef)  !(V2IsSplat || V2IsUndef)) {
-Op = CommuteVectorShuffle(Op, DAG);
-V1 = Op.getOperand(0);
-V2 = Op.getOperand(1);
-PermMask = Op.getOperand(2);
+Op = CommuteVectorShuffle(Op, V1, V2, PermMask, DAG);
 std::swap(V1IsSplat, V2IsSplat);
 std::swap(V1IsUndef, V2IsUndef);
+Commuted = true;
   }
 
   if (isCommutedMOVL(PermMask.Val, V2IsSplat, V2IsUndef)) {
 if (V2IsUndef) return V1;
-Op = CommuteVectorShuffle(Op, DAG);
-V1 = Op.getOperand(0);
-V2 = Op.getOperand(1);
-PermMask = Op.getOperand(2);
+Op = CommuteVectorShuffle(Op, V1, V2, PermMask, DAG);
 if (V2IsSplat) {
   // V2 is a splat, so the mask may be malformed. That is, it may point
   // to any V2 element. The instruction selectior won't like this. Get
@@ -3515,13 +3511,17 @@
   }
 
   // Normalize the node to match x86 shuffle ops if needed
-  if (V2.getOpcode() != ISD::UNDEF)
-if (isCommutedSHUFP(PermMask.Val)) {
-  Op = CommuteVectorShuffle(Op, DAG);
-  V1 = Op.getOperand(0);
-  V2 = Op.getOperand(1);
-  PermMask = Op.getOperand(2);
-}
+  if (V2.getOpcode() != ISD::UNDEF  isCommutedSHUFP(PermMask.Val))
+  Op = CommuteVectorShuffle(Op, V1, V2, PermMask, DAG);
+
+  if (Commuted) {
+// Commute is back and try unpck* again.
+Op = CommuteVectorShuffle(Op, V1, V2, PermMask, DAG);
+if (X86::isUNPCKL_v_undef_Mask(PermMask.Val) ||
+X86::isUNPCKLMask(PermMask.Val) ||
+X86::isUNPCKHMask(PermMask.Val))
+  return Op;
+  }
 
   // If VT is integer, try PSHUF* first, then SHUFP*.
   if (MVT::isInteger(VT)) {



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


[llvm-commits] CVS: llvm/test/Regression/CodeGen/X86/vec_shuffle-9.ll

2006-10-25 Thread Evan Cheng


Changes in directory llvm/test/Regression/CodeGen/X86:

vec_shuffle-9.ll added (r1.1)
---
Log message:

New shuffle test case.

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

 vec_shuffle-9.ll |   20 
 1 files changed, 20 insertions(+)


Index: llvm/test/Regression/CodeGen/X86/vec_shuffle-9.ll
diff -c /dev/null llvm/test/Regression/CodeGen/X86/vec_shuffle-9.ll:1.1
*** /dev/null   Wed Oct 25 16:59:10 2006
--- llvm/test/Regression/CodeGen/X86/vec_shuffle-9.ll   Wed Oct 25 16:59:00 2006
***
*** 0 
--- 1,20 
+ ; RUN: llvm-as  %s | llc -march=x86 -mattr=+sse2 
+ ; RUN: llvm-as  %s | llc -march=x86 -mattr=+sse2 | grep punpck | wc -l | 
grep 2 
+ ; RUN: llvm-as  %s | llc -march=x86 -mattr=+sse2 | not grep pextrw
+ 
+ 4 x int %test(sbyte** %ptr) {
+ entry:
+   %tmp = load sbyte** %ptr
+   %tmp = cast sbyte* %tmp to float*
+   %tmp = load float* %tmp
+   %tmp = insertelement 4 x float undef, float %tmp, uint 0
+   %tmp9 = insertelement 4 x float %tmp, float 0.00e+00, uint 1
+   %tmp10 = insertelement 4 x float %tmp9, float 0.00e+00, uint 2
+   %tmp11 = insertelement 4 x float %tmp10, float 0.00e+00, uint 3
+   %tmp21 = cast 4 x float %tmp11 to 16 x sbyte
+   %tmp22 = shufflevector 16 x sbyte %tmp21, 16 x sbyte 
zeroinitializer, 16 x uint  uint 0, uint 16, uint 1, uint 17, uint 2, uint 
18, uint 3, uint 19, uint 4, uint 20, uint 5, uint 21, uint 6, uint 22, uint 7, 
uint 23 
+   %tmp31 = cast 16 x sbyte %tmp22 to 8 x short
+   %tmp = shufflevector 8 x short zeroinitializer, 8 x short %tmp31, 
8 x uint  uint 0, uint 8, uint 1, uint 9, uint 2, uint 10, uint 3, uint 11 
+   %tmp36 = cast 8 x short %tmp to 4 x int
+   ret 4 x int %tmp36
+ }



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


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

2006-10-25 Thread Chris Lattner


Changes in directory llvm/lib/CodeGen:

BranchFolding.cpp updated: 1.23 - 1.24
---
Log message:

simplify code


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

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


Index: llvm/lib/CodeGen/BranchFolding.cpp
diff -u llvm/lib/CodeGen/BranchFolding.cpp:1.23 
llvm/lib/CodeGen/BranchFolding.cpp:1.24
--- llvm/lib/CodeGen/BranchFolding.cpp:1.23 Wed Oct 25 13:08:50 2006
+++ llvm/lib/CodeGen/BranchFolding.cpp  Wed Oct 25 17:21:37 2006
@@ -417,7 +417,7 @@
   
   // Otherwise, if it is conditional and has no explicit false block, it falls
   // through.
-  return !Cond.empty()  FBB == 0;
+  return FBB == 0;
 }
 
 /// OptimizeBlock - Analyze and optimize control flow related to the specified



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


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

2006-10-25 Thread Nick Lewycky


Changes in directory llvm/lib/Transforms/Scalar:

PredicateSimplifier.cpp updated: 1.27 - 1.28
---
Log message:

Resurrect r1.25.
Fix and comment the or, and and xor transformations.


---
Diffs of the changes:  (+154 -117)

 PredicateSimplifier.cpp |  271 +++-
 1 files changed, 154 insertions(+), 117 deletions(-)


Index: llvm/lib/Transforms/Scalar/PredicateSimplifier.cpp
diff -u llvm/lib/Transforms/Scalar/PredicateSimplifier.cpp:1.27 
llvm/lib/Transforms/Scalar/PredicateSimplifier.cpp:1.28
--- llvm/lib/Transforms/Scalar/PredicateSimplifier.cpp:1.27 Wed Oct 25 
16:14:31 2006
+++ llvm/lib/Transforms/Scalar/PredicateSimplifier.cpp  Wed Oct 25 18:48:24 2006
@@ -41,6 +41,7 @@
 #include llvm/Support/Debug.h
 #include llvm/Support/InstVisitor.h
 #include iostream
+#include list
 using namespace llvm;
 
 typedef DominatorTree::Node DTNodeType;
@@ -74,14 +75,14 @@
   return leaders.empty();
 }
 
-iterator findLeader(ElemTy e) {
+iterator findLeader(ElemTy e) {
   typename std::mapElemTy, unsigned::iterator MI = mapping.find(e);
   if (MI == mapping.end()) return 0;
 
   return MI-second;
 }
 
-const_iterator findLeader(ElemTy e) const {
+const_iterator findLeader(ElemTy e) const {
   typename std::mapElemTy, unsigned::const_iterator MI =
   mapping.find(e);
   if (MI == mapping.end()) return 0;
@@ -116,6 +117,11 @@
 
 // Mutators
 
+void remove(ElemTy e) {
+  ElemTy E = e;  // The parameter to erase must not be a reference to
+  mapping.erase(E);  // an element contained in the map.
+}
+
 /// Combine two sets referring to the same element, inserting the
 /// elements as needed. Returns a valid iterator iff two already
 /// existing disjoint synonym sets were combined. The iterator
@@ -124,7 +130,7 @@
 
 /// Returns an iterator pointing to the synonym set containing
 /// element e. If none exists, a new one is created and returned.
-iterator findOrInsert(ElemTy e) {
+iterator findOrInsert(ElemTy e) {
   iterator I = findLeader(e);
   if (I) return I;
 
@@ -203,6 +209,19 @@
   return union_find.empty();
 }
 
+void remove(Value *V) {
+  SynonymIterator I = union_find.findLeader(V);
+  if (!I) return;
+
+  union_find.remove(V);
+
+  for (PropertyIterator PI = Properties.begin(), PE = Properties.end();
+   PI != PE;) {
+Property P = *PI++;
+if (P.I1 == I || P.I2 == I) Properties.erase(PI);
+  }
+}
+
 void addEqual(Value *V1, Value *V2) {
   // If %x = 0. and %y = -0., seteq %x, %y is true, but
   // copysign(%x) is not the same as copysign(%y).
@@ -211,6 +230,10 @@
   order(V1, V2);
   if (isaConstant(V2)) return; // refuse to set false == true.
 
+  if (union_find.findLeader(V1) 
+  union_find.findLeader(V1) == union_find.findLeader(V2))
+return; // no-op
+
   SynonymIterator deleted = union_find.unionSets(V1, V2);
   if (deleted) {
 SynonymIterator replacement = union_find.findLeader(V1);
@@ -234,7 +257,7 @@
   if (isaConstant(V1)  isaConstant(V2)) return;
 
   if (findProperty(NE, V1, V2) != Properties.end())
-return; // found.
+return; // no-op.
 
   // Add the property.
   SynonymIterator I1 = union_find.findOrInsert(V1),
@@ -308,6 +331,73 @@
   }
 }
 
+void addToResolve(Value *V, std::listValue * WorkList) {
+  if (!isaConstant(V)  !isaBasicBlock(V)) {
+for (Value::use_iterator UI = V-use_begin(), UE = V-use_end();
+ UI != UE; ++UI) {
+  if (!isaConstant(*UI)  !isaBasicBlock(*UI)) {
+WorkList.push_back(*UI);
+  }
+}
+  }
+}
+
+void resolve(std::listValue * WorkList) {
+  if (WorkList.empty()) return;
+
+  Value *V = WorkList.front();
+  WorkList.pop_front();
+
+  if (empty()) return;
+
+  Instruction *I = dyn_castInstruction(V);
+  if (!I) return;
+
+  if (BinaryOperator *BO = dyn_castBinaryOperator(I)) {
+Value *lhs = canonicalize(BO-getOperand(0)),
+  *rhs = canonicalize(BO-getOperand(1));
+
+ConstantIntegral *CI1 = dyn_castConstantIntegral(lhs),
+ *CI2 = dyn_castConstantIntegral(rhs);
+
+if (CI1  CI2) {
+  addToResolve(BO, WorkList);
+  addEqual(BO, ConstantExpr::get(BO-getOpcode(), CI1, CI2));
+} else if (SetCondInst *SCI = dyn_castSetCondInst(BO)) {
+  PropertySet::ConstPropertyIterator NE =
+ findProperty(PropertySet::NE, lhs, rhs);
+
+  if (NE != Properties.end()) {
+switch (SCI-getOpcode()) {
+case Instruction::SetEQ:
+  addToResolve(SCI, WorkList);
+  addEqual(SCI, ConstantBool::getFalse());
+  break;
+case Instruction::SetNE:
+  addToResolve(SCI, WorkList);
+  addEqual(SCI, 

[llvm-commits] CVS: llvm/test/Regression/Transforms/PredicateSimplifier/2006-10-22-IntOr.ll

2006-10-25 Thread Nick Lewycky


Changes in directory llvm/test/Regression/Transforms/PredicateSimplifier:

2006-10-22-IntOr.ll updated: 1.1 - 1.2
---
Log message:

This testcase was logically wrong! Fixing, and including the test for the
mistake that I made in the file too.


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

 2006-10-22-IntOr.ll |   27 ---
 1 files changed, 24 insertions(+), 3 deletions(-)


Index: llvm/test/Regression/Transforms/PredicateSimplifier/2006-10-22-IntOr.ll
diff -u 
llvm/test/Regression/Transforms/PredicateSimplifier/2006-10-22-IntOr.ll:1.1 
llvm/test/Regression/Transforms/PredicateSimplifier/2006-10-22-IntOr.ll:1.2
--- llvm/test/Regression/Transforms/PredicateSimplifier/2006-10-22-IntOr.ll:1.1 
Sun Oct 22 16:36:41 2006
+++ llvm/test/Regression/Transforms/PredicateSimplifier/2006-10-22-IntOr.ll 
Wed Oct 25 19:51:58 2006
@@ -1,9 +1,11 @@
-; RUN: llvm-as  %s | opt -predsimplify -instcombine -simplifycfg | llvm-dis | 
grep -v declare | not grep fail
+; RUN: llvm-as  %s | opt -predsimplify -instcombine -simplifycfg 
+; RUN: llvm-as  %s | opt -predsimplify -instcombine -simplifycfg | llvm-dis | 
grep -v declare | grep -c fail | grep 1 
+; RUN: llvm-as  %s | opt -predsimplify -instcombine -simplifycfg | llvm-dis | 
grep -v declare | grep -c pass | grep 1
 
-int %f(int %x, int %y) {
+int %test1(int %x, int %y) {
 entry:
%tmp2 = or int %x, %y   ; int [#uses=1]
-   %tmp = setne int %tmp2, 0   ; bool [#uses=1]
+   %tmp = seteq int %tmp2, 0   ; bool [#uses=1]
br bool %tmp, label %cond_true, label %return
 
 cond_true: ; preds = %entry
@@ -18,4 +20,23 @@
ret int 0
 }
 
+int %test2(int %x, int %y) {
+entry:
+   %tmp2 = or int %x, %y   ; int [#uses=1]
+   %tmp = setne int %tmp2, 0   ; bool [#uses=1]
+   br bool %tmp, label %cond_true, label %return
+
+cond_true: ; preds = %entry
+   %tmp4 = seteq int %x, 0 ; bool [#uses=1]
+   br bool %tmp4, label %cond_true5, label %return
+
+cond_true5:; preds = %cond_true
+   %tmp6 = call int %pass( )   ; int [#uses=0]
+   ret int %tmp6
+
+return:; preds = %cond_next7
+   ret int 0
+}
+
 declare int %fail()
+declare int %pass()



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


[llvm-commits] CVS: llvm/lib/VMCore/Makefile

2006-10-25 Thread Reid Spencer


Changes in directory llvm/lib/VMCore:

Makefile updated: 1.18 - 1.19
---
Log message:

Make the makefile tell us when Intrinsics.gen is being updated.


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

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


Index: llvm/lib/VMCore/Makefile
diff -u llvm/lib/VMCore/Makefile:1.18 llvm/lib/VMCore/Makefile:1.19
--- llvm/lib/VMCore/Makefile:1.18   Thu Jul 20 14:08:27 2006
+++ llvm/lib/VMCore/MakefileWed Oct 25 20:42:23 2006
@@ -24,7 +24,9 @@
$(Verb) $(TableGen) $(INTRINSICTD) -o $@ -gen-intrinsic
 
 $(GENFILE): $(ObjDir)/Intrinsics.gen.tmp
-   $(Verb) $(CMP) -s $@ $ || $(CP) $ $@
+   $(Verb) $(CMP) -s $@ $ || ( $(CP) $ $@  \
+ $(EchoCmd) Updated Intrinsics.gen because Intrinsics.gen.tmp \
+   changed significantly. )
 
 install-local:: $(GENFILE)
$(Echo) Installing $(PROJ_includedir)/llvm/Intrinsics.gen



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


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

2006-10-25 Thread Reid Spencer


Changes in directory llvm/lib/Target/CBackend:

Writer.cpp updated: 1.272.2.6 - 1.272.2.7
---
Log message:

Round 2 of DIV updates. 


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

 Writer.cpp |  156 +++--
 1 files changed, 152 insertions(+), 4 deletions(-)


Index: llvm/lib/Target/CBackend/Writer.cpp
diff -u llvm/lib/Target/CBackend/Writer.cpp:1.272.2.6 
llvm/lib/Target/CBackend/Writer.cpp:1.272.2.7
--- llvm/lib/Target/CBackend/Writer.cpp:1.272.2.6   Mon Oct 23 13:13:27 2006
+++ llvm/lib/Target/CBackend/Writer.cpp Wed Oct 25 20:58:05 2006
@@ -121,6 +121,8 @@
 
 void writeOperand(Value *Operand);
 void writeOperandInternal(Value *Operand);
+void writeOperandWithCast(Value* Operand, unsigned Opcode);
+bool writeInstructionCast(const Instruction I);
 
   private :
 void lowerIntrinsics(Function F);
@@ -136,6 +138,8 @@
 void printLoop(Loop *L);
 
 void printConstant(Constant *CPV);
+void printConstantWithCast(Constant *CPV, unsigned Opcode);
+bool printConstExprCast(const ConstantExpr *CE);
 void printConstantArray(ConstantArray *CPA);
 void printConstantPacked(ConstantPacked *CP);
 
@@ -604,7 +608,8 @@
 case Instruction::Shl:
 case Instruction::Shr:
   Out  '(';
-  printConstant(CE-getOperand(0));
+  bool NeedsClosingParens = printConstExprCast(CE); 
+  printConstantWithCast(CE-getOperand(0), CE-getOpcode());
   switch (CE-getOpcode()) {
   case Instruction::Add: Out   + ; break;
   case Instruction::Sub: Out   - ; break;
@@ -628,7 +633,9 @@
   case Instruction::Shr: Out; break;
   default: assert(0  Illegal opcode here!);
   }
-  printConstant(CE-getOperand(1));
+  printConstantWithCast(CE-getOperand(1), CE-getOpcode());
+  if (NeedsClosingParens)
+Out  ));
   Out  ')';
   return;
 
@@ -813,6 +820,71 @@
   }
 }
 
+// Some constant expressions need to be casted back to the original types
+// because their operands were casted to the expected type. This function takes
+// care of detecting that case and printing the cast for the ConstantExpr.
+bool CWriter::printConstExprCast(const ConstantExpr* CE) {
+  bool Result = false;
+  const Type* Ty = CE-getOperand(0)-getType();
+  switch (CE-getOpcode()) {
+  case Instruction::UDiv: Result = Ty-isSigned(); break;
+  case Instruction::SDiv: Result = Ty-isUnsigned(); break;
+  default: break;
+  }
+  if (Result) {
+Out  ((;
+printType(Out, Ty);
+Out  )(;
+  }
+  return Result;
+}
+
+//  Print a constant assuming that it is the operand for a given Opcode. The
+//  opcodes that care about sign need to cast their operands to the expected
+//  type before the operation proceeds. This function does the casting.
+void CWriter::printConstantWithCast(Constant* CPV, unsigned Opcode) {
+
+  // Extract the operand's type, we'll need it.
+  const Type* OpTy = CPV-getType();
+
+  // Indicate whether to do the cast or not.
+  bool shouldCast = false;
+
+  // Based on the Opcode for which this Constant is being written, determine
+  // the new type to which the operand should be casted by setting the value
+  // of OpTy. If we change OpTy, also set shouldCast to true.
+  switch (Opcode) {
+default:
+  // for most instructions, it doesn't matter
+  break; 
+case Instruction::UDiv:
+  // For UDiv to have unsigned operands
+  if (OpTy-isSigned()) {
+OpTy = OpTy-getUnsignedVersion();
+shouldCast = true;
+  }
+  break;
+case Instruction::SDiv:
+  if (OpTy-isUnsigned()) {
+OpTy = OpTy-getSignedVersion();
+shouldCast = true;
+  }
+  break;
+  }
+
+  // Write out the casted constnat if we should, otherwise just write the
+  // operand.
+  if (shouldCast) {
+Out  ((;
+printType(Out, OpTy);
+Out  );
+printConstant(CPV);
+Out  );
+  } else 
+writeOperand(CPV);
+
+}
+
 void CWriter::writeOperandInternal(Value *Operand) {
   if (Instruction *I = dyn_castInstruction(Operand))
 if (isInlinableInst(*I)  !isDirectAlloca(I)) {
@@ -841,6 +913,72 @@
 Out  ')';
 }
 
+// Some instructions need to have their result value casted back to the 
+// original types because their operands were casted to the expected type. 
+// This function takes care of detecting that case and printing the cast 
+// for the Instruction.
+bool CWriter::writeInstructionCast(const Instruction I) {
+  bool Result = false;
+  const Type* Ty = I.getOperand(0)-getType();
+  switch (I.getOpcode()) {
+  case Instruction::UDiv: Result = Ty-isSigned(); break;
+  case Instruction::SDiv: Result = Ty-isUnsigned(); break;
+  default: break;
+  }
+  if (Result) {
+Out  ((;
+printType(Out, Ty);
+Out  )(;
+  }
+  return Result;
+}
+
+// Write the operand with a cast to another type based on the Opcode being 
used.
+// This will be used in cases where an instruction has specific type
+// requirements (usually signedness) for its 

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

2006-10-25 Thread Reid Spencer


Changes in directory llvm/lib/Transforms/Scalar:

InstructionCombining.cpp updated: 1.520.2.9 - 1.520.2.10
---
Log message:

Round 2 of DIV updates. 


---
Diffs of the changes:  (+185 -165)

 InstructionCombining.cpp |  350 ---
 1 files changed, 185 insertions(+), 165 deletions(-)


Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp
diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.520.2.9 
llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.520.2.10
--- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.520.2.9   Mon Oct 
23 13:13:27 2006
+++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp Wed Oct 25 20:58:05 2006
@@ -1987,7 +1987,7 @@
   // 0 - (X sdiv C)  - (X sdiv -C)
   if (Op1I-getOpcode() == Instruction::SDiv)
 if (ConstantInt *CSI = dyn_castConstantInt(Op0))
-  if (CSI-getType()-isSigned()  CSI-isNullValue())
+  if (CSI-isNullValue())
 if (Constant *DivRHS = dyn_castConstant(Op1I-getOperand(1)))
   return BinaryOperator::createSDiv(Op1I-getOperand(0),
ConstantExpr::getNeg(DivRHS));
@@ -2169,53 +2169,21 @@
 Instruction* InstCombiner::commonDivTransforms(BinaryOperator I) {
   Value *Op0 = I.getOperand(0), *Op1 = I.getOperand(1);
 
-  if (isaUndefValue(Op0))  // undef / X - 0
+  // undef / X - 0
+  if (isaUndefValue(Op0))
 return ReplaceInstUsesWith(I, Constant::getNullValue(I.getType()));
-  if (isaUndefValue(Op1))
-return ReplaceInstUsesWith(I, Op1);  // X / undef - undef
-  return 0;
-}
-
-Instruction* InstCombiner::commonIDivTransforms(BinaryOperator I) {
-  Value *Op0 = I.getOperand(0), *Op1 = I.getOperand(1);
-
-  if (ConstantInt *RHS = dyn_castConstantInt(Op1)) {
-// div X, 1 == X
-if (RHS-equalsInt(1))
-  return ReplaceInstUsesWith(I, Op0);
-
-// div X, -1 == -X
-if (RHS-isAllOnesValue())
-  return BinaryOperator::createNeg(Op0);
-
-// (X / C1) / C2  - X / (C1*C2)
-if (Instruction *LHS = dyn_castInstruction(Op0))
-  if (LHS-getOpcode() == Instruction::SDiv || 
-  LHS-getOpcode()==Instruction::UDiv ||
-  LHS-getOpcode()==Instruction::FDiv)
-if (ConstantInt *LHSRHS = dyn_castConstantInt(LHS-getOperand(1))) {
-  return BinaryOperator::create(
-Instruction::BinaryOps(LHS-getOpcode()), LHS-getOperand(0),
-  ConstantExpr::getMul(RHS, LHSRHS));
-}
 
-if (!RHS-isNullValue()) { // avoid X udiv 0
-  if (SelectInst *SI = dyn_castSelectInst(Op0))
-if (Instruction *R = FoldOpIntoSelect(I, SI, this))
-  return R;
-  if (isaPHINode(Op0))
-if (Instruction *NV = FoldOpIntoPhi(I))
-  return NV;
-}
-  }
+  // X / undef - undef
+  if (isaUndefValue(Op1))
+return ReplaceInstUsesWith(I, Op1);
 
-  // Handle div X, Cond?Y:Z
+  // Handle cases involving: div X, (select Cond, Y, Z)
   if (SelectInst *SI = dyn_castSelectInst(Op1)) {
 // div X, (Cond ? 0 : Y) - div X, Y.  If the div and the select are in the
-// same basic block, then we replace the select with Y, and the condition 
of
-// the select with false (if the cond value is in the same BB).  If the
+// same basic block, then we replace the select with Y, and the condition 
+// of the select with false (if the cond value is in the same BB).  If the
 // select has uses other than the div, this allows them to be simplified
-// also.
+// also. Note that div X, Y is just as good as div X, 0 (undef)
 if (Constant *ST = dyn_castConstant(SI-getOperand(1)))
   if (ST-isNullValue()) {
 Instruction *CondI = dyn_castInstruction(SI-getOperand(0));
@@ -2227,6 +2195,7 @@
   UpdateValueUsesWith(SI, SI-getOperand(2));
 return I;
   }
+
 // Likewise for: div X, (Cond ? Y : 0) - div X, Y
 if (Constant *ST = dyn_castConstant(SI-getOperand(2)))
   if (ST-isNullValue()) {
@@ -2239,28 +2208,38 @@
   UpdateValueUsesWith(SI, SI-getOperand(1));
 return I;
   }
+  }
 
-// If this is 'udiv X, (Cond ? C1, C2)' where C1C2 are powers of two,
-// transform this into: '(Cond ? (udiv X, C1) : (udiv X, C2))'.
-if (ConstantInt *STO = dyn_castConstantInt(SI-getOperand(1)))
-  if (ConstantInt *SFO = dyn_castConstantInt(SI-getOperand(2))) 
-if (STO-getType()-isUnsigned()  SFO-getType()-isUnsigned()) {
-  // STO == 0 and SFO == 0 handled above.
-  uint64_t TVA = STO-getZExtValue(), FVA = SFO-getZExtValue();
-  if (isPowerOf2_64(TVA)  isPowerOf2_64(FVA)) {
-unsigned TSA = Log2_64(TVA), FSA = Log2_64(FVA);
-Constant *TC = ConstantInt::get(Type::UByteTy, TSA);
-Instruction *TSI = new ShiftInst(Instruction::Shr, Op0,
- TC, SI-getName()+.t);
-TSI = InsertNewInstBefore(TSI, I);
-
-

[llvm-commits] [SignlessTypes] CVS: llvm/lib/Transforms/IPO/SimplifyLibCalls.cpp

2006-10-25 Thread Reid Spencer


Changes in directory llvm/lib/Transforms/IPO:

SimplifyLibCalls.cpp updated: 1.69.2.3 - 1.69.2.4
---
Log message:

Round 2 of DIV updates. 


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

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


Index: llvm/lib/Transforms/IPO/SimplifyLibCalls.cpp
diff -u llvm/lib/Transforms/IPO/SimplifyLibCalls.cpp:1.69.2.3 
llvm/lib/Transforms/IPO/SimplifyLibCalls.cpp:1.69.2.4
--- llvm/lib/Transforms/IPO/SimplifyLibCalls.cpp:1.69.2.3   Fri Oct 20 
03:19:49 2006
+++ llvm/lib/Transforms/IPO/SimplifyLibCalls.cppWed Oct 25 20:58:05 2006
@@ -1275,7 +1275,7 @@
 return true;
   } else if (Op2V == -1.0) {
 // pow(x,-1.0)- 1.0/x
-BinaryOperator* div_inst= BinaryOperator::createSDiv(
+BinaryOperator* div_inst= BinaryOperator::createFDiv(
   ConstantFP::get(Ty,1.0), base, ci-getName()+.pow, ci);
 ci-replaceAllUsesWith(div_inst);
 ci-eraseFromParent();



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


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

2006-10-25 Thread Reid Spencer


Changes in directory llvm/docs:

LangRef.html updated: 1.158.2.1 - 1.158.2.2
---
Log message:

Round 2 of DIV updates. 


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

 LangRef.html |   36 +++-
 1 files changed, 19 insertions(+), 17 deletions(-)


Index: llvm/docs/LangRef.html
diff -u llvm/docs/LangRef.html:1.158.2.1 llvm/docs/LangRef.html:1.158.2.2
--- llvm/docs/LangRef.html:1.158.2.1Mon Oct 23 01:58:29 2006
+++ llvm/docs/LangRef.html  Wed Oct 25 20:58:05 2006
@@ -1642,13 +1642,14 @@
 pThe 'ttudiv/tt' instruction returns the quotient of its two
 operands./p
 h5Arguments:/h5
-pThe two arguments to the 'ttdiv/tt' instruction must be 
-a href=#t_integerinteger/a values. The arguments are considered to be
-unsigned integer quantities.  This instruction can also take 
-a href=#t_packedpacked/a versions of the values.  Both arguments must 
-have identical types./p
-h5Semantics:/h5
-pThe value produced is the unsigned integer quotient of the two operands./p
+pThe two arguments to the 'ttudiv/tt' instruction must be 
+a href=#t_integerinteger/a values. Both arguments must have identical 
+types. This instruction can also take a href=#t_packedpacked/a versions 
+of the values in which case the elements must be integers./p
+h5Semantics:/h5
+pThe value produced is the unsigned integer quotient of the two operands. 
This
+instruction always performs an unsigned division operation, regardless of 
+whether the arguments are unsigned or not./p
 h5Example:/h5
 pre  lt;resultgt; = udiv uint 4, %var  i; yields {uint}:result = 
4 / %var/i
 /pre
@@ -1665,12 +1666,13 @@
 operands./p
 h5Arguments:/h5
 pThe two arguments to the 'ttsdiv/tt' instruction must be
-a href=#t_integerinteger/a values. The arguments are considered to be 
-signed integer quantities. This instruction can also take 
-a href=#t_packedpacked/a versions of the values.  Both arguments must 
-have identical types./p
-h5Semantics:/h5
-pThe value produced is the signed integer quotient of the two operands./p
+a href=#t_integerinteger/a values.  Both arguments must have identical 
+types. This instruction can also take a href=#t_packedpacked/a versions 
+of the values in which case the elements must be integers./p
+h5Semantics:/h5
+pThe value produced is the signed integer quotient of the two operands. This
+instruction always performs a signed division operation, regardless of whether
+the arguments are signed or not./p
 h5Example:/h5
 pre  lt;resultgt; = sdiv int 4, %var  i; yields {int}:result = 4 
/ %var/i
 /pre
@@ -1687,9 +1689,9 @@
 operands./p
 h5Arguments:/h5
 pThe two arguments to the 'ttdiv/tt' instruction must be
-a href=#t_floatingfloating point/a values.  This instruction can also 
-take a href=#t_packedpacked/a versions of the values.
-Both arguments must have identical types./p
+a href=#t_floatingfloating point/a values.  Both arguments must have
+identical types.  This instruction can also take a href=#t_packedpacked/a
+versions of the values in which case the elements must be floating point./p
 h5Semantics:/h5
 pThe value produced is the floating point quotient of the two operands./p
 h5Example:/h5
@@ -3954,7 +3956,7 @@
 
   a href=mailto:[EMAIL PROTECTED]Chris Lattner/abr
   a href=http://llvm.org;The LLVM Compiler Infrastructure/abr
-  Last modified: $Date: 2006/10/23 06:58:29 $
+  Last modified: $Date: 2006/10/26 01:58:05 $
 /address
 /body
 /html



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


[llvm-commits] [SignlessTypes] CVS: llvm/lib/Analysis/DataStructure/Local.cpp

2006-10-25 Thread Reid Spencer


Changes in directory llvm/lib/Analysis/DataStructure:

Local.cpp updated: 1.154.2.1 - 1.154.2.2
---
Log message:

Round 2 of DIV updates. 


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

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


Index: llvm/lib/Analysis/DataStructure/Local.cpp
diff -u llvm/lib/Analysis/DataStructure/Local.cpp:1.154.2.1 
llvm/lib/Analysis/DataStructure/Local.cpp:1.154.2.2
--- llvm/lib/Analysis/DataStructure/Local.cpp:1.154.2.1 Wed Oct 18 22:57:55 2006
+++ llvm/lib/Analysis/DataStructure/Local.cpp   Wed Oct 25 20:58:05 2006
@@ -419,7 +419,7 @@
 #if 0
 if (const SequentialType *STy = castSequentialType(*I)) {
   CurTy = STy-getElementType();
-  if (ConstantSInt *CS = dyn_castConstantSInt(GEP.getOperand(i))) {
+  if (ConstantInt *CS = dyn_castConstantInt(GEP.getOperand(i))) {
 Offset += CS-getValue()*TD.getTypeSize(CurTy);
   } else {
 // Variable index into a node.  We must merge all of the elements of 
the



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


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

2006-10-25 Thread Reid Spencer


Changes in directory llvm/lib/VMCore:

ConstantFolding.cpp updated: 1.93.2.8 - 1.93.2.9
Constants.cpp updated: 1.163.2.9 - 1.163.2.10
Instructions.cpp updated: 1.42.2.6 - 1.42.2.7
---
Log message:

Round 2 of DIV updates. 


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

 ConstantFolding.cpp |   28 
 Constants.cpp   |   34 ++
 Instructions.cpp|   33 +++--
 3 files changed, 73 insertions(+), 22 deletions(-)


Index: llvm/lib/VMCore/ConstantFolding.cpp
diff -u llvm/lib/VMCore/ConstantFolding.cpp:1.93.2.8 
llvm/lib/VMCore/ConstantFolding.cpp:1.93.2.9
--- llvm/lib/VMCore/ConstantFolding.cpp:1.93.2.8Mon Oct 23 13:13:27 2006
+++ llvm/lib/VMCore/ConstantFolding.cpp Wed Oct 25 20:58:05 2006
@@ -531,30 +531,27 @@
 if (V2-isAllOnesValue()   // MIN_INT / -1
 (BuiltinType)V1-getZExtValue() == -(BuiltinType)V1-getZExtValue())
   return 0;
-BuiltinType R = 
-  (BuiltinType)V1-getZExtValue() / (BuiltinType)V2-getZExtValue();
+BuiltinType R = BuiltinType(V1-getZExtValue() / V2-getZExtValue());
 return ConstantInt::get(*Ty, R);
   }
 
-  static Constant *URem(const ConstantInt *V1,
-const ConstantInt *V2) {
-if (V2-isNullValue()) return 0; // X / 0
+  static Constant *SDiv(const ConstantInt *V1, const ConstantInt *V2) {
+if (V2-isNullValue()) 
+  return 0;
 if (V2-isAllOnesValue()   // MIN_INT / -1
-(BuiltinType)V1-getZExtValue() == -(BuiltinType)V1-getZExtValue())
+(BuiltinType)V1-getSExtValue() == -(BuiltinType)V1-getSExtValue())
   return 0;
-BuiltinType R = 
-  (BuiltinType)V1-getZExtValue() % (BuiltinType)V2-getZExtValue();
+BuiltinType R = BuiltinType(V1-getSExtValue() / V2-getSExtValue());
 return ConstantInt::get(*Ty, R);
   }
 
-  static Constant *SDiv(const ConstantInt *V1, const ConstantInt *V2) {
-if (V2-isNullValue()) 
-  return 0;
+  static Constant *URem(const ConstantInt *V1,
+const ConstantInt *V2) {
+if (V2-isNullValue()) return 0; // X / 0
 if (V2-isAllOnesValue()   // MIN_INT / -1
-(BuiltinType)V1-getSExtValue() == -(BuiltinType)V1-getSExtValue())
+(BuiltinType)V1-getZExtValue() == -(BuiltinType)V1-getZExtValue())
   return 0;
-BuiltinType R = 
-  (BuiltinType)V1-getSExtValue() / (BuiltinType)V2-getSExtValue();
+BuiltinType R = BuiltinType(V1-getZExtValue() % V2-getZExtValue());
 return ConstantInt::get(*Ty, R);
   }
 
@@ -564,8 +561,7 @@
 if (V2-isAllOnesValue()   // MIN_INT / -1
 (BuiltinType)V1-getSExtValue() == -(BuiltinType)V1-getSExtValue())
   return 0;
-BuiltinType R = 
-  (BuiltinType)V1-getSExtValue() % (BuiltinType)V2-getSExtValue();
+BuiltinType R = BuiltinType(V1-getSExtValue() % V2-getSExtValue());
 return ConstantInt::get(*Ty, R);
   }
 


Index: llvm/lib/VMCore/Constants.cpp
diff -u llvm/lib/VMCore/Constants.cpp:1.163.2.9 
llvm/lib/VMCore/Constants.cpp:1.163.2.10
--- llvm/lib/VMCore/Constants.cpp:1.163.2.9 Mon Oct 23 13:13:27 2006
+++ llvm/lib/VMCore/Constants.cpp   Wed Oct 25 20:58:05 2006
@@ -1421,15 +1421,41 @@
 Constant *ConstantExpr::get(unsigned Opcode, Constant *C1, Constant *C2) {
 #ifndef NDEBUG
   switch (Opcode) {
-  case Instruction::Add: case Instruction::Sub:
-  case Instruction::URem: case Instruction::SRem: case Instruction::FRem:
-  case Instruction::Mul: case Instruction::UDiv: 
-  case Instruction::SDiv: case Instruction::FDiv:
+  case Instruction::Add: 
+  case Instruction::Sub:
+  case Instruction::Mul: 
 assert(C1-getType() == C2-getType()  Op types should be identical!);
 assert((C1-getType()-isInteger() || C1-getType()-isFloatingPoint() ||
 isaPackedType(C1-getType())) 
Tried to create an arithmetic operation on a non-arithmetic 
type!);
 break;
+  case Instruction::UDiv: 
+  case Instruction::SDiv: 
+assert(C1-getType() == C2-getType()  Op types should be identical!);
+assert((C1-getType()-isInteger() || (isaPackedType(C1-getType()) 
+  castPackedType(C1-getType())-getElementType()-isInteger())) 
+   Tried to create an arithmetic operation on a non-arithmetic 
type!);
+break;
+  case Instruction::FDiv:
+assert(C1-getType() == C2-getType()  Op types should be identical!);
+assert((C1-getType()-isFloatingPoint() || (isaPackedType(C1-getType())
+   
castPackedType(C1-getType())-getElementType()-isFloatingPoint())) 
+   Tried to create an arithmetic operation on a non-arithmetic type!);
+break;
+  case Instruction::URem: 
+  case Instruction::SRem: 
+assert(C1-getType() == C2-getType()  Op types should be identical!);
+assert((C1-getType()-isInteger() || (isaPackedType(C1-getType()) 
+  castPackedType(C1-getType())-getElementType()-isInteger())) 
+   Tried to create an arithmetic operation 

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

2006-10-25 Thread Reid Spencer


Changes in directory llvm/lib/Bytecode/Reader:

Reader.cpp updated: 1.198.2.7 - 1.198.2.8
---
Log message:

Round 2 of DIV updates. 


---
Diffs of the changes:  (+348 -342)

 Reader.cpp |  690 ++---
 1 files changed, 348 insertions(+), 342 deletions(-)


Index: llvm/lib/Bytecode/Reader/Reader.cpp
diff -u llvm/lib/Bytecode/Reader/Reader.cpp:1.198.2.7 
llvm/lib/Bytecode/Reader/Reader.cpp:1.198.2.8
--- llvm/lib/Bytecode/Reader/Reader.cpp:1.198.2.7   Mon Oct 23 13:13:26 2006
+++ llvm/lib/Bytecode/Reader/Reader.cpp Wed Oct 25 20:58:05 2006
@@ -562,10 +562,17 @@
 insertValue(AI, getTypeSlot(AI-getType()), FunctionValues);
 }
 
-/// Convert previous opcode values into the current value and/or construct
-/// the instruction. This function handles all *abnormal* cases for instruction
-/// generation based on obsolete opcode values. The normal cases are handled
-/// in ParseInstruction below.
+// Convert previous opcode values into the current value and/or construct
+// the instruction. This function handles all *abnormal* cases for instruction
+// generation based on obsolete opcode values. The normal cases are handled
+// in ParseInstruction below.  Generally this function just produces a new
+// Opcode value (first argument). In a few cases (VAArg, VANext) the upgrade
+// path requies that the instruction (sequence) be generated differently from
+// the normal case in order to preserve the original semantics. In these 
+// cases the result of the function will be a non-zero Instruction pointer. In
+// all other cases, zero will be returned indicating that the *normal*
+// instruction generation should be used, but with the new Opcode value.
+// 
 Instruction*
 BytecodeReader::handleObsoleteOpcodes(
   unsigned Opcode,   /// The old opcode, possibly updated by this function
@@ -575,11 +582,21 @@
   BasicBlock* BB  /// The basic block to insert into, if we need to
 ) {
 
-  // Declare the resulting instruction we might build.
+  // First, short circuit this if no conversion is required. When signless
+  // instructions were implemented the entire opcode sequence was revised so
+  // we key on this first which means that the opcode value read is the one
+  // we should use.
+  if (!hasSignlessInstructions)
+return 0; // The opcode is fine the way it is.
+
+  // Declare the resulting instruction we might build. In general we just 
+  // change the Opcode argument but in a few cases we need to generate the 
+  // Instruction here because the upgrade case is significantly different from 
+  // the normal case.
   Instruction *Result = 0;
 
   // If this is a bytecode format that did not include the unreachable
-  // instruction, bump up the opcode number to adjust
+  // instruction, bump up the opcode number to adjust it.
   if (hasNoUnreachableInst) {
 if (Opcode = Instruction::Unreachable 
 Opcode  62) { // 62 
@@ -587,20 +604,15 @@
 }
   }
 
-  // First, short circuit this if no conversion is required. When signless
-  // instructions were implemented the entire opcode sequence was revised so
-  // we key on this first which means that the opcode value read is the one
-  // we should use.
-  if (!hasSignlessInstructions)
-return Result;
-
   // We're dealing with an upgrade situation. For each of the opcode values,
   // perform the necessary conversion.
   switch (Opcode) {
-default: // Pass Through
-  // If we don't match any of the cases here then the opcode is fine the
-  // way it is. That will happen for the opcodes  53 which are the
-  // volatile load/store, and call/invoke with calling conventions.
+default: // Error
+  // This switch statement provides cases for all known opcodes prior to
+  // version 6 bytecode format. We know we're in an upgrade situation so
+  // if there isn't a match in this switch, then something is horribly
+  // wrong.
+  error(Unknown obsolete opcode encountered.);
   break;
 case 1: // Ret
   Opcode = Instruction::Ret;
@@ -886,12 +898,12 @@
 handleObsoleteOpcodes(Opcode, Oprnds, iType, InstTy, BB);
 
   // We have enough info to inform the handler now.
-  if (Handler) Handler-handleInstruction(Opcode, InstTy, Oprnds, At-SaveAt);
+  if (Handler) 
+Handler-handleInstruction(Opcode, InstTy, Oprnds, At-SaveAt);
 
   // If the backwards compatibility code didn't produce an instruction then
   // we do the *normal* thing ..
   if (!Result) {
-
 // First, handle the easy binary operators case
 if (Opcode = Instruction::BinaryOpsBegin 
 Opcode   Instruction::BinaryOpsEnd   Oprnds.size() == 2)
@@ -900,361 +912,355 @@
   getValue(iType, Oprnds[1]));
 
 // Indicate that we don't think this is a call instruction (yet).
-bool isCall = false;
-
 // Process based on the Opcode read
 switch (Opcode) {
-  default: // There was an error, this shouldn't happen.
-if 

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

2006-10-25 Thread Reid Spencer


Changes in directory llvm/lib/CodeGen/SelectionDAG:

SelectionDAGISel.cpp updated: 1.289.2.6 - 1.289.2.7
---
Log message:

Round 2 of DIV updates. 


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

 SelectionDAGISel.cpp |   14 ++
 1 files changed, 6 insertions(+), 8 deletions(-)


Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
diff -u llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.289.2.6 
llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.289.2.7
--- llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.289.2.6Mon Oct 
23 13:13:26 2006
+++ llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp  Wed Oct 25 20:58:05 2006
@@ -1109,13 +1109,12 @@
   SDOperand Op1 = getValue(I.getOperand(0));
   SDOperand Op2 = getValue(I.getOperand(1));
 
-  if (Ty-isIntegral()) {
-setValue(I, DAG.getNode(IntOp, Op1.getValueType(), Op1, Op2));
-  } else {
-const PackedType *PTy = castPackedType(Ty);
+  if (const PackedType *PTy = dyn_castPackedType(Ty)) {
 SDOperand Num = DAG.getConstant(PTy-getNumElements(), MVT::i32);
 SDOperand Typ = DAG.getValueType(TLI.getValueType(PTy-getElementType()));
 setValue(I, DAG.getNode(VecOp, MVT::Vector, Op1, Op2, Num, Typ));
+  } else {
+setValue(I, DAG.getNode(IntOp, Op1.getValueType(), Op1, Op2));
   }
 }
 
@@ -1125,13 +1124,12 @@
   SDOperand Op1 = getValue(I.getOperand(0));
   SDOperand Op2 = getValue(I.getOperand(1));
 
-  if (Ty-isFloatingPoint()) {
-setValue(I, DAG.getNode(FPOp, Op1.getValueType(), Op1, Op2));
-  } else {
-const PackedType *PTy = castPackedType(Ty);
+  if (const PackedType *PTy = dyn_castPackedType(Ty)) {
 SDOperand Num = DAG.getConstant(PTy-getNumElements(), MVT::i32);
 SDOperand Typ = DAG.getValueType(TLI.getValueType(PTy-getElementType()));
 setValue(I, DAG.getNode(VecOp, MVT::Vector, Op1, Op2, Num, Typ));
+  } else {
+setValue(I, DAG.getNode(FPOp, Op1.getValueType(), Op1, Op2));
   }
 }
 



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


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

2006-10-25 Thread Reid Spencer


Changes in directory llvm/lib/ExecutionEngine/Interpreter:

Execution.cpp updated: 1.139.6.4 - 1.139.6.5
---
Log message:

Round 2 of DIV updates. 


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

 Execution.cpp |   60 ++
 1 files changed, 48 insertions(+), 12 deletions(-)


Index: llvm/lib/ExecutionEngine/Interpreter/Execution.cpp
diff -u llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.139.6.4 
llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.139.6.5
--- llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.139.6.4Mon Oct 
23 13:13:26 2006
+++ llvm/lib/ExecutionEngine/Interpreter/Execution.cpp  Wed Oct 25 20:58:05 2006
@@ -42,8 +42,12 @@
const Type *Ty);
 static GenericValue executeRemInst(GenericValue Src1, GenericValue Src2,
const Type *Ty);
-static GenericValue executeDivInst(GenericValue Src1, GenericValue Src2,
-   const Type *Ty);
+static GenericValue executeUDivInst(GenericValue Src1, GenericValue Src2,
+const Type *Ty);
+static GenericValue executeSDivInst(GenericValue Src1, GenericValue Src2,
+const Type *Ty);
+static GenericValue executeFDivInst(GenericValue Src1, GenericValue Src2,
+const Type *Ty);
 static GenericValue executeAndInst(GenericValue Src1, GenericValue Src2,
const Type *Ty);
 static GenericValue executeOrInst(GenericValue Src1, GenericValue Src2,
@@ -90,11 +94,17 @@
   getOperandValue(CE-getOperand(1), SF),
   CE-getOperand(0)-getType());
   case Instruction::SDiv:
+return executeSDivInst(getOperandValue(CE-getOperand(0), SF),
+   getOperandValue(CE-getOperand(1), SF),
+   CE-getOperand(0)-getType());
   case Instruction::UDiv:
+return executeUDivInst(getOperandValue(CE-getOperand(0), SF),
+   getOperandValue(CE-getOperand(1), SF),
+   CE-getOperand(0)-getType());
   case Instruction::FDiv:
-return executeDivInst(getOperandValue(CE-getOperand(0), SF),
-  getOperandValue(CE-getOperand(1), SF),
-  CE-getOperand(0)-getType());
+return executeFDivInst(getOperandValue(CE-getOperand(0), SF),
+   getOperandValue(CE-getOperand(1), SF),
+   CE-getOperand(0)-getType());
   case Instruction::URem:
   case Instruction::SRem:
 return executeRemInst(getOperandValue(CE-getOperand(0), SF),
@@ -245,18 +255,44 @@
   return Dest;
 }
 
-static GenericValue executeDivInst(GenericValue Src1, GenericValue Src2,
+static GenericValue executeUDivInst(GenericValue Src1, GenericValue Src2,
const Type *Ty) {
   GenericValue Dest;
+  if (Ty-isSigned())
+Ty = Ty-getUnsignedVersion();
   switch (Ty-getTypeID()) {
 IMPLEMENT_BINARY_OPERATOR(/, UByte);
-IMPLEMENT_BINARY_OPERATOR(/, SByte);
 IMPLEMENT_BINARY_OPERATOR(/, UShort);
-IMPLEMENT_BINARY_OPERATOR(/, Short);
 IMPLEMENT_BINARY_OPERATOR(/, UInt);
-IMPLEMENT_BINARY_OPERATOR(/, Int);
 IMPLEMENT_BINARY_OPERATOR(/, ULong);
+  default:
+std::cout  Unhandled type for UDiv instruction:   *Ty  \n;
+abort();
+  }
+  return Dest;
+}
+
+static GenericValue executeSDivInst(GenericValue Src1, GenericValue Src2,
+   const Type *Ty) {
+  GenericValue Dest;
+  if (Ty-isUnsigned())
+Ty = Ty-getSignedVersion();
+  switch (Ty-getTypeID()) {
+IMPLEMENT_BINARY_OPERATOR(/, SByte);
+IMPLEMENT_BINARY_OPERATOR(/, Short);
+IMPLEMENT_BINARY_OPERATOR(/, Int);
 IMPLEMENT_BINARY_OPERATOR(/, Long);
+  default:
+std::cout  Unhandled type for SDiv instruction:   *Ty  \n;
+abort();
+  }
+  return Dest;
+}
+
+static GenericValue executeFDivInst(GenericValue Src1, GenericValue Src2,
+   const Type *Ty) {
+  GenericValue Dest;
+  switch (Ty-getTypeID()) {
 IMPLEMENT_BINARY_OPERATOR(/, Float);
 IMPLEMENT_BINARY_OPERATOR(/, Double);
   default:
@@ -510,9 +546,9 @@
   case Instruction::URem:
   case Instruction::SRem:  
   case Instruction::FRem:  R = executeRemInst  (Src1, Src2, Ty); break;
-  case Instruction::SDiv:  
-  case Instruction::UDiv:  
-  case Instruction::FDiv:  R = executeDivInst  (Src1, Src2, Ty); break;
+  case Instruction::UDiv:  R = executeUDivInst (Src1, Src2, Ty); break;
+  case Instruction::SDiv:  R = executeSDivInst (Src1, Src2, Ty); break;
+  case Instruction::FDiv:  R = executeFDivInst (Src1, Src2, Ty); break;
   case Instruction::And:   R = executeAndInst  (Src1, Src2, Ty); break;
   case Instruction::Or:R = executeOrInst   (Src1, Src2, Ty); break;
   case Instruction::Xor:   R = executeXorInst  (Src1, Src2, Ty); break;




[llvm-commits] [SignlessTypes] CVS: llvm/lib/Analysis/ScalarEvolution.cpp

2006-10-25 Thread Reid Spencer


Changes in directory llvm/lib/Analysis:

ScalarEvolution.cpp updated: 1.53.2.4 - 1.53.2.5
---
Log message:

Round 2 of DIV updates. 


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

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


Index: llvm/lib/Analysis/ScalarEvolution.cpp
diff -u llvm/lib/Analysis/ScalarEvolution.cpp:1.53.2.4 
llvm/lib/Analysis/ScalarEvolution.cpp:1.53.2.5
--- llvm/lib/Analysis/ScalarEvolution.cpp:1.53.2.4  Mon Oct 23 13:13:26 2006
+++ llvm/lib/Analysis/ScalarEvolution.cpp   Wed Oct 25 20:58:05 2006
@@ -1385,9 +1385,8 @@
   return SCEVMulExpr::get(getSCEV(I-getOperand(0)),
   getSCEV(I-getOperand(1)));
 case Instruction::SDiv:
-  if (V-getType()-isInteger())
-return SCEVSDivExpr::get(getSCEV(I-getOperand(0)),
- getSCEV(I-getOperand(1)));
+  return SCEVSDivExpr::get(getSCEV(I-getOperand(0)),
+  getSCEV(I-getOperand(1)));
   break;
 
 case Instruction::Sub:



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


[llvm-commits] [SignlessTypes] CVS: llvm/lib/AsmParser/llvmAsmParser.y

2006-10-25 Thread Reid Spencer


Changes in directory llvm/lib/AsmParser:

llvmAsmParser.y updated: 1.266.2.8 - 1.266.2.9
---
Log message:

Round 2 of DIV updates. 


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

 llvmAsmParser.y |   92 
 1 files changed, 47 insertions(+), 45 deletions(-)


Index: llvm/lib/AsmParser/llvmAsmParser.y
diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.266.2.8 
llvm/lib/AsmParser/llvmAsmParser.y:1.266.2.9
--- llvm/lib/AsmParser/llvmAsmParser.y:1.266.2.8Mon Oct 23 13:13:26 2006
+++ llvm/lib/AsmParser/llvmAsmParser.y  Wed Oct 25 20:58:05 2006
@@ -813,50 +813,48 @@
   return Ty;
 }
 
-// This template function is used to obtain the correct opcode for an 
-// instruction when an obsolete opcode is encountered. The OpcodeInfo template
-// keeps track of the opcode and the obsolete flag. These are generated by
-// the lexer and obsolete will be true when the lexer encounters the token for
+// This function is used to obtain the correct opcode for an instruction when 
+// an obsolete opcode is encountered. The OI parameter (OpcodeInfo) has both 
+// an opcode and an obsolete flag. These are generated by the lexer and 
+// the obsolete member will be true when the lexer encounters the token for
 // an obsolete opcode. For example, div was replaced by [usf]div but we need
 // to maintain backwards compatibility for asm files that still have the div
 // instruction. This function handles converting div - [usf]div appropriately.
-template class EnumKind
-static void sanitizeOpCode(OpcodeInfoEnumKind OI, const PATypeHolder Ty) {
-  if (OI.obsolete) {
-switch (OI.opcode) {
-  default:
-GenerateError(Invalid Obsolete OpCode);
-break;
-  case Instruction::UDiv:
-if (Ty-isFloatingPoint()) 
-  OI.opcode = Instruction::FDiv;
-else if (Ty-isSigned())
-  OI.opcode = Instruction::SDiv;
-break;
-  case Instruction::SDiv:
-if (Ty-isFloatingPoint()) 
-  OI.opcode = Instruction::FDiv;
-else if (Ty-isUnsigned())
-  OI.opcode = Instruction::UDiv;
-break;
-  case Instruction::URem:
-if (Ty-isFloatingPoint()) 
-  OI.opcode = Instruction::FRem;
-else if (Ty-isSigned())
-  OI.opcode = Instruction::SRem;
-break;
-  case Instruction::SRem:
-if (Ty-isFloatingPoint()) 
-  OI.opcode = Instruction::FRem;
-else if (Ty-isUnsigned())
-  OI.opcode = Instruction::URem;
-break;
-}
-OI.obsolete = false;
+static void 
+sanitizeOpCode(OpcodeInfoInstruction::BinaryOps OI, const PATypeHolder 
PATy)
+{
+  // If its not obsolete, don't do anything
+  if (!OI.obsolete) 
+return;
+
+  // If its a packed type we want to use the element type
+  const Type* Ty = PATy;
+  if (const PackedType* PTy = dyn_castPackedType(Ty))
+Ty = PTy-getElementType();
+
+  // Depending on the opcode ..
+  switch (OI.opcode) {
+default:
+  GenerateError(Invalid Obsolete OpCode);
+  break;
+case Instruction::UDiv:
+  // Handle cases where the opcode needs to change
+  if (Ty-isFloatingPoint()) 
+OI.opcode = Instruction::FDiv;
+  else if (Ty-isSigned())
+OI.opcode = Instruction::SDiv;
+  break;
+case Instruction::URem:
+  if (Ty-isFloatingPoint()) 
+OI.opcode = Instruction::FRem;
+  else if (Ty-isSigned())
+OI.opcode = Instruction::SRem;
+  break;
   }
+  // Its not obsolete any more, we fixed it.
+  OI.obsolete = false;
 }
-
-
+  
 // common code from the two 'RunVMAsmParser' functions
 static Module* RunParser(Module * M) {
 
@@ -1045,13 +1043,13 @@
   bool  BoolVal;
 
   char *StrVal;   // This memory is strdup'd!
-  llvm::ValID ValIDVal; // strdup'd memory maybe!
+  llvm::ValID   ValIDVal; // strdup'd memory maybe!
 
-  BinaryOpInfo  BinaryOpVal;
-  TermOpInfoTermOpVal;
-  MemOpInfo MemOpVal;
-  OtherOpInfo   OtherOpVal;
-  llvm::Module::Endianness  Endianness;
+  BinaryOpInfo  BinaryOpVal;
+  TermOpInfoTermOpVal;
+  MemOpInfo MemOpVal;
+  OtherOpInfo   OtherOpVal;
+  llvm::Module::Endianness  Endianness;
 }
 
 %type ModuleVal Module FunctionList
@@ -1685,8 +1683,11 @@
   | ArithmeticOps '(' ConstVal ',' ConstVal ')' {
 if ($3-getType() != $5-getType())
   GEN_ERROR(Binary operator types must match!);
+// First, make sure we're dealing with the right opcode by upgrading from
+// obsolete versions.
 sanitizeOpCode($1,$3-getType());
 CHECK_FOR_ERROR;
+
 // HACK: llvm 1.3 and earlier used to emit invalid pointer constant exprs.
 // To retain backward compatibility with these early compilers, we emit a
 // cast to the appropriate integer type automatically if we are in the
@@ -2473,6 

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

2006-10-25 Thread Nick Lewycky


Changes in directory llvm/lib/Transforms/Scalar:

PredicateSimplifier.cpp updated: 1.28 - 1.29
---
Log message:

Fix 2006-10-25-AddSetCC. A relational operator (like setlt) can never
produce an EQ property.


---
Diffs of the changes:  (+46 -27)

 PredicateSimplifier.cpp |   73 ++--
 1 files changed, 46 insertions(+), 27 deletions(-)


Index: llvm/lib/Transforms/Scalar/PredicateSimplifier.cpp
diff -u llvm/lib/Transforms/Scalar/PredicateSimplifier.cpp:1.28 
llvm/lib/Transforms/Scalar/PredicateSimplifier.cpp:1.29
--- llvm/lib/Transforms/Scalar/PredicateSimplifier.cpp:1.28 Wed Oct 25 
18:48:24 2006
+++ llvm/lib/Transforms/Scalar/PredicateSimplifier.cpp  Wed Oct 25 21:35:18 2006
@@ -316,21 +316,6 @@
   Iter I1, I2;
 };
 
-void add(Ops Opcode, Value *V1, Value *V2, bool invert) {
-  switch (Opcode) {
-case EQ:
-  if (invert) addNotEqual(V1, V2);
-  elseaddEqual(V1, V2);
-  break;
-case NE:
-  if (invert) addEqual(V1, V2);
-  elseaddNotEqual(V1, V2);
-  break;
-default:
-  assert(0  Unknown property opcode.);
-  }
-}
-
 void addToResolve(Value *V, std::listValue * WorkList) {
   if (!isaConstant(V)  !isaBasicBlock(V)) {
 for (Value::use_iterator UI = V-use_begin(), UE = V-use_end();
@@ -398,31 +383,65 @@
   if (!WorkList.empty()) resolve(WorkList);
 }
 
-// Finds the properties implied by an equivalence and adds them too.
-// Example: (seteq %a, %b, true,  EQ) -- (%a, %b, EQ)
-//  (seteq %a, %b, false, EQ) -- (%a, %b, NE)
+void add(Ops Opcode, Value *V1, Value *V2, bool invert) {
+  switch (Opcode) {
+case EQ:
+  if (invert) addNotEqual(V1, V2);
+  elseaddEqual(V1, V2);
+  break;
+case NE:
+  if (invert) addEqual(V1, V2);
+  elseaddNotEqual(V1, V2);
+  break;
+default:
+  assert(0  Unknown property opcode.);
+  }
+}
+
+/// Finds the properties implied by an equivalence and adds them too.
+/// Example: (seteq %a, %b, true,  EQ) -- (%a, %b, EQ)
+///  (seteq %a, %b, false, EQ) -- (%a, %b, NE)
 void addImpliedProperties(Ops Opcode, Value *V1, Value *V2) {
   order(V1, V2);
 
   if (BinaryOperator *BO = dyn_castBinaryOperator(V2)) {
 switch (BO-getOpcode()) {
 case Instruction::SetEQ:
+  // seteq int %a, %b EQ true  then %a EQ %b
+  // seteq int %a, %b EQ false then %a NE %b
+  // seteq int %a, %b NE true  then %a NE %b
+  // seteq int %a, %b NE false then %a EQ %b
   if (ConstantBool *V1CB = dyn_castConstantBool(V1))
 add(Opcode, BO-getOperand(0), 
BO-getOperand(1),!V1CB-getValue());
   break;
 case Instruction::SetNE:
+  // setne int %a, %b EQ true  then %a NE %b
+  // setne int %a, %b EQ false then %a EQ %b
+  // setne int %a, %b NE true  then %a EQ %b
+  // setne int %a, %b NE false then %a NE %b
   if (ConstantBool *V1CB = dyn_castConstantBool(V1))
 add(Opcode, BO-getOperand(0), BO-getOperand(1), 
V1CB-getValue());
   break;
 case Instruction::SetLT:
 case Instruction::SetGT:
-  if (V1 == ConstantBool::getTrue())
-add(Opcode, BO-getOperand(0), BO-getOperand(1), true);
+  // setlt/gt int %a, %b EQ true  then %a NE %b
+  // setlt/gt int %a, %b NE false then %a NE %b
+
+  // setlt int %a, %b NE true then %a EQ %b
+
+  if (ConstantBool *CB = dyn_castConstantBool(V1)) {
+if (CB-getValue() ^ Opcode==NE)
+  addNotEqual(BO-getOperand(0), BO-getOperand(1));
+ }
   break;
 case Instruction::SetLE:
 case Instruction::SetGE:
-  if (V1 == ConstantBool::getFalse())
-add(Opcode, BO-getOperand(0), BO-getOperand(1), true);
+  // setle/ge int %a, %b EQ false then %a NE %b
+  // setle/ge int %a, %b NE true  then %a NE %b
+  if (ConstantBool *CB = dyn_castConstantBool(V1)) {
+if (CB-getValue() ^ Opcode==EQ)
+  addNotEqual(BO-getOperand(0), BO-getOperand(1));
+ }
   break;
 case Instruction::And: {
   // and int %a, %b  EQ 0xff  then %a EQ 0xff and %b EQ 0xff
@@ -461,15 +480,15 @@
   //EQ true and NE true in place of EQ false.
   // xor int %c, %a EQ %c then %a = 0
   // xor int %c, %a NE %c then %a != 0
-  // 2. Repeat all of the above, with the operands swapped.
+  // 2. Repeat all of the above, with order of operands reversed.
 
   Value *LHS = BO-getOperand(0), *RHS = BO-getOperand(1);
   if (!isaConstant(LHS)) std::swap(LHS, RHS);
 
   if (ConstantBool *CB = dyn_castConstantBool(V1)) {
 if (ConstantBool *A = dyn_castConstantBool(LHS)) {

[llvm-commits] CVS: llvm/test/Regression/Transforms/PredicateSimplifier/2006-10-25-AddSetCC.ll

2006-10-25 Thread Nick Lewycky


Changes in directory llvm/test/Regression/Transforms/PredicateSimplifier:

2006-10-25-AddSetCC.ll added (r1.1)
---
Log message:

Handling of setlt/le/gt/ge is broken at the moment; predsimplify removes
the call the pass2.


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

 2006-10-25-AddSetCC.ll |   27 +++
 1 files changed, 27 insertions(+)


Index: 
llvm/test/Regression/Transforms/PredicateSimplifier/2006-10-25-AddSetCC.ll
diff -c /dev/null 
llvm/test/Regression/Transforms/PredicateSimplifier/2006-10-25-AddSetCC.ll:1.1
*** /dev/null   Wed Oct 25 21:34:01 2006
--- llvm/test/Regression/Transforms/PredicateSimplifier/2006-10-25-AddSetCC.ll  
Wed Oct 25 21:33:51 2006
***
*** 0 
--- 1,27 
+ ; RUN: llvm-as  %s | opt -predsimplify -instcombine -simplifycfg 
-disable-output 
+ ; RUN: llvm-as  %s | opt -predsimplify -instcombine -simplifycfg | llvm-dis 
| grep -v declare | grep -c pass | grep 2
+ 
+ int %test(int %x, int %y) {
+ entry:
+ %tmp2 = setlt int %x, %y
+   %tmp = setne bool %tmp2, true
+   br bool %tmp, label %cond_true, label %return
+ 
+ cond_true:; preds = %entry
+   %tmp4 = seteq int %x, %y; bool [#uses=1]
+   br bool %tmp4, label %cond_true5, label %cond_false
+ 
+ cond_true5:   ; preds = %cond_true
+   %tmp6 = call int %pass1( )  ; int [#uses=1]
+   ret int %tmp6
+ 
+ cond_false:
+   %tmp8 = call int %pass2( )  ; int [#uses=1]
+   ret int %tmp8
+ 
+ return:   ; preds = %cond_next7
+   ret int 0
+ }
+ 
+ declare int %pass1()
+ declare int %pass2()



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


Re: [llvm-commits] Div-[USF]Div Patch, Attempt #2

2006-10-25 Thread Chris Lattner
On Oct 25, 2006, at 12:15 PM, Reid Spencer wrote:Attached are two patch files to replace the DIV instruction with 3instructions: SDiv, UDiv, FDiv. The first file patches llvm. The secondfile patches llvm-gcc4. This is the 2nd attempt to provide the patch.  All comments are welcome.llvm-gcc part first:Instead of adding a switch stmt to EmitBinOp, please change it to something like this:+++ gcc/llvm-convert.cpp	(working copy)@@ -544,9 +544,15 @@   case PLUS_EXPR:      Result = EmitBinOp(exp, DestLoc, Instruction::Add);break;   case MINUS_EXPR:     Result = EmitBinOp(exp, DestLoc, Instruction::Sub);break;   case MULT_EXPR:      Result = EmitBinOp(exp, DestLoc, Instruction::Mul);break;-  case TRUNC_DIV_EXPR: Result = EmitBinOp(exp, DestLoc, Instruction::Div);break;-  case EXACT_DIV_EXPR: Result = EmitBinOp(exp, DestLoc, Instruction::Div);break;-  case RDIV_EXPR:      Result = EmitBinOp(exp, DestLoc, Instruction::Div);break;+  case TRUNC_DIV_EXPR: +    if (TREE_UNSIGNED(TREE_TYPE(exp)))+      Result = EmitBinOp(exp, DestLoc, Instruction::UDiv);+    else+      Result = EmitBinOp(exp, DestLoc, Instruction::SDiv);+    break;EXACT_DIV_EXPR should always be UDiv, RDIV_EXPR is fine.-Chris___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


Re: [llvm-commits] Div-[USF]Div Patch, Attempt #2

2006-10-25 Thread Chris Lattner
On Oct 25, 2006, at 12:15 PM, Reid Spencer wrote:Attached are two patch files to replace the DIV instruction with 3instructions: SDiv, UDiv, FDiv. The first file patches llvm. The secondfile patches llvm-gcc4. This is the 2nd attempt to provide the patch.  All comments are welcome.This patch is *far* improved over the last one.  Nit picky stuff below.  Please make these changes, but there is no need to repost these diffs for review.llvm part, without instcombine:+// This function is used to obtain the correct opcode for an instruction when +// an obsolete opcode is encountered. The OI parameter (OpcodeInfo) has both +// an opcode and an "obsolete" flag. These are generated by the lexer and +// the "obsolete" member will be true when the lexer encounters the token for+// an obsolete opcode. For example, "div" was replaced by [usf]div but we need+// to maintain backwards compatibility for asm files that still have the "div"+// instruction. This function handles converting div - [usf]div appropriately.+static void +sanitizeOpCode(OpcodeInfoInstruction::BinaryOps OI, const PATypeHolder PATy)+{Please convert this to a doxygen comment.  Please change the second argument to "const Type *Ty".Bytecode/Reader.cpp:+  // If this is a bytecode format that did not include the unreachable+  // instruction, bump up the opcode number to adjust it.+  if (hasNoUnreachableInst) {+    if (Opcode = Instruction::Unreachable +        Opcode  62) { // 62 +      ++Opcode;+    }+  }What is the "// 62" comment?+    case 11: // Rem+      // As with "Div", make the signed/unsigned Rem instruction choice based+      // on the type of the instruction.+      if (ArgVec[0]-getType()-isFloatingPoint())+        Opcode = Instruction::Rem;+      else if (ArgVec[0]-getType()-isSigned())+        Opcode = Instruction::Rem;+      else+        Opcode = Instruction::Rem;Heh, so forward looking :), no need to change it.+  // In version 5 and prior, the integer types were distinguished by sign. +  // That is we have UIntTy and IntTy as well as ConstantSInt and +  // ConstantUInt. In version 6, the integer types became signless so we+  // need to note that we have signed integer types in prior versions.+  bool hasSignedIntegers;This is set but never checked, please remove it.diff -t -d -u -p -5 -r1.94 ConstantFolding.cpp--- lib/VMCore/ConstantFolding.cpp	20 Oct 2006 07:07:24 -	1.94+++ lib/VMCore/ConstantFolding.cpp	25 Oct 2006 18:51:19 -@@ -38,11 +38,13 @@ namespace {...+  static Constant *UDiv(const ConstantInt *V1, const ConstantInt *V2) {+    if (V2-isNullValue()) +      return 0;     if (V2-isAllOnesValue()               // MIN_INT / -1         (BuiltinType)V1-getZExtValue() == -(BuiltinType)V1-getZExtValue())       return 0;+    BuiltinType R = (BuiltinType)(V1-getZExtValue() / V2-getZExtValue());+    return ConstantInt::get(*Ty, R);+  }This check:      if (V2-isAllOnesValue()               // MIN_INT / -1         (BuiltinType)V1-getZExtValue() == -(BuiltinType)V1-getZExtValue())       return 0;Is not needed in the udiv case, it is over-conservative (yes, the original code was over-conservative in the same way).-Chris___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


Re: [llvm-commits] Div-[USF]Div Patch, Attempt #2

2006-10-25 Thread Chris Lattner
On Oct 25, 2006, at 12:15 PM, Reid Spencer wrote:Attached are two patch files to replace the DIV instruction with 3instructions: SDiv, UDiv, FDiv. The first file patches llvm. The secondfile patches llvm-gcc4. This is the 2nd attempt to provide the patch.  All comments are welcome.Reid.DIV.patchDIV-llvmgcc.patch___llvm-commits mailing listllvm-commits@cs.uiuc.eduhttp://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits Overall, this patch looks very nice.  Please fix the one bug below (adding the regtest) and you are approved to check the whole mess in.Final part (instcombine):+Instruction *InstCombiner::visitFDiv(BinaryOperator I) {+  Value *Op0 = I.getOperand(0), *Op1 = I.getOperand(1);++  return commonDivTransforms(I);+}You can delete Op0/Op1.+          // FIXME: If the operand types don't match the type of the divide +          // then don't attempt this transform. The code below doesn't have the+          // logic to deal with a signed divide and an unsigned compare (and+          // vice versa). This is because (x /s C1) s C2  produces different +          // results than (x /s C1) u C2 or (x /u C1) s C2 or even+          // (x /u C1) u C2.  Simply casting the operands and result won't +          // work. :(  The if statement below tests that condition and bails +          // if it finds it. +          const Type* DivRHSTy = DivRHS-getType();+          unsigned DivOpCode = LHSI-getOpcode();+          if ((DivOpCode == Instruction::SDiv  DivRHSTy-isUnsigned()) ||+              (DivOpCode == Instruction::UDiv  DivRHSTy-isSigned()))+            break;This is good but slightly over conservative.  Please allow the xform to happen if the comparison is an ==/!= comparison (i.e. SetCondInst::isEquality() returns true).Instruction* InstCombiner::commonDivTransforms(BinaryOperator I) {Please add comments above each new function.  The visit* methods don't need comments above them.    // (X / C1) / C2  - X / (C1*C2)    if (Instruction *LHS = dyn_castInstruction(Op0))      if (Instruction::BinaryOps(LHS-getOpcode()) == I.getOpcode())This code is a bit simpler as:    // (X / C1) / C2  - X / (C1*C2)    if (BinaryOperator *LHS = dyn_castBinaryOperator(Op0))      if (LHS-getOpcode() == I.getOpcode())  // udiv X, (Select Cond, C1, C2) -- Select Cond, (shr X, C1), (shr X, C2)  // where C1C2 are powers of two                X = InsertNewInstBefore(                  new CastInst(X, X-getType()-getUnsignedVersion()), I);This (and similar cases) is easier/cleaner with InsertCastBefore.              // Finally, construct the select instruction and return it.              return new SelectInst(SI-getOperand(0), TSI, FSI);In the same xform, this needs to cast the result back to the right type if the operation was signed.  Please write a short regtest for this and check it in with your patch to verify that you get this right (add it to the end of div.ll or something).  Something like this:int %test(int %X, int %Y, bool %C) {	%A = select bool %C, int 1024, int 32	%B = udiv int %Y, %A	ret int %B}-Chris___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


Re: [llvm-commits] Div-[USF]Div Patch, Attempt #2

2006-10-25 Thread Reid Spencer
Done.

On Wed, 2006-10-25 at 20:37 -0700, Chris Lattner wrote:
 
 On Oct 25, 2006, at 12:15 PM, Reid Spencer wrote:
 
  Attached are two patch files to replace the DIV instruction with 3
  instructions: SDiv, UDiv, FDiv. The first file patches llvm. The
  second
  file patches llvm-gcc4. 
  
  
  This is the 2nd attempt to provide the patch.  All comments are
  welcome.
 
 llvm-gcc part first:
 
 
 Instead of adding a switch stmt to EmitBinOp, please change it to
 something like this:
 
 
 +++ gcc/llvm-convert.cpp (working copy)
 @@ -544,9 +544,15 @@
case PLUS_EXPR:  Result = EmitBinOp(exp, DestLoc,
 Instruction::Add);break;
case MINUS_EXPR: Result = EmitBinOp(exp, DestLoc,
 Instruction::Sub);break;
case MULT_EXPR:  Result = EmitBinOp(exp, DestLoc,
 Instruction::Mul);break;
 -  case TRUNC_DIV_EXPR: Result = EmitBinOp(exp, DestLoc,
 Instruction::Div);break;
 -  case EXACT_DIV_EXPR: Result = EmitBinOp(exp, DestLoc,
 Instruction::Div);break;
 -  case RDIV_EXPR:  Result = EmitBinOp(exp, DestLoc,
 Instruction::Div);break;
 +  case TRUNC_DIV_EXPR: 
 +if (TREE_UNSIGNED(TREE_TYPE(exp)))
 +  Result = EmitBinOp(exp, DestLoc, Instruction::UDiv);
 +else
 +  Result = EmitBinOp(exp, DestLoc, Instruction::SDiv);
 +break;
 
 
 EXACT_DIV_EXPR should always be UDiv, RDIV_EXPR is fine.
 
 
 -Chris
 
 
 
 

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


Re: [llvm-commits] Div-[USF]Div Patch, Attempt #2

2006-10-25 Thread Reid Spencer
All Done.

On Wed, 2006-10-25 at 21:03 -0700, Chris Lattner wrote:
 
 On Oct 25, 2006, at 12:15 PM, Reid Spencer wrote:
 
  Attached are two patch files to replace the DIV instruction with 3
  instructions: SDiv, UDiv, FDiv. The first file patches llvm. The
  second
  file patches llvm-gcc4. 
  
  
  This is the 2nd attempt to provide the patch.  All comments are
  welcome.
 
 
 This patch is *far* improved over the last one.  Nit picky stuff
 below.  Please make these changes, but there is no need to repost
 these diffs for review.
 
 
 
 llvm part, without instcombine:
 
 
 +// This function is used to obtain the correct opcode for an
 instruction when 
 +// an obsolete opcode is encountered. The OI parameter (OpcodeInfo)
 has both 
 +// an opcode and an obsolete flag. These are generated by the lexer
 and 
 +// the obsolete member will be true when the lexer encounters the
 token for
 +// an obsolete opcode. For example, div was replaced by [usf]div
 but we need
 +// to maintain backwards compatibility for asm files that still have
 the div
 +// instruction. This function handles converting div - [usf]div
 appropriately.
 +static void 
 +sanitizeOpCode(OpcodeInfoInstruction::BinaryOps OI, const
 PATypeHolder PATy)
 +{
 
 
 Please convert this to a doxygen comment.  Please change the second
 argument to const Type *Ty.
 
 
 
 
 
 
 Bytecode/Reader.cpp:
 
 
 +  // If this is a bytecode format that did not include the
 unreachable
 +  // instruction, bump up the opcode number to adjust it.
 +  if (hasNoUnreachableInst) {
 +if (Opcode = Instruction::Unreachable 
 +Opcode  62) { // 62 
 +  ++Opcode;
 +}
 +  }
 
 
 What is the // 62 comment?
 
 
 
 
 
 
 +case 11: // Rem
 +  // As with Div, make the signed/unsigned Rem instruction
 choice based
 +  // on the type of the instruction.
 +  if (ArgVec[0]-getType()-isFloatingPoint())
 +Opcode = Instruction::Rem;
 +  else if (ArgVec[0]-getType()-isSigned())
 +Opcode = Instruction::Rem;
 +  else
 +Opcode = Instruction::Rem;
 
 
 Heh, so forward looking :), no need to change it.
 
 
 
 
 +  // In version 5 and prior, the integer types were distinguished by
 sign. 
 +  // That is we have UIntTy and IntTy as well as ConstantSInt and 
 +  // ConstantUInt. In version 6, the integer types became signless so
 we
 +  // need to note that we have signed integer types in prior
 versions.
 +  bool hasSignedIntegers;
 
 
 This is set but never checked, please remove it.
 
 
 
 
 diff -t -d -u -p -5 -r1.94 ConstantFolding.cpp
 --- lib/VMCore/ConstantFolding.cpp 20 Oct 2006 07:07:24 - 1.94
 +++ lib/VMCore/ConstantFolding.cpp 25 Oct 2006 18:51:19 -
 @@ -38,11 +38,13 @@ namespace {
 
 
 ...
 
 
 +  static Constant *UDiv(const ConstantInt *V1, const ConstantInt *V2)
 {
 +if (V2-isNullValue()) 
 +  return 0;
  if (V2-isAllOnesValue()   // MIN_INT / -1
  (BuiltinType)V1-getZExtValue() ==
 -(BuiltinType)V1-getZExtValue())
return 0;
 +BuiltinType R = (BuiltinType)(V1-getZExtValue() /
 V2-getZExtValue());
 +return ConstantInt::get(*Ty, R);
 +  }
 
 
 
 
 This check: 
  if (V2-isAllOnesValue()   // MIN_INT / -1
  (BuiltinType)V1-getZExtValue() ==
 -(BuiltinType)V1-getZExtValue())
return 0;
 
 
 Is not needed in the udiv case, it is over-conservative (yes, the
 original code was over-conservative in the same way).
 
 
 
 
 -Chris
 
 

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


Re: [llvm-commits] Div-[USF]Div Patch, Attempt #2

2006-10-25 Thread Reid Spencer
Chris,

A couple side notes on this one ...

On Wed, 2006-10-25 at 21:19 -0700, Chris Lattner wrote:

 
 Overall, this patch looks very nice.  Please fix the one bug below
 (adding the regtest) and you are approved to check the whole mess in.

Thank you.


 // (X / C1) / C2  - X / (C1*C2)
 if (Instruction *LHS = dyn_castInstruction(Op0))
   if (Instruction::BinaryOps(LHS-getOpcode()) == I.getOpcode())
 
 
 This code is a bit simpler as:
 
 
 // (X / C1) / C2  - X / (C1*C2)
 if (BinaryOperator *LHS = dyn_castBinaryOperator(Op0))
   if (LHS-getOpcode() == I.getOpcode())
 

Didn't apply this because it causes a compiler warning about
signed/unsigned comparison.

   // udiv X, (Select Cond, C1, C2) -- Select Cond, (shr X, C1), (shr
 X, C2)
   // where C1C2 are powers of two.
 ...
 X = InsertNewInstBefore(
   new CastInst(X, X-getType()-getUnsignedVersion()),
 I);
 
 
 This (and similar cases) is easier/cleaner with InsertCastBefore.

Yes, I agree. I changed the ones in my code but there are actually
dozens (hundreds) of instances in the file (not related to my changes).
I'm going to commit the DIV patch first, then I'll come back and clean
up the others in a separate patch (tested, of course).

Thanks for your excellent reviews, Chris. I know it takes a lot of your
time and I appreciate that you so willingly give it. I'll apply what I
learned from DIV to the REM patch which I'm reviewing for Sheng soon.
Hopefully REM will fare better than DIV did. 

Reid.

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