[llvm] ccf8c96 - [InstCombine] reorder code, fix formatting; NFC
Sanjay Patel via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 22 13:33:09 PDT 2022
Author: Sanjay Patel
Date: 2022-03-22T16:33:01-04:00
New Revision: ccf8c969c2a1150bf95229d495aa555c229a3925
URL: https://github.com/llvm/llvm-project/commit/ccf8c969c2a1150bf95229d495aa555c229a3925
DIFF: https://github.com/llvm/llvm-project/commit/ccf8c969c2a1150bf95229d495aa555c229a3925.diff
LOG: [InstCombine] reorder code, fix formatting; NFC
The affected code can be updated to solve #54364,
so make some cosmetic diffs before real changes.
Added:
Modified:
llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp b/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
index 1732b29344fae..d2a92ad128c7f 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;
More information about the llvm-commits
mailing list