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

2007-01-30 Thread Chris Lattner


Changes in directory llvm/lib/Transforms/Utils:

Local.cpp updated: 1.67 -> 1.68
---
Log message:

move a bunch of constant folding code f rom Transforms/Utils/Local.cpp into
libanalysis/ConstantFolding.cpp.


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

 Local.cpp |  152 --
 1 files changed, 152 deletions(-)


Index: llvm/lib/Transforms/Utils/Local.cpp
diff -u llvm/lib/Transforms/Utils/Local.cpp:1.67 
llvm/lib/Transforms/Utils/Local.cpp:1.68
--- llvm/lib/Transforms/Utils/Local.cpp:1.67Tue Jan 30 17:29:47 2007
+++ llvm/lib/Transforms/Utils/Local.cpp Tue Jan 30 17:45:45 2007
@@ -21,7 +21,6 @@
 #include "llvm/Target/TargetData.h"
 #include "llvm/Support/GetElementPtrTypeIterator.h"
 #include "llvm/Support/MathExtras.h"
-#include "llvm/ADT/SmallVector.h"
 #include 
 using namespace llvm;
 
@@ -46,99 +45,6 @@
   return false;
 }
 
-/// ConstantFoldInstruction - Attempt to constant fold the specified
-/// instruction.  If successful, the constant result is returned, if not, null
-/// is returned.  Note that this function can only fail when attempting to fold
-/// instructions like loads and stores, which have no constant expression form.
-///
-Constant *llvm::ConstantFoldInstruction(Instruction *I, const TargetData *TD) {
-  if (PHINode *PN = dyn_cast(I)) {
-if (PN->getNumIncomingValues() == 0)
-  return Constant::getNullValue(PN->getType());
-
-Constant *Result = dyn_cast(PN->getIncomingValue(0));
-if (Result == 0) return 0;
-
-// Handle PHI nodes specially here...
-for (unsigned i = 1, e = PN->getNumIncomingValues(); i != e; ++i)
-  if (PN->getIncomingValue(i) != Result && PN->getIncomingValue(i) != PN)
-return 0;   // Not all the same incoming constants...
-
-// If we reach here, all incoming values are the same constant.
-return Result;
-  }
-
-  // Scan the operand list, checking to see if they are all constants, if so,
-  // hand off to ConstantFoldInstOperands.
-  SmallVector Ops;
-  for (unsigned i = 0, e = I->getNumOperands(); i != e; ++i)
-if (Constant *Op = dyn_cast(I->getOperand(i)))
-  Ops.push_back(Op);
-else
-  return 0;  // All operands not constant!
-
-  return ConstantFoldInstOperands(I, &Ops[0], Ops.size());
-}
-
-/// ConstantFoldInstOperands - Attempt to constant fold an instruction with the
-/// specified opcode and operands.  If successful, the constant result is
-/// returned, if not, null is returned.  Note that this function can fail when
-/// attempting to fold instructions like loads and stores, which have no
-/// constant expression form.
-///
-Constant *llvm::ConstantFoldInstOperands(const Instruction* I, 
- Constant** Ops, unsigned NumOps,
- const TargetData *TD) {
-  unsigned Opc = I->getOpcode();
-  const Type *DestTy = I->getType();
-
-  // Handle easy binops first
-  if (isa(I))
-return ConstantExpr::get(Opc, Ops[0], Ops[1]);
-  
-  switch (Opc) {
-  default: return 0;
-  case Instruction::Call:
-if (Function *F = dyn_cast(Ops[0]))
-  if (canConstantFoldCallTo(F))
-return ConstantFoldCall(F, Ops+1, NumOps);
-return 0;
-  case Instruction::ICmp:
-  case Instruction::FCmp:
-return ConstantExpr::getCompare(cast(I)->getPredicate(), Ops[0], 
-Ops[1]);
-  case Instruction::Shl:
-  case Instruction::LShr:
-  case Instruction::AShr:
-return ConstantExpr::get(Opc, Ops[0], Ops[1]);
-  case Instruction::Trunc:
-  case Instruction::ZExt:
-  case Instruction::SExt:
-  case Instruction::FPTrunc:
-  case Instruction::FPExt:
-  case Instruction::UIToFP:
-  case Instruction::SIToFP:
-  case Instruction::FPToUI:
-  case Instruction::FPToSI:
-  case Instruction::PtrToInt:
-  case Instruction::IntToPtr:
-  case Instruction::BitCast:
-return ConstantExpr::getCast(Opc, Ops[0], DestTy);
-  case Instruction::Select:
-return ConstantExpr::getSelect(Ops[0], Ops[1], Ops[2]);
-  case Instruction::ExtractElement:
-return ConstantExpr::getExtractElement(Ops[0], Ops[1]);
-  case Instruction::InsertElement:
-return ConstantExpr::getInsertElement(Ops[0], Ops[1], Ops[2]);
-  case Instruction::ShuffleVector:
-return ConstantExpr::getShuffleVector(Ops[0], Ops[1], Ops[2]);
-  case Instruction::GetElementPtr:
-return ConstantExpr::getGetElementPtr(Ops[0],
-  std::vector(Ops+1, 
- Ops+NumOps));
-  }
-}
-
 // ConstantFoldTerminator - If a terminator instruction is predicated on a
 // constant value, convert it into an unconditional branch to the constant
 // destination.
@@ -259,64 +165,6 @@
   return false;
 }
 
-/// ConstantFoldLoadThroughGEPConstantExpr - Given a constant and a
-/// getelementptr constantexpr, return the constant value being addressed by 
the
-/// constant expression, or null if something is funny and we can't

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

2007-01-30 Thread Chris Lattner


Changes in directory llvm/lib/Transforms/Utils:

Local.cpp updated: 1.66 -> 1.67
---
Log message:

