[llvm-commits] [llvm] r47262 - /llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp

2008-02-18 Thread Evan Cheng
Author: evancheng
Date: Mon Feb 18 02:40:53 2008
New Revision: 47262

URL: http://llvm.org/viewvc/llvm-project?rev=47262view=rev
Log:
For now, avoid commuting def MI for copy MI's whose source is not killed. That 
simply trade a live interval for another and because only the non-two-address 
operands can be folded into loads, may end up pessimising code.

Modified:
llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp

Modified: llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp?rev=47262r1=47261r2=47262view=diff

==
--- llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp (original)
+++ llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp Mon Feb 18 02:40:53 2008
@@ -247,6 +247,13 @@
 
   unsigned CopyIdx = li_-getDefIndex(li_-getInstructionIndex(CopyMI));
 
+  // FIXME: For now, only eliminate the copy by commuting its def is the source
+  // does not live pass the move. Coalescing those copies may end up may simply
+  // end up swapping a live interval for another. That and because usually only
+  // the non-two address operand can be folded can end up pessimizing the code.
+  if (CopyMI-findRegisterUseOperandIdx(IntA.reg, true) != -1)
+return false;
+
   // BValNo is a value number in B that is defined by a copy from A. 'B3' in
   // the example above.
   LiveInterval::iterator BLR = IntB.FindLiveRangeContaining(CopyIdx);


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


Re: [llvm-commits] [llvm] r47252 - /llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp

2008-02-18 Thread Owen Anderson
Two issues: first, it was ignoring  the parameters to a memcpy when  
determining if the memcpy mod/ref'ed a value, and the tail call based  
check is invalid for sret arguments.


--Owen

On Feb 18, 2008, at 12:27 AM, Bill Wendling wrote:


What are the bugs?

-bw

On Feb 17, 2008, at 6:31 PM, Owen Anderson wrote:


Author: resistor
Date: Sun Feb 17 20:31:23 2008
New Revision: 47252

URL: http://llvm.org/viewvc/llvm-project?rev=47252view=rev
Log:
Fix bugs that Chris noticed in my last patch.

Modified:
   llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp

Modified: llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/
BasicAliasAnalysis.cpp?rev=47252r1=47251r2=47252view=diff

= 
=


--- llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp (original)
+++ llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp Sun Feb 17
20:31:23 2008
@@ -250,22 +250,30 @@
const Value *Object = getUnderlyingObject(P);
// Allocations and byval arguments are new objects.
if (Object 
-(isaAllocationInst(Object) ||
- (isaArgument(Object) 
- (castArgument(Object)-

hasByValAttr() ||

-  castArgument(Object)-

hasNoAliasAttr() {

+(isaAllocationInst(Object) || isaArgument(Object))) {
  // Okay, the pointer is to a stack allocated (or effectively
so, for
  // for noalias parameters) object.  If we can prove that
  // the pointer never escapes, then we know the call cannot
clobber it,
  // because it simply can't get its address.
-  if (!AddressMightEscape(Object))
-return NoModRef;
+  if (isaAllocationInst(Object) ||
+  castArgument(Object)-hasByValAttr() ||
+  castArgument(Object)-hasNoAliasAttr())
+if (!AddressMightEscape(Object)) {
+  for (CallSite::arg_iterator CI = CS.arg_begin(), CE =
CS.arg_end();
+  CI != CE; ++CI)
+if (getUnderlyingObject(CI-get()) == P)
+  return AliasAnalysis::getModRefInfo(CS, P, Size);
+
+  return NoModRef;
+}

  // If this is a tail call and P points to a stack location,
we know that
  // the tail call cannot access or modify the local stack.
-  if (CallInst *CI = dyn_castCallInst(CS.getInstruction()))
-if (CI-isTailCall()  !isaMallocInst(Object))
-  return NoModRef;
+  if (isaAllocationInst(Object) ||
+  castArgument(Object)-hasByValAttr())
+if (CallInst *CI = dyn_castCallInst(CS.getInstruction()))
+  if (CI-isTailCall()  !isaMallocInst(Object))
+return NoModRef;
}
  }



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


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




smime.p7s
Description: S/MIME cryptographic signature
___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [llvm] r47263 - /llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp

2008-02-18 Thread Owen Anderson
Author: resistor
Date: Mon Feb 18 03:11:02 2008
New Revision: 47263

URL: http://llvm.org/viewvc/llvm-project?rev=47263view=rev
Log:
This check is not correct for mallocs, so exclude them earlier.

Modified:
llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp

Modified: llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp?rev=47263r1=47262r2=47263view=diff

==
--- llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp (original)
+++ llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp Mon Feb 18 03:11:02 2008
@@ -271,10 +271,10 @@
 
   // If this is a tail call and P points to a stack location, we know that
   // the tail call cannot access or modify the local stack.
-  if (isaAllocationInst(Object) ||
+  if (isaAllocaInst(Object) ||
   castArgument(Object)-hasByValAttr())
 if (CallInst *CI = dyn_castCallInst(CS.getInstruction()))
-  if (CI-isTailCall()  !isaMallocInst(Object))
+  if (CI-isTailCall())
 return NoModRef;
 }
   }


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


[llvm-commits] [llvm] r47264 - /llvm/trunk/lib/VMCore/Function.cpp

2008-02-18 Thread Owen Anderson
Author: resistor
Date: Mon Feb 18 03:22:21 2008
New Revision: 47264

URL: http://llvm.org/viewvc/llvm-project?rev=47264view=rev
Log:
I got the predicate backwards in my last patch.  The comment is correct, the 
code was not.

Modified:
llvm/trunk/lib/VMCore/Function.cpp

Modified: llvm/trunk/lib/VMCore/Function.cpp
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Function.cpp?rev=47264r1=47263r2=47264view=diff

==
--- llvm/trunk/lib/VMCore/Function.cpp (original)
+++ llvm/trunk/lib/VMCore/Function.cpp Mon Feb 18 03:22:21 2008
@@ -107,7 +107,7 @@
 /// it in its containing function.
 bool Argument::hasStructRetAttr() const {
   if (!isaPointerType(getType())) return false;
-  if (getArgNo()) return false; // StructRet param must be first param
+  if (this != getParent()-arg_begin()) return false; // StructRet param must 
be first param
   return getParent()-paramHasAttr(1, ParamAttr::StructRet);
 }
 


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


[llvm-commits] [llvm-gcc-4.2] r47266 - /llvm-gcc-4.2/trunk/gcc/llvm-types.cpp

2008-02-18 Thread Owen Anderson
Author: resistor
Date: Mon Feb 18 03:32:29 2008
New Revision: 47266

URL: http://llvm.org/viewvc/llvm-project?rev=47266view=rev
Log:
llvm-gcc ensures (by inserting extra alloca's and memcpy's) that all sret 
parameters are noalias as well.
By properly marking this as such, we can enable sret return slot optimization 
in GVN.

Modified:
llvm-gcc-4.2/trunk/gcc/llvm-types.cpp

Modified: llvm-gcc-4.2/trunk/gcc/llvm-types.cpp
URL: 
http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-types.cpp?rev=47266r1=47265r2=47266view=diff

==
--- llvm-gcc-4.2/trunk/gcc/llvm-types.cpp (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-types.cpp Mon Feb 18 03:32:29 2008
@@ -1054,10 +1054,11 @@
 Attrs.push_back(ParamAttrsWithIndex::get(0, RAttributes));
 
   // If this is a struct-return function, the dest loc is passed in as a
-  // pointer.  Mark that pointer as structret.
+  // pointer.  Mark that pointer as structret and noalias.
   if (ABIConverter.isStructReturn())
 Attrs.push_back(ParamAttrsWithIndex::get(ArgTys.size(),
- ParamAttr::StructRet));
+ParamAttr::StructRet | 
ParamAttr::NoAlias));
+  
   if (static_chain) {
 // Pass the static chain as the first parameter.
 ABIConverter.HandleArgument(TREE_TYPE(static_chain));
@@ -1152,10 +1153,10 @@
 Attrs.push_back(ParamAttrsWithIndex::get(0, RAttributes));
   
   // If this is a struct-return function, the dest loc is passed in as a
-  // pointer.  Mark that pointer as structret.
+  // pointer.  Mark that pointer as structret, and noalias.
   if (ABIConverter.isStructReturn())
 Attrs.push_back(ParamAttrsWithIndex::get(ArgTypes.size(),
- ParamAttr::StructRet));
+ParamAttr::StructRet | 
ParamAttr::NoAlias));
 
   if (static_chain) {
 // Pass the static chain as the first parameter.


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


Re: [llvm-commits] [llvm] r47264 - /llvm/trunk/lib/VMCore/Function.cpp

2008-02-18 Thread Owen Anderson

On Feb 18, 2008, at 3:22 AM, Owen Anderson wrote:


Author: resistor
Date: Mon Feb 18 03:22:21 2008
New Revision: 47264

URL: http://llvm.org/viewvc/llvm-project?rev=47264view=rev
Log:
I got the predicate backwards in my last patch.  The comment is  
correct, the code was not.





Oops.  This comment was based on an older diff.  That actual change is:

Use a constant time check rather than a linear time one.

smime.p7s
Description: S/MIME cryptographic signature
___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [llvm] r47265 - in /llvm/trunk: lib/Transforms/Scalar/GVN.cpp test/Transforms/GVN/sret.ll

2008-02-18 Thread Owen Anderson
Author: resistor
Date: Mon Feb 18 03:24:53 2008
New Revision: 47265

URL: http://llvm.org/viewvc/llvm-project?rev=47265view=rev
Log:
Add support to GVN for performing sret return slot optimization.  This means 
that, if an sret function tail calls
another sret function, it should pass its own sret parameter to the tail 
callee, allowing it to fill in the correct
return value.  llvm-gcc does not emit this by default.  Instead, it allocates 
space in the caller for the sret of
the tail call and then uses memcpy to copy the result into the caller's sret 
parameter.  This optimization detects
and optimizes that case.

Added:
llvm/trunk/test/Transforms/GVN/sret.ll
Modified:
llvm/trunk/lib/Transforms/Scalar/GVN.cpp

Modified: llvm/trunk/lib/Transforms/Scalar/GVN.cpp
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/GVN.cpp?rev=47265r1=47264r2=47265view=diff

==
--- llvm/trunk/lib/Transforms/Scalar/GVN.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/GVN.cpp Mon Feb 18 03:24:53 2008
@@ -21,6 +21,7 @@
 #include llvm/Function.h
 #include llvm/IntrinsicInst.h
 #include llvm/Instructions.h
+#include llvm/ParameterAttributes.h
 #include llvm/Value.h
 #include llvm/ADT/BitVector.h
 #include llvm/ADT/DenseMap.h
@@ -738,6 +739,8 @@
 bool processNonLocalLoad(LoadInst* L,
  SmallVectorInstruction*, 4 toErase);
 bool processMemCpy(MemCpyInst* M, SmallVectorInstruction*, 4 toErase);
+bool performReturnSlotOptzn(MemCpyInst* cpy, CallInst* C,
+SmallVectorInstruction*, 4 toErase);
 Value *GetValueForBlock(BasicBlock *BB, LoadInst* orig,
 DenseMapBasicBlock*, Value* Phis,
 bool top_level = false);
@@ -1048,6 +1051,62 @@
   return deletedLoad;
 }
 
