Skip to content

Commit 9363658

Browse files
committed
[InstCombiner] Make isFreeToInvert() and friends instance functions (NFC)
In order to use SQ inside of these. There doesn't seem to be any strong need for these to be static.
1 parent e59a0cd commit 9363658

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

llvm/include/llvm/Transforms/InstCombine/InstCombiner.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -240,18 +240,18 @@ class LLVM_LIBRARY_VISIBILITY InstCombiner {
240240
/// dereferenceable).
241241
/// If the inversion will consume instructions, `DoesConsume` will be set to
242242
/// true. Otherwise it will be false.
243-
static Value *getFreelyInvertedImpl(Value *V, bool WillInvertAllUses,
243+
Value *getFreelyInvertedImpl(Value *V, bool WillInvertAllUses,
244244
BuilderTy *Builder, bool &DoesConsume,
245245
unsigned Depth);
246246

247-
static Value *getFreelyInverted(Value *V, bool WillInvertAllUses,
247+
Value *getFreelyInverted(Value *V, bool WillInvertAllUses,
248248
BuilderTy *Builder, bool &DoesConsume) {
249249
DoesConsume = false;
250250
return getFreelyInvertedImpl(V, WillInvertAllUses, Builder, DoesConsume,
251251
/*Depth*/ 0);
252252
}
253253

254-
static Value *getFreelyInverted(Value *V, bool WillInvertAllUses,
254+
Value *getFreelyInverted(Value *V, bool WillInvertAllUses,
255255
BuilderTy *Builder) {
256256
bool Unused;
257257
return getFreelyInverted(V, WillInvertAllUses, Builder, Unused);
@@ -263,13 +263,13 @@ class LLVM_LIBRARY_VISIBILITY InstCombiner {
263263
/// uses of V and only keep uses of ~V.
264264
///
265265
/// See also: canFreelyInvertAllUsersOf()
266-
static bool isFreeToInvert(Value *V, bool WillInvertAllUses,
266+
bool isFreeToInvert(Value *V, bool WillInvertAllUses,
267267
bool &DoesConsume) {
268268
return getFreelyInverted(V, WillInvertAllUses, /*Builder*/ nullptr,
269269
DoesConsume) != nullptr;
270270
}
271271

272-
static bool isFreeToInvert(Value *V, bool WillInvertAllUses) {
272+
bool isFreeToInvert(Value *V, bool WillInvertAllUses) {
273273
bool Unused;
274274
return isFreeToInvert(V, WillInvertAllUses, Unused);
275275
}
@@ -279,7 +279,7 @@ class LLVM_LIBRARY_VISIBILITY InstCombiner {
279279
/// NOTE: for Instructions only!
280280
///
281281
/// See also: isFreeToInvert()
282-
static bool canFreelyInvertAllUsersOf(Instruction *V, Value *IgnoredUser) {
282+
bool canFreelyInvertAllUsersOf(Instruction *V, Value *IgnoredUser) {
283283
// Look at every user of V.
284284
for (Use &U : V->uses()) {
285285
if (U.getUser() == IgnoredUser)

llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1610,7 +1610,7 @@ static Instruction *reassociateFCmps(BinaryOperator &BO,
16101610
/// (~A & ~B) == (~(A | B))
16111611
/// (~A | ~B) == (~(A & B))
16121612
static Instruction *matchDeMorgansLaws(BinaryOperator &I,
1613-
InstCombiner::BuilderTy &Builder) {
1613+
InstCombiner &IC) {
16141614
const Instruction::BinaryOps Opcode = I.getOpcode();
16151615
assert((Opcode == Instruction::And || Opcode == Instruction::Or) &&
16161616
"Trying to match De Morgan's Laws with something other than and/or");
@@ -1623,10 +1623,10 @@ static Instruction *matchDeMorgansLaws(BinaryOperator &I,
16231623
Value *A, *B;
16241624
if (match(Op0, m_OneUse(m_Not(m_Value(A)))) &&
16251625
match(Op1, m_OneUse(m_Not(m_Value(B)))) &&
1626-
!InstCombiner::isFreeToInvert(A, A->hasOneUse()) &&
1627-
!InstCombiner::isFreeToInvert(B, B->hasOneUse())) {
1626+
!IC.isFreeToInvert(A, A->hasOneUse()) &&
1627+
!IC.isFreeToInvert(B, B->hasOneUse())) {
16281628
Value *AndOr =
1629-
Builder.CreateBinOp(FlippedOpcode, A, B, I.getName() + ".demorgan");
1629+
IC.Builder.CreateBinOp(FlippedOpcode, A, B, I.getName() + ".demorgan");
16301630
return BinaryOperator::CreateNot(AndOr);
16311631
}
16321632

@@ -1638,8 +1638,8 @@ static Instruction *matchDeMorgansLaws(BinaryOperator &I,
16381638
Value *C;
16391639
if (match(Op0, m_OneUse(m_c_BinOp(Opcode, m_Value(A), m_Not(m_Value(B))))) &&
16401640
match(Op1, m_Not(m_Value(C)))) {
1641-
Value *FlippedBO = Builder.CreateBinOp(FlippedOpcode, B, C);
1642-
return BinaryOperator::Create(Opcode, A, Builder.CreateNot(FlippedBO));
1641+
Value *FlippedBO = IC.Builder.CreateBinOp(FlippedOpcode, B, C);
1642+
return BinaryOperator::Create(Opcode, A, IC.Builder.CreateNot(FlippedBO));
16431643
}
16441644

16451645
return nullptr;
@@ -2483,7 +2483,7 @@ Instruction *InstCombinerImpl::visitAnd(BinaryOperator &I) {
24832483
if (Instruction *FoldedLogic = foldBinOpIntoSelectOrPhi(I))
24842484
return FoldedLogic;
24852485

2486-
if (Instruction *DeMorgan = matchDeMorgansLaws(I, Builder))
2486+
if (Instruction *DeMorgan = matchDeMorgansLaws(I, *this))
24872487
return DeMorgan;
24882488

24892489
{
@@ -3517,7 +3517,7 @@ Instruction *InstCombinerImpl::visitOr(BinaryOperator &I) {
35173517
if (match(Op0, m_And(m_Or(m_Specific(Op1), m_Value(C)), m_Value(A))))
35183518
return BinaryOperator::CreateOr(Op1, Builder.CreateAnd(A, C));
35193519

3520-
if (Instruction *DeMorgan = matchDeMorgansLaws(I, Builder))
3520+
if (Instruction *DeMorgan = matchDeMorgansLaws(I, *this))
35213521
return DeMorgan;
35223522

35233523
// Canonicalize xor to the RHS.
@@ -4124,7 +4124,7 @@ static bool canFreelyInvert(InstCombiner &IC, Value *Op,
41244124
Instruction *IgnoredUser) {
41254125
auto *I = dyn_cast<Instruction>(Op);
41264126
return I && IC.isFreeToInvert(I, /*WillInvertAllUses=*/true) &&
4127-
InstCombiner::canFreelyInvertAllUsersOf(I, IgnoredUser);
4127+
IC.canFreelyInvertAllUsersOf(I, IgnoredUser);
41284128
}
41294129

41304130
static Value *freelyInvert(InstCombinerImpl &IC, Value *Op,

0 commit comments

Comments
 (0)