remove now-dead code.


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

 Local.cpp |   14 --
 1 files changed, 14 deletions(-)


Index: llvm/lib/Transforms/Utils/Local.cpp
diff -u llvm/lib/Transforms/Utils/Local.cpp:1.66 
llvm/lib/Transforms/Utils/Local.cpp:1.67
--- llvm/lib/Transforms/Utils/Local.cpp:1.66Tue Jan 30 17:13:49 2007
+++ llvm/lib/Transforms/Utils/Local.cpp Tue Jan 30 17:29:47 2007
@@ -68,20 +68,6 @@
 return Result;
   }
 
-  Constant *Op0 = 0, *Op1 = 0;
-  switch (I->getNumOperands()) {
-  default:
-  case 2:
-Op1 = dyn_cast(I->getOperand(1));
-if (Op1 == 0) return 0;// Not a constant?, can't fold
-/* FALL THROUGH */
-  case 1:
-Op0 = dyn_cast(I->getOperand(0));
-if (Op0 == 0) return 0;// Not a constant?, can't fold
-break;
-  case 0: return 0;
-  }
-
   // Scan the operand list, checking to see if they are all constants, if so,
   // hand off to ConstantFoldInstOperands.
   SmallVector Ops;



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


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

2006-11-26 Thread Reid Spencer


Changes in directory llvm/lib/Transforms/Utils:

Local.cpp updated: 1.61 -> 1.62
LowerAllocations.cpp updated: 1.62 -> 1.63
LowerInvoke.cpp updated: 1.43 -> 1.44
SimplifyCFG.cpp updated: 1.106 -> 1.107
---
Log message:

For PR950: http://llvm.org/PR950 :
The long awaited CAST patch. This introduces 12 new instructions into LLVM
to replace the cast instruction. Corresponding changes throughout LLVM are
provided. This passes llvm-test, llvm/test, and SPEC CPUINT2000 with the
exception of 175.vpr which fails only on a slight floating point output
difference.


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

 Local.cpp|   15 +--
 LowerAllocations.cpp |   14 +-
 LowerInvoke.cpp  |   14 ++
 SimplifyCFG.cpp  |5 -
 4 files changed, 32 insertions(+), 16 deletions(-)


Index: llvm/lib/Transforms/Utils/Local.cpp
diff -u llvm/lib/Transforms/Utils/Local.cpp:1.61 
llvm/lib/Transforms/Utils/Local.cpp:1.62
--- llvm/lib/Transforms/Utils/Local.cpp:1.61Wed Nov  8 13:16:44 2006
+++ llvm/lib/Transforms/Utils/Local.cpp Sun Nov 26 19:05:10 2006
@@ -122,8 +122,19 @@
   case Instruction::LShr:
   case Instruction::AShr:
 return ConstantExpr::get(Opc, Ops[0], Ops[1]);
-  case Instruction::Cast:
-return ConstantExpr::getCast(Ops[0], DestTy);
+  case Instruction::Trunc:
+  case Instruction::ZExt:
+  case Instruction::SExt:
+  case Instruction::FPTrunc:
+  case Instruction::FPExt:
+  case Instruction::UIToFP:
+  case Instruction::SIToFP:
+  case Instruction::FPToUI:
+  case Instruction::FPToSI:
+  case Instruction::PtrToInt:
+  case Instruction::IntToPtr:
+  case Instruction::BitCast:
+return ConstantExpr::getCast(Opc, Ops[0], DestTy);
   case Instruction::Select:
 return ConstantExpr::getSelect(Ops[0], Ops[1], Ops[2]);
   case Instruction::ExtractElement:


