< prev index next >

src/hotspot/share/opto/cfgnode.cpp

Print this page




   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "classfile/systemDictionary.hpp"

  27 #include "memory/allocation.inline.hpp"
  28 #include "memory/resourceArea.hpp"
  29 #include "oops/objArrayKlass.hpp"
  30 #include "opto/addnode.hpp"
  31 #include "opto/castnode.hpp"
  32 #include "opto/cfgnode.hpp"
  33 #include "opto/connode.hpp"
  34 #include "opto/convertnode.hpp"
  35 #include "opto/loopnode.hpp"
  36 #include "opto/machnode.hpp"
  37 #include "opto/movenode.hpp"
  38 #include "opto/narrowptrnode.hpp"
  39 #include "opto/mulnode.hpp"
  40 #include "opto/phaseX.hpp"
  41 #include "opto/regmask.hpp"
  42 #include "opto/runtime.hpp"
  43 #include "opto/subnode.hpp"
  44 #include "utilities/vmError.hpp"
  45 
  46 // Portions of code courtesy of Clifford Click


1430     flipped = 1-flipped;        // Test is vs 1 instead of 0!
1431   }
1432 
1433   // Check for setting zero/one opposite expected
1434   if( tzero == TypeInt::ZERO ) {
1435     if( tone == TypeInt::ONE ) {
1436     } else return NULL;
1437   } else if( tzero == TypeInt::ONE ) {
1438     if( tone == TypeInt::ZERO ) {
1439       flipped = 1-flipped;
1440     } else return NULL;
1441   } else return NULL;
1442 
1443   // Check for boolean test backwards
1444   if( b->_test._test == BoolTest::ne ) {
1445   } else if( b->_test._test == BoolTest::eq ) {
1446     flipped = 1-flipped;
1447   } else return NULL;
1448 
1449   // Build int->bool conversion
1450   Node *n = new Conv2BNode( cmp->in(1) );



