1 /*
  2  * Copyright (c) 1997, 2026, Oracle and/or its affiliates. All rights reserved.
  3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  4  *
  5  * This code is free software; you can redistribute it and/or modify it
  6  * under the terms of the GNU General Public License version 2 only, as
  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 #ifndef SHARE_OPTO_SUBNODE_HPP
 26 #define SHARE_OPTO_SUBNODE_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 //------------------------------SUBNode----------------------------------------
 35 // Class SUBTRACTION functionality.  This covers all the usual 'subtract'
 36 // behaviors.  Subtract-integer, -float, -double, binary xor, compare-integer,
 37 // -float, and -double are all inherited from this class.  The compare
 38 // functions behave like subtract functions, except that all negative answers
 39 // are compressed into -1, and all positive answers compressed to 1.
 40 class SubNode : public Node {
 41 public:
 42   SubNode( Node *in1, Node *in2 ) : Node(nullptr,in1,in2) {
 43     init_class_id(Class_Sub);
 44   }
 45 
 46   // Handle algebraic identities here.  If we have an identity, return the Node
 47   // we are equivalent to.  We look for "add of zero" as an identity.
 48   virtual Node* Identity(PhaseGVN* phase);
 49 
 50   // Compute a new Type for this node.  Basically we just do the pre-check,
 51   // then call the virtual add() to set the type.
 52   virtual const Type* Value(PhaseGVN* phase) const;
 53   const Type* Value_common(PhaseValues* phase) const;
 54 
 55   // Supplied function returns the subtractend of the inputs.
 56   // This also type-checks the inputs for sanity.  Guaranteed never to
 57   // be passed a TOP or BOTTOM type, these are filtered out by a pre-check.
 58   virtual const Type *sub( const Type *, const Type * ) const = 0;
 59 
 60   // Supplied function to return the additive identity type.
 61   // This is returned whenever the subtracts inputs are the same.
 62   virtual const Type *add_id() const = 0;
 63 
 64   static SubNode* make(Node* in1, Node* in2, BasicType bt);
 65 };
 66 
 67 
 68 // NOTE: SubINode should be taken away and replaced by add and negate
 69 //------------------------------SubINode---------------------------------------
 70 // Subtract 2 integers
 71 class SubINode : public SubNode {
 72 public:
 73   SubINode( Node *in1, Node *in2 ) : SubNode(in1,in2) {}
 74   virtual int Opcode() const;
 75   virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
 76   virtual const Type *sub( const Type *, const Type * ) const;
 77   const Type *add_id() const { return TypeInt::ZERO; }
 78   const Type *bottom_type() const { return TypeInt::INT; }
 79   virtual uint ideal_reg() const { return Op_RegI; }
 80 };
 81 
 82 //------------------------------SubLNode---------------------------------------
 83 // Subtract 2 integers
 84 class SubLNode : public SubNode {
 85 public:
 86   SubLNode( Node *in1, Node *in2 ) : SubNode(in1,in2) {}
 87   virtual int Opcode() const;
 88   virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
 89   virtual const Type *sub( const Type *, const Type * ) const;
 90   const Type *add_id() const { return TypeLong::ZERO; }
 91   const Type *bottom_type() const { return TypeLong::LONG; }
 92   virtual uint ideal_reg() const { return Op_RegL; }
 93 };
 94 
 95 // NOTE: SubFPNode should be taken away and replaced by add and negate
 96 //------------------------------SubFPNode--------------------------------------
 97 // Subtract 2 floats or doubles
 98 class SubFPNode : public SubNode {
 99 protected:
100   SubFPNode( Node *in1, Node *in2 ) : SubNode(in1,in2) {}
101 public:
102   const Type* Value(PhaseGVN* phase) const;
103 };
104 
105 // NOTE: SubFNode should be taken away and replaced by add and negate
106 //------------------------------SubFNode---------------------------------------
107 // Subtract 2 doubles
108 class SubFNode : public SubFPNode {
109 public:
110   SubFNode( Node *in1, Node *in2 ) : SubFPNode(in1,in2) {}
111   virtual int Opcode() const;
112   virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
113   virtual const Type *sub( const Type *, const Type * ) const;
114   const Type   *add_id() const { return TypeF::ZERO; }
115   const Type   *bottom_type() const { return Type::FLOAT; }
116   virtual uint  ideal_reg() const { return Op_RegF; }
117 };
118 
119 // NOTE: SubDNode should be taken away and replaced by add and negate
120 //------------------------------SubDNode---------------------------------------
121 // Subtract 2 doubles
122 class SubDNode : public SubFPNode {
123 public:
124   SubDNode( Node *in1, Node *in2 ) : SubFPNode(in1,in2) {}
125   virtual int Opcode() const;
126   virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
127   virtual const Type *sub( const Type *, const Type * ) const;
128   const Type   *add_id() const { return TypeD::ZERO; }
129   const Type   *bottom_type() const { return Type::DOUBLE; }
130   virtual uint  ideal_reg() const { return Op_RegD; }
131 };
132 
133 //------------------------------SubHFNode--------------------------------------
134 // Subtract 2 half floats
135 class SubHFNode : public SubFPNode {
136 public:
137   SubHFNode(Node* in1, Node* in2) : SubFPNode(in1, in2) {}
138   virtual int Opcode() const;
139   virtual const Type* sub(const Type*, const Type*) const;
140   const Type* add_id() const { return TypeH::ZERO; }
141   const Type* bottom_type() const { return Type::HALF_FLOAT; }
142   virtual uint  ideal_reg() const { return Op_RegF; }
143 };
144 
145 //------------------------------CmpNode---------------------------------------
146 // Compare 2 values, returning condition codes (-1, 0 or 1).
147 class CmpNode : public SubNode {
148 public:
149   CmpNode( Node *in1, Node *in2 ) : SubNode(in1,in2) {
150     init_class_id(Class_Cmp);
151   }
152   virtual Node* Identity(PhaseGVN* phase);
153   const Type *add_id() const { return TypeInt::ZERO; }
154   const Type *bottom_type() const { return TypeInt::CC; }
155   virtual uint ideal_reg() const { return Op_RegFlags; }
156 
157   static CmpNode *make(Node *in1, Node *in2, BasicType bt, bool unsigned_comp = false);
158 };
159 
160 //------------------------------CmpINode---------------------------------------
161 // Compare 2 signed values, returning condition codes (-1, 0 or 1).
162 class CmpINode : public CmpNode {
163 public:
164   CmpINode( Node *in1, Node *in2 ) : CmpNode(in1,in2) {}
165   virtual int Opcode() const;
166   virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
167   virtual const Type *sub( const Type *, const Type * ) const;
168   virtual const Type* Value(PhaseGVN* phase) const;
169 };
170 
171 //------------------------------CmpUNode---------------------------------------
172 // Compare 2 unsigned values (integer or pointer), returning condition codes (-1, 0 or 1).
173 class CmpUNode : public CmpNode {
174 public:
175   CmpUNode( Node *in1, Node *in2 ) : CmpNode(in1,in2) {}
176   virtual int Opcode() const;
177   virtual const Type *sub( const Type *, const Type * ) const;
178   const Type* Value(PhaseGVN* phase) const;
179   bool is_index_range_check() const;
180 };
181 
182 //------------------------------CmpU3Node--------------------------------------
183 // Compare 2 unsigned values, returning integer value (-1, 0 or 1).
184 class CmpU3Node : public CmpUNode {
185 public:
186   CmpU3Node( Node *in1, Node *in2 ) : CmpUNode(in1,in2) {
187     // Since it is not consumed by Bools, it is not really a Cmp.
188     init_class_id(Class_Sub);
189   }
190   virtual int Opcode() const;
191   virtual uint ideal_reg() const { return Op_RegI; }
192 };
193 
194 //------------------------------CmpPNode---------------------------------------
195 // Compare 2 pointer values, returning condition codes (-1, 0 or 1).
196 class CmpPNode : public CmpNode {
197 public:
198   CmpPNode( Node *in1, Node *in2 ) : CmpNode(in1,in2) {}
199   virtual int Opcode() const;
200   virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
201   virtual const Type* Value(PhaseGVN* phase) const;
202   virtual const Type *sub( const Type *, const Type * ) const;
203 };
204 
205 //------------------------------CmpNNode--------------------------------------
206 // Compare 2 narrow oop values, returning condition codes (-1, 0 or 1).
207 class CmpNNode : public CmpNode {
208 public:
209   CmpNNode( Node *in1, Node *in2 ) : CmpNode(in1,in2) {}
210   virtual int Opcode() const;
211   virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
212   virtual const Type *sub( const Type *, const Type * ) const;
213 };
214 
215 //------------------------------CmpLNode---------------------------------------
216 // Compare 2 long values, returning condition codes (-1, 0 or 1).
217 class CmpLNode : public CmpNode {
218 public:
219   CmpLNode( Node *in1, Node *in2 ) : CmpNode(in1,in2) {}
220   virtual int    Opcode() const;
221   virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
222   virtual const Type *sub( const Type *, const Type * ) const;
223 };
224 
225 //------------------------------CmpULNode---------------------------------------
226 // Compare 2 unsigned long values, returning condition codes (-1, 0 or 1).
227 class CmpULNode : public CmpNode {
228 public:
229   CmpULNode(Node* in1, Node* in2) : CmpNode(in1, in2) { }
230   virtual int Opcode() const;
231   virtual const Type* sub(const Type*, const Type*) const;
232 };
233 
234 //------------------------------CmpL3Node--------------------------------------
235 // Compare 2 long values, returning integer value (-1, 0 or 1).
236 class CmpL3Node : public CmpLNode {
237 public:
238   CmpL3Node( Node *in1, Node *in2 ) : CmpLNode(in1,in2) {
239     // Since it is not consumed by Bools, it is not really a Cmp.
240     init_class_id(Class_Sub);
241   }
242   virtual int Opcode() const;
243   virtual uint ideal_reg() const { return Op_RegI; }
244 };
245 
246 //------------------------------CmpUL3Node-------------------------------------
247 // Compare 2 unsigned long values, returning integer value (-1, 0 or 1).
248 class CmpUL3Node : public CmpULNode {
249 public:
250   CmpUL3Node( Node *in1, Node *in2 ) : CmpULNode(in1,in2) {
251     // Since it is not consumed by Bools, it is not really a Cmp.
252     init_class_id(Class_Sub);
253   }
254   virtual int Opcode() const;
255   virtual uint ideal_reg() const { return Op_RegI; }
256 };
257 
258 //------------------------------CmpFNode---------------------------------------
259 // Compare 2 float values, returning condition codes (-1, 0 or 1).
260 // This implements the Java bytecode fcmpl, so unordered returns -1.
261 // Operands may not commute.
262 class CmpFNode : public CmpNode {
263 public:
264   CmpFNode( Node *in1, Node *in2 ) : CmpNode(in1,in2) {}
265   virtual int Opcode() const;
266   virtual const Type *sub( const Type *, const Type * ) const { ShouldNotReachHere(); return nullptr; }
267   const Type* Value(PhaseGVN* phase) const;
268 };
269 
270 //------------------------------CmpF3Node--------------------------------------
271 // Compare 2 float values, returning integer value (-1, 0 or 1).
272 // This implements the Java bytecode fcmpl, so unordered returns -1.
273 // Operands may not commute.
274 class CmpF3Node : public CmpFNode {
275 public:
276   CmpF3Node( Node *in1, Node *in2 ) : CmpFNode(in1,in2) {
277     // Since it is not consumed by Bools, it is not really a Cmp.
278     init_class_id(Class_Sub);
279   }
280   virtual int Opcode() const;
281   // Since it is not consumed by Bools, it is not really a Cmp.
282   virtual uint ideal_reg() const { return Op_RegI; }
283 };
284 
285 
286 //------------------------------CmpDNode---------------------------------------
287 // Compare 2 double values, returning condition codes (-1, 0 or 1).
288 // This implements the Java bytecode dcmpl, so unordered returns -1.
289 // Operands may not commute.
290 class CmpDNode : public CmpNode {
291 public:
292   CmpDNode( Node *in1, Node *in2 ) : CmpNode(in1,in2) {}
293   virtual int Opcode() const;
294   virtual const Type *sub( const Type *, const Type * ) const { ShouldNotReachHere(); return nullptr; }
295   const Type* Value(PhaseGVN* phase) const;
296   virtual Node  *Ideal(PhaseGVN *phase, bool can_reshape);
297 };
298 
299 //------------------------------CmpD3Node--------------------------------------
300 // Compare 2 double values, returning integer value (-1, 0 or 1).
301 // This implements the Java bytecode dcmpl, so unordered returns -1.
302 // Operands may not commute.
303 class CmpD3Node : public CmpDNode {
304 public:
305   CmpD3Node( Node *in1, Node *in2 ) : CmpDNode(in1,in2) {
306     // Since it is not consumed by Bools, it is not really a Cmp.
307     init_class_id(Class_Sub);
308   }
309   virtual int Opcode() const;
310   virtual uint ideal_reg() const { return Op_RegI; }
311 };
312 
313 
314 //------------------------------BoolTest---------------------------------------
315 // Convert condition codes to a boolean test value (0 or -1).
316 // We pick the values as 3 bits; the low order 2 bits we compare against the
317 // condition codes, the high bit flips the sense of the result.
318 // For vector compares, additionally, the 4th bit indicates if the compare is unsigned
319 struct BoolTest {
320   enum mask { eq = 0, ne = 4, le = 5, ge = 7, lt = 3, gt = 1, overflow = 2, no_overflow = 6, never = 8, illegal = 9,
321               // The following values are used with vector compares
322               // A BoolTest value should not be constructed for such values
323               unsigned_compare = 16,
324               ule = unsigned_compare | le, uge = unsigned_compare | ge, ult = unsigned_compare | lt, ugt = unsigned_compare | gt };
325   mask _test;
326   BoolTest( mask btm ) : _test(btm) { assert((btm & unsigned_compare) == 0, "unsupported");}
327   const Type *cc2logical( const Type *CC ) const;
328   // Commute the test.  I use a small table lookup.  The table is created as
329   // a simple char array where each element is the ASCII version of a 'mask'
330   // enum from above.
331   mask commute( ) const { return mask("032147658"[_test]-'0'); }
332   mask negate( ) const { return negate_mask(_test); }
333   // Return the negative mask for the given mask, for both signed and unsigned comparison.
334   static mask negate_mask(mask btm) { return mask(btm ^ 4); }
335   static mask unsigned_mask(mask btm);
336   bool is_canonical( ) const { return (_test == BoolTest::ne || _test == BoolTest::lt || _test == BoolTest::le || _test == BoolTest::overflow); }
337   bool is_less( )  const { return _test == BoolTest::lt || _test == BoolTest::le; }
338   bool is_greater( ) const { return _test == BoolTest::gt || _test == BoolTest::ge; }
339   void dump_on(outputStream *st) const;
340   mask merge(BoolTest other) const;
341 };
342 
343 //------------------------------BoolNode---------------------------------------
344 // A Node to convert a Condition Codes to a Logical result.
345 class BoolNode : public Node {
346   virtual uint hash() const;
347   virtual bool cmp( const Node &n ) const;
348   virtual uint size_of() const;
349 
350   // Try to optimize signed integer comparison
351   Node* fold_cmpI(PhaseGVN* phase, SubNode* cmp, Node* cmp1, int cmp_op,
352                   int cmp1_op, const TypeInt* cmp2_type);
353 public:
354   const BoolTest _test;
355   BoolNode(Node *cc, BoolTest::mask t): Node(nullptr,cc), _test(t) {
356     init_class_id(Class_Bool);
357   }
358   // Convert an arbitrary int value to a Bool or other suitable predicate.
359   static Node* make_predicate(Node* test_value, PhaseGVN* phase);
360   // Convert self back to an integer value.
361   Node* as_int_value(PhaseGVN* phase);
362   // Invert sense of self, returning new Bool.
363   BoolNode* negate(PhaseGVN* phase);
364   virtual int Opcode() const;
365   virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
366   const Type* Value_cmpu_and_mask(PhaseValues* phase) const;
367   virtual const Type* Value(PhaseGVN* phase) const;
368   virtual const Type *bottom_type() const { return TypeInt::BOOL; }
369   uint match_edge(uint idx) const { return 0; }
370   virtual uint ideal_reg() const { return Op_RegI; }
371 
372   bool is_counted_loop_exit_test();
373 #ifndef PRODUCT
374   virtual void dump_spec(outputStream *st) const;
375 #endif
376 };
377 
378 //------------------------------AbsNode----------------------------------------
379 // Abstract class for absolute value.  Mostly used to get a handy wrapper
380 // for finding this pattern in the graph.
381 class AbsNode : public Node {
382 public:
383   AbsNode( Node *value ) : Node(nullptr,value) {}
384   virtual Node* Identity(PhaseGVN* phase);
385   virtual Node* Ideal(PhaseGVN* phase, bool can_reshape);
386   virtual const Type* Value(PhaseGVN* phase) const;
387 };
388 
389 //------------------------------AbsINode---------------------------------------
390 // Absolute value an integer.  Since a naive graph involves control flow, we
391 // "match" it in the ideal world (so the control flow can be removed).
392 class AbsINode : public AbsNode {
393 public:
394   AbsINode( Node *in1 ) : AbsNode(in1) {}
395   virtual int Opcode() const;
396   const Type *bottom_type() const { return TypeInt::INT; }
397   virtual uint ideal_reg() const { return Op_RegI; }
398 };
399 
400 //------------------------------AbsLNode---------------------------------------
401 // Absolute value a long.  Since a naive graph involves control flow, we
402 // "match" it in the ideal world (so the control flow can be removed).
403 class AbsLNode : public AbsNode {
404 public:
405   AbsLNode( Node *in1 ) : AbsNode(in1) {}
406   virtual int Opcode() const;
407   const Type *bottom_type() const { return TypeLong::LONG; }
408   virtual uint ideal_reg() const { return Op_RegL; }
409 };
410 
411 //------------------------------AbsFNode---------------------------------------
412 // Absolute value a float, a common float-point idiom with a cheap hardware
413 // implementation on most chips.  Since a naive graph involves control flow, we
414 // "match" it in the ideal world (so the control flow can be removed).
415 class AbsFNode : public AbsNode {
416 public:
417   AbsFNode( Node *in1 ) : AbsNode(in1) {}
418   virtual int Opcode() const;
419   const Type *bottom_type() const { return Type::FLOAT; }
420   virtual uint ideal_reg() const { return Op_RegF; }
421 };
422 
423 //------------------------------AbsDNode---------------------------------------
424 // Absolute value a double, a common float-point idiom with a cheap hardware
425 // implementation on most chips.  Since a naive graph involves control flow, we
426 // "match" it in the ideal world (so the control flow can be removed).
427 class AbsDNode : public AbsNode {
428 public:
429   AbsDNode( Node *in1 ) : AbsNode(in1) {}
430   virtual int Opcode() const;
431   const Type *bottom_type() const { return Type::DOUBLE; }
432   virtual uint ideal_reg() const { return Op_RegD; }
433 };
434 
435 
436 //------------------------------CmpLTMaskNode----------------------------------
437 // If p < q, return -1 else return 0.  Nice for flow-free idioms.
438 class CmpLTMaskNode : public Node {
439 public:
440   CmpLTMaskNode( Node *p, Node *q ) : Node(nullptr, p, q) {}
441   virtual int Opcode() const;
442   const Type *bottom_type() const { return TypeInt::INT; }
443   virtual uint ideal_reg() const { return Op_RegI; }
444 };
445 
446 
447 //------------------------------NegNode----------------------------------------
448 class NegNode : public Node {
449 public:
450   NegNode(Node* in1) : Node(nullptr, in1) {
451     init_class_id(Class_Neg);
452   }
453 };
454 
455 //------------------------------NegINode---------------------------------------
456 // Negate value an int.  For int values, negation is the same as subtraction
457 // from zero
458 class NegINode : public NegNode {
459 public:
460   NegINode(Node *in1) : NegNode(in1) {}
461   virtual int Opcode() const;
462   const Type *bottom_type() const { return TypeInt::INT; }
463   virtual uint ideal_reg() const { return Op_RegI; }
464 };
465 
466 //------------------------------NegLNode---------------------------------------
467 // Negate value an int.  For int values, negation is the same as subtraction
468 // from zero
469 class NegLNode : public NegNode {
470 public:
471   NegLNode(Node *in1) : NegNode(in1) {}
472   virtual int Opcode() const;
473   const Type *bottom_type() const { return TypeLong::LONG; }
474   virtual uint ideal_reg() const { return Op_RegL; }
475 };
476 
477 //------------------------------NegFNode---------------------------------------
478 // Negate value a float.  Negating 0.0 returns -0.0, but subtracting from
479 // zero returns +0.0 (per JVM spec on 'fneg' bytecode).  As subtraction
480 // cannot be used to replace negation we have to implement negation as ideal
481 // node; note that negation and addition can replace subtraction.
482 class NegFNode : public NegNode {
483 public:
484   NegFNode( Node *in1 ) : NegNode(in1) {}
485   virtual int Opcode() const;
486   const Type *bottom_type() const { return Type::FLOAT; }
487   virtual uint ideal_reg() const { return Op_RegF; }
488 };
489 
490 //------------------------------NegDNode---------------------------------------
491 // Negate value a double.  Negating 0.0 returns -0.0, but subtracting from
492 // zero returns +0.0 (per JVM spec on 'dneg' bytecode).  As subtraction
493 // cannot be used to replace negation we have to implement negation as ideal
494 // node; note that negation and addition can replace subtraction.
495 class NegDNode : public NegNode {
496 public:
497   NegDNode( Node *in1 ) : NegNode(in1) {}
498   virtual int Opcode() const;
499   const Type *bottom_type() const { return Type::DOUBLE; }
500   virtual uint ideal_reg() const { return Op_RegD; }
501 };
502 
503 //------------------------------AtanDNode--------------------------------------
504 // arcus tangens of a double
505 class AtanDNode : public Node {
506 public:
507   AtanDNode(Node *c, Node *in1, Node *in2  ) : Node(c, in1, in2) {}
508   virtual int Opcode() const;
509   const Type *bottom_type() const { return Type::DOUBLE; }
510   virtual uint ideal_reg() const { return Op_RegD; }
511 
512 private:
513   virtual bool depends_only_on_test_impl() const { return false; }
514 };
515 
516 
517 //------------------------------SqrtDNode--------------------------------------
518 // square root a double
519 class SqrtDNode : public Node {
520 public:
521   SqrtDNode(Compile* C, Node *c, Node *in1) : Node(c, in1) {
522     init_flags(Flag_is_expensive);
523     C->add_expensive_node(this);
524   }
525   virtual int Opcode() const;
526   const Type *bottom_type() const { return Type::DOUBLE; }
527   virtual uint ideal_reg() const { return Op_RegD; }
528   virtual const Type* Value(PhaseGVN* phase) const;
529 
530 private:
531   virtual bool depends_only_on_test_impl() const { return false; }
532 };
533 
534 //------------------------------SqrtFNode--------------------------------------
535 // square root a float
536 class SqrtFNode : public Node {
537 public:
538   SqrtFNode(Compile* C, Node *c, Node *in1) : Node(c, in1) {
539     init_flags(Flag_is_expensive);
540     if (c != nullptr) {
541       // Treat node only as expensive if a control input is set because it might
542       // be created from a SqrtDNode in ConvD2FNode::Ideal() that was found to
543       // be unique and therefore has no control input.
544       C->add_expensive_node(this);
545     }
546   }
547   virtual int Opcode() const;
548   const Type *bottom_type() const { return Type::FLOAT; }
549   virtual uint ideal_reg() const { return Op_RegF; }
550   virtual const Type* Value(PhaseGVN* phase) const;
551 
552 private:
553   virtual bool depends_only_on_test_impl() const { return false; }
554 };
555 
556 //------------------------------SqrtHFNode-------------------------------------
557 // square root of a half-precision float
558 class SqrtHFNode : public Node {
559 public:
560   SqrtHFNode(Compile* C, Node* c, Node* in1) : Node(c, in1) {
561     init_flags(Flag_is_expensive);
562     C->add_expensive_node(this);
563   }
564   virtual int Opcode() const;
565   const Type* bottom_type() const { return Type::HALF_FLOAT; }
566   virtual uint ideal_reg() const { return Op_RegF; }
567   virtual const Type* Value(PhaseGVN* phase) const;
568 
569 private:
570   virtual bool depends_only_on_test_impl() const { return false; }
571 };
572 
573 
574 class ReverseBytesNode : public Node {
575 public:
576   ReverseBytesNode(Node* in) : Node(nullptr, in) {}
577   virtual const Type* Value(PhaseGVN* phase) const;
578 };
579 //-------------------------------ReverseBytesINode--------------------------------
580 // reverse bytes of an integer
581 class ReverseBytesINode : public ReverseBytesNode {
582 public:
583   ReverseBytesINode(Node* in) : ReverseBytesNode(in) {}
584   virtual int Opcode() const;
585   const Type* bottom_type() const { return TypeInt::INT; }
586   virtual uint ideal_reg() const { return Op_RegI; }
587 };
588 
589 //-------------------------------ReverseBytesLNode--------------------------------
590 // reverse bytes of a long
591 class ReverseBytesLNode : public ReverseBytesNode {
592 public:
593   ReverseBytesLNode(Node* in) : ReverseBytesNode(in) {}
594   virtual int Opcode() const;
595   const Type* bottom_type() const { return TypeLong::LONG; }
596   virtual uint ideal_reg() const { return Op_RegL; }
597 };
598 
599 //-------------------------------ReverseBytesUSNode--------------------------------
600 // reverse bytes of an unsigned short / char
601 class ReverseBytesUSNode : public ReverseBytesNode {
602 public:
603   ReverseBytesUSNode(Node* in1) : ReverseBytesNode(in1) {}
604   virtual int Opcode() const;
605   const Type* bottom_type() const { return TypeInt::CHAR; }
606   virtual uint ideal_reg() const { return Op_RegI; }
607 };
608 
609 //-------------------------------ReverseBytesSNode--------------------------------
610 // reverse bytes of a short
611 class ReverseBytesSNode : public ReverseBytesNode {
612 public:
613   ReverseBytesSNode(Node* in) : ReverseBytesNode(in) {}
614   virtual int Opcode() const;
615   const Type* bottom_type() const { return TypeInt::SHORT; }
616   virtual uint ideal_reg() const { return Op_RegI; }
617 };
618 
619 //-------------------------------ReverseINode--------------------------------
620 // reverse bits of an int
621 class ReverseINode : public Node {
622 public:
623   ReverseINode(Node* in) : Node(nullptr,in) {}
624   virtual int Opcode() const;
625   const Type* bottom_type() const { return TypeInt::INT; }
626   virtual uint ideal_reg() const { return Op_RegI; }
627   virtual Node* Identity(PhaseGVN* phase);
628   virtual const Type* Value(PhaseGVN* phase) const;
629 };
630 
631 //-------------------------------ReverseLNode--------------------------------
632 // reverse bits of a long
633 class ReverseLNode : public Node {
634 public:
635   ReverseLNode(Node* in) : Node(nullptr, in) {}
636   virtual int Opcode() const;
637   const Type* bottom_type() const { return TypeLong::LONG; }
638   virtual uint ideal_reg() const { return Op_RegL; }
639   virtual Node* Identity(PhaseGVN* phase);
640   virtual const Type* Value(PhaseGVN* phase) const;
641 };
642 
643 #endif // SHARE_OPTO_SUBNODE_HPP