From: Sanjay Patel Date: Tue, 22 Mar 2022 20:02:09 +0000 (-0400) Subject: [InstCombine] reorder code, fix formatting; NFC X-Git-Tag: upstream/15.0.7~12706 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ccf8c969c2a1150bf95229d495aa555c229a3925;p=platform%2Fupstream%2Fllvm.git [InstCombine] reorder code, fix formatting; NFC The affected code can be updated to solve #54364, so make some cosmetic diffs before real changes. --- diff --git a/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp b/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp index 1732b29..d2a92ad 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp @@ -1918,24 +1918,24 @@ static BinopElts getAlternateBinop(BinaryOperator *BO, const DataLayout &DL) { Value *BO0 = BO->getOperand(0), *BO1 = BO->getOperand(1); Type *Ty = BO->getType(); switch (BO->getOpcode()) { - case Instruction::Shl: { - // shl X, C --> mul X, (1 << C) - Constant *C; - if (match(BO1, m_Constant(C))) { - Constant *ShlOne = ConstantExpr::getShl(ConstantInt::get(Ty, 1), C); - return { Instruction::Mul, BO0, ShlOne }; - } - break; - } - case Instruction::Or: { - // or X, C --> add X, C (when X and C have no common bits set) - const APInt *C; - if (match(BO1, m_APInt(C)) && MaskedValueIsZero(BO0, *C, DL)) - return { Instruction::Add, BO0, BO1 }; - break; + case Instruction::Shl: { + // shl X, C --> mul X, (1 << C) + Constant *C; + if (match(BO1, m_Constant(C))) { + Constant *ShlOne = ConstantExpr::getShl(ConstantInt::get(Ty, 1), C); + return {Instruction::Mul, BO0, ShlOne}; } - default: - break; + break; + } + case Instruction::Or: { + // or X, C --> add X, C (when X and C have no common bits set) + const APInt *C; + if (match(BO1, m_APInt(C)) && MaskedValueIsZero(BO0, *C, DL)) + return {Instruction::Add, BO0, BO1}; + break; + } + default: + break; } return {}; } @@ -2055,12 +2055,12 @@ Instruction *InstCombinerImpl::foldSelectShuffle(ShuffleVectorInst &Shuf) { Value *X, *Y; Constant *C0, *C1; bool ConstantsAreOp1; - if (match(B0, m_BinOp(m_Value(X), m_Constant(C0))) && - match(B1, m_BinOp(m_Value(Y), m_Constant(C1)))) - ConstantsAreOp1 = true; - else if (match(B0, m_BinOp(m_Constant(C0), m_Value(X))) && - match(B1, m_BinOp(m_Constant(C1), m_Value(Y)))) + if (match(B0, m_BinOp(m_Constant(C0), m_Value(X))) && + match(B1, m_BinOp(m_Constant(C1), m_Value(Y)))) ConstantsAreOp1 = false; + else if (match(B0, m_BinOp(m_Value(X), m_Constant(C0))) && + match(B1, m_BinOp(m_Value(Y), m_Constant(C1)))) + ConstantsAreOp1 = true; else return nullptr;