diff --git a/compiler/src/prog8/compiler/astprocessing/StatementReorderer.kt b/compiler/src/prog8/compiler/astprocessing/StatementReorderer.kt index 4b732ccdf..f3c8096af 100644 --- a/compiler/src/prog8/compiler/astprocessing/StatementReorderer.kt +++ b/compiler/src/prog8/compiler/astprocessing/StatementReorderer.kt @@ -226,36 +226,6 @@ internal class StatementReorderer( // A = v A ==> A = A v return listOf(IAstModification.SwapOperands(binExpr)) } - - val leftBinExpr = binExpr.left as? BinaryExpression - if(leftBinExpr?.operator == binExpr.operator) { - return if(leftBinExpr.left isSameAs assignment.target) { - // A = (A x) y ==> A = A (x y) - val newRight = BinaryExpression(leftBinExpr.right, binExpr.operator, binExpr.right, binExpr.position) - val newValue = BinaryExpression(leftBinExpr.left, binExpr.operator, newRight, binExpr.position) - listOf(IAstModification.ReplaceNode(binExpr, newValue, assignment)) - } - else { - // A = (x A) y ==> A = A (x y) - val newRight = BinaryExpression(leftBinExpr.left, binExpr.operator, binExpr.right, binExpr.position) - val newValue = BinaryExpression(leftBinExpr.right, binExpr.operator, newRight, binExpr.position) - listOf(IAstModification.ReplaceNode(binExpr, newValue, assignment)) - } - } - val rightBinExpr = binExpr.right as? BinaryExpression - if(rightBinExpr?.operator == binExpr.operator) { - return if(rightBinExpr.left isSameAs assignment.target) { - // A = x (A y) ==> A = A (x y) - val newRight = BinaryExpression(binExpr.left, binExpr.operator, rightBinExpr.right, binExpr.position) - val newValue = BinaryExpression(rightBinExpr.left, binExpr.operator, newRight, binExpr.position) - listOf(IAstModification.ReplaceNode(binExpr, newValue, assignment)) - } else { - // A = x (y A) ==> A = A (x y) - val newRight = BinaryExpression(binExpr.left, binExpr.operator, rightBinExpr.left, binExpr.position) - val newValue = BinaryExpression(rightBinExpr.right, binExpr.operator, newRight, binExpr.position) - listOf(IAstModification.ReplaceNode(binExpr, newValue, assignment)) - } - } } } diff --git a/docs/source/todo.rst b/docs/source/todo.rst index 0ae3b304b..24d785c46 100644 --- a/docs/source/todo.rst +++ b/docs/source/todo.rst @@ -1,9 +1,7 @@ TODO ==== -- why is the right term of cx16.r0 = (cx16.r1+cx16.r2) + (cx16.r1+cx16.r2) flipped around but the left term isn't? - -- Revert or fix current "desugar chained comparisons" it causes problems with if statements. +- Revert or fix current "desugar chained comparisons" it causes problems with if statements (in optimizer). ubyte @shared n=20 ubyte @shared L1=10 ubyte @shared L2=100