Skip to content

Commit 7c95602

Browse files
committed
fix : Inverted Op
1 parent 62e98ae commit 7c95602

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

lib/Dialect/Synth/SynthOps.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -103,15 +103,13 @@ OpFoldResult MajorityInverterOp::fold(FoldAdaptor adaptor) {
103103
else
104104
return getOperand(index); // fix if it is a Inverted
105105
}
106-
auto getConstant = [&](unsigned index) -> std::optional<llvm::APInt> {
107-
APInt value;
108-
if (mlir::matchPattern(getInputs()[index], mlir::m_ConstantInt(&value)))
109-
return isInverted(index) ? ~value : value;
110-
return std::nullopt;
111-
};
112106
// Pattern match following cases:
113107
// maj_inv(x, x, y) -> x
114108
// maj_inv(x, y, not y) -> x
109+
auto retIndex = [&](size_t index) {
110+
if (!isInverted(index))
111+
return getOperand(index);
112+
};
115113
for (int i = 0; i < 2; ++i) {
116114
for (int j = i + 1; j < 3; ++j) {
117115
int k = 3 - (i + j);
@@ -120,9 +118,11 @@ OpFoldResult MajorityInverterOp::fold(FoldAdaptor adaptor) {
120118
if (getOperand(i) == getOperand(j)) {
121119
// If they are inverted differently, we can fold to the third.
122120
if (isInverted(i) != isInverted(j)) {
123-
return getOperand(k);
121+
if (!isInverted(k))
122+
return getOperand(k);
124123
}
125-
return getOperand(i);
124+
if (!isInverted(i))
125+
return getOperand(i);
126126
}
127127
}
128128
}

0 commit comments

Comments
 (0)