Index: llvm/lib/Transforms/Utils/LowerAllocations.cpp
diff -u llvm/lib/Transforms/Utils/LowerAllocations.cpp:1.62 
llvm/lib/Transforms/Utils/LowerAllocations.cpp:1.63
--- llvm/lib/Transforms/Utils/LowerAllocations.cpp:1.62 Fri Oct 20 02:07:24 2006
+++ llvm/lib/Transforms/Utils/LowerAllocations.cpp  Sun Nov 26 19:05:10 2006
@@ -134,7 +134,7 @@
 } else {
   Value *Scale = MI->getOperand(0);
   if (Scale->getType() != IntPtrTy)
-Scale = new CastInst(Scale, IntPtrTy, "", I);
+Scale = CastInst::createInferredCast(Scale, IntPtrTy, "", I);
 
   // Multiply it by the array size if necessary...
   MallocArg = BinaryOperator::create(Instruction::Mul, Scale,
@@ -148,10 +148,13 @@
   if (MallocFTy->getNumParams() > 0 || MallocFTy->isVarArg()) {
 if (MallocFTy->isVarArg()) {
   if (MallocArg->getType() != IntPtrTy)
-MallocArg = new CastInst(MallocArg, IntPtrTy, "", I);
+MallocArg = CastInst::createInferredCast(MallocArg, IntPtrTy, "", 
+ I);
 } else if (MallocFTy->getNumParams() > 0 &&
MallocFTy->getParamType(0) != Type::UIntTy)
-  MallocArg = new CastInst(MallocArg, MallocFTy->getParamType(0), 
"",I);
+  MallocArg = 
+CastInst::createInferredCast(MallocArg, MallocFTy->getParamType(0),
+ "",I);
 MallocArgs.push_back(MallocArg);
   }
 
@@ -166,7 +169,7 @@
   // Create a cast instruction to convert to the right type...
   Value *MCast;
   if (MCall->getType() != Type::VoidTy)
-MCast = new CastInst(MCall, MI->getType(), "", I);
+MCast = CastInst::createInferredCast(MCall, MI->getType(), "", I);
   else
 MCast = Constant::getNullValue(MI->getType());
 
@@ -183,7 +186,8 @@
 Value *MCast = FI->getOperand(0);
 if (FreeFTy->getNumParams() > 0 &&
 FreeFTy->getParamType(0) != MCast->getType())
-  MCast = new CastInst(MCast, FreeFTy->getParamType(0), "", I);
+  MCast = CastInst::createInferredCast(MCast, 
FreeFTy->getParamType(0), 
+   "", I);
 FreeArgs.push_back(MCast);
   }
 


Index: llvm/lib/Transforms/Utils/LowerInvoke.cpp
diff -u llvm/lib/Transforms/Utils/LowerInvoke.cpp:1.43 
llvm/lib/Transforms/Utils/LowerInvoke.cpp:1.44
--- llvm/lib/Transforms/Utils/LowerInvoke.cpp:1.43  Thu Nov  2 14:25:50 2006
+++ llvm/lib/Transforms/Utils/LowerInvoke.cpp   Sun Nov 26 19:05:10 2006
@@ -326,7 +326,7 @@
   Function *F = Invokes.back()->getParent()->getParent();
   
   // To avoid having to handle incoming arguments specially, we lower each arg
-  // to a copy instruction in the entry block.  This ensure that the argument
+  // to a copy instruction in the entry block.  This ensures that the argument
   // value itself cannot be live across the entry block.
   BasicBlock::iterator AfterAllocaInsertPt = F->begin()->begin();
   while (isa(AfterAllocaInsertPt) &&
@@ -334,10 +334,16 @@
 ++AfterAllocaInsertPt;
   for (Function::arg

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

2006-11-08 Thread Jim Laskey


Changes in directory llvm/lib/Transforms/Utils:

Local.cpp updated: 1.60 -> 1.61
---
Log message:

Remove redundant .

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

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


Index: llvm/lib/Transforms/Utils/Local.cpp
diff -u llvm/lib/Transforms/Utils/Local.cpp:1.60 
llvm/lib/Transforms/Utils/Local.cpp:1.61
--- llvm/lib/Transforms/Utils/Local.cpp:1.60Wed Nov  8 00:47:33 2006
+++ llvm/lib/Transforms/Utils/Local.cpp Wed Nov  8 13:16:44 2006
@@ -21,7 +21,6 @@
 #include "llvm/Support/GetElementPtrTypeIterator.h"
 #include "llvm/Support/MathExtras.h"
 #include 
-#include 
 using namespace llvm;
 
 
//===--===//



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


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

2006-11-07 Thread Reid Spencer


Changes in directory llvm/lib/Transforms/Utils:

Local.cpp updated: 1.59 -> 1.60
SimplifyCFG.cpp updated: 1.103 -> 1.104
---
Log message:

For PR950: http://llvm.org/PR950 :
This patch converts the old SHR instruction into two instructions, 
AShr (Arithmetic) and LShr (Logical). The Shr instructions now are not
dependent on the sign of their operands.


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

 Local.cpp   |3 ++-
 SimplifyCFG.cpp |3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)


Index: llvm/lib/Transforms/Utils/Local.cpp
diff -u llvm/lib/Transforms/Utils/Local.cpp:1.59 
llvm/lib/Transforms/Utils/Local.cpp:1.60
--- llvm/lib/Transforms/Utils/Local.cpp:1.59Fri Oct 20 02:07:24 2006
+++ llvm/lib/Transforms/Utils/Local.cpp Wed Nov  8 00:47:33 2006
@@ -120,7 +120,8 @@
 }
 return 0;
   case Instruction::Shl:
-  case Instruction::Shr:
+  case Instruction::LShr:
+  case Instruction::AShr:
 return ConstantExpr::get(Opc, Ops[0], Ops[1]);
   case Instruction::Cast:
 return ConstantExpr::getCast(Ops[0], DestTy);


Index: llvm/lib/Transforms/Utils/SimplifyCFG.cpp
diff -u llvm/lib/Transforms/Utils/SimplifyCFG.cpp:1.103 
llvm/lib/Transforms/Utils/SimplifyCFG.cpp:1.104
--- llvm/lib/Transforms/Utils/SimplifyCFG.cpp:1.103 Thu Nov  2 14:25:50 2006
+++ llvm/lib/Transforms/Utils/SimplifyCFG.cpp   Wed Nov  8 00:47:33 2006
@@ -368,7 +368,8 @@
   case Instruction::Or:
   case Instruction::Xor:
   case Instruction::Shl:
-  case Instruction::Shr:
+  case Instruction::LShr:
+  case Instruction::AShr:
   case Instruction::SetEQ:
   case Instruction::SetNE:
   case Instruction::SetLT:



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


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

2006-05-26 Thread Chris Lattner


Changes in directory llvm/lib/Transforms/Utils:

Local.cpp updated: 1.57 -> 1.58
---
Log message:

Refactor some code to expose an interface to constant fold and instruction 
given it's opcode, typeand operands.



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

 Local.cpp |   84 --
 1 files changed, 49 insertions(+), 35 deletions(-)


Index: llvm/lib/Transforms/Utils/Local.cpp
diff -u llvm/lib/Transforms/Utils/Local.cpp:1.57 
llvm/lib/Transforms/Utils/Local.cpp:1.58
--- llvm/lib/Transforms/Utils/Local.cpp:1.57Thu May 25 16:25:12 2006
+++ llvm/lib/Transforms/Utils/Local.cpp Fri May 26 20:18:04 2006
@@ -64,18 +64,6 @@
 
 // If we reach here, all incoming values are the same constant.
 return Result;
-  } else if (CallInst *CI = dyn_cast(I)) {
-if (Function *F = CI->getCalledFunction())
-  if (canConstantFoldCallTo(F)) {
-std::vector Args;
-for (unsigned i = 1, e = CI->getNumOperands(); i != e; ++i)
-  if (Constant *Op = dyn_cast(CI->getOperand(i)))
-Args.push_back(Op);
-  else
-return 0;
-return ConstantFoldCall(F, Args);
-  }
-return 0;
   }
 
   Constant *Op0 = 0, *Op1 = 0;