+/// performReturnSlotOptzn - takes a memcpy and a call that it depends on,
+/// and checks for the possibility of a return slot optimization by having
+/// the call write its result directly into the callees return parameter
+/// rather than using memcpy
+bool GVN::performReturnSlotOptzn(MemCpyInst* cpy, CallInst* C,
+ SmallVectorInstruction*, 4 toErase) {
+  // Check that we're copying to an argument...
+  Value* cpyDest = cpy-getDest();
+  if (!isaArgument(cpyDest))
+return false;
+  
+  // And that the argument is the return slot
+  Argument* sretArg = castArgument(cpyDest);
+  if (!sretArg-hasStructRetAttr())
+return false;
+  
+  // Make sure the return slot is otherwise dead
+  std::setUser* useList(sretArg-use_begin(), sretArg-use_end());
+  while (!useList.empty()) {
+User* UI = *useList.begin();
+
+if (isaGetElementPtrInst(UI) || isaBitCastInst(UI)) {
+  useList.insert(UI-use_begin(), UI-use_end());
+  useList.erase(UI);
+} else if (UI == cpy)
+  useList.erase(UI);
+else
+  return false;
+  }
+  
+  // Make sure the call cannot modify the return slot in some unpredicted way
+  AliasAnalysis AA = getAnalysisAliasAnalysis();
+  if (AA.getModRefInfo(C, cpy-getRawDest(), ~0UL) != AliasAnalysis::NoModRef)
+return false;
+  
+  // If all checks passed, then we can perform the transformation
+  CallSite CS = CallSite::get(C);
+  for (unsigned i = 0; i  CS.arg_size(); ++i) {
+if (CS.paramHasAttr(i+1, ParamAttr::StructRet)) {
+  if (CS.getArgument(i)-getType() != cpyDest-getType())
+return false;
+  
+  CS.setArgument(i, cpyDest);
+  break;
+}
+  }
+  
+  MemoryDependenceAnalysis MD = getAnalysisMemoryDependenceAnalysis();
+  MD.dropInstruction(C);
+  
+  // Remove the memcpy
+  toErase.push_back(cpy);
+  
+  return true;
+}
+
 /// processMemCpy - perform simplication of memcpy's.  If we have memcpy A 
which
 /// copies X to Y, and memcpy B which copies Y to Z, then we can rewrite B to 
be
 /// a memcpy from X to Z (or potentially a memmove, depending on 
circumstances).
@@ -1059,9 +1118,14 @@
   // First, we have to check that the dependency is another memcpy
   Instruction* dep = MD.getDependency(M);
   if  (dep == MemoryDependenceAnalysis::None ||
-   dep == MemoryDependenceAnalysis::NonLocal ||
-   !isaMemCpyInst(dep))
+   dep == MemoryDependenceAnalysis::NonLocal)
 return false;
+  else if (!isaMemCpyInst(dep)) {
+if (CallInst* C = dyn_castCallInst(dep))
+  return performReturnSlotOptzn(M, C, toErase);
+else
+  return false;
+  }
   
   // We can only transforms memcpy's where the dest of one is the source of the
   // other

Added: llvm/trunk/test/Transforms/GVN/sret.ll
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/GVN/sret.ll?rev=47265view=auto

==
--- llvm/trunk/test/Transforms/GVN/sret.ll (added)
+++ llvm/trunk/test/Transforms/GVN/sret.ll Mon Feb 18 03:24:53 2008
@@ -0,0 +1,28 @@
+; RUN: llvm-as  

Re: [llvm-commits] [llvm] r47220 - in /llvm/trunk: lib/Transforms/IPO/GlobalOpt.cpp test/Transforms/GlobalOpt/2008-02-16-NestAttr.ll

2008-02-18 Thread Duncan Sands
Hi Chris,

  Nice.  Out of curiousity, how does nest do to codegen?
 
  'nest' causes a specific register to be grabbed for the
  parameter in calls.  So removing it doesn't do much :)
 
 Ok.

if you want me to remove the transform, just ask :)  I mostly did it
because seeing all those useless nest attributes floating around
annoys me when rummaging about in Ada produced .ll's.

 You can just do:
CallSite User(castInstruction(*UI));
 
 and then handle user generically.

Actually you couldn't, but you can now (see the CallSite changes just
committed).

Thanks for the review!

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


[llvm-commits] [llvm] r47267 - in /llvm/trunk: include/llvm/CodeGen/LiveIntervalAnalysis.h lib/CodeGen/LiveIntervalAnalysis.cpp

2008-02-18 Thread Roman Levenstein
Author: romix
Date: Mon Feb 18 03:35:30 2008
New Revision: 47267

URL: http://llvm.org/viewvc/llvm-project?rev=47267view=rev
Log:
New helper function getMBBFromIndex() that given an index in any instruction of 
an MBB returns a pointer the MBB. Reviewed by Evan.

Modified:
llvm/trunk/include/llvm/CodeGen/LiveIntervalAnalysis.h
llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp

Modified: llvm/trunk/include/llvm/CodeGen/LiveIntervalAnalysis.h
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/LiveIntervalAnalysis.h?rev=47267r1=47266r2=47267view=diff

==
--- llvm/trunk/include/llvm/CodeGen/LiveIntervalAnalysis.h (original)
+++ llvm/trunk/include/llvm/CodeGen/LiveIntervalAnalysis.h Mon Feb 18 03:35:30 
2008
@@ -40,6 +40,20 @@
   class VirtRegMap;
   typedef std::pairunsigned, MachineBasicBlock* IdxMBBPair;
 
+  inline bool operator(unsigned V, const IdxMBBPair IM) {
+return V  IM.first;
+  }
+
+  inline bool operator(const IdxMBBPair IM, unsigned V) {
+return IM.first  V;
+  }
+
+  struct Idx2MBBCompare {
+bool operator()(const IdxMBBPair LHS, const IdxMBBPair RHS) const {
+  return LHS.first  RHS.first;
+}
+  };
+
   class LiveIntervals : public MachineFunctionPass {
 MachineFunction* mf_;
 const TargetMachine* tm_;
@@ -153,6 +167,22 @@
   return MBB2IdxMap[MBBNo].second;
 }
 
+/// getMBBFromIndex - given an index in any instruction of an
+/// MBB return a pointer the MBB
+MachineBasicBlock* getMBBFromIndex(unsigned index) const {
+  std::vectorIdxMBBPair::const_iterator I =
+   std::lower_bound(Idx2MBBMap.begin(), Idx2MBBMap.end(), index);
+  // Take the pair containing the index
+  std::vectorIdxMBBPair::const_iterator J =
+ ((I != Idx2MBBMap.end()  I-first  index) ||
+  (I == Idx2MBBMap.end()  Idx2MBBMap.size()0)) ? (I-1): I;
+
+  assert(J != Idx2MBBMap.end()  J-first  index+1 
+index = getMBBEndIdx(J-second) 
+index does not correspond to an MBB);
+  return J-second;
+}
+
 /// getInstructionIndex - returns the base index of instr
 unsigned getInstructionIndex(MachineInstr* instr) const {
   Mi2IndexMap::const_iterator it = mi2iMap_.find(instr);

Modified: llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp?rev=47267r1=47266r2=47267view=diff

==
--- llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp (original)
+++ llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp Mon Feb 18 03:35:30 2008
@@ -79,22 +79,6 @@
 delete ClonedMIs[i];
 }
 
