File tree Expand file tree Collapse file tree 1 file changed +8
-8
lines changed Expand file tree Collapse file tree 1 file changed +8
-8
lines changed Original file line number Diff line number Diff 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 }
You can’t perform that action at this time.
0 commit comments