diff options
-rw-r--r-- | compiler/optimizing/constant_folding.cc | 20 | ||||
-rw-r--r-- | compiler/optimizing/constant_folding.h | 8 | ||||
-rw-r--r-- | compiler/optimizing/constant_folding_test.cc | 4 | ||||
-rw-r--r-- | compiler/optimizing/optimization.cc | 5 | ||||
-rw-r--r-- | compiler/optimizing/optimization.h | 1 | ||||
-rw-r--r-- | compiler/optimizing/optimizing_compiler.cc | 2 | ||||
-rw-r--r-- | test/2244-checker-remove-try-boundary/src/Main.java | 15 | ||||
-rw-r--r-- | test/442-checker-constant-folding/src/Main.java | 186 | ||||
-rw-r--r-- | test/485-checker-dce-loop-update/smali/TestCase.smali | 6 | ||||
-rw-r--r-- | test/543-checker-dce-trycatch/smali/TestCase.smali | 6 |
10 files changed, 105 insertions, 148 deletions
diff --git a/compiler/optimizing/constant_folding.cc b/compiler/optimizing/constant_folding.cc index 66bbf548bb..64ef17898a 100644 --- a/compiler/optimizing/constant_folding.cc +++ b/compiler/optimizing/constant_folding.cc @@ -32,8 +32,8 @@ namespace art HIDDEN { // as constants. class HConstantFoldingVisitor final : public HGraphDelegateVisitor { public: - HConstantFoldingVisitor(HGraph* graph, OptimizingCompilerStats* stats, bool use_all_optimizations) - : HGraphDelegateVisitor(graph, stats), use_all_optimizations_(use_all_optimizations) {} + explicit HConstantFoldingVisitor(HGraph* graph, OptimizingCompilerStats* stats) + : HGraphDelegateVisitor(graph, stats) {} private: void VisitBasicBlock(HBasicBlock* block) override; @@ -66,9 +66,6 @@ class HConstantFoldingVisitor final : public HGraphDelegateVisitor { void FoldNumberOfLeadingZerosIntrinsic(HInvoke* invoke); void FoldNumberOfTrailingZerosIntrinsic(HInvoke* invoke); - // Use all optimizations without restrictions. - bool use_all_optimizations_; - DISALLOW_COPY_AND_ASSIGN(HConstantFoldingVisitor); }; @@ -109,7 +106,7 @@ class InstructionWithAbsorbingInputSimplifier : public HGraphVisitor { bool HConstantFolding::Run() { - HConstantFoldingVisitor visitor(graph_, stats_, use_all_optimizations_); + HConstantFoldingVisitor visitor(graph_, stats_); // Process basic blocks in reverse post-order in the dominator tree, // so that an instruction turned into a constant, used as input of // another instruction, may possibly be used to turn that second @@ -232,11 +229,6 @@ void HConstantFoldingVisitor::PropagateValue(HBasicBlock* starting_block, uses_before = variable->GetUses().SizeSlow(); } - if (variable->GetUses().HasExactlyOneElement()) { - // Nothing to do, since we only have the `if (variable)` use or the `condition` use. - return; - } - variable->ReplaceUsesDominatedBy( starting_block->GetFirstInstruction(), constant, /* strictly_dominated= */ false); @@ -249,12 +241,6 @@ void HConstantFoldingVisitor::PropagateValue(HBasicBlock* starting_block, } void HConstantFoldingVisitor::VisitIf(HIf* inst) { - // This optimization can take a lot of compile time since we have a lot of If instructions in - // graphs. - if (!use_all_optimizations_) { - return; - } - // Consistency check: the true and false successors do not dominate each other. DCHECK(!inst->IfTrueSuccessor()->Dominates(inst->IfFalseSuccessor()) && !inst->IfFalseSuccessor()->Dominates(inst->IfTrueSuccessor())); diff --git a/compiler/optimizing/constant_folding.h b/compiler/optimizing/constant_folding.h index 29648e907c..73ac3ceb81 100644 --- a/compiler/optimizing/constant_folding.h +++ b/compiler/optimizing/constant_folding.h @@ -43,18 +43,14 @@ class HConstantFolding : public HOptimization { public: HConstantFolding(HGraph* graph, OptimizingCompilerStats* stats = nullptr, - const char* name = kConstantFoldingPassName, - bool use_all_optimizations = false) - : HOptimization(graph, name, stats), use_all_optimizations_(use_all_optimizations) {} + const char* name = kConstantFoldingPassName) + : HOptimization(graph, name, stats) {} bool Run() override; static constexpr const char* kConstantFoldingPassName = "constant_folding"; private: - // Use all optimizations without restrictions. - bool use_all_optimizations_; - DISALLOW_COPY_AND_ASSIGN(HConstantFolding); }; diff --git a/compiler/optimizing/constant_folding_test.cc b/compiler/optimizing/constant_folding_test.cc index acdc8e6d3c..689d77111c 100644 --- a/compiler/optimizing/constant_folding_test.cc +++ b/compiler/optimizing/constant_folding_test.cc @@ -60,9 +60,7 @@ class ConstantFoldingTest : public CommonCompilerTest, public OptimizingUnitTest std::string actual_before = printer_before.str(); EXPECT_EQ(expected_before, actual_before); - HConstantFolding constant_folding( - graph_, /* stats= */ nullptr, "constant_folding", /* use_all_optimizations= */ true); - constant_folding.Run(); + HConstantFolding(graph_, /* stats= */ nullptr, "constant_folding").Run(); GraphChecker graph_checker_cf(graph_); graph_checker_cf.Run(); ASSERT_TRUE(graph_checker_cf.IsValid()); diff --git a/compiler/optimizing/optimization.cc b/compiler/optimizing/optimization.cc index 16045d447c..9c1506afa5 100644 --- a/compiler/optimizing/optimization.cc +++ b/compiler/optimizing/optimization.cc @@ -80,7 +80,6 @@ const char* OptimizationPassName(OptimizationPass pass) { return BoundsCheckElimination::kBoundsCheckEliminationPassName; case OptimizationPass::kLoadStoreElimination: return LoadStoreElimination::kLoadStoreEliminationPassName; - case OptimizationPass::kAggressiveConstantFolding: case OptimizationPass::kConstantFolding: return HConstantFolding::kConstantFoldingPassName; case OptimizationPass::kDeadCodeElimination: @@ -238,10 +237,6 @@ ArenaVector<HOptimization*> ConstructOptimizations( case OptimizationPass::kConstantFolding: opt = new (allocator) HConstantFolding(graph, stats, pass_name); break; - case OptimizationPass::kAggressiveConstantFolding: - opt = new (allocator) - HConstantFolding(graph, stats, pass_name, /* use_all_optimizations_ = */ true); - break; case OptimizationPass::kDeadCodeElimination: opt = new (allocator) HDeadCodeElimination(graph, stats, pass_name); break; diff --git a/compiler/optimizing/optimization.h b/compiler/optimizing/optimization.h index 57c5f4639c..55aa8f914b 100644 --- a/compiler/optimizing/optimization.h +++ b/compiler/optimizing/optimization.h @@ -67,7 +67,6 @@ class HOptimization : public ArenaObject<kArenaAllocOptimization> { // field is preferred over a string lookup at places where performance matters. // TODO: generate this table and lookup methods below automatically? enum class OptimizationPass { - kAggressiveConstantFolding, kAggressiveInstructionSimplifier, kBoundsCheckElimination, kCHAGuardOptimization, diff --git a/compiler/optimizing/optimizing_compiler.cc b/compiler/optimizing/optimizing_compiler.cc index d458462226..8909a59ddf 100644 --- a/compiler/optimizing/optimizing_compiler.cc +++ b/compiler/optimizing/optimizing_compiler.cc @@ -666,7 +666,7 @@ void OptimizingCompiler::RunOptimizations(HGraph* graph, OptDef(OptimizationPass::kGlobalValueNumbering), // Simplification (TODO: only if GVN occurred). OptDef(OptimizationPass::kSelectGenerator), - OptDef(OptimizationPass::kAggressiveConstantFolding, + OptDef(OptimizationPass::kConstantFolding, "constant_folding$after_gvn"), OptDef(OptimizationPass::kInstructionSimplifier, "instruction_simplifier$after_gvn"), diff --git a/test/2244-checker-remove-try-boundary/src/Main.java b/test/2244-checker-remove-try-boundary/src/Main.java index 65c40c5daa..1b616a5ecc 100644 --- a/test/2244-checker-remove-try-boundary/src/Main.java +++ b/test/2244-checker-remove-try-boundary/src/Main.java @@ -158,30 +158,29 @@ public class Main { } // The throw gets eliminated by `SimplifyIfs` in DCE, so we can detect that nothing can throw in - // the graph and eliminate the `TryBoundary` instructions. It does so in `after_gvn` since it - // requires the VisitIf optimization which happens later in the graph. + // the graph and eliminate the `TryBoundary` instructions. - /// CHECK-START: int Main.$noinline$testOptimizeAfterOneBranchDisappears(int, boolean) dead_code_elimination$after_gvn (before) + /// CHECK-START: int Main.$noinline$testOptimizeAfterOneBranchDisappears(int, boolean) dead_code_elimination$initial (before) /// CHECK: Throw - /// CHECK-START: int Main.$noinline$testOptimizeAfterOneBranchDisappears(int, boolean) dead_code_elimination$after_gvn (before) + /// CHECK-START: int Main.$noinline$testOptimizeAfterOneBranchDisappears(int, boolean) dead_code_elimination$initial (before) /// CHECK: TryBoundary /// CHECK: TryBoundary /// CHECK: TryBoundary /// CHECK: TryBoundary /// CHECK-NOT: TryBoundary - /// CHECK-START: int Main.$noinline$testOptimizeAfterOneBranchDisappears(int, boolean) dead_code_elimination$after_gvn (before) + /// CHECK-START: int Main.$noinline$testOptimizeAfterOneBranchDisappears(int, boolean) dead_code_elimination$initial (before) /// CHECK: flags "catch_block" /// CHECK-NOT: flags "catch_block" - /// CHECK-START: int Main.$noinline$testOptimizeAfterOneBranchDisappears(int, boolean) dead_code_elimination$after_gvn (after) + /// CHECK-START: int Main.$noinline$testOptimizeAfterOneBranchDisappears(int, boolean) dead_code_elimination$initial (after) /// CHECK-NOT: Throw - /// CHECK-START: int Main.$noinline$testOptimizeAfterOneBranchDisappears(int, boolean) dead_code_elimination$after_gvn (after) + /// CHECK-START: int Main.$noinline$testOptimizeAfterOneBranchDisappears(int, boolean) dead_code_elimination$initial (after) /// CHECK-NOT: TryBoundary - /// CHECK-START: int Main.$noinline$testOptimizeAfterOneBranchDisappears(int, boolean) dead_code_elimination$after_gvn (after) + /// CHECK-START: int Main.$noinline$testOptimizeAfterOneBranchDisappears(int, boolean) dead_code_elimination$initial (after) /// CHECK-NOT: flags "catch_block" public static int $noinline$testOptimizeAfterOneBranchDisappears(int a, boolean val) { try { diff --git a/test/442-checker-constant-folding/src/Main.java b/test/442-checker-constant-folding/src/Main.java index 4539fae097..7c6d6091ee 100644 --- a/test/442-checker-constant-folding/src/Main.java +++ b/test/442-checker-constant-folding/src/Main.java @@ -1551,21 +1551,20 @@ public class Main { return (double) imm; } - /// CHECK-START: int Main.$inline$SpecialCaseForZeroInt(int) constant_folding$after_gvn (before) - /// CHECK-DAG: Add - /// CHECK-DAG: Shl + /// CHECK-START: int Main.$inline$SpecialCaseForZeroInt(int) constant_folding (before) /// CHECK-DAG: Add + /// CHECK-DAG: Mul - /// CHECK-START: int Main.$inline$SpecialCaseForZeroInt(int) constant_folding$after_gvn (before) + /// CHECK-START: int Main.$inline$SpecialCaseForZeroInt(int) constant_folding (before) /// CHECK-NOT: IntConstant 6 - /// CHECK-START: int Main.$inline$SpecialCaseForZeroInt(int) constant_folding$after_gvn (after) + /// CHECK-START: int Main.$inline$SpecialCaseForZeroInt(int) constant_folding (after) /// CHECK-NOT: Add - /// CHECK-START: int Main.$inline$SpecialCaseForZeroInt(int) constant_folding$after_gvn (after) - /// CHECK-NOT: Shl + /// CHECK-START: int Main.$inline$SpecialCaseForZeroInt(int) constant_folding (after) + /// CHECK-NOT: Mul - /// CHECK-START: int Main.$inline$SpecialCaseForZeroInt(int) constant_folding$after_gvn (after) + /// CHECK-START: int Main.$inline$SpecialCaseForZeroInt(int) constant_folding (after) /// CHECK-DAG: <<Const:i\d+>> IntConstant 6 /// CHECK-DAG: Return [<<Const>>] private static int $inline$SpecialCaseForZeroInt(int value) { @@ -1575,21 +1574,20 @@ public class Main { return value; } - /// CHECK-START: long Main.$inline$SpecialCaseForZeroLong(long) constant_folding$after_gvn (before) - /// CHECK-DAG: Add - /// CHECK-DAG: Shl + /// CHECK-START: long Main.$inline$SpecialCaseForZeroLong(long) constant_folding (before) /// CHECK-DAG: Add + /// CHECK-DAG: Mul - /// CHECK-START: long Main.$inline$SpecialCaseForZeroLong(long) constant_folding$after_gvn (before) + /// CHECK-START: long Main.$inline$SpecialCaseForZeroLong(long) constant_folding (before) /// CHECK-NOT: LongConstant 6 - /// CHECK-START: long Main.$inline$SpecialCaseForZeroLong(long) constant_folding$after_gvn (after) + /// CHECK-START: long Main.$inline$SpecialCaseForZeroLong(long) constant_folding (after) /// CHECK-NOT: Add - /// CHECK-START: long Main.$inline$SpecialCaseForZeroLong(long) constant_folding$after_gvn (after) - /// CHECK-NOT: Shl + /// CHECK-START: long Main.$inline$SpecialCaseForZeroLong(long) constant_folding (after) + /// CHECK-NOT: Mul - /// CHECK-START: long Main.$inline$SpecialCaseForZeroLong(long) constant_folding$after_gvn (after) + /// CHECK-START: long Main.$inline$SpecialCaseForZeroLong(long) constant_folding (after) /// CHECK-DAG: <<Const:j\d+>> LongConstant 6 /// CHECK-DAG: Return [<<Const>>] private static long $inline$SpecialCaseForZeroLong(long value) { @@ -1599,14 +1597,14 @@ public class Main { return value; } - /// CHECK-START: float Main.$noinline$SpecialCaseForZeroFloat(float) constant_folding$after_gvn (before) + /// CHECK-START: float Main.$noinline$SpecialCaseForZeroFloat(float) constant_folding (before) /// CHECK-DAG: Add /// CHECK-DAG: Mul - /// CHECK-START: float Main.$noinline$SpecialCaseForZeroFloat(float) constant_folding$after_gvn (after) + /// CHECK-START: float Main.$noinline$SpecialCaseForZeroFloat(float) constant_folding (after) /// CHECK-NOT: FloatConstant 6 - /// CHECK-START: float Main.$noinline$SpecialCaseForZeroFloat(float) constant_folding$after_gvn (after) + /// CHECK-START: float Main.$noinline$SpecialCaseForZeroFloat(float) constant_folding (after) /// CHECK-DAG: Add /// CHECK-DAG: Mul private static float $noinline$SpecialCaseForZeroFloat(float value) { @@ -1616,14 +1614,14 @@ public class Main { return value; } - /// CHECK-START: double Main.$noinline$SpecialCaseForZeroDouble(double) constant_folding$after_gvn (before) + /// CHECK-START: double Main.$noinline$SpecialCaseForZeroDouble(double) constant_folding (before) /// CHECK-DAG: Add /// CHECK-DAG: Mul - /// CHECK-START: double Main.$noinline$SpecialCaseForZeroDouble(double) constant_folding$after_gvn (after) + /// CHECK-START: double Main.$noinline$SpecialCaseForZeroDouble(double) constant_folding (after) /// CHECK-NOT: DoubleConstant 6 - /// CHECK-START: double Main.$noinline$SpecialCaseForZeroDouble(double) constant_folding$after_gvn (after) + /// CHECK-START: double Main.$noinline$SpecialCaseForZeroDouble(double) constant_folding (after) /// CHECK-DAG: Add /// CHECK-DAG: Mul private static double $noinline$SpecialCaseForZeroDouble(double value) { @@ -1634,17 +1632,17 @@ public class Main { } // Note that we have Add instead of sub since internally we do `Add(value, -1)`. - /// CHECK-START: int Main.$noinline$NotEqualsPropagationInt(int) constant_folding$after_gvn (before) + /// CHECK-START: int Main.$noinline$NotEqualsPropagationInt(int) constant_folding (before) /// CHECK-DAG: Add /// CHECK-DAG: Div - /// CHECK-START: int Main.$noinline$NotEqualsPropagationInt(int) constant_folding$after_gvn (after) + /// CHECK-START: int Main.$noinline$NotEqualsPropagationInt(int) constant_folding (after) /// CHECK-NOT: Add - /// CHECK-START: int Main.$noinline$NotEqualsPropagationInt(int) constant_folding$after_gvn (after) + /// CHECK-START: int Main.$noinline$NotEqualsPropagationInt(int) constant_folding (after) /// CHECK-NOT: Div - /// CHECK-START: int Main.$noinline$NotEqualsPropagationInt(int) constant_folding$after_gvn (after) + /// CHECK-START: int Main.$noinline$NotEqualsPropagationInt(int) constant_folding (after) /// CHECK-DAG: <<Const:i\d+>> IntConstant 1 /// CHECK-DAG: Return [<<Const>>] private static int $noinline$NotEqualsPropagationInt(int value) { @@ -1655,17 +1653,17 @@ public class Main { } } - /// CHECK-START: long Main.$noinline$NotEqualsPropagationLong(long) constant_folding$after_gvn (before) + /// CHECK-START: long Main.$noinline$NotEqualsPropagationLong(long) constant_folding (before) /// CHECK-DAG: Sub /// CHECK-DAG: Div - /// CHECK-START: long Main.$noinline$NotEqualsPropagationLong(long) constant_folding$after_gvn (after) + /// CHECK-START: long Main.$noinline$NotEqualsPropagationLong(long) constant_folding (after) /// CHECK-NOT: Sub - /// CHECK-START: long Main.$noinline$NotEqualsPropagationLong(long) constant_folding$after_gvn (after) + /// CHECK-START: long Main.$noinline$NotEqualsPropagationLong(long) constant_folding (after) /// CHECK-NOT: Div - /// CHECK-START: long Main.$noinline$NotEqualsPropagationLong(long) constant_folding$after_gvn (after) + /// CHECK-START: long Main.$noinline$NotEqualsPropagationLong(long) constant_folding (after) /// CHECK-DAG: <<Const:j\d+>> LongConstant 1 /// CHECK-DAG: Return [<<Const>>] private static long $noinline$NotEqualsPropagationLong(long value) { @@ -1676,13 +1674,13 @@ public class Main { } } - /// CHECK-START: float Main.$noinline$NotEqualsPropagationFloat(float) constant_folding$after_gvn (before) + /// CHECK-START: float Main.$noinline$NotEqualsPropagationFloat(float) constant_folding (before) /// CHECK-DAG: Sub - /// CHECK-DAG: Mul + /// CHECK-DAG: Div - /// CHECK-START: float Main.$noinline$NotEqualsPropagationFloat(float) constant_folding$after_gvn (after) + /// CHECK-START: float Main.$noinline$NotEqualsPropagationFloat(float) constant_folding (after) /// CHECK-DAG: Sub - /// CHECK-DAG: Mul + /// CHECK-DAG: Div private static float $noinline$NotEqualsPropagationFloat(float value) { if (value != 3F) { return value; @@ -1691,13 +1689,13 @@ public class Main { } } - /// CHECK-START: double Main.$noinline$NotEqualsPropagationDouble(double) constant_folding$after_gvn (before) + /// CHECK-START: double Main.$noinline$NotEqualsPropagationDouble(double) constant_folding (before) /// CHECK-DAG: Sub - /// CHECK-DAG: Mul + /// CHECK-DAG: Div - /// CHECK-START: double Main.$noinline$NotEqualsPropagationDouble(double) constant_folding$after_gvn (after) + /// CHECK-START: double Main.$noinline$NotEqualsPropagationDouble(double) constant_folding (after) /// CHECK-DAG: Sub - /// CHECK-DAG: Mul + /// CHECK-DAG: Div private static double $noinline$NotEqualsPropagationDouble(double value) { if (value != 3D) { return value; @@ -1706,46 +1704,32 @@ public class Main { } } - /// CHECK-START: int Main.$noinline$InlineCalleeWithSpecialCaseForZeroInt(int) constant_folding$after_gvn (before) - /// CHECK-DAG: Add - /// CHECK-DAG: Shl - /// CHECK-DAG: Add - - /// CHECK-START: int Main.$noinline$InlineCalleeWithSpecialCaseForZeroInt(int) constant_folding$after_gvn (after) + /// CHECK-START: int Main.$noinline$InlineCaleeWithSpecialCaseForZeroInt(int) inliner (after) /// CHECK-NOT: Add - /// CHECK-START: int Main.$noinline$InlineCalleeWithSpecialCaseForZeroInt(int) constant_folding$after_gvn (after) - /// CHECK-NOT: Shl + /// CHECK-START: int Main.$noinline$InlineCaleeWithSpecialCaseForZeroInt(int) inliner (after) + /// CHECK-NOT: Mul - /// CHECK-START: int Main.$noinline$InlineCalleeWithSpecialCaseForZeroInt(int) dead_code_elimination$after_gvn (after) - /// CHECK-DAG: <<Param:i\d+>> ParameterValue - /// CHECK-DAG: <<Const6:i\d+>> IntConstant 6 - /// CHECK-DAG: Return [<<Param>>] - /// CHECK-DAG: Return [<<Const6>>] - private static int $noinline$InlineCalleeWithSpecialCaseForZeroInt(int value) { + /// CHECK-START: int Main.$noinline$InlineCaleeWithSpecialCaseForZeroInt(int) inliner (after) + /// CHECK-DAG: <<Const:i\d+>> IntConstant 6 + /// CHECK-DAG: Return [<<Const>>] + private static int $noinline$InlineCaleeWithSpecialCaseForZeroInt(int value) { if (value == 0) { return $inline$SpecialCaseForZeroInt(value); } return value; } - /// CHECK-START: long Main.$noinline$InlineCalleeWithSpecialCaseForZeroLong(long) constant_folding$after_gvn (before) - /// CHECK-DAG: Add - /// CHECK-DAG: Shl - /// CHECK-DAG: Add - - /// CHECK-START: long Main.$noinline$InlineCalleeWithSpecialCaseForZeroLong(long) constant_folding$after_gvn (after) + /// CHECK-START: long Main.$noinline$InlineCaleeWithSpecialCaseForZeroLong(long) inliner (after) /// CHECK-NOT: Add - /// CHECK-START: long Main.$noinline$InlineCalleeWithSpecialCaseForZeroLong(long) constant_folding$after_gvn (after) - /// CHECK-NOT: Shl + /// CHECK-START: long Main.$noinline$InlineCaleeWithSpecialCaseForZeroLong(long) inliner (after) + /// CHECK-NOT: Mul - /// CHECK-START: long Main.$noinline$InlineCalleeWithSpecialCaseForZeroLong(long) dead_code_elimination$after_gvn (after) - /// CHECK-DAG: <<Param:j\d+>> ParameterValue - /// CHECK-DAG: <<Const6:j\d+>> LongConstant 6 - /// CHECK-DAG: Return [<<Param>>] - /// CHECK-DAG: Return [<<Const6>>] - private static long $noinline$InlineCalleeWithSpecialCaseForZeroLong(long value) { + /// CHECK-START: long Main.$noinline$InlineCaleeWithSpecialCaseForZeroLong(long) inliner (after) + /// CHECK-DAG: <<Const:j\d+>> LongConstant 6 + /// CHECK-DAG: Return [<<Const>>] + private static long $noinline$InlineCaleeWithSpecialCaseForZeroLong(long value) { if (value == 0L) { return $inline$SpecialCaseForZeroLong(value); } @@ -1754,11 +1738,11 @@ public class Main { // Check that don't propagate the value == 3 on `if not true` branch, as the `if true` branch also // flows into the same block. - /// CHECK-START: int Main.$noinline$NotEqualsImplicitElseInt(int) constant_folding$after_gvn (before) + /// CHECK-START: int Main.$noinline$NotEqualsImplicitElseInt(int) constant_folding (before) /// CHECK-DAG: Add /// CHECK-DAG: Div - /// CHECK-START: int Main.$noinline$NotEqualsImplicitElseInt(int) constant_folding$after_gvn (after) + /// CHECK-START: int Main.$noinline$NotEqualsImplicitElseInt(int) constant_folding (after) /// CHECK-DAG: Add /// CHECK-DAG: Div private static int $noinline$NotEqualsImplicitElseInt(int value) { @@ -1768,11 +1752,11 @@ public class Main { return (value - 1) / 2; } - /// CHECK-START: long Main.$noinline$NotEqualsImplicitElseLong(long) constant_folding$after_gvn (before) + /// CHECK-START: long Main.$noinline$NotEqualsImplicitElseLong(long) constant_folding (before) /// CHECK-DAG: Sub /// CHECK-DAG: Div - /// CHECK-START: long Main.$noinline$NotEqualsImplicitElseLong(long) constant_folding$after_gvn (after) + /// CHECK-START: long Main.$noinline$NotEqualsImplicitElseLong(long) constant_folding (after) /// CHECK-DAG: Sub /// CHECK-DAG: Div private static long $noinline$NotEqualsImplicitElseLong(long value) { @@ -1782,13 +1766,13 @@ public class Main { return (value - 1L) / 2L; } - /// CHECK-START: float Main.$noinline$NotEqualsImplicitElseFloat(float) constant_folding$after_gvn (before) + /// CHECK-START: float Main.$noinline$NotEqualsImplicitElseFloat(float) constant_folding (before) /// CHECK-DAG: Sub - /// CHECK-DAG: Mul + /// CHECK-DAG: Div - /// CHECK-START: float Main.$noinline$NotEqualsImplicitElseFloat(float) constant_folding$after_gvn (after) + /// CHECK-START: float Main.$noinline$NotEqualsImplicitElseFloat(float) constant_folding (after) /// CHECK-DAG: Sub - /// CHECK-DAG: Mul + /// CHECK-DAG: Div private static float $noinline$NotEqualsImplicitElseFloat(float value) { if (value != 3F) { value += 1F; @@ -1796,13 +1780,13 @@ public class Main { return (value - 1F) / 2F; } - /// CHECK-START: double Main.$noinline$NotEqualsImplicitElseDouble(double) constant_folding$after_gvn (before) + /// CHECK-START: double Main.$noinline$NotEqualsImplicitElseDouble(double) constant_folding (before) /// CHECK-DAG: Sub - /// CHECK-DAG: Mul + /// CHECK-DAG: Div - /// CHECK-START: double Main.$noinline$NotEqualsImplicitElseDouble(double) constant_folding$after_gvn (after) + /// CHECK-START: double Main.$noinline$NotEqualsImplicitElseDouble(double) constant_folding (after) /// CHECK-DAG: Sub - /// CHECK-DAG: Mul + /// CHECK-DAG: Div private static double $noinline$NotEqualsImplicitElseDouble(double value) { if (value != 3D) { value += 1D; @@ -1810,39 +1794,37 @@ public class Main { return (value - 1D) / 2D; } - // By propagating the boolean we can eliminate some equality comparisons as we already know their + // By propagating the boolean we can elimniate some equality comparisons as we already know their // result. In turn, we also enable DeadCodeElimination to eliminate more code. - /// CHECK-START: int Main.$noinline$PropagatingParameterValue(boolean, int) constant_folding$after_gvn (before) - /// CHECK-DAG: <<Param:z\d+>> ParameterValue - /// CHECK-DAG: Select [{{i\d+}},{{i\d+}},<<Param>>] - /// CHECK-DAG: Select [{{i\d+}},{{i\d+}},<<Param>>] + /// CHECK-START: int Main.$noinline$PropagatingParameterValue(boolean) constant_folding (before) + /// CHECK-DAG: Equal + /// CHECK-DAG: Equal + /// CHECK-DAG: Equal - /// CHECK-START: int Main.$noinline$PropagatingParameterValue(boolean, int) constant_folding$after_gvn (after) - /// CHECK-DAG: <<Const0:i\d+>> IntConstant 0 - /// CHECK-DAG: <<Const1:i\d+>> IntConstant 1 - /// CHECK-DAG: Select [{{i\d+}},{{i\d+}},<<Const0>>] - /// CHECK-DAG: Select [{{i\d+}},{{i\d+}},<<Const1>>] + /// CHECK-START: int Main.$noinline$PropagatingParameterValue(boolean) constant_folding (after) + /// CHECK: Equal + /// CHECK-NOT: Equal - /// CHECK-START: int Main.$noinline$PropagatingParameterValue(boolean, int) dead_code_elimination$after_gvn (before) + /// CHECK-START: int Main.$noinline$PropagatingParameterValue(boolean) dead_code_elimination$initial (before) /// CHECK-DAG: IntConstant 1 /// CHECK-DAG: IntConstant 2 /// CHECK-DAG: IntConstant 3 /// CHECK-DAG: IntConstant 4 - /// CHECK-START: int Main.$noinline$PropagatingParameterValue(boolean, int) dead_code_elimination$after_gvn (after) + /// CHECK-START: int Main.$noinline$PropagatingParameterValue(boolean) dead_code_elimination$initial (after) /// CHECK-DAG: IntConstant 1 /// CHECK-DAG: IntConstant 4 - /// CHECK-START: int Main.$noinline$PropagatingParameterValue(boolean, int) dead_code_elimination$after_gvn (after) + /// CHECK-START: int Main.$noinline$PropagatingParameterValue(boolean) dead_code_elimination$initial (after) /// CHECK-NOT: IntConstant 2 - /// CHECK-START: int Main.$noinline$PropagatingParameterValue(boolean, int) dead_code_elimination$after_gvn (after) + /// CHECK-START: int Main.$noinline$PropagatingParameterValue(boolean) dead_code_elimination$initial (after) /// CHECK-NOT: IntConstant 3 - private static int $noinline$PropagatingParameterValue(boolean value, int initial_value) { + private static int $noinline$PropagatingParameterValue(boolean value) { if (value) { - return value ? initial_value + 1 : initial_value + 2; + return value ? 1 : 2; } else { - return value ? initial_value + 3 : initial_value + 4; + return value ? 3 : 4; } } @@ -1980,7 +1962,7 @@ public class Main { // Tests for propagating known values due to if clauses. // Propagating within the same method. These are marked $inline$ since we used them in - // `InlineCalleeWithSpecialCaseForZeroInt`. + // `InlineCaleeWithSpecialCaseForZeroInt`. assertIntEquals(6, $inline$SpecialCaseForZeroInt(0)); assertIntEquals(3, $inline$SpecialCaseForZeroInt(3)); assertLongEquals(6L, $inline$SpecialCaseForZeroLong(0L)); @@ -2003,10 +1985,10 @@ public class Main { assertDoubleEquals(1D, $noinline$NotEqualsPropagationDouble(3D)); // Propagating so that the inliner can use it. - assertIntEquals(6, $noinline$InlineCalleeWithSpecialCaseForZeroInt(0)); - assertIntEquals(3, $noinline$InlineCalleeWithSpecialCaseForZeroInt(3)); - assertLongEquals(6L, $noinline$InlineCalleeWithSpecialCaseForZeroLong(0L)); - assertLongEquals(3L, $noinline$InlineCalleeWithSpecialCaseForZeroLong(3L)); + assertIntEquals(6, $noinline$InlineCaleeWithSpecialCaseForZeroInt(0)); + assertIntEquals(3, $noinline$InlineCaleeWithSpecialCaseForZeroInt(3)); + assertLongEquals(6L, $noinline$InlineCaleeWithSpecialCaseForZeroLong(0L)); + assertLongEquals(3L, $noinline$InlineCaleeWithSpecialCaseForZeroLong(3L)); // Propagating within the same method, with not equals assertIntEquals(0, $noinline$NotEqualsImplicitElseInt(0)); @@ -2019,8 +2001,8 @@ public class Main { assertDoubleEquals(1D, $noinline$NotEqualsImplicitElseDouble(3D)); // Propagating parameters. - assertIntEquals(1, $noinline$PropagatingParameterValue(true, 0)); - assertIntEquals(4, $noinline$PropagatingParameterValue(false, 0)); + assertIntEquals(1, $noinline$PropagatingParameterValue(true)); + assertIntEquals(4, $noinline$PropagatingParameterValue(false)); } Main() throws ClassNotFoundException { diff --git a/test/485-checker-dce-loop-update/smali/TestCase.smali b/test/485-checker-dce-loop-update/smali/TestCase.smali index 5290bad3ed..3e7bca93c9 100644 --- a/test/485-checker-dce-loop-update/smali/TestCase.smali +++ b/test/485-checker-dce-loop-update/smali/TestCase.smali @@ -224,7 +224,7 @@ ## CHECK-DAG: If [<<ArgY>>] loop:<<HeaderY>> # # ### Inner loop ### -## CHECK-DAG: <<PhiZ2:i\d+>> Phi [<<PhiZ1>>,<<XorZ>>] loop:<<HeaderZ:B\d+>> +## CHECK-DAG: <<PhiZ2:i\d+>> Phi [<<PhiZ1>>,<<Cst0>>] loop:<<HeaderZ:B\d+>> ## CHECK-DAG: <<XorZ>> Xor [<<PhiZ2>>,<<Cst1>>] loop:<<HeaderZ>> ## CHECK-DAG: <<CondZ:z\d+>> Equal [<<XorZ>>,<<Cst0>>] loop:<<HeaderZ>> ## CHECK-DAG: If [<<CondZ>>] loop:<<HeaderZ>> @@ -246,8 +246,8 @@ ## CHECK-DAG: <<Add7>> Add [<<PhiX>>,<<Cst7>>] loop:<<HeaderY>> # # ### Inner loop ### -## CHECK-DAG: <<PhiZ:i\d+>> Phi [<<ArgZ>>,<<XorZ:i\d+>>] loop:<<HeaderZ:B\d+>> -## CHECK-DAG: <<XorZ>> Xor [<<PhiZ>>,<<Cst1>>] loop:<<HeaderZ>> +## CHECK-DAG: <<PhiZ:i\d+>> Phi [<<ArgZ>>,<<Cst0>>] loop:<<HeaderZ:B\d+>> +## CHECK-DAG: <<XorZ:i\d+>> Xor [<<PhiZ>>,<<Cst1>>] loop:<<HeaderZ>> ## CHECK-DAG: <<CondZ:z\d+>> Equal [<<XorZ>>,<<Cst0>>] loop:<<HeaderZ>> ## CHECK-DAG: If [<<CondZ>>] loop:<<HeaderZ>> # diff --git a/test/543-checker-dce-trycatch/smali/TestCase.smali b/test/543-checker-dce-trycatch/smali/TestCase.smali index 7ad9ba8e64..15eaabbc04 100644 --- a/test/543-checker-dce-trycatch/smali/TestCase.smali +++ b/test/543-checker-dce-trycatch/smali/TestCase.smali @@ -206,6 +206,7 @@ ## CHECK-START: int TestCase.testCatchPhiInputs_DefinedInTryBlock(int, int, int, int) dead_code_elimination$after_inlining (before) ## CHECK-DAG: <<Arg0:i\d+>> ParameterValue ## CHECK-DAG: <<Arg1:i\d+>> ParameterValue +## CHECK-DAG: <<Const0x0:i\d+>> IntConstant 0 ## CHECK-DAG: <<Const0xa:i\d+>> IntConstant 10 ## CHECK-DAG: <<Const0xb:i\d+>> IntConstant 11 ## CHECK-DAG: <<Const0xc:i\d+>> IntConstant 12 @@ -215,7 +216,7 @@ ## CHECK-DAG: <<Const0x10:i\d+>> IntConstant 16 ## CHECK-DAG: <<Const0x11:i\d+>> IntConstant 17 ## CHECK-DAG: <<Add:i\d+>> Add [<<Arg0>>,<<Arg1>>] -## CHECK-DAG: <<Phi:i\d+>> Phi [<<Add>>,<<Const0xf>>] reg:3 is_catch_phi:false +## CHECK-DAG: <<Phi:i\d+>> Phi [<<Const0x0>>,<<Const0xf>>] reg:3 is_catch_phi:false ## CHECK-DAG: Phi [<<Const0xa>>,<<Const0xb>>,<<Const0xd>>] reg:1 is_catch_phi:true ## CHECK-DAG: Phi [<<Add>>,<<Const0xc>>,<<Const0xe>>] reg:2 is_catch_phi:true ## CHECK-DAG: Phi [<<Phi>>,<<Const0x10>>,<<Const0x11>>] reg:3 is_catch_phi:true @@ -248,7 +249,8 @@ if-eqz v3, :define_phi const v3, 0xf :define_phi - # v3 = Phi [Add, 0xf] # dead catch phi input, defined in the dead block (HPhi) + # v3 = Phi [Add, 0xf] # dead catch phi input, defined in the dead block (HPhi). + # Note that the Add has to be equal to 0 since we do `if-eqz v3` div-int/2addr p0, v2 :else |