-namespace llvm {
-  inline bool operator(unsigned V, const IdxMBBPair IM) {
-return V  IM.first;
-  }
-
-  inline bool operator(const IdxMBBPair IM, unsigned V) {
-return IM.first  V;
-  }
-
-  struct Idx2MBBCompare {
-bool operator()(const IdxMBBPair LHS, const IdxMBBPair RHS) const {
-  return LHS.first  RHS.first;
-}
-  };
-}
-
 /// runOnMachineFunction - Register allocate the whole function
 ///
 bool LiveIntervals::runOnMachineFunction(MachineFunction fn) {


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


Re: [llvm-commits] [llvm] r47244 - in /llvm/trunk: lib/Transforms/Scalar/InstructionCombining.cpp test/Transforms/InstCombine/addnegneg.ll

2008-02-18 Thread Dale Johannesen

On Feb 17, 2008, at 1:03 PM, Chris Lattner wrote:

 Author: lattner
 Date: Sun Feb 17 15:03:36 2008
 New Revision: 47244

 URL: http://llvm.org/viewvc/llvm-project?rev=47244view=rev
 Log:
 Fold (-x + -y) - -(x+y) which promotes better association, fixing
 the second half of PR2047

This is unsafe for IEEE floating point.  Try x=0, y= -0.

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


Re: [llvm-commits] [llvm] r47220 - in /llvm/trunk: lib/Transforms/IPO/GlobalOpt.cpp test/Transforms/GlobalOpt/2008-02-16-NestAttr.ll

2008-02-18 Thread Chris Lattner

On Feb 18, 2008, at 9:35 AM, Duncan Sands wrote:

 Hi Chris,

 Nice.  Out of curiousity, how does nest do to codegen?

 'nest' causes a specific register to be grabbed for the
 parameter in calls.  So removing it doesn't do much :)

 Ok.

 if you want me to remove the transform, just ask :)  I mostly did it
 because seeing all those useless nest attributes floating around
 annoys me when rummaging about in Ada produced .ll's.

I have no problem with it.  It makes sense to me.

 You can just do:
   CallSite User(castInstruction(*UI));

 and then handle user generically.

 Actually you couldn't, but you can now (see the CallSite changes just
 committed).


Ah, strange, I thought that was allowed :)

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


[llvm-commits] [llvm] r47275 - /llvm/trunk/lib/Transforms/Scalar/GVN.cpp

2008-02-18 Thread Chris Lattner
Author: lattner
Date: Mon Feb 18 11:47:29 2008
New Revision: 47275

URL: http://llvm.org/viewvc/llvm-project?rev=47275view=rev
Log:
minor code simplification, no functionality change.

Modified:
llvm/trunk/lib/Transforms/Scalar/GVN.cpp

Modified: llvm/trunk/lib/Transforms/Scalar/GVN.cpp
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/GVN.cpp?rev=47275r1=47274r2=47275view=diff

==
--- llvm/trunk/lib/Transforms/Scalar/GVN.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/GVN.cpp Mon Feb 18 11:47:29 2008
@@ -1117,15 +1117,13 @@
   
   // First, we have to check that the dependency is another memcpy
   Instruction* dep = MD.getDependency(M);
-  if  (dep == MemoryDependenceAnalysis::None ||
-   dep == MemoryDependenceAnalysis::NonLocal)
+  if (dep == MemoryDependenceAnalysis::None ||
+  dep == MemoryDependenceAnalysis::NonLocal)
+return false;
+  else if (CallInst* C = dyn_castCallInst(dep))
+return performReturnSlotOptzn(M, C, toErase);
+  else if (!isaMemCpyInst(dep))
 return false;
-  else if (!isaMemCpyInst(dep)) {
-if (CallInst* C = dyn_castCallInst(dep))
-  return performReturnSlotOptzn(M, C, toErase);
-else
-  return false;
-  }
   
   // We can only transforms memcpy's where the dest of one is the source of the
   // other


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


[llvm-commits] [llvm] r47274 - /llvm/trunk/test/Transforms/GVN/sret.ll

2008-02-18 Thread Chris Lattner
Author: lattner
Date: Mon Feb 18 11:33:10 2008
New Revision: 47274

URL: http://llvm.org/viewvc/llvm-project?rev=47274view=rev
Log:
make this just a bit more strict.

Modified:
llvm/trunk/test/Transforms/GVN/sret.ll

Modified: llvm/trunk/test/Transforms/GVN/sret.ll
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/GVN/sret.ll?rev=47274r1=47273r2=47274view=diff

==
--- llvm/trunk/test/Transforms/GVN/sret.ll (original)
+++ llvm/trunk/test/Transforms/GVN/sret.ll Mon Feb 18 11:33:10 2008
@@ -1,4 +1,4 @@
-; RUN: llvm-as  %s | opt -gvn | llvm-dis | grep memcpy | count 1
+; RUN: llvm-as  %s | opt -gvn | llvm-dis | not grep {call.*memcpy}
 
 target datalayout = 
e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128
 target triple = i686-apple-darwin9


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


[llvm-commits] [llvm] r47273 - in /llvm/trunk: include/llvm/Support/CallSite.h lib/Transforms/IPO/GlobalOpt.cpp lib/VMCore/Instructions.cpp

2008-02-18 Thread Duncan Sands
Author: baldrick
Date: Mon Feb 18 11:32:13 2008
New Revision: 47273

URL: http://llvm.org/viewvc/llvm-project?rev=47273view=rev
Log:
Simplify caller updating using a CallSite, as
requested by Chris.  While there, do the same
for an existing function committed by someone
called lattner :)

Modified:
llvm/trunk/include/llvm/Support/CallSite.h
llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp
llvm/trunk/lib/VMCore/Instructions.cpp

Modified: llvm/trunk/include/llvm/Support/CallSite.h
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/CallSite.h?rev=47273r1=47272r2=47273view=diff

==
--- llvm/trunk/include/llvm/Support/CallSite.h (original)
+++ llvm/trunk/include/llvm/Support/CallSite.h Mon Feb 18 11:32:13 2008
@@ -35,6 +35,7 @@
   CallSite() : I(0) {}
   CallSite(CallInst *CI) : I(reinterpret_castInstruction*(CI)) {}
   CallSite(InvokeInst *II) : I(reinterpret_castInstruction*(II)) {}
+  CallSite(Instruction *C);
   CallSite(const CallSite CS) : I(CS.I) {}
   CallSite operator=(const CallSite CS) { I = CS.I; return *this; }
 

Modified: llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp?rev=47273r1=47272r2=47273view=diff

==
--- llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp Mon Feb 18 11:32:13 2008
@@ -25,6 +25,7 @@
 #include llvm/Pass.h
 #include llvm/Analysis/ConstantFolding.h
 #include llvm/Target/TargetData.h
+#include llvm/Support/CallSite.h
 #include llvm/Support/Compiler.h
 #include llvm/Support/Debug.h
 #include llvm/Support/GetElementPtrTypeIterator.h
