103 shouldFoldSwitch("remByPowerOf2NegativeX");
104 }
105
106 public int remByNonPowerOf2(int n) {
107 switch (n % 7) {
108 case 9:
109 return hashCode();
110 default:
111 return 1;
112 }
113 }
114
115 @Test
116 public void testRemByNonPowerOf2() {
117 shouldFoldSwitch("remByNonPowerOf2");
118 }
119
120 private void shouldFoldSwitch(String methodName) {
121 StructuredGraph graph = parseForCompile(getResolvedJavaMethod(methodName));
122 new CanonicalizerPhase().apply(graph, getDefaultHighTierContext());
123 assertFalse(graph.hasNode(IntegerSwitchNode.TYPE));
124 }
125
126 }
|
103 shouldFoldSwitch("remByPowerOf2NegativeX");
104 }
105
106 public int remByNonPowerOf2(int n) {
107 switch (n % 7) {
108 case 9:
109 return hashCode();
110 default:
111 return 1;
112 }
113 }
114
115 @Test
116 public void testRemByNonPowerOf2() {
117 shouldFoldSwitch("remByNonPowerOf2");
118 }
119
120 private void shouldFoldSwitch(String methodName) {
121 StructuredGraph graph = parseForCompile(getResolvedJavaMethod(methodName));
122 new CanonicalizerPhase().apply(graph, getDefaultHighTierContext());
123 assertTrue(graph.getNodes().filter(IntegerSwitchNode.class).isEmpty());
124 }
125
126 }
|