@@ -239,18 +239,18 @@ MulNode* MulNode::make(Node* in1, Node* in2, BasicType bt) {
239
239
// ------------------------------Ideal------------------------------------------
240
240
// Check for power-of-2 multiply, then try the regular MulNode::Ideal
241
241
Node *MulINode::Ideal (PhaseGVN *phase, bool can_reshape) {
242
- // Swap constant to right
243
- jint con;
244
- if ((con = in (1 )->find_int_con (0 )) != 0 ) {
245
- swap_edges (1 , 2 );
246
- // Finish rest of method to use info in 'con'
247
- } else if ((con = in (2 )->find_int_con (0 )) == 0 ) {
242
+ const jint con = in (2 )->find_int_con (0 );
243
+ if (con == 0 ) {
244
+ // If in(2) is not a constant, call Ideal() of the parent class to
245
+ // try to move constant to the right side.
248
246
return MulNode::Ideal (phase, can_reshape);
249
247
}
250
248
251
- // Now we have a constant Node on the right and the constant in con
252
- if (con == 0 ) return NULL ; // By zero is handled by Value call
253
- if (con == 1 ) return NULL ; // By one is handled by Identity call
249
+ // Now we have a constant Node on the right and the constant in con.
250
+ if (con == 1 ) {
251
+ // By one is handled by Identity call
252
+ return NULL ;
253
+ }
254
254
255
255
// Check for negative constant; if so negate the final result
256
256
bool sign_flip = false ;
@@ -262,7 +262,7 @@ Node *MulINode::Ideal(PhaseGVN *phase, bool can_reshape) {
262
262
263
263
// Get low bit; check for being the only bit
264
264
Node *res = NULL ;
265
- unsigned int bit1 = abs_con & ( 0 - abs_con); // Extract low bit
265
+ unsigned int bit1 = submultiple_power_of_2 ( abs_con);
266
266
if (bit1 == abs_con) { // Found a power of 2?
267
267
res = new LShiftINode (in (1 ), phase->intcon (log2i_exact (bit1)));
268
268
} else {
@@ -334,18 +334,18 @@ const Type *MulINode::mul_ring(const Type *t0, const Type *t1) const {
334
334
// ------------------------------Ideal------------------------------------------
335
335
// Check for power-of-2 multiply, then try the regular MulNode::Ideal
336
336
Node *MulLNode::Ideal (PhaseGVN *phase, bool can_reshape) {
337
- // Swap constant to right
338
- jlong con;
339
- if ((con = in (1 )->find_long_con (0 )) != 0 ) {
340
- swap_edges (1 , 2 );
341
- // Finish rest of method to use info in 'con'
342
- } else if ((con = in (2 )->find_long_con (0 )) == 0 ) {
337
+ const jlong con = in (2 )->find_long_con (0 );
338
+ if (con == 0 ) {
339
+ // If in(2) is not a constant, call Ideal() of the parent class to
340
+ // try to move constant to the right side.
343
341
return MulNode::Ideal (phase, can_reshape);
344
342
}
345
343
346
- // Now we have a constant Node on the right and the constant in con
347
- if (con == CONST64 (0 )) return NULL ; // By zero is handled by Value call
348
- if (con == CONST64 (1 )) return NULL ; // By one is handled by Identity call
344
+ // Now we have a constant Node on the right and the constant in con.
345
+ if (con == 1 ) {
346
+ // By one is handled by Identity call
347
+ return NULL ;
348
+ }
349
349
350
350
// Check for negative constant; if so negate the final result
351
351
bool sign_flip = false ;
@@ -356,7 +356,7 @@ Node *MulLNode::Ideal(PhaseGVN *phase, bool can_reshape) {
356
356
357
357
// Get low bit; check for being the only bit
358
358
Node *res = NULL ;
359
- julong bit1 = abs_con & ( 0 - abs_con); // Extract low bit
359
+ julong bit1 = submultiple_power_of_2 ( abs_con);
360
360
if (bit1 == abs_con) { // Found a power of 2?
361
361
res = new LShiftLNode (in (1 ), phase->intcon (log2i_exact (bit1)));
362
362
} else {
0 commit comments