src/share/vm/opto/mulnode.hpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File hotspot Sdiff src/share/vm/opto

src/share/vm/opto/mulnode.hpp

Print this page
rev 10222 : 8149745: C2 should optimize long accumulations in a counted loop
summary: Look for parallel iv for long adds
Reviewed-by:


  24 
  25 #ifndef SHARE_VM_OPTO_MULNODE_HPP
  26 #define SHARE_VM_OPTO_MULNODE_HPP
  27 
  28 #include "opto/node.hpp"
  29 #include "opto/opcodes.hpp"
  30 #include "opto/type.hpp"
  31 
  32 // Portions of code courtesy of Clifford Click
  33 
  34 class PhaseTransform;
  35 
  36 //------------------------------MulNode----------------------------------------
  37 // Classic MULTIPLY functionality.  This covers all the usual 'multiply'
  38 // behaviors for an algebraic ring.  Multiply-integer, multiply-float,
  39 // multiply-double, and binary-and are all inherited from this class.  The
  40 // various identity values are supplied by virtual functions.
  41 class MulNode : public Node {
  42   virtual uint hash() const;
  43 public:
  44   MulNode( Node *in1, Node *in2 ): Node(0,in1,in2) {
  45     init_class_id(Class_Mul);
  46   }
  47 
  48   // Handle algebraic identities here.  If we have an identity, return the Node
  49   // we are equivalent to.  We look for "add of zero" as an identity.
  50   virtual Node* Identity(PhaseGVN* phase);
  51 
  52   // We also canonicalize the Node, moving constants to the right input,
  53   // and flatten expressions (so that 1+x+2 becomes x+3).
  54   virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
  55 
  56   // Compute a new Type for this node.  Basically we just do the pre-check,
  57   // then call the virtual add() to set the type.
  58   virtual const Type* Value(PhaseGVN* phase) const;
  59 
  60   // Supplied function returns the product of the inputs.
  61   // This also type-checks the inputs for sanity.  Guaranteed never to
  62   // be passed a TOP or BOTTOM type, these are filtered out by a pre-check.
  63   // This call recognizes the multiplicative zero type.
  64   virtual const Type *mul_ring( const Type *, const Type * ) const = 0;
  65 
  66   // Supplied function to return the multiplicative identity type
  67   virtual const Type *mul_id() const = 0;
  68 
  69   // Supplied function to return the additive identity type
  70   virtual const Type *add_id() const = 0;
  71 
  72   // Supplied function to return the additive opcode
  73   virtual int add_opcode() const = 0;
  74 
  75   // Supplied function to return the multiplicative opcode
  76   virtual int mul_opcode() const = 0;
  77 

  78 };
  79 
  80 //------------------------------MulINode---------------------------------------
  81 // Multiply 2 integers
  82 class MulINode : public MulNode {
  83 public:
  84   MulINode( Node *in1, Node *in2 ) : MulNode(in1,in2) {}
  85   virtual int Opcode() const;
  86   virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
  87   virtual const Type *mul_ring( const Type *, const Type * ) const;
  88   const Type *mul_id() const { return TypeInt::ONE; }
  89   const Type *add_id() const { return TypeInt::ZERO; }
  90   int add_opcode() const { return Op_AddI; }
  91   int mul_opcode() const { return Op_MulI; }
  92   const Type *bottom_type() const { return TypeInt::INT; }
  93   virtual uint ideal_reg() const { return Op_RegI; }
  94 };
  95 
  96 //------------------------------MulLNode---------------------------------------
  97 // Multiply 2 longs




  24 
  25 #ifndef SHARE_VM_OPTO_MULNODE_HPP
  26 #define SHARE_VM_OPTO_MULNODE_HPP
  27 
  28 #include "opto/node.hpp"
  29 #include "opto/opcodes.hpp"
  30 #include "opto/type.hpp"
  31 
  32 // Portions of code courtesy of Clifford Click
  33 
  34 class PhaseTransform;
  35 
  36 //------------------------------MulNode----------------------------------------
  37 // Classic MULTIPLY functionality.  This covers all the usual 'multiply'
  38 // behaviors for an algebraic ring.  Multiply-integer, multiply-float,
  39 // multiply-double, and binary-and are all inherited from this class.  The
  40 // various identity values are supplied by virtual functions.
  41 class MulNode : public Node {
  42   virtual uint hash() const;
  43 public:
  44   MulNode(Node *in1, Node *in2): Node(0,in1,in2) {
  45     init_class_id(Class_Mul);
  46   }
  47 
  48   // Handle algebraic identities here.  If we have an identity, return the Node
  49   // we are equivalent to.  We look for "add of zero" as an identity.
  50   virtual Node* Identity(PhaseGVN* phase);
  51 
  52   // We also canonicalize the Node, moving constants to the right input,
  53   // and flatten expressions (so that 1+x+2 becomes x+3).
  54   virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
  55 
  56   // Compute a new Type for this node.  Basically we just do the pre-check,
  57   // then call the virtual add() to set the type.
  58   virtual const Type* Value(PhaseGVN* phase) const;
  59 
  60   // Supplied function returns the product of the inputs.
  61   // This also type-checks the inputs for sanity.  Guaranteed never to
  62   // be passed a TOP or BOTTOM type, these are filtered out by a pre-check.
  63   // This call recognizes the multiplicative zero type.
  64   virtual const Type *mul_ring(const Type*, const Type*) const = 0;
  65 
  66   // Supplied function to return the multiplicative identity type
  67   virtual const Type *mul_id() const = 0;
  68 
  69   // Supplied function to return the additive identity type
  70   virtual const Type *add_id() const = 0;
  71 
  72   // Supplied function to return the additive opcode
  73   virtual int add_opcode() const = 0;
  74 
  75   // Supplied function to return the multiplicative opcode
  76   virtual int mul_opcode() const = 0;
  77 
  78   static MulNode* make(BasicType bt, Node *in1, Node *in2);
  79 };
  80 
  81 //------------------------------MulINode---------------------------------------
  82 // Multiply 2 integers
  83 class MulINode : public MulNode {
  84 public:
  85   MulINode( Node *in1, Node *in2 ) : MulNode(in1,in2) {}
  86   virtual int Opcode() const;
  87   virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
  88   virtual const Type *mul_ring( const Type *, const Type * ) const;
  89   const Type *mul_id() const { return TypeInt::ONE; }
  90   const Type *add_id() const { return TypeInt::ZERO; }
  91   int add_opcode() const { return Op_AddI; }
  92   int mul_opcode() const { return Op_MulI; }
  93   const Type *bottom_type() const { return TypeInt::INT; }
  94   virtual uint ideal_reg() const { return Op_RegI; }
  95 };
  96 
  97 //------------------------------MulLNode---------------------------------------
  98 // Multiply 2 longs


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