@@ -1584,25 +1585,23 @@
 /// function, changing them to FastCC.
 static void ChangeCalleesToFastCall(Function *F) {
   for (Value::use_iterator UI = F-use_begin(), E = F-use_end(); UI != 
E;++UI){
-Instruction *User = castInstruction(*UI);
-if (CallInst *CI = dyn_castCallInst(User))
-  CI-setCallingConv(CallingConv::Fast);
-else
-  castInvokeInst(User)-setCallingConv(CallingConv::Fast);
+CallSite User(castInstruction(*UI));
+User.setCallingConv(CallingConv::Fast);
   }
 }
 
 static const ParamAttrsList *StripNest(const ParamAttrsList *Attrs) {
-  if (Attrs) {
-for (unsigned i = 0, e = Attrs-size(); i != e; ++i) {
-  uint16_t A = Attrs-getParamAttrsAtIndex(i);
-  if (A  ParamAttr::Nest) {
-Attrs = ParamAttrsList::excludeAttrs(Attrs, Attrs-getParamIndex(i),
- ParamAttr::Nest);
-// There can be only one.
-break;
-  }
-}
+  if (!Attrs)
+return NULL;
+
+  for (unsigned i = 0, e = Attrs-size(); i != e; ++i) {
+if ((Attrs-getParamAttrsAtIndex(i)  ParamAttr::Nest) == 0)
+  continue;
+
+Attrs = ParamAttrsList::excludeAttrs(Attrs, Attrs-getParamIndex(i),
+ ParamAttr::Nest);
+// There can be only one.
+break;
   }
 
   return Attrs;
@@ -1611,13 +1610,8 @@
 static void RemoveNestAttribute(Function *F) {
   F-setParamAttrs(StripNest(F-getParamAttrs()));
   for (Value::use_iterator UI = F-use_begin(), E = F-use_end(); UI != 
E;++UI){
-Instruction *User = castInstruction(*UI);
-if (CallInst *CI = dyn_castCallInst(User)) {
-  CI-setParamAttrs(StripNest(CI-getParamAttrs()));
-} else {
-  InvokeInst *II = castInvokeInst(User);
-  II-setParamAttrs(StripNest(II-getParamAttrs()));
-}
+CallSite User(castInstruction(*UI));
+User.setParamAttrs(StripNest(User.getParamAttrs()));
   }
 }
 

Modified: llvm/trunk/lib/VMCore/Instructions.cpp
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Instructions.cpp?rev=47273r1=47272r2=47273view=diff

==
--- llvm/trunk/lib/VMCore/Instructions.cpp (original)
+++ llvm/trunk/lib/VMCore/Instructions.cpp Mon Feb 18 11:32:13 2008
@@ -27,6 +27,10 @@
 //CallSite Class
 
//===--===//
 
+CallSite::CallSite(Instruction *C) {
+  assert((isaCallInst(C) || isaInvokeInst(C))  Not a call!);
+  I = C;
+}
 unsigned CallSite::getCallingConv() const {
   if (CallInst *CI = dyn_castCallInst(I))
 return CI-getCallingConv();


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


[llvm-commits] [llvm] r47276 - /llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp

2008-02-18 Thread Chris Lattner
Author: lattner
Date: Mon Feb 18 11:50:16 2008
New Revision: 47276

URL: http://llvm.org/viewvc/llvm-project?rev=47276view=rev
Log:
Transforming -A + -B  --  -(A + B) isn't safe for FP, thanks
to Dale for noticing this!

Modified:
llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp

Modified: llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp?rev=47276r1=47275r2=47276view=diff

==
--- llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Mon Feb 18 
11:50:16 2008
@@ -2092,10 +2092,12 @@
   // -A + B  --  B - A
   // -A + -B  --  -(A + B)
   if (Value *LHSV = dyn_castNegVal(LHS)) {
-if (Value *RHSV = dyn_castNegVal(RHS)) {
-  Instruction *NewAdd = BinaryOperator::createAdd(LHSV, RHSV, sum);
-  InsertNewInstBefore(NewAdd, I);
-  return BinaryOperator::createNeg(NewAdd);
+if (LHS-getType()-isIntOrIntVector()) {
+  if (Value *RHSV = dyn_castNegVal(RHS)) {
+Instruction *NewAdd = BinaryOperator::createAdd(LHSV, RHSV, sum);
+InsertNewInstBefore(NewAdd, I);
+return BinaryOperator::createNeg(NewAdd);
+  }
 }
 
 return BinaryOperator::createSub(RHS, LHSV);


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


[llvm-commits] [llvm] r47277 - in /llvm/trunk: lib/Target/X86/X86ISelLowering.cpp test/CodeGen/X86/mul-remat.ll

2008-02-18 Thread Dan Gohman
Author: djg
Date: Mon Feb 18 11:55:26 2008
New Revision: 47277

URL: http://llvm.org/viewvc/llvm-project?rev=47277view=rev
Log:
Don't mark scalar integer multiplication as Expand on x86, since x86
has plain one-result scalar integer multiplication instructions.
This avoids expanding such instructions into MUL_LOHI sequences that
must be special-cased at isel time, and avoids the problem with that
code that provented memory operands from being folded.

This fixes PR1874, addressesing the most common case. The uncommon
cases of optimizing multiply-high operations will require work
in DAGCombiner.

Added:
llvm/trunk/test/CodeGen/X86/mul-remat.ll
Modified:
llvm/trunk/lib/Target/X86/X86ISelLowering.cpp

Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=47277r1=47276r2=47277view=diff

==
--- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Mon Feb 18 11:55:26 2008
@@ -169,35 +169,31 @@
 setOperationAction(ISD::BIT_CONVERT  , MVT::i32  , Expand);
   }
 
-  // Scalar integer multiply, multiply-high, divide, and remainder are
+  // Scalar integer multiply-high, divide, and remainder are
   // lowered to use operations that produce two results, to match the
   // available instructions. This exposes the two-result form to trivial
   // CSE, which is able to combine x/y and x%y into a single instruction,
   // for example. The single-result multiply instructions are introduced
   // in X86ISelDAGToDAG.cpp, after CSE, for uses where the the high part
   // is not needed.
-  setOperationAction(ISD::MUL , MVT::i8, Expand);
   setOperationAction(ISD::MULHS   , MVT::i8, Expand);
   setOperationAction(ISD::MULHU   , MVT::i8, Expand);
   setOperationAction(ISD::SDIV, MVT::i8, Expand);
   setOperationAction(ISD::UDIV, MVT::i8, Expand);
   setOperationAction(ISD::SREM, MVT::i8, Expand);
   setOperationAction(ISD::UREM, MVT::i8, Expand);
-  setOperationAction(ISD::MUL , MVT::i16   , Expand);
   setOperationAction(ISD::MULHS   , MVT::i16   , Expand);
   setOperationAction(ISD::MULHU   , MVT::i16   , Expand);
   setOperationAction(ISD::SDIV, MVT::i16   , Expand);
   setOperationAction(ISD::UDIV, MVT::i16   , Expand);
   setOperationAction(ISD::SREM, MVT::i16   , Expand);
   setOperationAction(ISD::UREM, MVT::i16   , Expand);
-  setOperationAction(ISD::MUL , MVT::i32   , Expand);
   setOperationAction(ISD::MULHS   , MVT::i32   , Expand);
   setOperationAction(ISD::MULHU   , MVT::i32   , Expand);
   setOperationAction(ISD::SDIV, MVT::i32   , Expand);
   setOperationAction(ISD::UDIV, MVT::i32   , Expand);
   setOperationAction(ISD::SREM, MVT::i32   , Expand);
   setOperationAction(ISD::UREM, MVT::i32   , Expand);
-  setOperationAction(ISD::MUL , MVT::i64   , Expand);
   setOperationAction(ISD::MULHS   , MVT::i64   , Expand);
   setOperationAction(ISD::MULHU   , MVT::i64   , Expand);
   setOperationAction(ISD::SDIV, MVT::i64   , Expand);
@@ -205,6 +201,11 @@
   setOperationAction(ISD::SREM, MVT::i64   , Expand);
   setOperationAction(ISD::UREM, MVT::i64   , Expand);
 
+  // 8, 16, and 32-bit plain multiply are legal. And 64-bit multiply
+  // is also legal on x86-64.
+  if (!Subtarget-is64Bit())
+setOperationAction(ISD::MUL   , MVT::i64   , Expand);
+
   setOperationAction(ISD::BR_JT, MVT::Other, Expand);
   setOperationAction(ISD::BRCOND   , MVT::Other, Custom);
   setOperationAction(ISD::BR_CC, MVT::Other, Expand);

Added: llvm/trunk/test/CodeGen/X86/mul-remat.ll
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/mul-remat.ll?rev=47277view=auto

==
--- llvm/trunk/test/CodeGen/X86/mul-remat.ll (added)
+++ llvm/trunk/test/CodeGen/X86/mul-remat.ll Mon Feb 18 11:55:26 2008
@@ -0,0 +1,8 @@
+; RUN: llvm-as  %s | llc -march=x86 | grep mov | count 1
+; PR1874
+   
+define i32 @test(i32 %a, i32 %b) {
+entry:
+   %tmp3 = mul i32 %b, %a
+   ret i32 %tmp3
+}


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


Re: [llvm-commits] [llvm] r47265 - in /llvm/trunk: lib/Transforms/Scalar/GVN.cpp test/Transforms/GVN/sret.ll

2008-02-18 Thread Duncan Sands
Hi Owen, nice transform!

 +  // Check that we're copying to an argument...
 +  Value* cpyDest = cpy-getDest();
 +  if (!isaArgument(cpyDest))
 +return false;
 +  
 +  // And that the argument is the return slot
 +  Argument* sretArg = castArgument(cpyDest);
 +  if (!sretArg-hasStructRetAttr())
 +return false;

why is it relevant that the memcpy is to an sret argument?
The transform would be equally valid if it was to a temporary
I think.  The essential condition seems to be: the memcpy
destination should not be accessable (for read or write) by
the function called.  Knowing that the destination is a
noalias parameter is simply helpful in determining that (I
don't see what sret has to do with it...).

On the other hand, it matters that the memcpy source is
passed to an sret parameter, because this means that the
called function does not read any existing values in it
(i.e. it is undefined what the callee gets if it tries to
read existing values via the sret parameter).  OK, I know
this is not explicitly part of the sret definition, but it
could reasonably be.  The patch doesn't seem to check
whether the memcpy source is being passed as an sret parameter.

Finally, it matters that the size of the memcpy is the
whole size of the memcpy source.  Imagine that you pass
a 10 byte memtmp to the call, then memcpy 5 bytes of it
to a 5 byte object.  It is clearly wrong to pass the
5 byte object directly to the call.

Ciao,

Duncan.

PS: The other conditions like no other uses also seem way
too strict.
___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [llvm] r47272 - /llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp

2008-02-18 Thread Chris Lattner
Author: lattner
Date: Mon Feb 18 11:28:21 2008
New Revision: 47272

URL: http://llvm.org/viewvc/llvm-project?rev=47272view=rev
Log:
don't bother calling getUnderlyingObject for non-pointers.

Modified:
llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp

Modified: llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp?rev=47272r1=47271r2=47272view=diff

==
--- llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp (original)
+++ llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp Mon Feb 18 11:28:21 2008
@@ -262,7 +262,8 @@
   bool passedAsArg = false;
   for (CallSite::arg_iterator CI = CS.arg_begin(), CE = CS.arg_end();
   CI != CE; ++CI)
-if (getUnderlyingObject(CI-get()) == P)
+if (isaPointerType((*CI)-getType()) 
+getUnderlyingObject(*CI) == P)
   passedAsArg = true;
   
   if (!passedAsArg)


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


[llvm-commits] [llvm] r47278 - /llvm/trunk/lib/Target/X86/README.txt

2008-02-18 Thread Chris Lattner
Author: lattner
Date: Mon Feb 18 12:30:13 2008
New Revision: 47278

URL: http://llvm.org/viewvc/llvm-project?rev=47278view=rev
Log:
Add a note about sext from i1 plus flags use.

Modified:
llvm/trunk/lib/Target/X86/README.txt

Modified: llvm/trunk/lib/Target/X86/README.txt
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/README.txt?rev=47278r1=47277r2=47278view=diff

==
--- llvm/trunk/lib/Target/X86/README.txt (original)
+++ llvm/trunk/lib/Target/X86/README.txt Mon Feb 18 12:30:13 2008
@@ -1528,3 +1528,55 @@
 See PR2053 for more details.
 
 //===-===//
+
+Consider:
+int test(unsigned long a, unsigned long b) { return -(a  b); }
+
+We currently compile this to:
+
+define i32 @test(i32 %a, i32 %b) nounwind  {
+   %tmp3 = icmp ult i32 %a, %b ; i1 [#uses=1]
+   %tmp34 = zext i1 %tmp3 to i32   ; i32 [#uses=1]
+   %tmp5 = sub i32 0, %tmp34   ; i32 [#uses=1]
+   ret i32 %tmp5
+}
+
+and
+
+_test:
+   movl8(%esp), %eax
+   cmpl%eax, 4(%esp)
+   setb%al
+   movzbl  %al, %eax
+   negl%eax
+   ret
+
+Several deficiencies here.  First, we should instcombine zext+neg into sext:
+
+define i32 @test2(i32 %a, i32 %b) nounwind  {
+   %tmp3 = icmp ult i32 %a, %b ; i1 [#uses=1]
+   %tmp34 = sext i1 %tmp3 to i32   ; i32 [#uses=1]
+   ret i32 %tmp34
+}
+
+However, before we can do that, we have to fix the bad codegen that we get for
+sext from bool:
+
+_test2:
+   movl8(%esp), %eax
+   cmpl%eax, 4(%esp)
+   setb%al
+   movzbl  %al, %eax
+   shll$31, %eax
+   sarl$31, %eax
+   ret
+
+This code should be at least as good as the code above.  Once this is fixed, we
+can optimize this specific case even more to:
+
+   movl8(%esp), %eax
+   xorl%ecx, %ecx
+cmpl%eax, 4(%esp)
+sbbl%ecx, %ecx
+
+//===-===//


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


[llvm-commits] [llvm] r47280 - /llvm/trunk/lib/Target/README.txt

2008-02-18 Thread Chris Lattner
Author: lattner
Date: Mon Feb 18 12:46:39 2008
New Revision: 47280

URL: http://llvm.org/viewvc/llvm-project?rev=47280view=rev
Log:
upgrade some tests.


Modified:
llvm/trunk/lib/Target/README.txt

Modified: llvm/trunk/lib/Target/README.txt
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/README.txt?rev=47280r1=47279r2=47280view=diff

==
--- llvm/trunk/lib/Target/README.txt (original)
+++ llvm/trunk/lib/Target/README.txt Mon Feb 18 12:46:39 2008
@@ -397,32 +397,32 @@
 ; This testcase is due to tail-duplication not wanting to copy the return
 ; instruction into the terminating blocks because there was other code
 ; optimized out of the function after the taildup happened.
-;RUN: llvm-upgrade  %s | llvm-as | opt -tailcallelim | llvm-dis | not grep 
call
+; RUN: llvm-as  %s | opt -tailcallelim | llvm-dis | not grep call
 
-int %t4(int %a) {
+define i32 @t4(i32 %a) {
 entry:
-%tmp.1 = and int %a, 1
-%tmp.2 = cast int %tmp.1 to bool
-br bool %tmp.2, label %then.0, label %else.0
-
-then.0:
-%tmp.5 = add int %a, -1
-%tmp.3 = call int %t4( int %tmp.5 )
-br label %return
-
-else.0:
-%tmp.7 = setne int %a, 0
-br bool %tmp.7, label %then.1, label %return
-
-then.1:
-%tmp.11 = add int %a, -2
-%tmp.9 = call int %t4( int %tmp.11 )
-br label %return
+   %tmp.1 = and i32 %a, 1  ; i32 [#uses=1]
+   %tmp.2 = icmp ne i32 %tmp.1, 0  ; i1 [#uses=1]
+   br i1 %tmp.2, label %then.0, label %else.0
+
+then.0:; preds = %entry
+   %tmp.5 = add i32 %a, -1 ; i32 [#uses=1]
+   %tmp.3 = call i32 @t4( i32 %tmp.5 ) ; i32 [#uses=1]
+   br label %return
+
+else.0:; preds = %entry
+   %tmp.7 = icmp ne i32 %a, 0  ; i1 [#uses=1]
+   br i1 %tmp.7, label %then.1, label %return
+
+then.1:; preds = %else.0
+   %tmp.11 = add i32 %a, -2; i32 [#uses=1]
+   %tmp.9 = call i32 @t4( i32 %tmp.11 ); i32 [#uses=1]
+   br label %return
 
-return:
-%result.0 = phi int [ 0, %else.0 ], [ %tmp.3, %then.0 ],
+return:; preds = %then.1, %else.0, %then.0
+   %result.0 = phi i32 [ 0, %else.0 ], [ %tmp.3, %then.0 ],
 [ %tmp.9, %then.1 ]
-ret int %result.0
+   ret i32 %result.0
 }
 
 //===-===//
@@ -446,21 +446,19 @@
 Argument promotion should promote arguments for recursive functions, like 
 this:
 
-; RUN: llvm-upgrade  %s | llvm-as | opt -argpromotion | llvm-dis | grep x.val
+; RUN: llvm-as  %s | opt -argpromotion | llvm-dis | grep x.val
 
-implementation   ; Functions:
-
-internal int %foo(int* %x) {
+define internal i32 @foo(i32* %x) {
 entry:
-%tmp = load int* %x
-%tmp.foo = call int %foo(int *%x)
-ret int %tmp.foo
+   %tmp = load i32* %x ; i32 [#uses=0]
+   %tmp.foo = call i32 @foo( i32* %x ) ; i32 [#uses=1]
+   ret i32 %tmp.foo
 }
 
-int %bar(int* %x) {
+define i32 @bar(i32* %x) {
 entry:
-%tmp3 = call int %foo( int* %x); int[#uses=1]
-ret int %tmp3
+   %tmp3 = call i32 @foo( i32* %x ); i32 [#uses=1]
+   ret i32 %tmp3
 }
 
 //===-===//
@@ -529,16 +527,22 @@
 corresponding integer operations.  On a yonah, this loop:
 
 double a[256];
- for (b = 0; b  1000; b++)
- for (i = 0; i  256; i++)
-   a[i] = -a[i];
+void foo() {
+  int i, b;
+  for (b = 0; b  1000; b++)
+  for (i = 0; i  256; i++)
+a[i] = -a[i];
+}
 
 is twice as slow as this loop:
 
 long long a[256];
- for (b = 0; b  1000; b++)
- for (i = 0; i  256; i++)
-   a[i] ^= (1ULL  63);
+void foo() {
+  int i, b;
+  for (b = 0; b  1000; b++)
+  for (i = 0; i  256; i++)
+a[i] ^= (1ULL  63);
+}
 
 and I suspect other processors are similar.  On X86 in particular this is a
 big win because doing this with integers allows the use of read/modify/write


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


Re: [llvm-commits] [llvm] r47277 - in /llvm/trunk: lib/Target/X86/X86ISelLowering.cpp test/CodeGen/X86/mul-remat.ll

2008-02-18 Thread Chris Lattner
On Feb 18, 2008, at 9:55 AM, Dan Gohman wrote:
 Don't mark scalar integer multiplication as Expand on x86, since x86
 has plain one-result scalar integer multiplication instructions.
 This avoids expanding such instructions into MUL_LOHI sequences that
 must be special-cased at isel time, and avoids the problem with that
 code that provented memory operands from being folded.

 This fixes PR1874, addressesing the most common case. The uncommon
 cases of optimizing multiply-high operations will require work
 in DAGCombiner.

Very nice!

 +  // 8, 16, and 32-bit plain multiply are legal. And 64-bit multiply
 +  // is also legal on x86-64.
 +  if (!Subtarget-is64Bit())
 +setOperationAction(ISD::MUL   , MVT::i64   , Expand);

Are you sure you need this?  if !is64Bit(), i64 won't be legal, so the  
multiply will be expanded unconditionally.

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


[llvm-commits] [llvm] r47279 - /llvm/trunk/lib/Target/README.txt

2008-02-18 Thread Nate Begeman
Author: sampo
Date: Mon Feb 18 12:39:23 2008
New Revision: 47279

URL: http://llvm.org/viewvc/llvm-project?rev=47279view=rev
Log:
Add a note

Modified:
llvm/trunk/lib/Target/README.txt

Modified: llvm/trunk/lib/Target/README.txt
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/README.txt?rev=47279r1=47278r2=47279view=diff

==
--- llvm/trunk/lib/Target/README.txt (original)
+++ llvm/trunk/lib/Target/README.txt Mon Feb 18 12:39:23 2008
@@ -621,3 +621,6 @@
 to know that it doesn't modify G either.  This is very tricky.
 
 //===-===//
+
+We should add an FRINT node to the DAG to model targets that have legal
+implementations of ceil/floor/rint.


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


[llvm-commits] [llvm] r47281 - /llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp

2008-02-18 Thread Evan Cheng
Author: evancheng
Date: Mon Feb 18 12:56:31 2008
New Revision: 47281

URL: http://llvm.org/viewvc/llvm-project?rev=47281view=rev
Log:
- Remove the previous check which broke coalescer-commute3.ll
- For now, conservatively ignore copy MI whose source is a physical register. 
Commuting its def MI can cause a physical register live interval to be live 
through a loop (since we know it's live coming into the def MI).

Modified:
llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp

Modified: llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp?rev=47281r1=47280r2=47281view=diff

==
--- llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp (original)
+++ llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp Mon Feb 18 12:56:31 2008
@@ -247,11 +247,11 @@
 
   unsigned CopyIdx = li_-getDefIndex(li_-getInstructionIndex(CopyMI));
 
-  // FIXME: For now, only eliminate the copy by commuting its def is the source
-  // does not live pass the move. Coalescing those copies may end up may simply
-  // end up swapping a live interval for another. That and because usually only
-  // the non-two address operand can be folded can end up pessimizing the code.
-  if (CopyMI-findRegisterUseOperandIdx(IntA.reg, true) != -1)
+  // FIXME: For now, only eliminate the copy by commuting its def when the
+  // source register is a virtual register. We want to guard against cases
+  // where the copy is a back edge copy and commuting the def lengthen the
+  // live interval of the source register to the entire loop.
+  if (TargetRegisterInfo::isPhysicalRegister(IntA.reg))
 return false;
 
   // BValNo is a value number in B that is defined by a copy from A. 'B3' in


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


[llvm-commits] [llvm] r47282 - /llvm/trunk/lib/Target/X86/X86ISelLowering.cpp

2008-02-18 Thread Dan Gohman
Author: djg
Date: Mon Feb 18 13:34:53 2008
New Revision: 47282

URL: http://llvm.org/viewvc/llvm-project?rev=47282view=rev
Log:
Chris pointed out that it's not necessary to set i64 MUL to Expand
on x86-32 since i64 itself is not a Legal type. And, update some
comments.

Modified:
llvm/trunk/lib/Target/X86/X86ISelLowering.cpp

Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=47282r1=47281r2=47282view=diff

==
--- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Mon Feb 18 13:34:53 2008
@@ -169,13 +169,16 @@
 setOperationAction(ISD::BIT_CONVERT  , MVT::i32  , Expand);
   }
 
-  // Scalar integer multiply-high, divide, and remainder are
-  // lowered to use operations that produce two results, to match the
-  // available instructions. This exposes the two-result form to trivial
-  // CSE, which is able to combine x/y and x%y into a single instruction,
-  // for example. The single-result multiply instructions are introduced
-  // in X86ISelDAGToDAG.cpp, after CSE, for uses where the the high part
-  // is not needed.
+  // Scalar integer divide and remainder are lowered to use operations that
+  // produce two results, to match the available instructions. This exposes
+  // the two-result form to trivial CSE, which is able to combine x/y and x%y
+  // into a single instruction.
+  //
+  // Scalar integer multiply-high is also lowered to use two-result
+  // operations, to match the available instructions. However, plain multiply
+  // (low) operations are left as Legal, as there are single-result
+  // instructions for this in x86. Using the two-result multiply instructions
+  // when both high and low results are needed must be arranged by dagcombine.
   setOperationAction(ISD::MULHS   , MVT::i8, Expand);
   setOperationAction(ISD::MULHU   , MVT::i8, Expand);
   setOperationAction(ISD::SDIV, MVT::i8, Expand);
@@ -201,11 +204,6 @@
   setOperationAction(ISD::SREM, MVT::i64   , Expand);
   setOperationAction(ISD::UREM, MVT::i64   , Expand);
 
-  // 8, 16, and 32-bit plain multiply are legal. And 64-bit multiply
-  // is also legal on x86-64.
-  if (!Subtarget-is64Bit())
-setOperationAction(ISD::MUL   , MVT::i64   , Expand);
-
   setOperationAction(ISD::BR_JT, MVT::Other, Expand);
   setOperationAction(ISD::BRCOND   , MVT::Other, Custom);
   setOperationAction(ISD::BR_CC, MVT::Other, Expand);


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


[llvm-commits] [poolalloc] r47283 - /poolalloc/trunk/lib/PoolAllocate/PoolAllocate.cpp

2008-02-18 Thread John Criswell
Author: criswell
Date: Mon Feb 18 13:49:35 2008
New Revision: 47283

URL: http://llvm.org/viewvc/llvm-project?rev=47283view=rev
Log:
Fixed line wrapping of comments.
No functionality changes.

Modified:
poolalloc/trunk/lib/PoolAllocate/PoolAllocate.cpp

Modified: poolalloc/trunk/lib/PoolAllocate/PoolAllocate.cpp
URL: 
http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/PoolAllocate/PoolAllocate.cpp?rev=47283r1=47282r2=47283view=diff

==
--- poolalloc/trunk/lib/PoolAllocate/PoolAllocate.cpp (original)
+++ poolalloc/trunk/lib/PoolAllocate/PoolAllocate.cpp Mon Feb 18 13:49:35 2008
@@ -135,10 +135,10 @@
 
   std::mapFunction*, Function* FuncMap;
 
-  // Now clone a function using the pool arg list obtained in the previous pass
-  // over the modules.  Loop over only the function initially in the program,
-  // don't traverse newly added ones.  If the function needs new arguments, 
make
-  // its clone.
+  // Now clone a function using the pool arg list obtained in the previous
+  // pass over the modules.  Loop over only the function initially in the
+  // program, don't traverse newly added ones.  If the function needs new
+  // arguments, make its clone.
   std::setFunction* ClonedFunctions;
 {TIME_REGION(X, MakeFunctionClone);
   for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I)
@@ -379,7 +379,8 @@
   ++NumCloned;
  
   
-  // Figure out what the arguments are to be for the new version of the 
function
+  // Figure out what the arguments are to be for the new version of the
+  // function
   const FunctionType *OldFuncTy = F.getFunctionType();
   std::vectorconst Type* ArgTys(FI.ArgNodes.size(), PoolDescPtrTy);
   ArgTys.reserve(OldFuncTy-getNumParams() + FI.ArgNodes.size());


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


Re: [llvm-commits] [llvm] r47247 - /llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp

2008-02-18 Thread Evan Cheng
Hi Resistor,

This breaks MultiSource/Benchmarks/Prolangs-C++/city under x86-64.  
Please take a look.

Thanks,

Evan

On Feb 17, 2008, at 1:29 PM, Owen Anderson wrote:

 Author: resistor
 Date: Sun Feb 17 15:29:08 2008
 New Revision: 47247

 URL: http://llvm.org/viewvc/llvm-project?rev=47247view=rev
 Log:
 Teach getModRefInfo that memcpy, memmove, and memset don't capture  
 memory addresses.
 Also, noalias arguments are be considered like stack allocated  
 ones for this purpose, because
 the only way they can be modref'ed is if they escape somewhere in  
 the current function.

 Modified:
llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp

 Modified: llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp
 URL: 
 http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp?rev=47247r1=47246r2=47247view=diff

 = 
 = 
 = 
 = 
 = 
 = 
 = 
 = 
 ==
 --- llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp (original)
 +++ llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp Sun Feb 17  
 15:29:08 2008
 @@ -21,7 +21,7 @@
 #include llvm/ParameterAttributes.h
 #include llvm/GlobalVariable.h
 #include llvm/Instructions.h
 -#include llvm/Intrinsics.h
 +#include llvm/IntrinsicInst.h
 #include llvm/Pass.h
 #include llvm/Target/TargetData.h
 #include llvm/ADT/SmallVector.h
 @@ -228,6 +228,13 @@
   // If returned, the address will escape to calling functions,  
 but no
   // callees could modify it.
   break; // next use
 +case Instruction::Call:
 +  // If the call is to a few known safe intrinsics, we know  
 that it does
 +  // not escape
 +  if (isaMemIntrinsic(I))
 +return false;
 +  else
 +return true;
 default:
   return true;
 }
 @@ -247,8 +254,11 @@
 // Allocations and byval arguments are new objects.
 if (Object 
 (isaAllocationInst(Object) ||
 - (isaArgument(Object)  castArgument(Object)- 
 hasByValAttr( {
 -  // Okay, the pointer is to a stack allocated object.  If we  
 can prove that
 + (isaArgument(Object) 
 + (castArgument(Object)- 
 hasByValAttr() ||
 +  castArgument(Object)- 
 hasNoAliasAttr() {
 +  // Okay, the pointer is to a stack allocated (or effectively  
 so, for
 +  // for noalias parameters) object.  If we can prove that
   // the pointer never escapes, then we know the call cannot  
 clobber it,
   // because it simply can't get its address.
   if (!AddressMightEscape(Object))


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

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


[llvm-commits] CVS: llvm-www/pubs/2008-02-23-TRANSACT-TangerObjBased.pdf

2008-02-18 Thread Chris Lattner


Changes in directory llvm-www/pubs:

2008-02-23-TRANSACT-TangerObjBased.pdf updated: 1.1 - 1.2
---
Log message:

updated paper.


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

 2008-02-23-TRANSACT-TangerObjBased.pdf |0 
 1 files changed


Index: llvm-www/pubs/2008-02-23-TRANSACT-TangerObjBased.pdf



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


[llvm-commits] [llvm] r47287 - in /llvm/trunk: lib/Transforms/Scalar/InstructionCombining.cpp test/Transforms/InstCombine/2008-02-16-SDivOverflow.ll test/Transforms/InstCombine/2008-02-16-SDivOverflow

2008-02-18 Thread Nick Lewycky
Author: nicholas
Date: Mon Feb 18 16:48:05 2008
New Revision: 47287

URL: http://llvm.org/viewvc/llvm-project?rev=47287view=rev
Log:
Correctly fold divide-by-constant, even when faced with overflow.

Added:
llvm/trunk/test/Transforms/InstCombine/2008-02-16-SDivOverflow.ll
llvm/trunk/test/Transforms/InstCombine/2008-02-16-SDivOverflow2.ll
Modified:
llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp

Modified: llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp?rev=47287r1=47286r2=47287view=diff

==
--- llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Mon Feb 18 
16:48:05 2008
@@ -605,6 +605,28 @@
 static ConstantInt *Multiply(ConstantInt *C1, ConstantInt *C2) {
   return ConstantInt::get(C1-getValue() * C2-getValue());
 }
+/// MultiplyOverflows - True if the multiply can not be expressed in an int
+/// this size.
+static bool MultiplyOverflows(ConstantInt *C1, ConstantInt *C2, bool sign) {
+  uint32_t W = C1-getBitWidth();
+  APInt LHSExt = C1-getValue(), RHSExt = C2-getValue();
+  if (sign) {
+LHSExt.sext(W * 2);
+RHSExt.sext(W * 2);
+  } else {
+LHSExt.zext(W * 2);
+RHSExt.zext(W * 2);
+  }
+
+  APInt MulExt = LHSExt * RHSExt;
+
+  if (sign) {
+APInt Min = APInt::getSignedMinValue(W).sext(W * 2);
+APInt Max = APInt::getSignedMaxValue(W).sext(W * 2);
+return MulExt.slt(Min) || MulExt.sgt(Max);
+  } else 
+return MulExt.ugt(APInt::getLowBitsSet(W * 2, W));
+}
 
 /// ComputeMaskedBits - Determine which of the bits specified in Mask are
 /// known to be either zero or one and return them in the KnownZero/KnownOne
@@ -2632,8 +2654,11 @@
 if (Instruction *LHS = dyn_castInstruction(Op0))
   if (Instruction::BinaryOps(LHS-getOpcode()) == I.getOpcode())
 if (ConstantInt *LHSRHS = dyn_castConstantInt(LHS-getOperand(1))) {
-  return BinaryOperator::create(I.getOpcode(), LHS-getOperand(0),
-Multiply(RHS, LHSRHS));
+  if (MultiplyOverflows(RHS, LHSRHS, I.getOpcode()==Instruction::SDiv))
+return ReplaceInstUsesWith(I, Constant::getNullValue(I.getType()));
+  else 
+return BinaryOperator::create(I.getOpcode(), LHS-getOperand(0),
+  Multiply(RHS, LHSRHS));
 }
 
 if (!RHS-isZero()) { // avoid X udiv 0

Added: llvm/trunk/test/Transforms/InstCombine/2008-02-16-SDivOverflow.ll
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/2008-02-16-SDivOverflow.ll?rev=47287view=auto

==
--- llvm/trunk/test/Transforms/InstCombine/2008-02-16-SDivOverflow.ll (added)
+++ llvm/trunk/test/Transforms/InstCombine/2008-02-16-SDivOverflow.ll Mon Feb 
18 16:48:05 2008
@@ -0,0 +1,14 @@
+; RUN: llvm-as  %s | opt -instcombine | llvm-dis | grep {ret i.* 0} | count 2
+; PR2048
+
+define i32 @i(i32 %a) {
+  %tmp1 = sdiv i32 %a, -1431655765
+  %tmp2 = sdiv i32 %tmp1, 3
+  ret i32 %tmp2
+}
+
+define i8 @j(i8 %a) {
+  %tmp1 = sdiv i8 %a, 64
+  %tmp2 = sdiv i8 %tmp1, 3
+  ret i8 %tmp2
+}

Added: llvm/trunk/test/Transforms/InstCombine/2008-02-16-SDivOverflow2.ll
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/2008-02-16-SDivOverflow2.ll?rev=47287view=auto

==
--- llvm/trunk/test/Transforms/InstCombine/2008-02-16-SDivOverflow2.ll (added)
+++ llvm/trunk/test/Transforms/InstCombine/2008-02-16-SDivOverflow2.ll Mon Feb 
18 16:48:05 2008
@@ -0,0 +1,9 @@
+; RUN: llvm-as  %s | opt -instcombine | llvm-dis | grep {sdiv i8 \%a, 9}
+; PR2048
+
+define i8 @i(i8 %a) {
+  %tmp1 = sdiv i8 %a, -3
+  %tmp2 = sdiv i8 %tmp1, -3
+  ret i8 %tmp2
+}
+


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


[llvm-commits] [llvm] r47290 - in /llvm/trunk: include/llvm/CodeGen/SelectionDAGNodes.h lib/CodeGen/SelectionDAG/DAGCombiner.cpp lib/CodeGen/SelectionDAG/SelectionDAG.cpp lib/Target/X86/X86ISelLowerin

2008-02-18 Thread Evan Cheng
Author: evancheng
Date: Mon Feb 18 17:04:32 2008
New Revision: 47290

URL: http://llvm.org/viewvc/llvm-project?rev=47290view=rev
Log:
- When DAG combiner is folding a bit convert into a BUILD_VECTOR, it should 
check if it's essentially a SCALAR_TO_VECTOR. Avoid turning (v8i16) 10, u, u, 
u to 10, 0, u, u, u, u, u, u. Instead, simply convert it to a 
SCALAR_TO_VECTOR of the proper type.
- X86 now normalize SCALAR_TO_VECTOR to (BIT_CONVERT (v4i32 SCALAR_TO_VECTOR)). 
Get rid of X86ISD::S2VEC.

Added:
llvm/trunk/test/CodeGen/X86/vec_shift2.ll
Modified:
llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h
llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
llvm/trunk/lib/Target/X86/X86ISelLowering.h
llvm/trunk/lib/Target/X86/X86InstrMMX.td
llvm/trunk/lib/Target/X86/X86InstrSSE.td

Modified: llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h?rev=47290r1=47289r2=47290view=diff

==
--- llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h (original)
+++ llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h Mon Feb 18 17:04:32 2008
@@ -611,6 +611,11 @@
   /// BUILD_VECTOR where all of the elements are 0 or undef.
   bool isBuildVectorAllZeros(const SDNode *N);
 
+  /// isScalarToVector - Return true if the specified node is a
+  /// ISD::SCALAR_TO_VECTOR node or a BUILD_VECTOR node where only the low
+  /// element is not an undef.
+  bool isScalarToVector(const SDNode *N);
+
   /// isDebugLabel - Return true if the specified node represents a debug
   /// label (i.e. ISD::LABEL or TargetInstrInfo::LABEL node and third operand
   /// is 0).

Modified: llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp?rev=47290r1=47289r2=47290view=diff

==
--- llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp Mon Feb 18 17:04:32 2008
@@ -3450,14 +3450,16 @@
 Ops.push_back(DAG.getConstant(NewBits, DstEltVT));
 }
 
-MVT::ValueType VT = MVT::getVectorType(DstEltVT,
-   Ops.size());
+MVT::ValueType VT = MVT::getVectorType(DstEltVT, Ops.size()); 
 return DAG.getNode(ISD::BUILD_VECTOR, VT, Ops[0], Ops.size());
   }
   
   // Finally, this must be the case where we are shrinking elements: each input
   // turns into multiple outputs.
+  bool isS2V = ISD::isScalarToVector(BV);
   unsigned NumOutputsPerInput = SrcBitSize/DstBitSize;
+  MVT::ValueType VT = MVT::getVectorType(DstEltVT,
+ NumOutputsPerInput * 
BV-getNumOperands());
   SmallVectorSDOperand, 8 Ops;
   for (unsigned i = 0, e = BV-getNumOperands(); i != e; ++i) {
 if (BV-getOperand(i).getOpcode() == ISD::UNDEF) {
@@ -3466,18 +3468,19 @@
   continue;
 }
 uint64_t OpVal = castConstantSDNode(BV-getOperand(i))-getValue();
-
 for (unsigned j = 0; j != NumOutputsPerInput; ++j) {
   unsigned ThisVal = OpVal  ((1ULL  DstBitSize)-1);
-  OpVal = DstBitSize;
   Ops.push_back(DAG.getConstant(ThisVal, DstEltVT));
+  if (isS2V  i == 0  j == 0  ThisVal == OpVal)
+// Simply turn this into a SCALAR_TO_VECTOR of the new type.
+return DAG.getNode(ISD::SCALAR_TO_VECTOR, VT, Ops[0]);
+  OpVal = DstBitSize;
 }
 
 // For big endian targets, swap the order of the pieces of each element.
 if (TLI.isBigEndian())
   std::reverse(Ops.end()-NumOutputsPerInput, Ops.end());
   }
-  MVT::ValueType VT = MVT::getVectorType(DstEltVT, Ops.size());
   return DAG.getNode(ISD::BUILD_VECTOR, VT, Ops[0], Ops.size());
 }
 

Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp?rev=47290r1=47289r2=47290view=diff

==
--- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Mon Feb 18 17:04:32 
2008
@@ -176,6 +176,27 @@
   return true;
 }
 
+/// isScalarToVector - Return true if the specified node is a
+/// ISD::SCALAR_TO_VECTOR node or a BUILD_VECTOR node where only the low
+/// element is not an undef.
+bool ISD::isScalarToVector(const SDNode *N) {
+  if (N-getOpcode() == ISD::SCALAR_TO_VECTOR)
+return true;
+
+  if (N-getOpcode() != ISD::BUILD_VECTOR)
+return false;
+  if (N-getOperand(0).getOpcode() == ISD::UNDEF)
+return false;
+  unsigned NumElems = N-getNumOperands();
+  for (unsigned i = 1; i  NumElems; ++i) {
+SDOperand V = N-getOperand(i);
+if 

[llvm-commits] [poolalloc] r47291 - /poolalloc/trunk/lib/PoolAllocate/PoolAllocate.cpp

2008-02-18 Thread John Criswell
Author: criswell
Date: Mon Feb 18 17:06:24 2008
New Revision: 47291

URL: http://llvm.org/viewvc/llvm-project?rev=47291view=rev
Log:
Taught pool allocation how to deal with the new function attributes.

Modified:
poolalloc/trunk/lib/PoolAllocate/PoolAllocate.cpp

Modified: poolalloc/trunk/lib/PoolAllocate/PoolAllocate.cpp
URL: 
http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/PoolAllocate/PoolAllocate.cpp?rev=47291r1=47290r2=47291view=diff

==
--- poolalloc/trunk/lib/PoolAllocate/PoolAllocate.cpp (original)
+++ poolalloc/trunk/lib/PoolAllocate/PoolAllocate.cpp Mon Feb 18 17:06:24 2008
@@ -24,6 +24,7 @@
 #include llvm/Instructions.h
 #include llvm/Module.h
 #include llvm/Constants.h
+#include llvm/ParameterAttributes.h
 #include llvm/Support/CFG.h
 #include llvm/Target/TargetData.h
 #include llvm/Transforms/Utils/BasicBlockUtils.h
@@ -424,6 +425,29 @@
 {TIME_REGION(X, CloneFunctionInto);
   CloneFunctionInto(New, F, ValueMap, Returns);
 }
+
+  //
+  // The CloneFunctionInto() function will copy the parameter attributes
+  // verbatim.  This is incorrect; each attribute should be shifted one so
+  // that the pool descriptor has no attributes.
+  //
+  const ParamAttrsList * OldAttrs = New-getParamAttrs();
+  ParamAttrsVector NewAttrsVector;
+  for (unsigned index = 0; index  OldAttrs-size(); ++index) {
+// Find the argument index
+unsigned argIndex = OldAttrs-getParamIndex (index);
+
+// If it's not the return value, move the attribute to the next
+// parameter.
+if (argIndex) ++argIndex;
+
+// Add the parameter to the new list.
+
NewAttrsVector.push_back(ParamAttrsWithIndex::get(argIndex,OldAttrs-getParamAttrsAtIndex(index)));
+  }
+
+  // Assign the new attributes to the function clone
+  New-setParamAttrs (ParamAttrsList::get (NewAttrsVector));
+
   // Invert the ValueMap into the NewToOldValueMap
   std::mapValue*, const Value* NewToOldValueMap = FI.NewToOldValueMap;
 


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


Re: [llvm-commits] [llvm] r47247 - /llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp

2008-02-18 Thread Owen Anderson
I can't reproduce on my Mac Pro.  Can you file a bug report with a  
reduce testcase?


--Owen

On Feb 18, 2008, at 1:43 PM, Evan Cheng wrote:


Hi Resistor,

This breaks MultiSource/Benchmarks/Prolangs-C++/city under x86-64.  
Please take a look.


Thanks,

Evan

On Feb 17, 2008, at 1:29 PM, Owen Anderson wrote:


Author: resistor
Date: Sun Feb 17 15:29:08 2008
New Revision: 47247

URL: http://llvm.org/viewvc/llvm-project?rev=47247view=rev
Log:
Teach getModRefInfo that memcpy, memmove, and memset don't  
capture memory addresses.
Also, noalias arguments are be considered like stack allocated  
ones for this purpose, because
the only way they can be modref'ed is if they escape somewhere in  
the current function.


Modified:
llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp

Modified: llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp?rev=47247r1=47246r2=47247view=diff

= 
= 
= 
= 
= 
= 
= 
= 
= 
=

--- llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp (original)
+++ llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp Sun Feb 17  
15:29:08 2008

@@ -21,7 +21,7 @@
#include llvm/ParameterAttributes.h
#include llvm/GlobalVariable.h
#include llvm/Instructions.h
-#include llvm/Intrinsics.h
+#include llvm/IntrinsicInst.h
#include llvm/Pass.h
#include llvm/Target/TargetData.h
#include llvm/ADT/SmallVector.h
@@ -228,6 +228,13 @@
   // If returned, the address will escape to calling functions,  
but no

   // callees could modify it.
   break; // next use
+case Instruction::Call:
+  // If the call is to a few known safe intrinsics, we know  
that it does

+  // not escape
+  if (isaMemIntrinsic(I))
+return false;
+  else
+return true;
 default:
   return true;
 }
@@ -247,8 +254,11 @@
 // Allocations and byval arguments are new objects.
 if (Object 
 (isaAllocationInst(Object) ||
- (isaArgument(Object)  castArgument(Object)- 
hasByValAttr( {
-  // Okay, the pointer is to a stack allocated object.  If we  
can prove that

+ (isaArgument(Object) 
+ (castArgument(Object)- 
hasByValAttr() ||
+  castArgument(Object)- 
hasNoAliasAttr() {
+  // Okay, the pointer is to a stack allocated (or effectively  
so, for

+  // for noalias parameters) object.  If we can prove that
   // the pointer never escapes, then we know the call cannot  
clobber it,

   // because it simply can't get its address.
   if (!AddressMightEscape(Object))


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






smime.p7s
Description: S/MIME cryptographic signature
___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


Re: [llvm-commits] [llvm] r47247 - /llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp

2008-02-18 Thread Chris Lattner

On Feb 18, 2008, at 3:31 PM, Owen Anderson wrote:

 I can't reproduce on my Mac Pro.  Can you file a bug report with a  
 reduce testcase?

Did you try building the testcase with -m64?  It doesn't happen at -m32.

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


[llvm-commits] [llvm] r47297 - in /llvm/trunk/test/Other: 2002-01-31-CallGraph.ll 2002-02-24-InlineBrokePHINodes.ll 2002-03-11-ConstPropCrash.ll 2003-02-19-LoopInfoNestingBug.ll 2004-08-16-LowerPacked

2008-02-18 Thread Tanya Lattner
Author: tbrethou
Date: Mon Feb 18 19:44:26 2008
New Revision: 47297

URL: http://llvm.org/viewvc/llvm-project?rev=47297view=rev
Log:
Remove llvm-upgrade and update tests.

Modified:
llvm/trunk/test/Other/2002-01-31-CallGraph.ll
llvm/trunk/test/Other/2002-02-24-InlineBrokePHINodes.ll
llvm/trunk/test/Other/2002-03-11-ConstPropCrash.ll
llvm/trunk/test/Other/2003-02-19-LoopInfoNestingBug.ll
llvm/trunk/test/Other/2004-08-16-LowerPacked.ll
llvm/trunk/test/Other/2004-08-16-PackedConstantInlineStore.ll
llvm/trunk/test/Other/2004-08-16-PackedGlobalConstant.ll
llvm/trunk/test/Other/2004-08-16-PackedSelect.ll
llvm/trunk/test/Other/2004-08-16-PackedSimple.ll
llvm/trunk/test/Other/2004-08-20-PackedControlFlow.ll
llvm/trunk/test/Other/2007-04-24-eliminate-mostly-empty-blocks.ll

Modified: llvm/trunk/test/Other/2002-01-31-CallGraph.ll
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Other/2002-01-31-CallGraph.ll?rev=47297r1=47296r2=47297view=diff

==
--- llvm/trunk/test/Other/2002-01-31-CallGraph.ll (original)
+++ llvm/trunk/test/Other/2002-01-31-CallGraph.ll Mon Feb 18 19:44:26 2008
@@ -1,15 +1,13 @@
 ;  Call graph construction crash: Not handling indirect calls right
 ;
-; RUN: llvm-upgrade  %s | llvm-as | opt -analyze -callgraph
+; RUN: llvm-as  %s | opt -analyze -callgraph
 ;
 
-%FunTy = type int(int)
+%FunTy = type i32 (i32)
 
-implementation
+define void @invoke(%FunTy* %x) {
+%foo = call i32 %x( i32 123 )   ; i32 [#uses=0]
+ret void
+}
 
-void invoke(%FunTy *%x)
-begin
-   %foo = call %FunTy* %x(int 123)
-   ret void
-end
 

Modified: llvm/trunk/test/Other/2002-02-24-InlineBrokePHINodes.ll
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Other/2002-02-24-InlineBrokePHINodes.ll?rev=47297r1=47296r2=47297view=diff

==
--- llvm/trunk/test/Other/2002-02-24-InlineBrokePHINodes.ll (original)
+++ llvm/trunk/test/Other/2002-02-24-InlineBrokePHINodes.ll Mon Feb 18 19:44:26 
2008
@@ -1,26 +1,23 @@
-; Inlining used to break PHI nodes.  This tests that they are correctly 
updated 
+; Inlining used to break PHI nodes.  This tests that they are correctly updated
 ; when a node is split around the call instruction.  The verifier caught the 
error.
 ;
-; RUN: llvm-upgrade  %s | llvm-as | opt -inline
+; RUN: llvm-as  %s | opt -inline
 ;
-implementation
 
-ulong test(ulong %X)
-begin
-   ret ulong %X
-end
+define i64 @test(i64 %X) {
+   ret i64 %X
+}
 
-ulong fib(ulong %n)
-begin
-  %T = setlt ulong %n, 2   ; {bool}:0
-  br bool %T, label %BaseCase, label %RecurseCase
+define i64 @fib(i64 %n) {
+; label:0
+   %T = icmp ult i64 %n, 2 ; i1 [#uses=1]
+   br i1 %T, label %BaseCase, label %RecurseCase
 
-RecurseCase:
-  %result = call ulong %test(ulong %n)
-  br label %BaseCase
-
-BaseCase:
-  %X = phi ulong [1, %0], [2, %RecurseCase]
-  ret ulong %X
-end
+RecurseCase:   ; preds = %0
+   %result = call i64 @test( i64 %n )  ; i64 [#uses=0]
+   br label %BaseCase
 
+BaseCase:  ; preds = %RecurseCase, %0
+   %X = phi i64 [ 1, %0 ], [ 2, %RecurseCase ] ; i64 
[#uses=1]
+   ret i64 %X
+}

Modified: llvm/trunk/test/Other/2002-03-11-ConstPropCrash.ll
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Other/2002-03-11-ConstPropCrash.ll?rev=47297r1=47296r2=47297view=diff

==
--- llvm/trunk/test/Other/2002-03-11-ConstPropCrash.ll (original)
+++ llvm/trunk/test/Other/2002-03-11-ConstPropCrash.ll Mon Feb 18 19:44:26 2008
@@ -5,21 +5,20 @@
 ;
 ; Fixed by adding new arguments to ConstantFoldTerminator
 ;
-; RUN: llvm-upgrade  %s | llvm-as | opt -constprop
+; RUN: llvm-as  %s | opt -constprop
 
-implementation
+define void @build_tree(i32 %ml) {
+; label:0
+br label %bb2
 
-void build_tree(int %ml)
-begin
-   br label %bb2
+bb2:; preds = %bb2, %0
+%reg137 = phi i32 [ %reg140, %bb2 ], [ 12, %0 ] ; i32 
[#uses=1]
+%reg138 = phi i32 [ %reg139, %bb2 ], [ 0, %0 ]  ; i32 
[#uses=1]
+%reg139 = add i32 %reg138, 1; i32 [#uses=1]
+%reg140 = add i32 %reg137, -1   ; i32 [#uses=1]
+br i1 false, label %bb2, label %bb3
 
-bb2:
-   %reg137 = phi int [ %reg140, %bb2 ], [ 12, %0 ] ; int 
[#uses=2]
-   %reg138 = phi uint [ %reg139, %bb2 ], [ 0, %0 ] ; uint 
[#uses=3]
-   %reg139 = add uint %reg138, 1   ; uint [#uses=1]
-   %reg140 = add int %reg137, -1   ; int [#uses=1]
-   br bool false, label %bb2, label %bb3
+bb3:; preds = %bb2
+ret void
+}
 
-bb3:
-   ret void
-end

Modified: llvm/trunk/test/Other/2003-02-19-LoopInfoNestingBug.ll
URL: