58 import jdk.vm.ci.meta.MetaAccessProvider;
59
60 public class DefaultLoopPolicies implements LoopPolicies {
61
62 public static class Options {
63 @Option(help = "", type = OptionType.Expert) public static final OptionKey<Integer> LoopUnswitchMaxIncrease = new OptionKey<>(500);
64 @Option(help = "", type = OptionType.Expert) public static final OptionKey<Integer> LoopUnswitchTrivial = new OptionKey<>(10);
65 @Option(help = "", type = OptionType.Expert) public static final OptionKey<Double> LoopUnswitchFrequencyBoost = new OptionKey<>(10.0);
66
67 @Option(help = "", type = OptionType.Expert) public static final OptionKey<Integer> FullUnrollMaxNodes = new OptionKey<>(300);
68 @Option(help = "", type = OptionType.Expert) public static final OptionKey<Integer> FullUnrollMaxIterations = new OptionKey<>(600);
69 @Option(help = "", type = OptionType.Expert) public static final OptionKey<Integer> ExactFullUnrollMaxNodes = new OptionKey<>(1200);
70 @Option(help = "", type = OptionType.Expert) public static final OptionKey<Integer> ExactPartialUnrollMaxNodes = new OptionKey<>(200);
71
72 @Option(help = "", type = OptionType.Expert) public static final OptionKey<Integer> UnrollMaxIterations = new OptionKey<>(16);
73 }
74
75 @Override
76 public boolean shouldPeel(LoopEx loop, ControlFlowGraph cfg, MetaAccessProvider metaAccess) {
77 LoopBeginNode loopBegin = loop.loopBegin();
78 double entryProbability = cfg.blockFor(loopBegin.forwardEnd()).probability();
79 OptionValues options = cfg.graph.getOptions();
80 if (entryProbability > MinimumPeelProbability.getValue(options) && loop.size() + loopBegin.graph().getNodeCount() < MaximumDesiredSize.getValue(options)) {
81 // check whether we're allowed to peel this loop
82 return loop.canDuplicateLoop();
83 } else {
84 return false;
85 }
86 }
87
88 @Override
89 public boolean shouldFullUnroll(LoopEx loop) {
90 if (!loop.isCounted() || !loop.counted().isConstantMaxTripCount()) {
91 return false;
92 }
93 OptionValues options = loop.entryPoint().getOptions();
94 CountedLoopInfo counted = loop.counted();
95 UnsignedLong maxTrips = counted.constantMaxTripCount();
96 if (maxTrips.equals(0)) {
97 return loop.canDuplicateLoop();
98 }
|
58 import jdk.vm.ci.meta.MetaAccessProvider;
59
60 public class DefaultLoopPolicies implements LoopPolicies {
61
62 public static class Options {
63 @Option(help = "", type = OptionType.Expert) public static final OptionKey<Integer> LoopUnswitchMaxIncrease = new OptionKey<>(500);
64 @Option(help = "", type = OptionType.Expert) public static final OptionKey<Integer> LoopUnswitchTrivial = new OptionKey<>(10);
65 @Option(help = "", type = OptionType.Expert) public static final OptionKey<Double> LoopUnswitchFrequencyBoost = new OptionKey<>(10.0);
66
67 @Option(help = "", type = OptionType.Expert) public static final OptionKey<Integer> FullUnrollMaxNodes = new OptionKey<>(300);
68 @Option(help = "", type = OptionType.Expert) public static final OptionKey<Integer> FullUnrollMaxIterations = new OptionKey<>(600);
69 @Option(help = "", type = OptionType.Expert) public static final OptionKey<Integer> ExactFullUnrollMaxNodes = new OptionKey<>(1200);
70 @Option(help = "", type = OptionType.Expert) public static final OptionKey<Integer> ExactPartialUnrollMaxNodes = new OptionKey<>(200);
71
72 @Option(help = "", type = OptionType.Expert) public static final OptionKey<Integer> UnrollMaxIterations = new OptionKey<>(16);
73 }
74
75 @Override
76 public boolean shouldPeel(LoopEx loop, ControlFlowGraph cfg, MetaAccessProvider metaAccess) {
77 LoopBeginNode loopBegin = loop.loopBegin();
78 double entryProbability = cfg.blockFor(loopBegin.forwardEnd()).getRelativeFrequency();
79 OptionValues options = cfg.graph.getOptions();
80 if (entryProbability > MinimumPeelProbability.getValue(options) && loop.size() + loopBegin.graph().getNodeCount() < MaximumDesiredSize.getValue(options)) {
81 // check whether we're allowed to peel this loop
82 return loop.canDuplicateLoop();
83 } else {
84 return false;
85 }
86 }
87
88 @Override
89 public boolean shouldFullUnroll(LoopEx loop) {
90 if (!loop.isCounted() || !loop.counted().isConstantMaxTripCount()) {
91 return false;
92 }
93 OptionValues options = loop.entryPoint().getOptions();
94 CountedLoopInfo counted = loop.counted();
95 UnsignedLong maxTrips = counted.constantMaxTripCount();
96 if (maxTrips.equals(0)) {
97 return loop.canDuplicateLoop();
98 }
|