@@ -91,37 +79,63 @@
   case 0: return 0;
   }
 
-  if (isa(I) || isa(I))
-return ConstantExpr::get(I->getOpcode(), Op0, Op1);
+  if (isa(I) || isa(I)) {
+if (Constant *Op0 = dyn_cast(I->getOperand(0)))
+  if (Constant *Op1 = dyn_cast(I->getOperand(1)))
+return ConstantExpr::get(I->getOpcode(), Op0, Op1);
+return 0;  // Operands not constants.
+  }
 
-  switch (I->getOpcode()) {
+  // Scan the operand list, checking to see if the are all constants, if so,
+  // hand off to ConstantFoldInstOperands.
+  std::vector Ops;
+  for (unsigned i = 0, e = I->getNumOperands(); i != e; ++i)
+if (Constant *Op = dyn_cast(I->getOperand(i)))
+  Ops.push_back(Op);
+else
+  return 0;  // All operands not constant!
+
+  return ConstantFoldInstOperands(I->getOpcode(), I->getType(), Ops);
+}
+
+/// ConstantFoldInstOperands - Attempt to constant fold an instruction with the
+/// specified opcode and operands.  If successful, the constant result is
+/// returned, if not, null is returned.  Note that this function can fail when
+/// attempting to fold instructions like loads and stores, which have no
+/// constant expression form.
+///
+Constant *llvm::ConstantFoldInstOperands(unsigned Opc, const Type *DestTy,
+ const std::vector &Ops) {
+  if (Opc >= Instruction::BinaryOpsBegin && Opc < Instruction::BinaryOpsEnd)
+return ConstantExpr::get(Opc, Ops[0], Ops[1]);
+  
+  switch (Opc) {
   default: return 0;
+  case Instruction::Call:
+if (Function *F = dyn_cast(Ops[0])) {
+  if (canConstantFoldCallTo(F)) {
+std::vector Args(Ops.begin()+1, Ops.end());
+return ConstantFoldCall(F, Args);
+  }
+}
+return 0;
+  case Instruction::Shl:
+  case Instruction::Shr:
+return ConstantExpr::get(Opc, Ops[0], Ops[1]);
   case Instruction::Cast:
-return ConstantExpr::getCast(Op0, I->getType());
+return ConstantExpr::getCast(Ops[0], DestTy);
   case Instruction::Select:
-if (Constant *Op2 = dyn_cast(I->getOperand(2)))
-  return ConstantExpr::getSelect(Op0, Op1, Op2);
-return 0;
+return ConstantExpr::getSelect(Ops[0], Ops[1], Ops[2]);
   case Instruction::ExtractElement:
-return ConstantExpr::getExtractElement(Op0, Op1);
+return ConstantExpr::getExtractElement(Ops[0], Ops[1]);
   case Instruction::InsertElement:
-if (Constant *Op2 = dyn_cast(I->getOperand(2)))
-  return ConstantExpr::getInsertElement(Op0, Op1, Op2);
-return 0;
+return ConstantExpr::getInsertElement(Ops[0], Ops[1], Ops[2]);
   case Instruction::ShuffleVector:
-if (Constant *Op2 = dyn_cast(I->getOperand(2)))
-  return ConstantExpr::getShuffleVector(Op0, Op1, Op2);
-return 0;
+return ConstantExpr::getShuffleVector(Ops[0], Ops[1], Ops[2]);
   case Instruction::GetElementPtr:
-std::vector IdxList;
-IdxList.reserve(I->getNumOperands()-1);
-if (Op1) IdxList.push_back(Op1);
-for (unsigned i = 2, e = I->getNumOperands(); i != e; ++i)
-  if (Constant *C = dyn_cast(I->getOperand(i)))
-IdxList.push_back(C);
-  else
-return 0;  // Non-constant operand
-return ConstantExpr::getGetElementPtr(Op0, IdxList);
+return ConstantExpr::getGetElementPtr(Ops[0],
+  
std::vector(Ops.begin()+1, 
+ Ops.end()));
   }
 }
 



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


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

2006-05-25 Thread Chris Lattner


Changes in directory llvm/lib/Transforms/Utils:

Local.cpp updated: 1.56 -> 1.57
---
Log message:

Revert a patch that is unsafe, due to out of range array accesses in inner
array scopes possibly accessing valid memory in outer subscripts.


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

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


