@@ -298,6 +298,10 @@ public void testCommuteMultiExpression() throws Exception {
298298 + "static int f1;"
299299 + "static A createA() { A.f1 = 1; return new A(); } "
300300 + "static boolean booleanWithSideEffects() { createA(); return true;}"
301+ + "@javaemul.internal.annotations.DoNotInline "
302+ + "static boolean notInlinedBool1() { return true;}"
303+ + "@javaemul.internal.annotations.DoNotInline "
304+ + "static boolean notInlinedBool2() { return true;}"
301305 + "static boolean booleanWithoutSideEffects() { return true;}"
302306 + "static int arithmeticWithSideEffects() { createA(); return 4;}"
303307 + "}" );
@@ -311,6 +315,28 @@ public void testCommuteMultiExpression() throws Exception {
311315 optimizeExpressions (false , "boolean" , "false && A.booleanWithSideEffects()" )
312316 .intoString ("return false;" );
313317
318+ optimizeExpressions (false , "boolean" , "A.notInlinedBool1() && false" )
319+ .intoString ("return (EntryPoint$A.notInlinedBool1(), false);" );
320+
321+ optimizeExpressions (false , "int" ,
322+ "A.notInlinedBool1() && (false && A.notInlinedBool2()) ? 1 : 2" )
323+ .intoString ("return (EntryPoint$A.notInlinedBool1(), 2);" );
324+
325+ optimizeExpressions (false , "int" ,
326+ "(A.notInlinedBool1() && false) && A.notInlinedBool2() ? 1 : 2" )
327+ .intoString ("return (EntryPoint$A.notInlinedBool1(), 2);" );
328+
329+ optimizeExpressions (false , "boolean" , "A.notInlinedBool1() || true" )
330+ .intoString ("return (EntryPoint$A.notInlinedBool1(), true);" );
331+
332+ optimizeExpressions (false , "int" ,
333+ "A.notInlinedBool1() || (true || A.notInlinedBool2()) ? 1 : 2" )
334+ .intoString ("return (EntryPoint$A.notInlinedBool1(), 1);" );
335+
336+ optimizeExpressions (false , "int" ,
337+ "(A.notInlinedBool1() || true) || A.notInlinedBool2() ? 1 : 2" )
338+ .intoString ("return (EntryPoint$A.notInlinedBool1(), 1);" );
339+
314340 optimizeExpressions (false , "int" , "3 + A.arithmeticWithSideEffects()" )
315341 .intoString ("return (EntryPoint$A.f1 = 1, new EntryPoint$A(), 7);" );
316342 }
0 commit comments