< prev index next >

src/hotspot/share/opto/cfgnode.cpp

Print this page




  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
  47 
  48 // Optimization - Graph Style
  49 
  50 //=============================================================================
  51 //------------------------------Value------------------------------------------
  52 // Compute the type of the RegionNode.
  53 const Type* RegionNode::Value(PhaseGVN* phase) const {
  54   for( uint i=1; i<req(); ++i ) {       // For all paths in
  55     Node *n = in(i);            // Get Control source
  56     if( !n ) continue;          // Missing inputs are TOP
  57     if( phase->type(n) == Type::CONTROL )
  58       return Type::CONTROL;
  59   }
  60   return Type::TOP;             // All paths dead?  Then so are we
  61 }
  62 
  63 //------------------------------Identity---------------------------------------
  64 // Check for Region being Identity.


1288       return NULL;
1289     flipped = 1-flipped;        // Test is vs 1 instead of 0!
1290   }
1291 
1292   // Check for setting zero/one opposite expected
1293   if( tzero == TypeInt::ZERO ) {
1294     if( tone == TypeInt::ONE ) {
1295     } else return NULL;
1296   } else if( tzero == TypeInt::ONE ) {
1297     if( tone == TypeInt::ZERO ) {
1298       flipped = 1-flipped;
1299     } else return NULL;
1300   } else return NULL;
1301 
1302   // Check for boolean test backwards
1303   if( b->_test._test == BoolTest::ne ) {
1304   } else if( b->_test._test == BoolTest::eq ) {
1305     flipped = 1-flipped;
1306   } else return NULL;
1307 
1308   // Build int->bool conversion
1309   Node *n = new Conv2BNode( cmp->in(1) );
1310   if( flipped )
1311     n = new XorINode( phase->transform(n), phase->intcon(1) );
1312 
1313   return n;
1314 }
1315 
1316 //------------------------------is_cond_add------------------------------------
1317 // Check for simple conditional add pattern:  "(P < Q) ? X+Y : X;"
1318 // To be profitable the control flow has to disappear; there can be no other
1319 // values merging here.  We replace the test-and-branch with:
1320 // "(sgn(P-Q))&Y) + X".  Basically, convert "(P < Q)" into 0 or -1 by
1321 // moving the carry bit from (P-Q) into a register with 'sbb EAX,EAX'.
1322 // Then convert Y to 0-or-Y and finally add.
1323 // This is a key transform for SpecJava _201_compress.
1324 static Node* is_cond_add(PhaseGVN *phase, PhiNode *phi, int true_path) {
1325   assert(true_path !=0, "only diamond shape graph expected");
1326 
1327   // is_diamond_phi() has guaranteed the correctness of the nodes sequence:
1328   // phi->region->if_proj->ifnode->bool->cmp
1329   RegionNode *region = (RegionNode*)phi->in(0);




  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 #include "utilities/macros.hpp"
  46 #if INCLUDE_SHENANDOAHGC
  47 #include "gc/shenandoah/c2/shenandoahBarrierSetC2.hpp"
  48 #endif
  49 
  50 // Portions of code courtesy of Clifford Click
  51 
  52 // Optimization - Graph Style
  53 
  54 //=============================================================================
  55 //------------------------------Value------------------------------------------
  56 // Compute the type of the RegionNode.
  57 const Type* RegionNode::Value(PhaseGVN* phase) const {
  58   for( uint i=1; i<req(); ++i ) {       // For all paths in
  59     Node *n = in(i);            // Get Control source
  60     if( !n ) continue;          // Missing inputs are TOP
  61     if( phase->type(n) == Type::CONTROL )
  62       return Type::CONTROL;
  63   }
  64   return Type::TOP;             // All paths dead?  Then so are we
  65 }
  66 
  67 //------------------------------Identity---------------------------------------
  68 // Check for Region being Identity.


1292       return NULL;
1293     flipped = 1-flipped;        // Test is vs 1 instead of 0!
1294   }
1295 
1296   // Check for setting zero/one opposite expected
1297   if( tzero == TypeInt::ZERO ) {
1298     if( tone == TypeInt::ONE ) {
1299     } else return NULL;
1300   } else if( tzero == TypeInt::ONE ) {
1301     if( tone == TypeInt::ZERO ) {
1302       flipped = 1-flipped;
1303     } else return NULL;
1304   } else return NULL;
1305 
1306   // Check for boolean test backwards
1307   if( b->_test._test == BoolTest::ne ) {
1308   } else if( b->_test._test == BoolTest::eq ) {
1309     flipped = 1-flipped;
1310   } else return NULL;
1311 
1312   // Build int->bool concfgversion
1313   Node *n = new Conv2BNode(cmp->in(1));
1314   if( flipped )
1315     n = new XorINode( phase->transform(n), phase->intcon(1) );
1316 
1317   return n;
1318 }
1319 
1320 //------------------------------is_cond_add------------------------------------
1321 // Check for simple conditional add pattern:  "(P < Q) ? X+Y : X;"
1322 // To be profitable the control flow has to disappear; there can be no other
1323 // values merging here.  We replace the test-and-branch with:
1324 // "(sgn(P-Q))&Y) + X".  Basically, convert "(P < Q)" into 0 or -1 by
1325 // moving the carry bit from (P-Q) into a register with 'sbb EAX,EAX'.
1326 // Then convert Y to 0-or-Y and finally add.
1327 // This is a key transform for SpecJava _201_compress.
1328 static Node* is_cond_add(PhaseGVN *phase, PhiNode *phi, int true_path) {
1329   assert(true_path !=0, "only diamond shape graph expected");
1330 
1331   // is_diamond_phi() has guaranteed the correctness of the nodes sequence:
1332   // phi->region->if_proj->ifnode->bool->cmp
1333   RegionNode *region = (RegionNode*)phi->in(0);


< prev index next >