Index: llvm/lib/Transforms/Utils/Local.cpp
diff -u llvm/lib/Transforms/Utils/Local.cpp:1.56 
llvm/lib/Transforms/Utils/Local.cpp:1.57
--- llvm/lib/Transforms/Utils/Local.cpp:1.56Wed May 24 12:34:30 2006
+++ llvm/lib/Transforms/Utils/Local.cpp Thu May 25 16:25:12 2006
@@ -274,7 +274,7 @@
 } else if (ConstantInt *CI = dyn_cast(I.getOperand())) {
   if (const ArrayType *ATy = dyn_cast(*I)) {
 if ((uint64_t)CI->getRawValue() >= ATy->getNumElements())
-  C = UndefValue::get(ATy->getElementType());
+ return 0;
 if (ConstantArray *CA = dyn_cast(C))
   C = CA->getOperand((unsigned)CI->getRawValue());
 else if (isa(C))
@@ -285,7 +285,7 @@
   return 0;
   } else if (const PackedType *PTy = dyn_cast(*I)) {
 if ((uint64_t)CI->getRawValue() >= PTy->getNumElements())
-  C = UndefValue::get(PTy->getElementType());
+  return 0;
 if (ConstantPacked *CP = dyn_cast(C))
   C = CP->getOperand((unsigned)CI->getRawValue());
 else if (isa(C))



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


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

2006-05-24 Thread Chris Lattner


Changes in directory llvm/lib/Transforms/Utils:

Local.cpp updated: 1.55 -> 1.56
---
Log message:

Patch for a new instcombine xform, patch contributed by Nick Lewycky!
This implements Transforms/InstCombine/2006-05-10-InvalidIndexUndef.ll


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

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


Index: llvm/lib/Transforms/Utils/Local.cpp
diff -u llvm/lib/Transforms/Utils/Local.cpp:1.55 
llvm/lib/Transforms/Utils/Local.cpp:1.56
--- llvm/lib/Transforms/Utils/Local.cpp:1.55Fri Apr  7 20:19:12 2006
+++ llvm/lib/Transforms/Utils/Local.cpp Wed May 24 12:34:30 2006
@@ -273,7 +273,8 @@
   }
 } else if (ConstantInt *CI = dyn_cast(I.getOperand())) {
   if (const ArrayType *ATy = dyn_cast(*I)) {
-if ((uint64_t)CI->getRawValue() >= ATy->getNumElements()) return 0;
+if ((uint64_t)CI->getRawValue() >= ATy->getNumElements())
+  C = UndefValue::get(ATy->getElementType());
 if (ConstantArray *CA = dyn_cast(C))
   C = CA->getOperand((unsigned)CI->getRawValue());
 else if (isa(C))
@@ -283,7 +284,8 @@
 else
   return 0;
   } else if (const PackedType *PTy = dyn_cast(*I)) {
-if ((uint64_t)CI->getRawValue() >= PTy->getNumElements()) return 0;
+if ((uint64_t)CI->getRawValue() >= PTy->getNumElements())
+  C = UndefValue::get(PTy->getElementType());
 if (ConstantPacked *CP = dyn_cast(C))
   C = CP->getOperand((unsigned)CI->getRawValue());
 else if (isa(C))



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


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

2006-04-07 Thread Chris Lattner


Changes in directory llvm/lib/Transforms/Utils:

Local.cpp updated: 1.54 -> 1.55
ValueMapper.cpp updated: 1.24 -> 1.25
---
Log message:

Add supprot for shufflevector


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

 Local.cpp   |5 +
 ValueMapper.cpp |5 +
 2 files changed, 10 insertions(+)


Index: llvm/lib/Transforms/Utils/Local.cpp
diff -u llvm/lib/Transforms/Utils/Local.cpp:1.54 
llvm/lib/Transforms/Utils/Local.cpp:1.55
--- llvm/lib/Transforms/Utils/Local.cpp:1.54Sat Apr  1 21:35:01 2006
+++ llvm/lib/Transforms/Utils/Local.cpp Fri Apr  7 20:19:12 2006
@@ -107,6 +107,11 @@
   case Instruction::InsertElement:
 if (Constant *Op2 = dyn_cast(I->getOperand(2)))
   return ConstantExpr::getInsertElement(Op0, Op1, Op2);
+return 0;
+  case Instruction::ShuffleVector:
+if (Constant *Op2 = dyn_cast(I->getOperand(2)))
+  return ConstantExpr::getShuffleVector(Op0, Op1, Op2);
+return 0;
   case Instruction::GetElementPtr:
 std::vector IdxList;
 IdxList.reserve(I->getNumOperands()-1);


Index: llvm/lib/Transforms/Utils/ValueMapper.cpp
diff -u llvm/lib/Transforms/Utils/ValueMapper.cpp:1.24 
llvm/lib/Transforms/Utils/ValueMapper.cpp:1.25
--- llvm/lib/Transforms/Utils/ValueMapper.cpp:1.24  Thu Apr  6 23:41:03 2006
+++ llvm/lib/Transforms/Utils/ValueMapper.cpp   Fri Apr  7 20:19:12 2006
@@ -94,6 +94,11 @@
 Constant *MV1 = cast(MapValue(CE->getOperand(0), VM));
 Constant *MV2 = cast(MapValue(CE->getOperand(1), VM));
 return VMSlot = ConstantExpr::getExtractElement(MV1, MV2);
+  } else if (CE->getOpcode() == Instruction::ShuffleVector) {
+Constant *MV1 = cast(MapValue(CE->getOperand(0), VM));
+Constant *MV2 = cast(MapValue(CE->getOperand(1), VM));
+Constant *MV3 = cast(CE->getOperand(2));
+return VMSlot = ConstantExpr::getShuffleVector(MV1, MV2, MV3);
   } else {
 assert(CE->getNumOperands() == 2 && "Must be binary operator?");
 Constant *MV1 = cast(MapValue(CE->getOperand(0), VM));



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


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

2006-04-01 Thread Chris Lattner


Changes in directory llvm/lib/Transforms/Utils:

Local.cpp updated: 1.53 -> 1.54
---
Log message:

Adjust to change in Intrinsics.gen interface.



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

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


Index: llvm/lib/Transforms/Utils/Local.cpp
diff -u llvm/lib/Transforms/Utils/Local.cpp:1.53 
llvm/lib/Transforms/Utils/Local.cpp:1.54
--- llvm/lib/Transforms/Utils/Local.cpp:1.53Thu Mar  9 16:38:10 2006
+++ llvm/lib/Transforms/Utils/Local.cpp Sat Apr  1 21:35:01 2006
@@ -308,6 +308,7 @@
 
   if (CallInst *CI = dyn_cast(I))
 if (Function *F = CI->getCalledFunction()) {
+  unsigned IntrinsicID = F->getIntrinsicID();
 #define GET_SIDE_EFFECT_INFO
 #include "llvm/Intrinsics.gen"
 #undef GET_SIDE_EFFECT_INFO



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


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

2006-03-09 Thread Chris Lattner


Changes in directory llvm/lib/Transforms/Utils:

Local.cpp updated: 1.52 -> 1.53
---
Log message:

use autogenerated side-effect information


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

 Local.cpp |   32 +---
 1 files changed, 5 insertions(+), 27 deletions(-)


Index: llvm/lib/Transforms/Utils/Local.cpp
diff -u llvm/lib/Transforms/Utils/Local.cpp:1.52 
llvm/lib/Transforms/Utils/Local.cpp:1.53
--- llvm/lib/Transforms/Utils/Local.cpp:1.52Thu Jan 19 17:53:23 2006
+++ llvm/lib/Transforms/Utils/Local.cpp Thu Mar  9 16:38:10 2006
@@ -307,33 +307,11 @@
   if (!I->mayWriteToMemory()) return true;
 
   if (CallInst *CI = dyn_cast(I))
-if (Function *F = CI->getCalledFunction())
-  switch (F->getIntrinsicID()) {
-  default: break;
-  case Intrinsic::returnaddress:
-  case Intrinsic::frameaddress:
-  case Intrinsic::stacksave:
-  case Intrinsic::isunordered_f32:
-  case Intrinsic::isunordered_f64:
-  case Intrinsic::bswap_i16:
-  case Intrinsic::bswap_i32:
-  case Intrinsic::bswap_i64:
-  case Intrinsic::ctpop_i8:
-  case Intrinsic::ctpop_i16:
-  case Intrinsic::ctpop_i32:
-  case Intrinsic::ctpop_i64:
-  case Intrinsic::ctlz_i8:
-  case Intrinsic::ctlz_i16:
-  case Intrinsic::ctlz_i32:
-  case Intrinsic::ctlz_i64:
-  case Intrinsic::cttz_i8:
-  case Intrinsic::cttz_i16:
-  case Intrinsic::cttz_i32:
-  case Intrinsic::cttz_i64:
-  case Intrinsic::sqrt_f32:
-  case Intrinsic::sqrt_f64:
-return true; // These intrinsics have no side effects.
-  }
+if (Function *F = CI->getCalledFunction()) {
+#define GET_SIDE_EFFECT_INFO
+#include "llvm/Intrinsics.gen"
+#undef GET_SIDE_EFFECT_INFO
+}
   return false;
 }
 



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


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

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


Changes in directory llvm/lib/Transforms/Utils:

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

ConstantFoldLoadThroughGEPConstantExpr wasn't handling pointers to
packed types correctly.



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

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


Index: llvm/lib/Transforms/Utils/Local.cpp
diff -u llvm/lib/Transforms/Utils/Local.cpp:1.51 
llvm/lib/Transforms/Utils/Local.cpp:1.52
--- llvm/lib/Transforms/Utils/Local.cpp:1.51Tue Jan 17 14:07:07 2006
+++ llvm/lib/Transforms/Utils/Local.cpp Thu Jan 19 17:53:23 2006
@@ -267,16 +267,29 @@
 return 0;
   }
 } else if (ConstantInt *CI = dyn_cast(I.getOperand())) {
-  const ArrayType *ATy = cast(*I);
-  if ((uint64_t)CI->getRawValue() >= ATy->getNumElements()) return 0;
-  if (ConstantArray *CA = dyn_cast(C))
-C = CA->getOperand((unsigned)CI->getRawValue());
-  else if (isa(C))
-C = Constant::getNullValue(ATy->getElementType());
-  else if (isa(C))
-C = UndefValue::get(ATy->getElementType());
-  else
+  if (const ArrayType *ATy = dyn_cast(*I)) {
+if ((uint64_t)CI->getRawValue() >= ATy->getNumElements()) return 0;
+if (ConstantArray *CA = dyn_cast(C))
+  C = CA->getOperand((unsigned)CI->getRawValue());
+else if (isa(C))
+  C = Constant::getNullValue(ATy->getElementType());
+else if (isa(C))
+  C = UndefValue::get(ATy->getElementType());
+else
+  return 0;
+  } else if (const PackedType *PTy = dyn_cast(*I)) {
+if ((uint64_t)CI->getRawValue() >= PTy->getNumElements()) return 0;
+if (ConstantPacked *CP = dyn_cast(C))
+  C = CP->getOperand((unsigned)CI->getRawValue());
+else if (isa(C))
+  C = Constant::getNullValue(PTy->getElementType());
+else if (isa(C))
+  C = UndefValue::get(PTy->getElementType());
+else
+  return 0;
+  } else {
 return 0;
+  }
 } else {
   return 0;
 }



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


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

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


