Skip to content

Commit 0410489

Browse files
committed
[InstCombine][NFC] Rename IsFreeToInvert() -> isFreeToInvert() for consistency
As per https://reviews.llvm.org/D65530#inline-592325 llvm-svn: 368686
1 parent 2635c32 commit 0410489

File tree

4 files changed

+18
-18
lines changed

4 files changed

+18
-18
lines changed

llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1809,7 +1809,7 @@ Instruction *InstCombiner::visitSub(BinaryOperator &I) {
18091809
std::swap(LHS, RHS);
18101810
// LHS is now O above and expected to have at least 2 uses (the min/max)
18111811
// NotA is epected to have 2 uses from the min/max and 1 from the sub.
1812-
if (IsFreeToInvert(LHS, !LHS->hasNUsesOrMore(3)) &&
1812+
if (isFreeToInvert(LHS, !LHS->hasNUsesOrMore(3)) &&
18131813
!NotA->hasNUsesOrMore(4)) {
18141814
// Note: We don't generate the inverse max/min, just create the not of
18151815
// it and let other folds do the rest.

llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1366,8 +1366,8 @@ static Instruction *matchDeMorgansLaws(BinaryOperator &I,
13661366
Value *A, *B;
13671367
if (match(I.getOperand(0), m_OneUse(m_Not(m_Value(A)))) &&
13681368
match(I.getOperand(1), m_OneUse(m_Not(m_Value(B)))) &&
1369-
!IsFreeToInvert(A, A->hasOneUse()) &&
1370-
!IsFreeToInvert(B, B->hasOneUse())) {
1369+
!isFreeToInvert(A, A->hasOneUse()) &&
1370+
!isFreeToInvert(B, B->hasOneUse())) {
13711371
Value *AndOr = Builder.CreateBinOp(Opcode, A, B, I.getName() + ".demorgan");
13721372
return BinaryOperator::CreateNot(AndOr);
13731373
}
@@ -1784,13 +1784,13 @@ Instruction *InstCombiner::visitAnd(BinaryOperator &I) {
17841784
// (A ^ B) & ((B ^ C) ^ A) -> (A ^ B) & ~C
17851785
if (match(Op0, m_Xor(m_Value(A), m_Value(B))))
17861786
if (match(Op1, m_Xor(m_Xor(m_Specific(B), m_Value(C)), m_Specific(A))))
1787-
if (Op1->hasOneUse() || IsFreeToInvert(C, C->hasOneUse()))
1787+
if (Op1->hasOneUse() || isFreeToInvert(C, C->hasOneUse()))
17881788
return BinaryOperator::CreateAnd(Op0, Builder.CreateNot(C));
17891789

17901790
// ((A ^ C) ^ B) & (B ^ A) -> (B ^ A) & ~C
17911791
if (match(Op0, m_Xor(m_Xor(m_Value(A), m_Value(C)), m_Value(B))))
17921792
if (match(Op1, m_Xor(m_Specific(B), m_Specific(A))))
1793-
if (Op0->hasOneUse() || IsFreeToInvert(C, C->hasOneUse()))
1793+
if (Op0->hasOneUse() || isFreeToInvert(C, C->hasOneUse()))
17941794
return BinaryOperator::CreateAnd(Op1, Builder.CreateNot(C));
17951795

17961796
// (A | B) & ((~A) ^ B) -> (A & B)
@@ -2806,9 +2806,9 @@ static Instruction *sinkNotIntoXor(BinaryOperator &I,
28062806
return nullptr;
28072807

28082808
// We only want to do the transform if it is free to do.
2809-
if (IsFreeToInvert(X, X->hasOneUse())) {
2809+
if (isFreeToInvert(X, X->hasOneUse())) {
28102810
// Ok, good.
2811-
} else if (IsFreeToInvert(Y, Y->hasOneUse())) {
2811+
} else if (isFreeToInvert(Y, Y->hasOneUse())) {
28122812
std::swap(X, Y);
28132813
} else
28142814
return nullptr;
@@ -2886,9 +2886,9 @@ Instruction *InstCombiner::visitXor(BinaryOperator &I) {
28862886
// Apply DeMorgan's Law when inverts are free:
28872887
// ~(X & Y) --> (~X | ~Y)
28882888
// ~(X | Y) --> (~X & ~Y)
2889-
if (IsFreeToInvert(NotVal->getOperand(0),
2889+
if (isFreeToInvert(NotVal->getOperand(0),
28902890
NotVal->getOperand(0)->hasOneUse()) &&
2891-
IsFreeToInvert(NotVal->getOperand(1),
2891+
isFreeToInvert(NotVal->getOperand(1),
28922892
NotVal->getOperand(1)->hasOneUse())) {
28932893
Value *NotX = Builder.CreateNot(NotVal->getOperand(0), "notlhs");
28942894
Value *NotY = Builder.CreateNot(NotVal->getOperand(1), "notrhs");
@@ -3111,24 +3111,24 @@ Instruction *InstCombiner::visitXor(BinaryOperator &I) {
31113111
if (SelectPatternResult::isMinOrMax(SPF)) {
31123112
// It's possible we get here before the not has been simplified, so make
31133113
// sure the input to the not isn't freely invertible.
3114-
if (match(LHS, m_Not(m_Value(X))) && !IsFreeToInvert(X, X->hasOneUse())) {
3114+
if (match(LHS, m_Not(m_Value(X))) && !isFreeToInvert(X, X->hasOneUse())) {
31153115
Value *NotY = Builder.CreateNot(RHS);
31163116
return SelectInst::Create(
31173117
Builder.CreateICmp(getInverseMinMaxPred(SPF), X, NotY), X, NotY);
31183118
}
31193119

31203120
// It's possible we get here before the not has been simplified, so make
31213121
// sure the input to the not isn't freely invertible.
3122-
if (match(RHS, m_Not(m_Value(Y))) && !IsFreeToInvert(Y, Y->hasOneUse())) {
3122+
if (match(RHS, m_Not(m_Value(Y))) && !isFreeToInvert(Y, Y->hasOneUse())) {
31233123
Value *NotX = Builder.CreateNot(LHS);
31243124
return SelectInst::Create(
31253125
Builder.CreateICmp(getInverseMinMaxPred(SPF), NotX, Y), NotX, Y);
31263126
}
31273127

31283128
// If both sides are freely invertible, then we can get rid of the xor
31293129
// completely.
3130-
if (IsFreeToInvert(LHS, !LHS->hasNUsesOrMore(3)) &&
3131-
IsFreeToInvert(RHS, !RHS->hasNUsesOrMore(3))) {
3130+
if (isFreeToInvert(LHS, !LHS->hasNUsesOrMore(3)) &&
3131+
isFreeToInvert(RHS, !RHS->hasNUsesOrMore(3))) {
31323132
Value *NotLHS = Builder.CreateNot(LHS);
31333133
Value *NotRHS = Builder.CreateNot(RHS);
31343134
return SelectInst::Create(

llvm/lib/Transforms/InstCombine/InstCombineInternal.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ static inline Constant *SubOne(Constant *C) {
141141
/// uses of V and only keep uses of ~V.
142142
///
143143
/// See also: canFreelyInvertAllUsersOf()
144-
static inline bool IsFreeToInvert(Value *V, bool WillInvertAllUses) {
144+
static inline bool isFreeToInvert(Value *V, bool WillInvertAllUses) {
145145
// ~(~(X)) -> X.
146146
if (match(V, m_Not(m_Value())))
147147
return true;
@@ -172,7 +172,7 @@ static inline bool IsFreeToInvert(Value *V, bool WillInvertAllUses) {
172172

173173
/// Given i1 V, can every user of V be freely adapted if V is changed to !V ?
174174
///
175-
/// See also: IsFreeToInvert()
175+
/// See also: isFreeToInvert()
176176
static inline bool canFreelyInvertAllUsersOf(Value *V, Value *IgnoredUser) {
177177
// Look at every user of V.
178178
for (User *U : V->users()) {

llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1338,7 +1338,7 @@ Instruction *InstCombiner::foldSPFofSPF(Instruction *Inner,
13381338
return true;
13391339
}
13401340

1341-
if (IsFreeToInvert(V, !V->hasNUsesOrMore(3))) {
1341+
if (isFreeToInvert(V, !V->hasNUsesOrMore(3))) {
13421342
NotV = nullptr;
13431343
return true;
13441344
}
@@ -2098,9 +2098,9 @@ Instruction *InstCombiner::visitSelectInst(SelectInst &SI) {
20982098
auto moveNotAfterMinMax = [&](Value *X, Value *Y) -> Instruction * {
20992099
Value *A;
21002100
if (match(X, m_Not(m_Value(A))) && !X->hasNUsesOrMore(3) &&
2101-
!IsFreeToInvert(A, A->hasOneUse()) &&
2101+
!isFreeToInvert(A, A->hasOneUse()) &&
21022102
// Passing false to only consider m_Not and constants.
2103-
IsFreeToInvert(Y, false)) {
2103+
isFreeToInvert(Y, false)) {
21042104
Value *B = Builder.CreateNot(Y);
21052105
Value *NewMinMax = createMinMax(Builder, getInverseMinMaxFlavor(SPF),
21062106
A, B);

0 commit comments

Comments
 (0)