Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/jdk17u
Path: blob/master/src/hotspot/share/opto/convertnode.cpp
64440 views
1
/*
2
* Copyright (c) 2014, 2019, 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
#include "precompiled.hpp"
26
#include "opto/addnode.hpp"
27
#include "opto/castnode.hpp"
28
#include "opto/convertnode.hpp"
29
#include "opto/matcher.hpp"
30
#include "opto/phaseX.hpp"
31
#include "opto/subnode.hpp"
32
#include "runtime/sharedRuntime.hpp"
33
34
//=============================================================================
35
//------------------------------Identity---------------------------------------
36
Node* Conv2BNode::Identity(PhaseGVN* phase) {
37
const Type *t = phase->type( in(1) );
38
if( t == Type::TOP ) return in(1);
39
if( t == TypeInt::ZERO ) return in(1);
40
if( t == TypeInt::ONE ) return in(1);
41
if( t == TypeInt::BOOL ) return in(1);
42
return this;
43
}
44
45
//------------------------------Value------------------------------------------
46
const Type* Conv2BNode::Value(PhaseGVN* phase) const {
47
const Type *t = phase->type( in(1) );
48
if( t == Type::TOP ) return Type::TOP;
49
if( t == TypeInt::ZERO ) return TypeInt::ZERO;
50
if( t == TypePtr::NULL_PTR ) return TypeInt::ZERO;
51
const TypePtr *tp = t->isa_ptr();
52
if( tp != NULL ) {
53
if( tp->ptr() == TypePtr::AnyNull ) return Type::TOP;
54
if( tp->ptr() == TypePtr::Constant) return TypeInt::ONE;
55
if (tp->ptr() == TypePtr::NotNull) return TypeInt::ONE;
56
return TypeInt::BOOL;
57
}
58
if (t->base() != Type::Int) return TypeInt::BOOL;
59
const TypeInt *ti = t->is_int();
60
if( ti->_hi < 0 || ti->_lo > 0 ) return TypeInt::ONE;
61
return TypeInt::BOOL;
62
}
63
64
65
// The conversions operations are all Alpha sorted. Please keep it that way!
66
//=============================================================================
67
//------------------------------Value------------------------------------------
68
const Type* ConvD2FNode::Value(PhaseGVN* phase) const {
69
const Type *t = phase->type( in(1) );
70
if( t == Type::TOP ) return Type::TOP;
71
if( t == Type::DOUBLE ) return Type::FLOAT;
72
const TypeD *td = t->is_double_constant();
73
return TypeF::make( (float)td->getd() );
74
}
75
76
//------------------------------Ideal------------------------------------------
77
// If we see pattern ConvF2D SomeDoubleOp ConvD2F, do operation as float.
78
Node *ConvD2FNode::Ideal(PhaseGVN *phase, bool can_reshape) {
79
if ( in(1)->Opcode() == Op_SqrtD ) {
80
Node* sqrtd = in(1);
81
if ( sqrtd->in(1)->Opcode() == Op_ConvF2D ) {
82
if ( Matcher::match_rule_supported(Op_SqrtF) ) {
83
Node* convf2d = sqrtd->in(1);
84
return new SqrtFNode(phase->C, sqrtd->in(0), convf2d->in(1));
85
}
86
}
87
}
88
return NULL;
89
}
90
91
//------------------------------Identity---------------------------------------
92
// Float's can be converted to doubles with no loss of bits. Hence
93
// converting a float to a double and back to a float is a NOP.
94
Node* ConvD2FNode::Identity(PhaseGVN* phase) {
95
return (in(1)->Opcode() == Op_ConvF2D) ? in(1)->in(1) : this;
96
}
97
98
//=============================================================================
99
//------------------------------Value------------------------------------------
100
const Type* ConvD2INode::Value(PhaseGVN* phase) const {
101
const Type *t = phase->type( in(1) );
102
if( t == Type::TOP ) return Type::TOP;
103
if( t == Type::DOUBLE ) return TypeInt::INT;
104
const TypeD *td = t->is_double_constant();
105
return TypeInt::make( SharedRuntime::d2i( td->getd() ) );
106
}
107
108
//------------------------------Ideal------------------------------------------
109
// If converting to an int type, skip any rounding nodes
110
Node *ConvD2INode::Ideal(PhaseGVN *phase, bool can_reshape) {
111
if (in(1)->Opcode() == Op_RoundDouble) {
112
set_req(1, in(1)->in(1));
113
return this;
114
}
115
return NULL;
116
}
117
118
//------------------------------Identity---------------------------------------
119
// Int's can be converted to doubles with no loss of bits. Hence
120
// converting an integer to a double and back to an integer is a NOP.
121
Node* ConvD2INode::Identity(PhaseGVN* phase) {
122
return (in(1)->Opcode() == Op_ConvI2D) ? in(1)->in(1) : this;
123
}
124
125
//=============================================================================
126
//------------------------------Value------------------------------------------
127
const Type* ConvD2LNode::Value(PhaseGVN* phase) const {
128
const Type *t = phase->type( in(1) );
129
if( t == Type::TOP ) return Type::TOP;
130
if( t == Type::DOUBLE ) return TypeLong::LONG;
131
const TypeD *td = t->is_double_constant();
132
return TypeLong::make( SharedRuntime::d2l( td->getd() ) );
133
}
134
135
//------------------------------Identity---------------------------------------
136
Node* ConvD2LNode::Identity(PhaseGVN* phase) {
137
// Remove ConvD2L->ConvL2D->ConvD2L sequences.
138
if( in(1) ->Opcode() == Op_ConvL2D &&
139
in(1)->in(1)->Opcode() == Op_ConvD2L )
140
return in(1)->in(1);
141
return this;
142
}
143
144
//------------------------------Ideal------------------------------------------
145
// If converting to an int type, skip any rounding nodes
146
Node *ConvD2LNode::Ideal(PhaseGVN *phase, bool can_reshape) {
147
if (in(1)->Opcode() == Op_RoundDouble) {
148
set_req(1, in(1)->in(1));
149
return this;
150
}
151
return NULL;
152
}
153
154
//=============================================================================
155
//------------------------------Value------------------------------------------
156
const Type* ConvF2DNode::Value(PhaseGVN* phase) const {
157
const Type *t = phase->type( in(1) );
158
if( t == Type::TOP ) return Type::TOP;
159
if( t == Type::FLOAT ) return Type::DOUBLE;
160
const TypeF *tf = t->is_float_constant();
161
return TypeD::make( (double)tf->getf() );
162
}
163
164
//=============================================================================
165
//------------------------------Value------------------------------------------
166
const Type* ConvF2INode::Value(PhaseGVN* phase) const {
167
const Type *t = phase->type( in(1) );
168
if( t == Type::TOP ) return Type::TOP;
169
if( t == Type::FLOAT ) return TypeInt::INT;
170
const TypeF *tf = t->is_float_constant();
171
return TypeInt::make( SharedRuntime::f2i( tf->getf() ) );
172
}
173
174
//------------------------------Identity---------------------------------------
175
Node* ConvF2INode::Identity(PhaseGVN* phase) {
176
// Remove ConvF2I->ConvI2F->ConvF2I sequences.
177
if( in(1) ->Opcode() == Op_ConvI2F &&
178
in(1)->in(1)->Opcode() == Op_ConvF2I )
179
return in(1)->in(1);
180
return this;
181
}
182
183
//------------------------------Ideal------------------------------------------
184
// If converting to an int type, skip any rounding nodes
185
Node *ConvF2INode::Ideal(PhaseGVN *phase, bool can_reshape) {
186
if (in(1)->Opcode() == Op_RoundFloat) {
187
set_req(1, in(1)->in(1));
188
return this;
189
}
190
return NULL;
191
}
192
193
//=============================================================================
194
//------------------------------Value------------------------------------------
195
const Type* ConvF2LNode::Value(PhaseGVN* phase) const {
196
const Type *t = phase->type( in(1) );
197
if( t == Type::TOP ) return Type::TOP;
198
if( t == Type::FLOAT ) return TypeLong::LONG;
199
const TypeF *tf = t->is_float_constant();
200
return TypeLong::make( SharedRuntime::f2l( tf->getf() ) );
201
}
202
203
//------------------------------Identity---------------------------------------
204
Node* ConvF2LNode::Identity(PhaseGVN* phase) {
205
// Remove ConvF2L->ConvL2F->ConvF2L sequences.
206
if( in(1) ->Opcode() == Op_ConvL2F &&
207
in(1)->in(1)->Opcode() == Op_ConvF2L )
208
return in(1)->in(1);
209
return this;
210
}
211
212
//------------------------------Ideal------------------------------------------
213
// If converting to an int type, skip any rounding nodes
214
Node *ConvF2LNode::Ideal(PhaseGVN *phase, bool can_reshape) {
215
if (in(1)->Opcode() == Op_RoundFloat) {
216
set_req(1, in(1)->in(1));
217
return this;
218
}
219
return NULL;
220
}
221
222
//=============================================================================
223
//------------------------------Value------------------------------------------
224
const Type* ConvI2DNode::Value(PhaseGVN* phase) const {
225
const Type *t = phase->type( in(1) );
226
if( t == Type::TOP ) return Type::TOP;
227
const TypeInt *ti = t->is_int();
228
if( ti->is_con() ) return TypeD::make( (double)ti->get_con() );
229
return bottom_type();
230
}
231
232
//=============================================================================
233
//------------------------------Value------------------------------------------
234
const Type* ConvI2FNode::Value(PhaseGVN* phase) const {
235
const Type *t = phase->type( in(1) );
236
if( t == Type::TOP ) return Type::TOP;
237
const TypeInt *ti = t->is_int();
238
if( ti->is_con() ) return TypeF::make( (float)ti->get_con() );
239
return bottom_type();
240
}
241
242
//------------------------------Identity---------------------------------------
243
Node* ConvI2FNode::Identity(PhaseGVN* phase) {
244
// Remove ConvI2F->ConvF2I->ConvI2F sequences.
245
if( in(1) ->Opcode() == Op_ConvF2I &&
246
in(1)->in(1)->Opcode() == Op_ConvI2F )
247
return in(1)->in(1);
248
return this;
249
}
250
251
//=============================================================================
252
//------------------------------Value------------------------------------------
253
const Type* ConvI2LNode::Value(PhaseGVN* phase) const {
254
const Type *t = phase->type( in(1) );
255
if( t == Type::TOP ) return Type::TOP;
256
const TypeInt *ti = t->is_int();
257
const Type* tl = TypeLong::make(ti->_lo, ti->_hi, ti->_widen);
258
// Join my declared type against my incoming type.
259
tl = tl->filter(_type);
260
return tl;
261
}
262
263
static inline bool long_ranges_overlap(jlong lo1, jlong hi1,
264
jlong lo2, jlong hi2) {
265
// Two ranges overlap iff one range's low point falls in the other range.
266
return (lo2 <= lo1 && lo1 <= hi2) || (lo1 <= lo2 && lo2 <= hi1);
267
}
268
269
#ifdef _LP64
270
// If there is an existing ConvI2L node with the given parent and type, return
271
// it. Otherwise, create and return a new one. Both reusing existing ConvI2L
272
// nodes and postponing the idealization of new ones are needed to avoid an
273
// explosion of recursive Ideal() calls when compiling long AddI chains.
274
static Node* find_or_make_convI2L(PhaseIterGVN* igvn, Node* parent,
275
const TypeLong* type) {
276
Node* n = new ConvI2LNode(parent, type);
277
Node* existing = igvn->hash_find_insert(n);
278
if (existing != NULL) {
279
n->destruct(igvn);
280
return existing;
281
}
282
return igvn->register_new_node_with_optimizer(n);
283
}
284
#endif
285
286
bool Compile::push_thru_add(PhaseGVN* phase, Node* z, const TypeInteger* tz, const TypeInteger*& rx, const TypeInteger*& ry,
287
BasicType bt) {
288
int op = z->Opcode();
289
if (op == Op_AddI || op == Op_SubI) {
290
Node* x = z->in(1);
291
Node* y = z->in(2);
292
assert (x != z && y != z, "dead loop in ConvI2LNode::Ideal");
293
if (phase->type(x) == Type::TOP) {
294
return false;
295
}
296
if (phase->type(y) == Type::TOP) {
297
return false;
298
}
299
const TypeInt* tx = phase->type(x)->is_int();
300
const TypeInt* ty = phase->type(y)->is_int();
301
302
jlong xlo = tx->is_int()->_lo;
303
jlong xhi = tx->is_int()->_hi;
304
jlong ylo = ty->is_int()->_lo;
305
jlong yhi = ty->is_int()->_hi;
306
jlong zlo = tz->lo_as_long();
307
jlong zhi = tz->hi_as_long();
308
jlong vbit = CONST64(1) << BitsPerInt;
309
int widen = MAX2(tx->_widen, ty->_widen);
310
if (op == Op_SubI) {
311
jlong ylo0 = ylo;
312
ylo = -yhi;
313
yhi = -ylo0;
314
}
315
// See if x+y can cause positive overflow into z+2**32
316
if (long_ranges_overlap(xlo+ylo, xhi+yhi, zlo+vbit, zhi+vbit)) {
317
return false;
318
}
319
// See if x+y can cause negative overflow into z-2**32
320
if (long_ranges_overlap(xlo+ylo, xhi+yhi, zlo-vbit, zhi-vbit)) {
321
return false;
322
}
323
// Now it's always safe to assume x+y does not overflow.
324
// This is true even if some pairs x,y might cause overflow, as long
325
// as that overflow value cannot fall into [zlo,zhi].
326
327
// Confident that the arithmetic is "as if infinite precision",
328
// we can now use z's range to put constraints on those of x and y.
329
// The "natural" range of x [xlo,xhi] can perhaps be narrowed to a
330
// more "restricted" range by intersecting [xlo,xhi] with the
331
// range obtained by subtracting y's range from the asserted range
332
// of the I2L conversion. Here's the interval arithmetic algebra:
333
// x == z-y == [zlo,zhi]-[ylo,yhi] == [zlo,zhi]+[-yhi,-ylo]
334
// => x in [zlo-yhi, zhi-ylo]
335
// => x in [zlo-yhi, zhi-ylo] INTERSECT [xlo,xhi]
336
// => x in [xlo MAX zlo-yhi, xhi MIN zhi-ylo]
337
jlong rxlo = MAX2(xlo, zlo - yhi);
338
jlong rxhi = MIN2(xhi, zhi - ylo);
339
// And similarly, x changing place with y:
340
jlong rylo = MAX2(ylo, zlo - xhi);
341
jlong ryhi = MIN2(yhi, zhi - xlo);
342
if (rxlo > rxhi || rylo > ryhi) {
343
return false; // x or y is dying; don't mess w/ it
344
}
345
if (op == Op_SubI) {
346
jlong rylo0 = rylo;
347
rylo = -ryhi;
348
ryhi = -rylo0;
349
}
350
assert(rxlo == (int)rxlo && rxhi == (int)rxhi, "x should not overflow");
351
assert(rylo == (int)rylo && ryhi == (int)ryhi, "y should not overflow");
352
rx = TypeInteger::make(rxlo, rxhi, widen, bt);
353
ry = TypeInteger::make(rylo, ryhi, widen, bt);
354
return true;
355
}
356
return false;
357
}
358
359
360
//------------------------------Ideal------------------------------------------
361
Node *ConvI2LNode::Ideal(PhaseGVN *phase, bool can_reshape) {
362
PhaseIterGVN *igvn = phase->is_IterGVN();
363
const TypeLong* this_type = this->type()->is_long();
364
Node* this_changed = NULL;
365
366
if (igvn != NULL) {
367
// Do NOT remove this node's type assertion until no more loop ops can happen.
368
if (phase->C->post_loop_opts_phase()) {
369
const TypeInt* in_type = phase->type(in(1))->isa_int();
370
if (in_type != NULL && this_type != NULL &&
371
(in_type->_lo != this_type->_lo ||
372
in_type->_hi != this_type->_hi)) {
373
// Although this WORSENS the type, it increases GVN opportunities,
374
// because I2L nodes with the same input will common up, regardless
375
// of slightly differing type assertions. Such slight differences
376
// arise routinely as a result of loop unrolling, so this is a
377
// post-unrolling graph cleanup. Choose a type which depends only
378
// on my input. (Exception: Keep a range assertion of >=0 or <0.)
379
jlong lo1 = this_type->_lo;
380
jlong hi1 = this_type->_hi;
381
int w1 = this_type->_widen;
382
if (lo1 != (jint)lo1 ||
383
hi1 != (jint)hi1 ||
384
lo1 > hi1) {
385
// Overflow leads to wraparound, wraparound leads to range saturation.
386
lo1 = min_jint; hi1 = max_jint;
387
} else if (lo1 >= 0) {
388
// Keep a range assertion of >=0.
389
lo1 = 0; hi1 = max_jint;
390
} else if (hi1 < 0) {
391
// Keep a range assertion of <0.
392
lo1 = min_jint; hi1 = -1;
393
} else {
394
lo1 = min_jint; hi1 = max_jint;
395
}
396
const TypeLong* wtype = TypeLong::make(MAX2((jlong)in_type->_lo, lo1),
397
MIN2((jlong)in_type->_hi, hi1),
398
MAX2((int)in_type->_widen, w1));
399
if (wtype != type()) {
400
set_type(wtype);
401
// Note: this_type still has old type value, for the logic below.
402
this_changed = this;
403
}
404
}
405
} else {
406
phase->C->record_for_post_loop_opts_igvn(this);
407
}
408
}
409
#ifdef _LP64
410
// Convert ConvI2L(AddI(x, y)) to AddL(ConvI2L(x), ConvI2L(y))
411
// but only if x and y have subranges that cannot cause 32-bit overflow,
412
// under the assumption that x+y is in my own subrange this->type().
413
414
// This assumption is based on a constraint (i.e., type assertion)
415
// established in Parse::array_addressing or perhaps elsewhere.
416
// This constraint has been adjoined to the "natural" type of
417
// the incoming argument in(0). We know (because of runtime
418
// checks) - that the result value I2L(x+y) is in the joined range.
419
// Hence we can restrict the incoming terms (x, y) to values such
420
// that their sum also lands in that range.
421
422
// This optimization is useful only on 64-bit systems, where we hope
423
// the addition will end up subsumed in an addressing mode.
424
// It is necessary to do this when optimizing an unrolled array
425
// copy loop such as x[i++] = y[i++].
426
427
// On 32-bit systems, it's better to perform as much 32-bit math as
428
// possible before the I2L conversion, because 32-bit math is cheaper.
429
// There's no common reason to "leak" a constant offset through the I2L.
430
// Addressing arithmetic will not absorb it as part of a 64-bit AddL.
431
432
Node* z = in(1);
433
const TypeInteger* rx = NULL;
434
const TypeInteger* ry = NULL;
435
if (Compile::push_thru_add(phase, z, this_type, rx, ry, T_LONG)) {
436
if (igvn == NULL) {
437
// Postpone this optimization to iterative GVN, where we can handle deep
438
// AddI chains without an exponential number of recursive Ideal() calls.
439
phase->record_for_igvn(this);
440
return this_changed;
441
}
442
int op = z->Opcode();
443
Node* x = z->in(1);
444
Node* y = z->in(2);
445
446
Node* cx = find_or_make_convI2L(igvn, x, rx->is_long());
447
Node* cy = find_or_make_convI2L(igvn, y, ry->is_long());
448
switch (op) {
449
case Op_AddI: return new AddLNode(cx, cy);
450
case Op_SubI: return new SubLNode(cx, cy);
451
default: ShouldNotReachHere();
452
}
453
}
454
#endif //_LP64
455
456
return this_changed;
457
}
458
459
//=============================================================================
460
//------------------------------Value------------------------------------------
461
const Type* ConvL2DNode::Value(PhaseGVN* phase) const {
462
const Type *t = phase->type( in(1) );
463
if( t == Type::TOP ) return Type::TOP;
464
const TypeLong *tl = t->is_long();
465
if( tl->is_con() ) return TypeD::make( (double)tl->get_con() );
466
return bottom_type();
467
}
468
469
//=============================================================================
470
//------------------------------Value------------------------------------------
471
const Type* ConvL2FNode::Value(PhaseGVN* phase) const {
472
const Type *t = phase->type( in(1) );
473
if( t == Type::TOP ) return Type::TOP;
474
const TypeLong *tl = t->is_long();
475
if( tl->is_con() ) return TypeF::make( (float)tl->get_con() );
476
return bottom_type();
477
}
478
479
//=============================================================================
480
//----------------------------Identity-----------------------------------------
481
Node* ConvL2INode::Identity(PhaseGVN* phase) {
482
// Convert L2I(I2L(x)) => x
483
if (in(1)->Opcode() == Op_ConvI2L) return in(1)->in(1);
484
return this;
485
}
486
487
//------------------------------Value------------------------------------------
488
const Type* ConvL2INode::Value(PhaseGVN* phase) const {
489
const Type *t = phase->type( in(1) );
490
if( t == Type::TOP ) return Type::TOP;
491
const TypeLong *tl = t->is_long();
492
const TypeInt* ti = TypeInt::INT;
493
if (tl->is_con()) {
494
// Easy case.
495
ti = TypeInt::make((jint)tl->get_con());
496
} else if (tl->_lo >= min_jint && tl->_hi <= max_jint) {
497
ti = TypeInt::make((jint)tl->_lo, (jint)tl->_hi, tl->_widen);
498
}
499
return ti->filter(_type);
500
}
501
502
//------------------------------Ideal------------------------------------------
503
// Return a node which is more "ideal" than the current node.
504
// Blow off prior masking to int
505
Node *ConvL2INode::Ideal(PhaseGVN *phase, bool can_reshape) {
506
Node *andl = in(1);
507
uint andl_op = andl->Opcode();
508
if( andl_op == Op_AndL ) {
509
// Blow off prior masking to int
510
if( phase->type(andl->in(2)) == TypeLong::make( 0xFFFFFFFF ) ) {
511
set_req_X(1,andl->in(1), phase);
512
return this;
513
}
514
}
515
516
// Swap with a prior add: convL2I(addL(x,y)) ==> addI(convL2I(x),convL2I(y))
517
// This replaces an 'AddL' with an 'AddI'.
518
if( andl_op == Op_AddL ) {
519
// Don't do this for nodes which have more than one user since
520
// we'll end up computing the long add anyway.
521
if (andl->outcnt() > 1) return NULL;
522
523
Node* x = andl->in(1);
524
Node* y = andl->in(2);
525
assert( x != andl && y != andl, "dead loop in ConvL2INode::Ideal" );
526
if (phase->type(x) == Type::TOP) return NULL;
527
if (phase->type(y) == Type::TOP) return NULL;
528
Node *add1 = phase->transform(new ConvL2INode(x));
529
Node *add2 = phase->transform(new ConvL2INode(y));
530
return new AddINode(add1,add2);
531
}
532
533
// Disable optimization: LoadL->ConvL2I ==> LoadI.
534
// It causes problems (sizes of Load and Store nodes do not match)
535
// in objects initialization code and Escape Analysis.
536
return NULL;
537
}
538
539
540
541
//=============================================================================
542
//------------------------------Identity---------------------------------------
543
// Remove redundant roundings
544
Node* RoundFloatNode::Identity(PhaseGVN* phase) {
545
assert(Matcher::strict_fp_requires_explicit_rounding, "should only generate for Intel");
546
// Do not round constants
547
if (phase->type(in(1))->base() == Type::FloatCon) return in(1);
548
int op = in(1)->Opcode();
549
// Redundant rounding
550
if( op == Op_RoundFloat ) return in(1);
551
// Already rounded
552
if( op == Op_Parm ) return in(1);
553
if( op == Op_LoadF ) return in(1);
554
return this;
555
}
556
557
//------------------------------Value------------------------------------------
558
const Type* RoundFloatNode::Value(PhaseGVN* phase) const {
559
return phase->type( in(1) );
560
}
561
562
//=============================================================================
563
//------------------------------Identity---------------------------------------
564
// Remove redundant roundings. Incoming arguments are already rounded.
565
Node* RoundDoubleNode::Identity(PhaseGVN* phase) {
566
assert(Matcher::strict_fp_requires_explicit_rounding, "should only generate for Intel");
567
// Do not round constants
568
if (phase->type(in(1))->base() == Type::DoubleCon) return in(1);
569
int op = in(1)->Opcode();
570
// Redundant rounding
571
if( op == Op_RoundDouble ) return in(1);
572
// Already rounded
573
if( op == Op_Parm ) return in(1);
574
if( op == Op_LoadD ) return in(1);
575
if( op == Op_ConvF2D ) return in(1);
576
if( op == Op_ConvI2D ) return in(1);
577
return this;
578
}
579
580
//------------------------------Value------------------------------------------
581
const Type* RoundDoubleNode::Value(PhaseGVN* phase) const {
582
return phase->type( in(1) );
583
}
584
585
//=============================================================================
586
RoundDoubleModeNode* RoundDoubleModeNode::make(PhaseGVN& gvn, Node* arg, RoundDoubleModeNode::RoundingMode rmode) {
587
ConINode* rm = gvn.intcon(rmode);
588
return new RoundDoubleModeNode(arg, (Node *)rm);
589
}
590
591
//------------------------------Identity---------------------------------------
592
// Remove redundant roundings.
593
Node* RoundDoubleModeNode::Identity(PhaseGVN* phase) {
594
int op = in(1)->Opcode();
595
// Redundant rounding e.g. floor(ceil(n)) -> ceil(n)
596
if(op == Op_RoundDoubleMode) return in(1);
597
return this;
598
}
599
const Type* RoundDoubleModeNode::Value(PhaseGVN* phase) const {
600
return Type::DOUBLE;
601
}
602
//=============================================================================
603
604