Changes in directory llvm/lib/Transforms/Utils:

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

Constant folding support for the insertelement operation.



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

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


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



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


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

2006-01-16 Thread Reid Spencer


Changes in directory llvm/lib/Transforms/Utils:

Local.cpp updated: 1.49 -> 1.50
---
Log message:

For PR411: http://llvm.cs.uiuc.edu/PR411 :
This patch is an incremental step towards supporting a flat symbol table.
It de-overloads the intrinsic functions by providing type-specific intrinsics
and arranging for automatically upgrading from the old overloaded name to
the new non-overloaded name. Specifically:
  llvm.isunordered -> llvm.isunordered.f32, llvm.isunordered.f64
  llvm.sqrt -> llvm.sqrt.f32, llvm.sqrt.f64
  llvm.ctpop -> llvm.ctpop.i8, llvm.ctpop.i16, llvm.ctpop.i32, llvm.ctpop.i64
  llvm.ctlz -> llvm.ctlz.i8, llvm.ctlz.i16, llvm.ctlz.i32, llvm.ctlz.i64
  llvm.cttz -> llvm.cttz.i8, llvm.cttz.i16, llvm.cttz.i32, llvm.cttz.i64
New code should not use the overloaded intrinsic names. Warnings will be 
emitted if they are used.


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

 Local.cpp |   21 -
 1 files changed, 16 insertions(+), 5 deletions(-)


