//===- ConstantFold.cpp - LLVM constant folder ----------------------------===////// The LLVM Compiler Infrastructure//// This file was developed by the LLVM research group and is distributed under// the University of Illinois Open Source License. See LICENSE.TXT for details.////===----------------------------------------------------------------------===////// This file implements folding of constants for LLVM. This implements the// (internal) ConstantFold.h interface, which is used by the// ConstantExpr::get* methods to automatically fold constants when possible.//// The current constant folding implementation is implemented in two pieces: the// template-based folder for simple primitive constants like ConstantInt, and// the special case hackery that we use to symbolically evaluate expressions// that use ConstantExprs.////===----------------------------------------------------------------------===//#include"ConstantFold.h"#include"llvm/Constants.h"#include"llvm/Instructions.h"#include"llvm/DerivedTypes.h"#include"llvm/Function.h"#include"llvm/ADT/SmallVector.h"#include"llvm/Support/Compiler.h"#include"llvm/Support/GetElementPtrTypeIterator.h"#include"llvm/Support/ManagedStatic.h"#include"llvm/Support/MathExtras.h"#include<limits>usingnamespacellvm;//===----------------------------------------------------------------------===//// ConstantFold*Instruction Implementations//===----------------------------------------------------------------------===///// CastConstantVector - Convert the specified ConstantVector node to the/// specified vector type. At this point, we know that the elements of the/// input packed constant are all simple integer or FP values.staticConstant*CastConstantVector(ConstantVector*CV,constVectorType*DstTy){unsignedSrcNumElts=CV->getType()->getNumElements();unsignedDstNumElts=DstTy->getNumElements();constType*SrcEltTy=CV->getType()->getElementType();constType*DstEltTy=DstTy->getElementType();// If both vectors have the sam