Commit c3985ea7 authored by JuanRod2's avatar JuanRod2 Committed by gbsbuild

Fixes for latest KW report dec/18. Mostly fixes for unitialized

variables

Change-Id: I40141001c1c878d28f29c3085e0dd1f2eaa3c5a8
parent 8d8afec3
......@@ -1056,7 +1056,7 @@ TRANSLATION_BLOCK_API void Register(
TRANSLATION_BLOCK_API CTranslationBlock* Create(
STB_CreateArgs* pCreateArgs)
{
CIGCTranslationBlock* pIGCTranslationBlock;
CIGCTranslationBlock* pIGCTranslationBlock = nullptr;
CIGCTranslationBlock::Create(
pCreateArgs,
......
......@@ -646,9 +646,9 @@ CodeGenPatternMatch::isFPToUnsignedIntSatWithInexactConstant( llvm::SelectInst *
}
bool CodeGenPatternMatch::MatchFPToIntegerWithSaturation(llvm::Instruction &I) {
Value *X;
unsigned Opcode;
VISA_Type type;
Value *X = nullptr;
unsigned Opcode = 0;
VISA_Type type = ISA_TYPE_NUM;
if (CastInst *CI = dyn_cast<CastInst>(&I)) {
std::tie(X, Opcode, type) = isFPToIntegerSatWithExactConstant(CI);
......
......@@ -208,7 +208,7 @@ bool VectorProcess::reLayoutLoadStore(Instruction* Inst)
II->getIntrinsicID() == GenISAIntrinsic::GenISA_storerawvector_indexed)))
&& "Inst should be either load or store");
Value *Ptr;
Value *Ptr = nullptr;
if (LI != nullptr)
{
Ptr = LI->getPointerOperand();
......
......@@ -1071,15 +1071,15 @@ Instruction *InstCombiner::visitAdd(BinaryOperator &I) {
if (Value *V = SimplifyUsingDistributiveLaws(I))
return replaceInstUsesWith(I, V);
const APInt *Val;
const APInt *Val = nullptr;
if (match(RHS, m_APInt(Val))) {
// X + (signbit) --> X ^ signbit
if (Val->isSignBit())
return BinaryOperator::CreateXor(LHS, RHS);
// Is this add the last step in a convoluted sext?
Value *X;
const APInt *C;
Value *X = nullptr;
const APInt *C = nullptr;
if (match(LHS, m_ZExt(m_Xor(m_Value(X), m_APInt(C)))) &&
C->isMinSignedValue() &&
C->sext(LHS->getType()->getScalarSizeInBits()) == *Val) {
......@@ -1199,7 +1199,7 @@ Instruction *InstCombiner::visitAdd(BinaryOperator &I) {
return BinaryOperator::CreateOr(LHS, RHS);
if (Constant *CRHS = dyn_cast<Constant>(RHS)) {
Value *X;
Value *X = nullptr;
if (match(LHS, m_Not(m_Value(X)))) // ~X + C --> (C-1) - X
return BinaryOperator::CreateSub(SubOne(CRHS), X);
}
......@@ -1209,8 +1209,8 @@ Instruction *InstCombiner::visitAdd(BinaryOperator &I) {
// removal.
if (ConstantInt *CRHS = dyn_cast<ConstantInt>(RHS)) {
// (X & FF00) + xx00 -> (X+xx00) & FF00
Value *X;
ConstantInt *C2;
Value *X = nullptr;
ConstantInt *C2 = nullptr;
if (LHS->hasOneUse() &&
match(LHS, m_And(m_Value(X), m_ConstantInt(C2))) &&
CRHS->getValue() == (CRHS->getValue() & C2->getValue())) {
......@@ -1248,7 +1248,7 @@ Instruction *InstCombiner::visitAdd(BinaryOperator &I) {
if (SI && SI->hasOneUse()) {
Value *TV = SI->getTrueValue();
Value *FV = SI->getFalseValue();
Value *N;
Value *N = nullptr;
// Can we fold the add into the argument of the select?
// We check both true and false select arguments for a matching subtract.
......@@ -1461,12 +1461,13 @@ Instruction *InstCombiner::visitFAdd(BinaryOperator &I) {
// select C, 0, B + select C, A, 0 -> select C, A, B
{
Value *A1, *B1, *C1, *A2, *B2, *C2;
Value *A1 = nullptr, *B1 = nullptr, *C1 = nullptr;
Value *A2 = nullptr, *B2 = nullptr, *C2 = nullptr;
if (match(LHS, m_Select(m_Value(C1), m_Value(A1), m_Value(B1))) &&
match(RHS, m_Select(m_Value(C2), m_Value(A2), m_Value(B2)))) {
if (C1 == C2) {
Constant *Z1=nullptr, *Z2=nullptr;
Value *A, *B, *C=C1;
Value *A = nullptr, *B = nullptr, *C=C1;
if (match(A1, m_AnyZero()) && match(B2, m_AnyZero())) {
Z1 = dyn_cast<Constant>(A1); A = A2;
Z2 = dyn_cast<Constant>(B2); B = B1;
......@@ -1610,7 +1611,7 @@ Instruction *InstCombiner::visitSub(BinaryOperator &I) {
return R;
// C-(X+C2) --> (C-C2)-X
Constant *C2;
Constant *C2 = nullptr;
if (match(Op1, m_Add(m_Value(X), m_Constant(C2))))
return BinaryOperator::CreateSub(ConstantExpr::getSub(C, C2), X);
......@@ -1628,7 +1629,7 @@ Instruction *InstCombiner::visitSub(BinaryOperator &I) {
return CastInst::CreateZExtOrBitCast(X, Op1->getType());
}
const APInt *Op0C;
const APInt *Op0C = nullptr;
if (match(Op0, m_APInt(Op0C))) {
unsigned BitWidth = I.getType()->getScalarSizeInBits();
......@@ -1661,7 +1662,7 @@ Instruction *InstCombiner::visitSub(BinaryOperator &I) {
}
{
Value *Y;
Value *Y = nullptr;
// X-(X+Y) == -Y X-(Y+X) == -Y
if (match(Op1, m_Add(m_Specific(Op0), m_Value(Y))) ||
match(Op1, m_Add(m_Value(Y), m_Specific(Op0))))
......@@ -1730,7 +1731,7 @@ Instruction *InstCombiner::visitSub(BinaryOperator &I) {
// X - A*-B -> X + A*B
// X - -A*B -> X + A*B
Value *A, *B;
Value *A = nullptr, *B = nullptr;
if (match(Op1, m_Mul(m_Value(A), m_Neg(m_Value(B)))) ||
match(Op1, m_Mul(m_Neg(m_Value(A)), m_Value(B))))
return BinaryOperator::CreateAdd(Op0, Builder->CreateMul(A, B));
......@@ -1746,7 +1747,7 @@ Instruction *InstCombiner::visitSub(BinaryOperator &I) {
// Optimize pointer differences into the same array into a size. Consider:
// &A[10] - &A[0]: we should compile this to "10".
Value *LHSOp, *RHSOp;
Value *LHSOp = nullptr, *RHSOp = nullptr;
if (match(Op0, m_PtrToInt(m_Value(LHSOp))) &&
match(Op1, m_PtrToInt(m_Value(RHSOp))))
if (Value *Res = OptimizePointerDifference(LHSOp, RHSOp, I.getType()))
......
......@@ -98,7 +98,7 @@ static unsigned getFCmpCode(FCmpInst::Predicate CC) {
/// use in the new icmp instruction.
static Value *getNewICmpValue(bool Sign, unsigned Code, Value *LHS, Value *RHS,
InstCombiner::BuilderTy *Builder) {
ICmpInst::Predicate NewPred;
ICmpInst::Predicate NewPred = ICmpInst::Predicate::BAD_ICMP_PREDICATE;
if (Value *NewConstant = getICmpValue(Sign, Code, LHS, RHS, NewPred))
return NewConstant;
return Builder->CreateICmp(NewPred, LHS, RHS);
......@@ -545,7 +545,7 @@ static unsigned foldLogOpOfMaskedICmpsHelper(Value*& A,
// above.
Value *L1 = LHS->getOperand(0);
Value *L2 = LHS->getOperand(1);
Value *L11,*L12,*L21,*L22;
Value *L11 = nullptr,*L12 = nullptr,*L21 = nullptr,*L22 = nullptr;
// Check whether the icmp can be decomposed into a bit test.
if (decomposeBitTestICmp(LHS, LHSCC, L11, L12, L2)) {
L21 = L22 = L1 = nullptr;
......@@ -576,7 +576,7 @@ static unsigned foldLogOpOfMaskedICmpsHelper(Value*& A,
Value *R1 = RHS->getOperand(0);
Value *R2 = RHS->getOperand(1);
Value *R11,*R12;
Value *R11 = nullptr,*R12 = nullptr;
bool ok = false;
if (decomposeBitTestICmp(RHS, RHSCC, R11, R12, R2)) {
if (R11 == L11 || R11 == L12 || R11 == L21 || R11 == L22) {
......@@ -785,7 +785,7 @@ Value *InstCombiner::simplifyRangeCheck(ICmpInst *Cmp0, ICmpInst *Cmp1,
Cmp1->getPredicate());
Value *Input = Cmp0->getOperand(0);
Value *RangeEnd;
Value *RangeEnd = nullptr;
if (Cmp1->getOperand(0) == Input) {
// For the upper range compare we have: icmp x, n
RangeEnd = Cmp1->getOperand(1);
......@@ -798,7 +798,7 @@ Value *InstCombiner::simplifyRangeCheck(ICmpInst *Cmp0, ICmpInst *Cmp1,
}
// Check the upper range comparison, e.g. x < n
ICmpInst::Predicate NewPred;
ICmpInst::Predicate NewPred = ICmpInst::Predicate::BAD_ICMP_PREDICATE;
switch (Pred1) {
case ICmpInst::ICMP_SLT: NewPred = ICmpInst::ICMP_ULT; break;
case ICmpInst::ICMP_SLE: NewPred = ICmpInst::ICMP_ULE; break;
......@@ -806,7 +806,7 @@ Value *InstCombiner::simplifyRangeCheck(ICmpInst *Cmp0, ICmpInst *Cmp1,
}
// This simplification is only valid if the upper range is not negative.
bool IsNegative, IsNotNegative;
bool IsNegative = false, IsNotNegative = false;
ComputeSignBit(RangeEnd, IsNotNegative, IsNegative, /*Depth=*/0, Cmp1);
if (!IsNotNegative)
return nullptr;
......@@ -1165,7 +1165,7 @@ static Instruction *foldLogicCastConstant(BinaryOperator &Logic, CastInst *Cast,
// If the first operand is bitcast, move the logic operation ahead of the
// bitcast (do the logic operation in the original type). This can eliminate
// bitcasts and allow combines that would otherwise be impeded by the bitcast.
Value *X;
Value *X = nullptr;
if (match(Cast, m_BitCast(m_Value(X)))) {
Value *NewConstant = ConstantExpr::getBitCast(C, SrcTy);
Value *NewOp = Builder->CreateBinOp(LogicOpc, X, NewConstant);
......@@ -1598,7 +1598,7 @@ static Value *getSelectCondition(Value *A, Value *B,
return A;
// If A and B are sign-extended, look through the sexts to find the booleans.
Value *Cond;
Value *Cond = nullptr;
if (match(A, m_SExt(m_Value(Cond))) &&
Cond->getType()->getScalarType()->isIntegerTy(1) &&
match(B, m_CombineOr(m_Not(m_SExt(m_Specific(Cond))),
......@@ -1611,7 +1611,7 @@ static Value *getSelectCondition(Value *A, Value *B,
return nullptr;
// If both operands are constants, see if the constants are inverse bitmasks.
Constant *AC, *BC;
Constant *AC = nullptr, *BC = nullptr;
if (match(A, m_Constant(AC)) && match(B, m_Constant(BC)) &&
areInverseVectorBitmasks(AC, BC))
return ConstantExpr::getTrunc(AC, CmpInst::makeCmpResultType(Ty));
......@@ -2589,8 +2589,8 @@ Instruction *InstCombiner::visitXor(BinaryOperator &I) {
} else if (Op0I->getOpcode() == Instruction::LShr) {
// ((X^C1) >> C2) ^ C3 -> (X>>C2) ^ ((C1>>C2)^C3)
// E1 = "X ^ C1"
BinaryOperator *E1;
ConstantInt *C1;
BinaryOperator *E1 = nullptr;
ConstantInt *C1 = nullptr;
if (Op0I->hasOneUse() &&
(E1 = dyn_cast<BinaryOperator>(Op0I->getOperand(0))) &&
E1->getOpcode() == Instruction::Xor &&
......@@ -2617,7 +2617,7 @@ Instruction *InstCombiner::visitXor(BinaryOperator &I) {
BinaryOperator *Op1I = dyn_cast<BinaryOperator>(Op1);
if (Op1I) {
Value *A, *B;
Value *A = nullptr, *B = nullptr;
if (match(Op1I, m_Or(m_Value(A), m_Value(B)))) {
if (A == Op0) { // B^(B|A) == (A|B)^B
Op1I->swapOperands();
......@@ -2642,7 +2642,7 @@ Instruction *InstCombiner::visitXor(BinaryOperator &I) {
BinaryOperator *Op0I = dyn_cast<BinaryOperator>(Op0);
if (Op0I) {
Value *A, *B;
Value *A = nullptr, *B = nullptr;
if (match(Op0I, m_Or(m_Value(A), m_Value(B))) &&
Op0I->hasOneUse()) {
if (A == Op1) // (B|A)^B == (A|B)^B
......@@ -2661,7 +2661,7 @@ Instruction *InstCombiner::visitXor(BinaryOperator &I) {
}
if (Op0I && Op1I) {
Value *A, *B, *C, *D;
Value *A = nullptr, *B = nullptr, *C = nullptr, *D = nullptr;
// (A & B)^(A | B) -> A ^ B
if (match(Op0I, m_And(m_Value(A), m_Value(B))) &&
match(Op1I, m_Or(m_Value(C), m_Value(D)))) {
......@@ -2728,7 +2728,7 @@ Instruction *InstCombiner::visitXor(BinaryOperator &I) {
// (A & ~B) ^ ~A -> ~(A & B)
// (~B & A) ^ ~A -> ~(A & B)
Value *A, *B;
Value *A = nullptr, *B = nullptr;
if (match(Op0, m_c_And(m_Value(A), m_Not(m_Value(B)))) &&
match(Op1, m_Not(m_Specific(A))))
return BinaryOperator::CreateNot(Builder->CreateAnd(A, B));
......
......@@ -90,7 +90,7 @@ static Value *decomposeSimpleLinearExpr(Value *Val, unsigned &Scale,
if (I->getOpcode() == Instruction::Add) {
// We have X+C. Check to see if we really have (X*C2)+C1,
// where C1 is divisible by C2.
unsigned SubScale;
unsigned SubScale = 0;
Value *SubVal =
decomposeSimpleLinearExpr(I->getOperand(0), SubScale, Offset);
Offset += RHS->getZExtValue();
......@@ -479,8 +479,8 @@ Instruction *InstCombiner::shrinkBitwiseLogic(TruncInst &Trunc) {
if (isa<IntegerType>(SrcTy) && !ShouldChangeType(SrcTy, DestTy))
return nullptr;
BinaryOperator *LogicOp;
Constant *C;
BinaryOperator *LogicOp = nullptr;
Constant *C = nullptr;
if (!match(Trunc.getOperand(0), m_OneUse(m_BinOp(LogicOp))) ||
!LogicOp->isBitwiseLogicOp() ||
!match(LogicOp->getOperand(1), m_Constant(C)))
......@@ -500,7 +500,7 @@ Instruction *InstCombiner::visitTrunc(TruncInst &CI) {
// minimum or maximum operation. If so, don't do any more simplification.
// Even simplifying demanded bits can break the canonical form of a
// min/max.
Value *LHS, *RHS;
Value *LHS = nullptr, *RHS = nullptr;
if (SelectInst *SI = dyn_cast<SelectInst>(CI.getOperand(0)))
if (matchSelectPattern(SI, LHS, RHS).Flavor != SPF_UNKNOWN)
return nullptr;
......@@ -879,7 +879,7 @@ Instruction *InstCombiner::visitZExt(ZExtInst &CI) {
// type. Only do this if the dest type is a simple type, don't convert the
// expression tree to something weird like i93 unless the source is also
// strange.
unsigned BitsToClear;
unsigned BitsToClear = 0;
if ((DestTy->isVectorTy() || ShouldChangeType(SrcTy, DestTy)) &&
canEvaluateZExtd(Src, DestTy, BitsToClear, *this, &CI)) {
assert(BitsToClear < SrcTy->getScalarSizeInBits() &&
......@@ -974,8 +974,8 @@ Instruction *InstCombiner::visitZExt(ZExtInst &CI) {
}
// zext(trunc(X) & C) -> (X & zext(C)).
Constant *C;
Value *X;
Constant *C = nullptr;
Value *X = nullptr;
if (SrcI &&
match(SrcI, m_OneUse(m_And(m_Trunc(m_Value(X)), m_Constant(C)))) &&
X->getType() == CI.getType())
......@@ -1163,7 +1163,7 @@ Instruction *InstCombiner::visitSExt(SExtInst &CI) {
// If we know that the value being extended is positive, we can use a zext
// instead.
bool KnownZero, KnownOne;
bool KnownZero = false, KnownOne = false;
ComputeSignBit(Src, KnownZero, KnownOne, 0, &CI);
if (KnownZero) {
Value *ZExt = Builder->CreateZExt(Src, DestTy);
......@@ -1246,7 +1246,7 @@ Instruction *InstCombiner::visitSExt(SExtInst &CI) {
/// Return a Constant* for the specified floating-point constant if it fits
/// in the specified FP type without changing its value.
static Constant *fitsInFPType(ConstantFP *CFP, const fltSemantics &Sem) {
bool losesInfo;
bool losesInfo = false;
APFloat F = CFP->getValueAPF();
(void)F.convert(Sem, APFloat::rmNearestTiesToEven, &losesInfo);
if (!losesInfo)
......@@ -1405,7 +1405,7 @@ Instruction *InstCombiner::visitFPTrunc(FPTruncInst &CI) {
// - but only if this isn't part of a min/max operation, else we'll
// ruin min/max canonical form which is to have the select and
// compare's operands be of the same type with no casts to look through.
Value *LHS, *RHS;
Value *LHS = nullptr, *RHS = nullptr;
SelectInst *SI = dyn_cast<SelectInst>(CI.getOperand(0));
if (SI &&
(isa<ConstantFP>(SI->getOperand(1)) ||
......@@ -1614,7 +1614,7 @@ static Instruction *optimizeVectorResize(Value *InVal, VectorType *DestTy,
// shuffle to use, which depends on whether we're increasing or decreasing the
// size of the input.
SmallVector<uint32_t, 16> ShuffleMask;
Value *V2;
Value *V2 = nullptr;
if (SrcTy->getNumElements() > DestTy->getNumElements()) {
// If we're shrinking the number of elements, just shuffle in the low
......@@ -1823,7 +1823,7 @@ static Instruction *canonicalizeBitCastExtElt(BitCastInst &BitCast,
static Instruction *foldBitCastBitwiseLogic(BitCastInst &BitCast,
InstCombiner::BuilderTy &Builder) {
Type *DestTy = BitCast.getType();
BinaryOperator *BO;
BinaryOperator *BO = nullptr;
if (!DestTy->getScalarType()->isIntegerTy() ||
!match(BitCast.getOperand(0), m_OneUse(m_BinOp(BO))) ||
!BO->isBitwiseLogicOp())
......@@ -1835,7 +1835,7 @@ static Instruction *foldBitCastBitwiseLogic(BitCastInst &BitCast,
if (!DestTy->isVectorTy() || !BO->getType()->isVectorTy())
return nullptr;
Value *X;
Value *X = nullptr;
if (match(BO->getOperand(0), m_OneUse(m_BitCast(m_Value(X)))) &&
X->getType() == DestTy && !isa<Constant>(X)) {
// bitcast(logic(bitcast(X), Y)) --> logic'(X, bitcast(Y))
......@@ -1856,7 +1856,7 @@ static Instruction *foldBitCastBitwiseLogic(BitCastInst &BitCast,
/// Change the type of a select if we can eliminate a bitcast.
static Instruction *foldBitCastSelect(BitCastInst &BitCast,
InstCombiner::BuilderTy &Builder) {
Value *Cond, *TVal, *FVal;
Value *Cond = nullptr, *TVal = nullptr, *FVal = nullptr;
if (!match(BitCast.getOperand(0),
m_OneUse(m_Select(m_Value(Cond), m_Value(TVal), m_Value(FVal)))))
return nullptr;
......@@ -1879,7 +1879,7 @@ static Instruction *foldBitCastSelect(BitCastInst &BitCast,
return nullptr;
auto *Sel = cast<Instruction>(BitCast.getOperand(0));
Value *X;
Value *X = nullptr;
if (match(TVal, m_OneUse(m_BitCast(m_Value(X)))) && X->getType() == DestTy &&
!isa<Constant>(X)) {
// bitcast(select(Cond, bitcast(X), Y)) --> select'(Cond, X, bitcast(Y))
......
......@@ -800,7 +800,7 @@ static bool canReplaceGEPIdxWithZero(InstCombiner &IC, GetElementPtrInst *GEPI,
// first non-zero index.
auto IsAllNonNegative = [&]() {
for (unsigned i = Idx+1, e = GEPI->getNumOperands(); i != e; ++i) {
bool KnownNonNegative, KnownNegative;
bool KnownNonNegative = false, KnownNegative = false;
IC.ComputeSignBit(GEPI->getOperand(i), KnownNonNegative,
KnownNegative, 0, MemI);
if (KnownNonNegative)
......
......@@ -106,7 +106,7 @@ static Value *simplifyValueKnownNonZero(Value *V, InstCombiner &IC,
/// True if the multiply can not be expressed in an int this size.
static bool MultiplyOverflows(const APInt &C1, const APInt &C2, APInt &Product,
bool IsSigned) {
bool Overflow;
bool Overflow = false;
if (IsSigned)
Product = C1.smul_ov(C2, Overflow);
else
......@@ -144,7 +144,7 @@ static bool IsMultiple(const APInt &C1, const APInt &C2, APInt &Quotient,
/// a new vector obtained from C replacing each element with its logBase2.
/// Return a null pointer otherwise.
static Constant *getLogBase2Vector(ConstantDataVector *CV) {
const APInt *IVal;
const APInt *IVal = nullptr;
SmallVector<Constant *, 4> Elts;
for (unsigned I = 0, E = CV->getNumElements(); I != E; ++I) {
......@@ -222,9 +222,9 @@ Instruction *InstCombiner::visitMul(BinaryOperator &I) {
// Also allow combining multiply instructions on vectors.
{
Value *NewOp;
Constant *C1, *C2;
const APInt *IVal;
Value *NewOp = nullptr;
Constant *C1 = nullptr, *C2 = nullptr;
const APInt *IVal = nullptr;
if (match(&I, m_Mul(m_Shl(m_Value(NewOp), m_Constant(C2)),
m_Constant(C1))) &&
match(C1, m_APInt(IVal))) {
......@@ -299,8 +299,8 @@ Instruction *InstCombiner::visitMul(BinaryOperator &I) {
// Canonicalize (X+C1)*CI -> X*CI+C1*CI.
{
Value *X;
Constant *C1;
Value *X = nullptr;
Constant *C1 = nullptr;
if (match(Op0, m_OneUse(m_Add(m_Value(X), m_Constant(C1))))) {
Value *Mul = Builder->CreateMul(C1, Op1);
// Only go forward with the transform if C1*CI simplifies to a tidier
......@@ -348,7 +348,7 @@ Instruction *InstCombiner::visitMul(BinaryOperator &I) {
return BinaryOperator::CreateNeg(Op0BO);
}
Value *Rem;
Value *Rem = nullptr;
if (BO->getOpcode() == Instruction::UDiv)
Rem = Builder->CreateURem(Op0BO, Op1BO);
else
......@@ -368,7 +368,7 @@ Instruction *InstCombiner::visitMul(BinaryOperator &I) {
// X*(1 << Y) --> X << Y
// (1 << Y)*X --> X << Y
{
Value *Y;
Value *Y = nullptr;
BinaryOperator *BO = nullptr;
bool ShlNSW = false;
if (match(Op0, m_Shl(m_One(), m_Value(Y)))) {
......@@ -1078,11 +1078,11 @@ static Instruction *foldUDivNegCst(Value *Op0, Value *Op1,
// X udiv (zext (C1 << N)), where C1 is "1<<C2" --> X >> (N+C2)
static Instruction *foldUDivShl(Value *Op0, Value *Op1, const BinaryOperator &I,
InstCombiner &IC) {
Value *ShiftLeft;
Value *ShiftLeft = nullptr;
if (!match(Op1, m_ZExt(m_Value(ShiftLeft))))
ShiftLeft = Op1;
const APInt *CI;
const APInt *CI = nullptr;
Value *N;
if (!match(ShiftLeft, m_Shl(m_APInt(CI), m_Value(N))))
llvm_unreachable("match should never fail here!");
......@@ -1155,8 +1155,8 @@ Instruction *InstCombiner::visitUDiv(BinaryOperator &I) {
// (x lshr C1) udiv C2 --> x udiv (C2 << C1)
{
Value *X;
const APInt *C1, *C2;
Value *X = nullptr;
const APInt *C1 = nullptr, *C2 = nullptr;
if (match(Op0, m_LShr(m_Value(X), m_APInt(C1))) &&
match(Op1, m_APInt(C2))) {
bool Overflow;
......@@ -1226,7 +1226,7 @@ Instruction *InstCombiner::visitSDiv(BinaryOperator &I) {
if (Instruction *Common = commonIDivTransforms(I))
return Common;
const APInt *Op1C;
const APInt *Op1C = nullptr;
if (match(Op1, m_APInt(Op1C))) {
// sdiv X, -1 == -X
if (Op1C->isAllOnesValue())
......@@ -1241,7 +1241,7 @@ Instruction *InstCombiner::visitSDiv(BinaryOperator &I) {
// If the dividend is sign-extended and the constant divisor is small enough
// to fit in the source type, shrink the division to the narrower type:
// (sext X) sdiv C --> sext (X sdiv C)
Value *Op0Src;
Value *Op0Src = nullptr;
if (match(Op0, m_OneUse(m_SExt(m_Value(Op0Src)))) &&
Op0Src->getType()->getScalarSizeInBits() >= Op1C->getMinSignedBits()) {
......@@ -1262,7 +1262,7 @@ Instruction *InstCombiner::visitSDiv(BinaryOperator &I) {
return new ZExtInst(Builder->CreateICmpEQ(Op0, Op1), I.getType());
// -X/C --> X/-C provided the negation doesn't overflow.
Value *X;
Value *X = nullptr;
if (match(Op0, m_NSWSub(m_Zero(), m_Value(X)))) {
auto *BO = BinaryOperator::CreateSDiv(X, ConstantExpr::getNeg(RHS));
BO->setIsExact(I.isExact());
......@@ -1322,7 +1322,7 @@ static Instruction *CvtFDivConstToReciprocal(Value *Dividend, Constant *Divisor,
if (!Cvt)
return nullptr;
ConstantFP *R;
ConstantFP *R = nullptr;
R = ConstantFP::get(Dividend->getType()->getContext(), Reciprocal);
return BinaryOperator::CreateFMul(Dividend, R);
}
......@@ -1353,7 +1353,7 @@ Instruction *InstCombiner::visitFDiv(BinaryOperator &I) {
if (AllowReassociate) {
Constant *C1 = nullptr;
Constant *C2 = Op1C;
Value *X;
Value *X = nullptr;
Instruction *Res = nullptr;
if (match(Op0, m_FMul(m_Value(X), m_Constant(C1)))) {
......@@ -1391,7 +1391,7 @@ Instruction *InstCombiner::visitFDiv(BinaryOperator &I) {
if (AllowReassociate && isa<Constant>(Op0)) {
Constant *C1 = cast<Constant>(Op0), *C2;
Constant *Fold = nullptr;
Value *X;
Value *X = nullptr;
bool CreateDiv = true;
// C1 / (X*C2) => (C1/C2) / X
......@@ -1416,7 +1416,7 @@ Instruction *InstCombiner::visitFDiv(BinaryOperator &I) {
}
if (AllowReassociate) {
Value *X, *Y;
Value *X = nullptr, *Y = nullptr;
Value *NewInst = nullptr;
Instruction *SimpR = nullptr;
......@@ -1454,8 +1454,8 @@ Instruction *InstCombiner::visitFDiv(BinaryOperator &I) {
}
}
Value *LHS;
Value *RHS;
Value *LHS = nullptr;
Value *RHS = nullptr;
// -x / -y -> x / y
if (match(Op0, m_FNeg(m_Value(LHS))) && match(Op1, m_FNeg(m_Value(RHS)))) {
......@@ -1491,7 +1491,7 @@ Instruction *InstCombiner::commonIRemTransforms(BinaryOperator &I) {
return R;
} else if (isa<PHINode>(Op0I)) {
using namespace llvm::PatternMatch;
const APInt *Op1Int;
const APInt *Op1Int = nullptr;
if (match(Op1, m_APInt(Op1Int)) && !Op1Int->isMinValue() &&
(I.getOpcode() == Instruction::URem ||
!Op1Int->isMinSignedValue())) {
......@@ -1569,7 +1569,7 @@ Instruction *InstCombiner::visitSRem(BinaryOperator &I) {
return Common;
{
const APInt *Y;
const APInt *Y = nullptr;
// X % -Y -> X % Y
if (match(Op1, m_APInt(Y)) && Y->isNegative() && !Y->isMinSignedValue()) {
Worklist.AddValue(I.getOperand(1));
......
......@@ -198,7 +198,7 @@ Instruction *InstCombiner::foldSelectOpOp(SelectInst &SI, Instruction *TI,
return nullptr;
// Figure out if the operations have any operands in common.
Value *MatchOp, *OtherOpT, *OtherOpF;
Value *MatchOp = nullptr, *OtherOpT = nullptr, *OtherOpF = nullptr;
bool MatchIsOpZero;
if (TI->getOperand(0) == FI->getOperand(0)) {
MatchOp = TI->getOperand(0);
......@@ -342,12 +342,12 @@ static Value *foldSelectICmpAndOr(const SelectInst &SI, Value *TrueVal,
if (!match(CmpRHS, m_Zero()))
return nullptr;
Value *X;
const APInt *C1;
Value *X = nullptr;
const APInt *C1 = nullptr;
if (!match(CmpLHS, m_And(m_Value(X), m_Power2(C1))))
return nullptr;
const APInt *C2;
const APInt *C2 = nullptr;
bool OrOnTrueVal = false;
bool OrOnFalseVal = match(FalseVal, m_Or(m_Specific(TrueVal), m_Power2(C2)));
if (!OrOnFalseVal)
......@@ -542,7 +542,7 @@ canonicalizeMinMaxWithConstant(SelectInst &Sel, ICmpInst &Cmp,
return nullptr;
// Canonicalize the compare predicate based on whether we have min or max.
Value *LHS, *RHS;
Value *LHS = nullptr, *RHS = nullptr;
ICmpInst::Predicate NewPred;
SelectPatternResult SPR = matchSelectPattern(&Sel, LHS, RHS);
switch (SPR.Flavor) {
......@@ -630,9 +630,9 @@ Instruction *InstCombiner::foldSelectInstWithICmp(SelectInst &SI,
unsigned BitWidth =
DL.getTypeSizeInBits(TrueVal->getType()->getScalarType());
APInt MinSignedValue = APInt::getSignBit(BitWidth);
Value *X;
const APInt *Y, *C;
bool TrueWhenUnset;
Value *X = nullptr;
const APInt *Y = nullptr, *C = nullptr;
bool TrueWhenUnset = false;
bool IsBitTest = false;
if (ICmpInst::isEquality(Pred) &&
match(CmpLHS, m_And(m_Value(X), m_Power2(Y))) &&
......@@ -802,7 +802,7 @@ Instruction *InstCombiner::foldSPFofSPF(Instruction *Inner,
return false;
};
Value *NotA, *NotB, *NotC;
Value *NotA = nullptr, *NotB = nullptr, *NotC = nullptr;
bool ElidesXor = false;
// MIN(MIN(~A, ~B), ~C) == ~MAX(MAX(A, B), C)
......@@ -847,7 +847,7 @@ static Value *foldSelectICmpAnd(const SelectInst &SI, ConstantInt *TrueVal,
if (!match(IC->getOperand(1), m_Zero()))
return nullptr;
ConstantInt *AndRHS;
ConstantInt *AndRHS = nullptr;
Value *LHS = IC->getOperand(0);
if (!match(LHS, m_And(m_Value(), m_ConstantInt(AndRHS))))
return nullptr;
......@@ -981,7 +981,7 @@ static Instruction *foldAddSubSelect(SelectInst &SI,
}
Instruction *InstCombiner::foldSelectExtConst(SelectInst &Sel) {
Instruction *ExtInst;
Instruction *ExtInst = nullptr;
if (!match(Sel.getTrueValue(), m_Instruction(ExtInst)) &&
!match(Sel.getFalseValue(), m_Instruction(ExtInst)))
return nullptr;
......@@ -996,7 +996,7 @@ Instruction *InstCombiner::foldSelectExtConst(SelectInst &Sel) {
if (!SmallType->getScalarType()->isIntegerTy(1))
return nullptr;
Constant *C;
Constant *C = nullptr;
if (!match(Sel.getTrueValue(), m_Constant(C)) &&
!match(Sel.getFalseValue(), m_Constant(C)))
return nullptr;
......@@ -1042,7 +1042,7 @@ Instruction *InstCombiner::foldSelectExtConst(SelectInst &Sel) {
/// shuffle for easier combining with other shuffles and insert/extract.
static Instruction *canonicalizeSelectToShuffle(SelectInst &SI) {
Value *CondVal = SI.getCondition();
Constant *CondC;
Constant *CondC = nullptr;
if (!CondVal->getType()->isVectorTy() || !match(CondVal, m_Constant(CondC)))
return nullptr;
......@@ -1084,7 +1084,7 @@ static Instruction *foldSelectCmpBitcasts(SelectInst &Sel,
Value *FVal = Sel.getFalseValue();
CmpInst::Predicate Pred;
Value *A, *B;
Value *A = nullptr, *B = nullptr;
if (!match(Cond, m_Cmp(Pred, m_Value(A), m_Value(B))))
return nullptr;
......@@ -1093,12 +1093,12 @@ static Instruction *foldSelectCmpBitcasts(SelectInst &Sel,
if (TVal == A || TVal == B || FVal == A || FVal == B)
return nullptr;
Value *C, *D;
Value *C = nullptr, *D = nullptr;
if (!match(A, m_BitCast(m_Value(C))) || !match(B, m_BitCast(m_Value(D))))
return nullptr;
// select (cmp (bitcast C), (bitcast D)), (bitcast TSrc), (bitcast FSrc)
Value *TSrc, *FSrc;
Value *TSrc = nullptr, *FSrc = nullptr;
if (!match(TVal, m_BitCast(m_Value(TSrc))) ||
!match(FVal, m_BitCast(m_Value(FSrc))))
return nullptr;
......@@ -1106,7 +1106,7 @@ static Instruction *foldSelectCmpBitcasts(SelectInst &Sel,