Index: llvm/lib/Transforms/Utils/Local.cpp
diff -u llvm/lib/Transforms/Utils/Local.cpp:1.49 
llvm/lib/Transforms/Utils/Local.cpp:1.50
--- llvm/lib/Transforms/Utils/Local.cpp:1.49Fri Jan 13 19:25:24 2006
+++ llvm/lib/Transforms/Utils/Local.cpp Mon Jan 16 15:12:35 2006
@@ -297,14 +297,25 @@
   case Intrinsic::returnaddress:
   case Intrinsic::frameaddress:
   case Intrinsic::stacksave:
-  case Intrinsic::isunordered:
+  case Intrinsic::isunordered_f32:
+  case Intrinsic::isunordered_f64:
   case Intrinsic::bswap_i16:
   case Intrinsic::bswap_i32:
   case Intrinsic::bswap_i64:
-  case Intrinsic::ctpop:
-  case Intrinsic::ctlz:
-  case Intrinsic::cttz:
-  case Intrinsic::sqrt:
+  case Intrinsic::ctpop_i8:
+  case Intrinsic::ctpop_i16:
+  case Intrinsic::ctpop_i32:
+  case Intrinsic::ctpop_i64:
+  case Intrinsic::ctlz_i8:
+  case Intrinsic::ctlz_i16:
+  case Intrinsic::ctlz_i32:
+  case Intrinsic::ctlz_i64:
+  case Intrinsic::cttz_i8:
+  case Intrinsic::cttz_i16:
+  case Intrinsic::cttz_i32:
+  case Intrinsic::cttz_i64:
+  case Intrinsic::sqrt_f32:
+  case Intrinsic::sqrt_f64:
 return true; // These intrinsics have no side effects.
   }
   return false;



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


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

2006-01-13 Thread Nate Begeman


Changes in directory llvm/lib/Transforms/Utils:

Local.cpp updated: 1.48 -> 1.49
---
Log message:

Add bswap intrinsics as documented in the Language Reference


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

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


Index: llvm/lib/Transforms/Utils/Local.cpp
diff -u llvm/lib/Transforms/Utils/Local.cpp:1.48 
llvm/lib/Transforms/Utils/Local.cpp:1.49
--- llvm/lib/Transforms/Utils/Local.cpp:1.48Fri Jan 13 15:31:54 2006
+++ llvm/lib/Transforms/Utils/Local.cpp Fri Jan 13 19:25:24 2006
@@ -298,6 +298,9 @@
   case Intrinsic::frameaddress:
   case Intrinsic::stacksave:
   case Intrinsic::isunordered:
+  case Intrinsic::bswap_i16:
+  case Intrinsic::bswap_i32:
+  case Intrinsic::bswap_i64:
   case Intrinsic::ctpop:
   case Intrinsic::ctlz:
   case Intrinsic::cttz:



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


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

2006-01-13 Thread Chris Lattner


Changes in directory llvm/lib/Transforms/Utils:

Local.cpp updated: 1.47 -> 1.48
---
Log message:

it is ok to dce stacksave.


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

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


Index: llvm/lib/Transforms/Utils/Local.cpp
diff -u llvm/lib/Transforms/Utils/Local.cpp:1.47 
llvm/lib/Transforms/Utils/Local.cpp:1.48
--- llvm/lib/Transforms/Utils/Local.cpp:1.47Tue Jan 10 13:05:15 2006
+++ llvm/lib/Transforms/Utils/Local.cpp Fri Jan 13 15:31:54 2006
@@ -296,6 +296,7 @@
   default: break;
   case Intrinsic::returnaddress:
   case Intrinsic::frameaddress:
+  case Intrinsic::stacksave:
   case Intrinsic::isunordered:
   case Intrinsic::ctpop:
   case Intrinsic::ctlz:



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


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

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


Changes in directory llvm/lib/Transforms/Utils:

Local.cpp updated: 1.46 -> 1.47
---
Log message:

Added support for the extractelement operation.



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

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


Index: llvm/lib/Transforms/Utils/Local.cpp
diff -u llvm/lib/Transforms/Utils/Local.cpp:1.46 
llvm/lib/Transforms/Utils/Local.cpp:1.47
--- llvm/lib/Transforms/Utils/Local.cpp:1.46Thu Oct 27 11:34:00 2005
+++ llvm/lib/Transforms/Utils/Local.cpp Tue Jan 10 13:05:15 2006
@@ -102,6 +102,8 @@
 if (Constant *Op2 = dyn_cast(I->getOperand(2)))
   return ConstantExpr::getSelect(Op0, Op1, Op2);
 return 0;
+  case Instruction::ExtractElement:
+return ConstantExpr::getExtractElement(Op0, Op1);
   case Instruction::GetElementPtr:
 std::vector IdxList;
 IdxList.reserve(I->getNumOperands()-1);



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


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

2005-10-27 Thread Chris Lattner


Changes in directory llvm/lib/Transforms/Utils:

Local.cpp updated: 1.45 -> 1.46
---
Log message:

Fix #include order


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

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


Index: llvm/lib/Transforms/Utils/Local.cpp
diff -u llvm/lib/Transforms/Utils/Local.cpp:1.45 
llvm/lib/Transforms/Utils/Local.cpp:1.46
--- llvm/lib/Transforms/Utils/Local.cpp:1.45Thu Oct 27 10:54:33 2005
+++ llvm/lib/Transforms/Utils/Local.cpp Thu Oct 27 11:34:00 2005
@@ -12,12 +12,12 @@
 //
 
//===--===//
 
