src/share/vm/opto/mulnode.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File 7069452 Sdiff src/share/vm/opto

src/share/vm/opto/mulnode.cpp

Print this page




  81   if( t2->singleton() &&        // Right input is a constant?
  82       op != Op_MulF &&          // Float & double cannot reassociate
  83       op != Op_MulD ) {
  84     if( t2 == Type::TOP ) return NULL;
  85     Node *mul1 = in(1);
  86 #ifdef ASSERT
  87     // Check for dead loop
  88     int   op1 = mul1->Opcode();
  89     if( phase->eqv( mul1, this ) || phase->eqv( in(2), this ) ||
  90         ( op1 == mul_opcode() || op1 == add_opcode() ) &&
  91         ( phase->eqv( mul1->in(1), this ) || phase->eqv( mul1->in(2), this ) ||
  92           phase->eqv( mul1->in(1), mul1 ) || phase->eqv( mul1->in(2), mul1 ) ) )
  93       assert(false, "dead loop in MulNode::Ideal");
  94 #endif
  95 
  96     if( mul1->Opcode() == mul_opcode() ) {  // Left input is a multiply?
  97       // Mul of a constant?
  98       const Type *t12 = phase->type( mul1->in(2) );
  99       if( t12->singleton() && t12 != Type::TOP) { // Left input is an add of a constant?
 100         // Compute new constant; check for overflow
 101         const Type *tcon01 = mul1->as_Mul()->mul_ring(t2,t12);
 102         if( tcon01->singleton() ) {
 103           // The Mul of the flattened expression
 104           set_req(1, mul1->in(1));
 105           set_req(2, phase->makecon( tcon01 ));
 106           t2 = tcon01;
 107           progress = this;      // Made progress
 108         }
 109       }
 110     }
 111     // If the right input is a constant, and the left input is an add of a
 112     // constant, flatten the tree: (X+con1)*con0 ==> X*con0 + con1*con0
 113     const Node *add1 = in(1);
 114     if( add1->Opcode() == add_opcode() ) {      // Left input is an add?
 115       // Add of a constant?
 116       const Type *t12 = phase->type( add1->in(2) );
 117       if( t12->singleton() && t12 != Type::TOP ) { // Left input is an add of a constant?
 118         assert( add1->in(1) != add1, "dead loop in MulNode::Ideal" );
 119         // Compute new constant; check for overflow
 120         const Type *tcon01 = mul_ring(t2,t12);
 121         if( tcon01->singleton() ) {




  81   if( t2->singleton() &&        // Right input is a constant?
  82       op != Op_MulF &&          // Float & double cannot reassociate
  83       op != Op_MulD ) {
  84     if( t2 == Type::TOP ) return NULL;
  85     Node *mul1 = in(1);
  86 #ifdef ASSERT
  87     // Check for dead loop
  88     int   op1 = mul1->Opcode();
  89     if( phase->eqv( mul1, this ) || phase->eqv( in(2), this ) ||
  90         ( op1 == mul_opcode() || op1 == add_opcode() ) &&
  91         ( phase->eqv( mul1->in(1), this ) || phase->eqv( mul1->in(2), this ) ||
  92           phase->eqv( mul1->in(1), mul1 ) || phase->eqv( mul1->in(2), mul1 ) ) )
  93       assert(false, "dead loop in MulNode::Ideal");
  94 #endif
  95 
  96     if( mul1->Opcode() == mul_opcode() ) {  // Left input is a multiply?
  97       // Mul of a constant?
  98       const Type *t12 = phase->type( mul1->in(2) );
  99       if( t12->singleton() && t12 != Type::TOP) { // Left input is an add of a constant?
 100         // Compute new constant; check for overflow
 101         const Type *tcon01 = ((MulNode*)mul1)->mul_ring(t2,t12);
 102         if( tcon01->singleton() ) {
 103           // The Mul of the flattened expression
 104           set_req(1, mul1->in(1));
 105           set_req(2, phase->makecon( tcon01 ));
 106           t2 = tcon01;
 107           progress = this;      // Made progress
 108         }
 109       }
 110     }
 111     // If the right input is a constant, and the left input is an add of a
 112     // constant, flatten the tree: (X+con1)*con0 ==> X*con0 + con1*con0
 113     const Node *add1 = in(1);
 114     if( add1->Opcode() == add_opcode() ) {      // Left input is an add?
 115       // Add of a constant?
 116       const Type *t12 = phase->type( add1->in(2) );
 117       if( t12->singleton() && t12 != Type::TOP ) { // Left input is an add of a constant?
 118         assert( add1->in(1) != add1, "dead loop in MulNode::Ideal" );
 119         // Compute new constant; check for overflow
 120         const Type *tcon01 = mul_ring(t2,t12);
 121         if( tcon01->singleton() ) {


src/share/vm/opto/mulnode.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File