Skip to content

Commit d066a85

Browse files
committed
Move simple expression check to caller
1 parent af90743 commit d066a85

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -59,18 +59,6 @@ static Value *createLogicFromTable3Var(const std::bitset<8> &Table, Value *Op0,
5959
Value *Op1, Value *Op2, Value *Root,
6060
IRBuilderBase &Builder, bool HasOneUse) {
6161
uint8_t TruthValue = Table.to_ulong();
62-
63-
// Skip transformation if expression is already simple (at most 2 levels
64-
// deep).
65-
if (Root->hasOneUse() && isa<BinaryOperator>(Root)) {
66-
if (auto *BO = dyn_cast<BinaryOperator>(Root)) {
67-
bool IsSimple = !isa<BinaryOperator>(BO->getOperand(0)) ||
68-
!isa<BinaryOperator>(BO->getOperand(1));
69-
if (IsSimple)
70-
return nullptr;
71-
}
72-
}
73-
7462
auto FoldConstant = [&](bool Val) {
7563
Constant *Res = Val ? Builder.getTrue() : Builder.getFalse();
7664
if (Op0->getType()->isVectorTy())
@@ -230,6 +218,17 @@ static Value *foldThreeVarBoolExpr(Value *Root,
230218
if (!isa<BinaryOperator>(Root))
231219
return nullptr;
232220

221+
// Skip transformation if expression is already simple (at most 2 levels
222+
// deep).
223+
if (Root->hasOneUse() && isa<BinaryOperator>(Root)) {
224+
if (auto *BO = dyn_cast<BinaryOperator>(Root)) {
225+
bool IsSimple = !isa<BinaryOperator>(BO->getOperand(0)) ||
226+
!isa<BinaryOperator>(BO->getOperand(1));
227+
if (IsSimple)
228+
return nullptr;
229+
}
230+
}
231+
233232
auto [Op0, Op1, Op2] = extractThreeVariables(Root);
234233
if (!Op0 || !Op1 || !Op2)
235234
return nullptr;

0 commit comments

Comments
 (0)