1451   if( flipped )
1452     n = new XorINode( phase->transform(n), phase->intcon(1) );
1453 
1454   return n;
1455 }
1456 
1457 //------------------------------is_cond_add------------------------------------
1458 // Check for simple conditional add pattern:  "(P < Q) ? X+Y : X;"
1459 // To be profitable the control flow has to disappear; there can be no other
1460 // values merging here.  We replace the test-and-branch with:
1461 // "(sgn(P-Q))&Y) + X".  Basically, convert "(P < Q)" into 0 or -1 by
1462 // moving the carry bit from (P-Q) into a register with 'sbb EAX,EAX'.
1463 // Then convert Y to 0-or-Y and finally add.
1464 // This is a key transform for SpecJava _201_compress.
1465 static Node* is_cond_add(PhaseGVN *phase, PhiNode *phi, int true_path) {
1466   assert(true_path !=0, "only diamond shape graph expected");
1467 
1468   // is_diamond_phi() has guaranteed the correctness of the nodes sequence:
1469   // phi->region->if_proj->ifnode->bool->cmp
1470   RegionNode *region = (RegionNode*)phi->in(0);


1796   // No change for igvn if new phi is not hooked
1797   if (new_phi && can_reshape)
1798     return NULL;
1799 
1800   // The are 2 situations when only one valid phi's input is left
1801   // (in addition to Region input).
1802   // One: region is not loop - replace phi with this input.
1803   // Two: region is loop - replace phi with top since this data path is dead
1804   //                       and we need to break the dead data loop.
1805   Node* progress = NULL;        // Record if any progress made
1806   for( uint j = 1; j < req(); ++j ){ // For all paths in
1807     // Check unreachable control paths
1808     Node* rc = r->in(j);
1809     Node* n = in(j);            // Get the input
1810     if (rc == NULL || phase->type(rc) == Type::TOP) {
1811       if (n != top) {           // Not already top?
1812         PhaseIterGVN *igvn = phase->is_IterGVN();
1813         if (can_reshape && igvn != NULL) {
1814           igvn->_worklist.push(r);
1815         }
1816         set_req(j, top);        // Nuke it down





1817         progress = this;        // Record progress
1818       }
1819     }
1820   }
1821 
1822   if (can_reshape && outcnt() == 0) {
1823     // set_req() above may kill outputs if Phi is referenced
1824     // only by itself on the dead (top) control path.
1825     return top;
1826   }
1827 
1828   bool uncasted = false;
1829   Node* uin = unique_input(phase, false);
1830   if (uin == NULL && can_reshape) {
1831     uncasted = true;
1832     uin = unique_input(phase, true);
1833   }
1834   if (uin == top) {             // Simplest case: no alive inputs.
1835     if (can_reshape)            // IGVN transformation
1836       return top;




   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "classfile/systemDictionary.hpp"
  27 #include "gc/shared/c2/barrierSetC2.hpp"
  28 #include "memory/allocation.inline.hpp"
  29 #include "memory/resourceArea.hpp"
  30 #include "oops/objArrayKlass.hpp"
  31 #include "opto/addnode.hpp"
  32 #include "opto/castnode.hpp"
  33 #include "opto/cfgnode.hpp"
  34 #include "opto/connode.hpp"
  35 #include "opto/convertnode.hpp"
  36 #include "opto/loopnode.hpp"
  37 #include "opto/machnode.hpp"
  38 #include "opto/movenode.hpp"
  39 #include "opto/narrowptrnode.hpp"
  40 #include "opto/mulnode.hpp"
  41 #include "opto/phaseX.hpp"
  42 #include "opto/regmask.hpp"
  43 #include "opto/runtime.hpp"
  44 #include "opto/subnode.hpp"
  45 #include "utilities/vmError.hpp"
  46 
  47 // Portions of code courtesy of Clifford Click


1431     flipped = 1-flipped;        // Test is vs 1 instead of 0!
1432   }
1433 
1434   // Check for setting zero/one opposite expected
1435   if( tzero == TypeInt::ZERO ) {
1436     if( tone == TypeInt::ONE ) {
1437     } else return NULL;
1438   } else if( tzero == TypeInt::ONE ) {
1439     if( tone == TypeInt::ZERO ) {
1440       flipped = 1-flipped;
1441     } else return NULL;
1442   } else return NULL;
1443 
1444   // Check for boolean test backwards
1445   if( b->_test._test == BoolTest::ne ) {
1446   } else if( b->_test._test == BoolTest::eq ) {
1447     flipped = 1-flipped;
1448   } else return NULL;
1449 
1450   // Build int->bool conversion
1451   Node *in1 = cmp->in(1);
1452   BarrierSetC2* bs = BarrierSet::barrier_set()->barrier_set_c2();
1453   in1 = bs->step_over_gc_barrier(in1);
1454   Node *n = new Conv2BNode(in1);
1455   if( flipped )
1456     n = new XorINode( phase->transform(n), phase->intcon(1) );
1457 
1458   return n;
1459 }
1460 
1461 //------------------------------is_cond_add------------------------------------
1462 // Check for simple conditional add pattern:  "(P < Q) ? X+Y : X;"
1463 // To be profitable the control flow has to disappear; there can be no other
1464 // values merging here.  We replace the test-and-branch with:
1465 // "(sgn(P-Q))&Y) + X".  Basically, convert "(P < Q)" into 0 or -1 by
1466 // moving the carry bit from (P-Q) into a register with 'sbb EAX,EAX'.
1467 // Then convert Y to 0-or-Y and finally add.
1468 // This is a key transform for SpecJava _201_compress.
1469 static Node* is_cond_add(PhaseGVN *phase, PhiNode *phi, int true_path) {
1470   assert(true_path !=0, "only diamond shape graph expected");
1471 
1472   // is_diamond_phi() has guaranteed the correctness of the nodes sequence:
1473   // phi->region->if_proj->ifnode->bool->cmp
1474   RegionNode *region = (RegionNode*)phi->in(0);


1800   // No change for igvn if new phi is not hooked
1801   if (new_phi && can_reshape)
1802     return NULL;
1803 
1804   // The are 2 situations when only one valid phi's input is left
1805   // (in addition to Region input).
1806   // One: region is not loop - replace phi with this input.
1807   // Two: region is loop - replace phi with top since this data path is dead
1808   //                       and we need to break the dead data loop.
1809   Node* progress = NULL;        // Record if any progress made
1810   for( uint j = 1; j < req(); ++j ){ // For all paths in
1811     // Check unreachable control paths
1812     Node* rc = r->in(j);
1813     Node* n = in(j);            // Get the input
1814     if (rc == NULL || phase->type(rc) == Type::TOP) {
1815       if (n != top) {           // Not already top?
1816         PhaseIterGVN *igvn = phase->is_IterGVN();
1817         if (can_reshape && igvn != NULL) {
1818           igvn->_worklist.push(r);
1819         }
1820         // Nuke it down
1821         if (can_reshape) {
1822           set_req_X(j, top, igvn);
1823         } else {
1824           set_req(j, top);
1825         }
1826         progress = this;        // Record progress
1827       }
1828     }
1829   }
1830 
1831   if (can_reshape && outcnt() == 0) {
1832     // set_req() above may kill outputs if Phi is referenced
1833     // only by itself on the dead (top) control path.
1834     return top;
1835   }
1836 
1837   bool uncasted = false;
1838   Node* uin = unique_input(phase, false);
1839   if (uin == NULL && can_reshape) {
1840     uncasted = true;
1841     uin = unique_input(phase, true);
1842   }
1843   if (uin == top) {             // Simplest case: no alive inputs.
1844     if (can_reshape)            // IGVN transformation
1845       return top;


< prev index next >