-#include "llvm/Analysis/ConstantFolding.h"
 #include "llvm/Transforms/Utils/Local.h"
 #include "llvm/Constants.h"
 #include "llvm/DerivedTypes.h"
 #include "llvm/Instructions.h"
 #include "llvm/Intrinsics.h"
+#include "llvm/Analysis/ConstantFolding.h"
 #include "llvm/Support/GetElementPtrTypeIterator.h"
 #include "llvm/Support/MathExtras.h"
 #include 



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


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

2005-10-27 Thread John Criswell


Changes in directory llvm/lib/Transforms/Utils:

Local.cpp updated: 1.44 -> 1.45
Makefile updated: 1.7 -> 1.8
---
Log message:

Move some constant folding code shared by Analysis and Transform passes
into the LLVMAnalysis library.
This allows LLVMTranform and LLVMTransformUtils to be archives and linked
with LLVMAnalysis.a, which provides any missing definitions.



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

 Local.cpp |  143 --
 Makefile  |1 
 2 files changed, 2 insertions(+), 142 deletions(-)


Index: llvm/lib/Transforms/Utils/Local.cpp
diff -u llvm/lib/Transforms/Utils/Local.cpp:1.44 
llvm/lib/Transforms/Utils/Local.cpp:1.45
--- llvm/lib/Transforms/Utils/Local.cpp:1.44Tue Sep 27 20:34:32 2005
+++ llvm/lib/Transforms/Utils/Local.cpp Thu Oct 27 10:54:33 2005
@@ -12,6 +12,7 @@
 //
 
//===--===//
 
+#include "llvm/Analysis/ConstantFolding.h"
 #include "llvm/Transforms/Utils/Local.h"
 #include "llvm/Constants.h"
 #include "llvm/DerivedTypes.h"
@@ -234,148 +235,6 @@
   return false;
 }
 
-/// canConstantFoldCallTo - Return true if its even possible to fold a call to
-/// the specified function.
-bool llvm::canConstantFoldCallTo(Function *F) {
-  const std::string &Name = F->getName();
-
-  switch (F->getIntrinsicID()) {
-  case Intrinsic::isunordered:
-  case Intrinsic::sqrt:
-return true;
-  default: break;
-  }
-
-  switch (Name[0])
-  {
-case 'a':
-  return Name == "acos" || Name == "asin" || Name == "atan" ||
- Name == "atan2";
-case 'c':
-  return Name == "ceil" || Name == "cos" || Name == "cosf" ||
- Name == "cosh";
-case 'e':
-  return Name == "exp";
-case 'f':
-  return Name == "fabs" || Name == "fmod" || Name == "floor";
-case 'l':
-  return Name == "log" || Name == "log10";
-case 'p':
-  return Name == "pow";
-case 's':
-  return Name == "sin" || Name == "sinh" || Name == "sqrt";
-case 't':
-  return Name == "tan" || Name == "tanh";
-default:
-  return false;
-  }
-}
-
-static Constant *ConstantFoldFP(double (*NativeFP)(double), double V,
-const Type *Ty) {
-  errno = 0;
-  V = NativeFP(V);
-  if (errno == 0)
-return ConstantFP::get(Ty, V);
-  return 0;
-}
-
-/// ConstantFoldCall - Attempt to constant fold a call to the specified 
function
-/// with the specified arguments, returning null if unsuccessful.
-Constant *llvm::ConstantFoldCall(Function *F,
- const std::vector &Operands) {
-  const std::string &Name = F->getName();
-  const Type *Ty = F->getReturnType();
-
-  if (Operands.size() == 1) {
-if (ConstantFP *Op = dyn_cast(Operands[0])) {
-  double V = Op->getValue();
-  switch (Name[0])
-  {
-case 'a':
-  if (Name == "acos")
-return ConstantFoldFP(acos, V, Ty);
-  else if (Name == "asin")
-return ConstantFoldFP(asin, V, Ty);
-  else if (Name == "atan")
-return ConstantFP::get(Ty, atan(V));
-  break;
-case 'c':
-  if (Name == "ceil")
-return ConstantFoldFP(ceil, V, Ty);
-  else if (Name == "cos")
-return ConstantFP::get(Ty, cos(V));
-  else if (Name == "cosh")
-return ConstantFP::get(Ty, cosh(V));
-  break;
-case 'e':
-  if (Name == "exp")
-return ConstantFP::get(Ty, exp(V));
-  break;
-case 'f':
-  if (Name == "fabs")
-return ConstantFP::get(Ty, fabs(V));
-  else if (Name == "floor")
-return ConstantFoldFP(floor, V, Ty);
-  break;
-case 'l':
-  if (Name == "log" && V > 0)
-return ConstantFP::get(Ty, log(V));
-  else if (Name == "log10" && V > 0)
-return ConstantFoldFP(log10, V, Ty);
-  else if (Name == "llvm.sqrt") {
-if (V >= -0.0)
-  return ConstantFP::get(Ty, sqrt(V));
-else // Undefined
-  return ConstantFP::get(Ty, 0.0);
-  }
-  break;
-case 's':
-  if (Name == "sin")
-return ConstantFP::get(Ty, sin(V));
-  else if (Name == "sinh")
-return ConstantFP::get(Ty, sinh(V));
-  else if (Name == "sqrt" && V >= 0)
-return ConstantFP::get(Ty, sqrt(V));
-  break;
-case 't':
-  if (Name == "tan")
-return ConstantFP::get(Ty, tan(V));
-  else if (Name == "tanh")
-return ConstantFP::get(Ty, tanh(V));
-  break;
-default:
-  break;
-  }
-}
-  } else if (Operands.size() == 2) {
-if (ConstantFP *Op1 = dyn_cast(Operands[0])) {
-  double Op1V = Op1->getValue();
-  if (ConstantFP *Op2 = dyn_cast(Operands[1])) {
-double Op2V = Op2->getValue();
-
-if (Name == "ll