Skip to content

Commit 5fb6555

Browse files
committed
[InstCombine] Remove unused visitUDivOperand() argument (NFC)
This function only works on the RHS operand.
1 parent 7036413 commit 5fb6555

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -972,37 +972,36 @@ static Instruction *foldUDivShl(Value *Op0, Value *Op1, const BinaryOperator &I,
972972
// instruction, seeing through select instructions, to determine if we can
973973
// replace the udiv with something simpler. If we find that an operand is not
974974
// able to simplify the udiv, we abort the entire transformation.
975-
static size_t visitUDivOperand(Value *Op0, Value *Op1, const BinaryOperator &I,
975+
static size_t visitUDivOperand(Value *Op, const BinaryOperator &I,
976976
SmallVectorImpl<UDivFoldAction> &Actions,
977977
unsigned Depth = 0) {
978978
// FIXME: assert that Op1 isn't/doesn't contain undef.
979979

980980
// Check to see if this is an unsigned division with an exact power of 2,
981981
// if so, convert to a right shift.
982-
if (match(Op1, m_Power2())) {
983-
Actions.push_back(UDivFoldAction(foldUDivPow2Cst, Op1));
982+
if (match(Op, m_Power2())) {
983+
Actions.push_back(UDivFoldAction(foldUDivPow2Cst, Op));
984984
return Actions.size();
985985
}
986986

987987
// X udiv (C1 << N), where C1 is "1<<C2" --> X >> (N+C2)
988-
if (match(Op1, m_Shl(m_Power2(), m_Value())) ||
989-
match(Op1, m_ZExt(m_Shl(m_Power2(), m_Value())))) {
990-
Actions.push_back(UDivFoldAction(foldUDivShl, Op1));
988+
if (match(Op, m_Shl(m_Power2(), m_Value())) ||
989+
match(Op, m_ZExt(m_Shl(m_Power2(), m_Value())))) {
990+
Actions.push_back(UDivFoldAction(foldUDivShl, Op));
991991
return Actions.size();
992992
}
993993

994994
// The remaining tests are all recursive, so bail out if we hit the limit.
995995
if (Depth++ == MaxDepth)
996996
return 0;
997997

998-
if (SelectInst *SI = dyn_cast<SelectInst>(Op1))
998+
if (SelectInst *SI = dyn_cast<SelectInst>(Op))
999999
// FIXME: missed optimization: if one of the hands of select is/contains
10001000
// undef, just directly pick the other one.
10011001
// FIXME: can both hands contain undef?
1002-
if (size_t LHSIdx =
1003-
visitUDivOperand(Op0, SI->getOperand(1), I, Actions, Depth))
1004-
if (visitUDivOperand(Op0, SI->getOperand(2), I, Actions, Depth)) {
1005-
Actions.push_back(UDivFoldAction(nullptr, Op1, LHSIdx - 1));
1002+
if (size_t LHSIdx = visitUDivOperand(SI->getOperand(1), I, Actions, Depth))
1003+
if (visitUDivOperand(SI->getOperand(2), I, Actions, Depth)) {
1004+
Actions.push_back(UDivFoldAction(nullptr, Op, LHSIdx - 1));
10061005
return Actions.size();
10071006
}
10081007

@@ -1108,7 +1107,7 @@ Instruction *InstCombinerImpl::visitUDiv(BinaryOperator &I) {
11081107

11091108
// (LHS udiv (select (select (...)))) -> (LHS >> (select (select (...))))
11101109
SmallVector<UDivFoldAction, 6> UDivActions;
1111-
if (visitUDivOperand(Op0, Op1, I, UDivActions))
1110+
if (visitUDivOperand(Op1, I, UDivActions))
11121111
for (unsigned i = 0, e = UDivActions.size(); i != e; ++i) {
11131112
FoldUDivOperandCb Action = UDivActions[i].FoldAction;
11141113
Value *ActionOp1 = UDivActions[i].OperandToFold;

0 commit comments

Comments
 (0)