Skip to content

Commit ec219ae

Browse files
author
David Holmes
committed
8346039: [BACKOUT] - [C1] LIR Operations with one input should be implemented as LIR_Op1
Reviewed-by: kvn, mdoerr
1 parent 05c5678 commit ec219ae

File tree

10 files changed

+99
-69
lines changed

10 files changed

+99
-69
lines changed

src/hotspot/cpu/aarch64/c1_LIRGenerator_aarch64.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -777,11 +777,13 @@ void LIRGenerator::do_MathIntrinsic(Intrinsic* x) {
777777
}
778778
case vmIntrinsics::_floatToFloat16: {
779779
LIR_Opr tmp = new_register(T_FLOAT);
780+
__ move(LIR_OprFact::floatConst(-0.0), tmp);
780781
__ f2hf(src, dst, tmp);
781782
break;
782783
}
783784
case vmIntrinsics::_float16ToFloat: {
784785
LIR_Opr tmp = new_register(T_FLOAT);
786+
__ move(LIR_OprFact::floatConst(-0.0), tmp);
785787
__ hf2f(src, dst, tmp);
786788
break;
787789
}

src/hotspot/cpu/ppc/c1_LIRGenerator_ppc.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -696,6 +696,8 @@ void LIRGenerator::do_MathIntrinsic(Intrinsic* x) {
696696
value.load_item();
697697
LIR_Opr dst = rlock_result(x);
698698
LIR_Opr tmp = new_register(T_FLOAT);
699+
// f2hf treats tmp as live_in. Workaround: initialize to some value.
700+
__ move(LIR_OprFact::floatConst(-0.0), tmp); // just to satisfy LinearScan
699701
__ f2hf(value.result(), dst, tmp);
700702
break;
701703
}

src/hotspot/cpu/x86/c1_LIRGenerator_x86.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,9 +349,11 @@ void LIRGenerator::do_NegateOp(NegateOp* x) {
349349
if (UseAVX > 2 && !VM_Version::supports_avx512vl()) {
350350
if (x->type()->tag() == doubleTag) {
351351
tmp = new_register(T_DOUBLE);
352+
__ move(LIR_OprFact::doubleConst(-0.0), tmp);
352353
}
353354
else if (x->type()->tag() == floatTag) {
354355
tmp = new_register(T_FLOAT);
356+
__ move(LIR_OprFact::floatConst(-0.0), tmp);
355357
}
356358
}
357359
#endif
@@ -832,10 +834,12 @@ void LIRGenerator::do_MathIntrinsic(Intrinsic* x) {
832834
if (UseAVX > 2 && (!VM_Version::supports_avx512vl()) &&
833835
(x->id() == vmIntrinsics::_dabs)) {
834836
tmp = new_register(T_DOUBLE);
837+
__ move(LIR_OprFact::doubleConst(-0.0), tmp);
835838
}
836839
#endif
837840
if (x->id() == vmIntrinsics::_floatToFloat16) {
838841
tmp = new_register(T_FLOAT);
842+
__ move(LIR_OprFact::floatConst(-0.0), tmp);
839843
}
840844

841845
switch(x->id()) {

src/hotspot/cpu/x86/c1_LinearScan_x86.cpp

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2005, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -635,24 +635,6 @@ void FpuStackAllocator::handle_op1(LIR_Op1* op1) {
635635
break;
636636
}
637637

638-
case lir_abs:
639-
case lir_sqrt:
640-
case lir_neg: {
641-
assert(in->is_fpu_register(), "must be");
642-
assert(res->is_fpu_register(), "must be");
643-
assert(in->is_last_use(), "old value gets destroyed");
644-
645-
insert_free_if_dead(res, in);
646-
insert_exchange(in);
647-
do_rename(in, res);
648-
649-
new_in = to_fpu_stack_top(res);
650-
new_res = new_in;
651-
652-
op1->set_fpu_stack_size(sim()->stack_size());
653-
break;
654-
}
655-
656638
default: {
657639
assert(!in->is_float_kind() && !res->is_float_kind(), "missed a fpu-operation");
658640
}
@@ -774,6 +756,26 @@ void FpuStackAllocator::handle_op2(LIR_Op2* op2) {
774756
break;
775757
}
776758

759+
case lir_abs:
760+
case lir_sqrt:
761+
case lir_neg: {
762+
// Right argument appears to be unused
763+
assert(right->is_illegal(), "must be");
764+
assert(left->is_fpu_register(), "must be");
765+
assert(res->is_fpu_register(), "must be");
766+
assert(left->is_last_use(), "old value gets destroyed");
767+
768+
insert_free_if_dead(res, left);
769+
insert_exchange(left);
770+
do_rename(left, res);
771+
772+
new_left = to_fpu_stack_top(res);
773+
new_res = new_left;
774+
775+
op2->set_fpu_stack_size(sim()->stack_size());
776+
break;
777+
}
778+
777779
default: {
778780
assert(false, "missed a fpu-operation");
779781
}

src/hotspot/cpu/x86/c1_LinearScan_x86.hpp

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -66,7 +66,35 @@ inline bool LinearScan::is_caller_save(int assigned_reg) {
6666

6767

6868
inline void LinearScan::pd_add_temps(LIR_Op* op) {
69-
// No special case behaviours yet
69+
switch (op->code()) {
70+
case lir_tan: {
71+
// The slow path for these functions may need to save and
72+
// restore all live registers but we don't want to save and
73+
// restore everything all the time, so mark the xmms as being
74+
// killed. If the slow path were explicit or we could propagate
75+
// live register masks down to the assembly we could do better
76+
// but we don't have any easy way to do that right now. We
77+
// could also consider not killing all xmm registers if we
78+
// assume that slow paths are uncommon but it's not clear that
79+
// would be a good idea.
80+
if (UseSSE > 0) {
81+
#ifdef ASSERT
82+
if (TraceLinearScanLevel >= 2) {
83+
tty->print_cr("killing XMMs for trig");
84+
}
85+
#endif
86+
int num_caller_save_xmm_regs = FrameMap::get_num_caller_save_xmms();
87+
int op_id = op->id();
88+
for (int xmm = 0; xmm < num_caller_save_xmm_regs; xmm++) {
89+
LIR_Opr opr = FrameMap::caller_save_xmm_reg_at(xmm);
90+
add_temp(reg_num(opr), op_id, noUse, T_ILLEGAL);
91+
}
92+
}
93+
break;
94+
}
95+
default:
96+
break;
97+
}
7098
}
7199

72100

src/hotspot/share/c1/c1_LIR.cpp

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -452,18 +452,12 @@ void LIR_OpVisitState::visit(LIR_Op* op) {
452452
case lir_monaddr: // input and result always valid, info always invalid
453453
case lir_null_check: // input and info always valid, result always invalid
454454
case lir_move: // input and result always valid, may have info
455-
case lir_sqrt: // FP Ops have no info, but input and result
456-
case lir_abs:
457-
case lir_neg:
458-
case lir_f2hf:
459-
case lir_hf2f:
460455
{
461456
assert(op->as_Op1() != nullptr, "must be");
462457
LIR_Op1* op1 = (LIR_Op1*)op;
463458

464459
if (op1->_info) do_info(op1->_info);
465460
if (op1->_opr->is_valid()) do_input(op1->_opr);
466-
if (op1->_tmp->is_valid()) do_temp(op1->_tmp);
467461
if (op1->_result->is_valid()) do_output(op1->_result);
468462

469463
break;
@@ -489,7 +483,6 @@ void LIR_OpVisitState::visit(LIR_Op* op) {
489483

490484
assert(op1->_info != nullptr, ""); do_info(op1->_info);
491485
if (op1->_opr->is_valid()) do_temp(op1->_opr); // safepoints on SPARC need temporary register
492-
assert(op1->_tmp->is_illegal(), "not used");
493486
assert(op1->_result->is_illegal(), "safepoint does not produce value");
494487

495488
break;
@@ -573,6 +566,11 @@ void LIR_OpVisitState::visit(LIR_Op* op) {
573566
case lir_add:
574567
case lir_sub:
575568
case lir_rem:
569+
case lir_sqrt:
570+
case lir_abs:
571+
case lir_neg:
572+
case lir_f2hf:
573+
case lir_hf2f:
576574
case lir_logic_and:
577575
case lir_logic_or:
578576
case lir_logic_xor:
@@ -669,7 +667,6 @@ void LIR_OpVisitState::visit(LIR_Op* op) {
669667

670668
assert(op1->_info == nullptr, "no info");
671669
assert(op1->_opr->is_valid(), "exception oop"); do_input(op1->_opr);
672-
assert(op1->_tmp->is_illegal(), "not used");
673670
assert(op1->_result->is_illegal(), "no result");
674671

675672
break;
@@ -1733,11 +1730,6 @@ const char * LIR_Op::name() const {
17331730
case lir_cond_float_branch: s = "flt_cond_br"; break;
17341731
case lir_move: s = "move"; break;
17351732
case lir_roundfp: s = "roundfp"; break;
1736-
case lir_abs: s = "abs"; break;
1737-
case lir_neg: s = "neg"; break;
1738-
case lir_sqrt: s = "sqrt"; break;
1739-
case lir_f2hf: s = "f2hf"; break;
1740-
case lir_hf2f: s = "hf2f"; break;
17411733
case lir_rtcall: s = "rtcall"; break;
17421734
case lir_throw: s = "throw"; break;
17431735
case lir_unwind: s = "unwind"; break;
@@ -1754,6 +1746,11 @@ const char * LIR_Op::name() const {
17541746
case lir_mul: s = "mul"; break;
17551747
case lir_div: s = "div"; break;
17561748
case lir_rem: s = "rem"; break;
1749+
case lir_abs: s = "abs"; break;
1750+
case lir_neg: s = "neg"; break;
1751+
case lir_sqrt: s = "sqrt"; break;
1752+
case lir_f2hf: s = "f2hf"; break;
1753+
case lir_hf2f: s = "hf2f"; break;
17571754
case lir_logic_and: s = "logic_and"; break;
17581755
case lir_logic_or: s = "logic_or"; break;
17591756
case lir_logic_xor: s = "logic_xor"; break;

src/hotspot/share/c1/c1_LIR.hpp

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -939,11 +939,6 @@ enum LIR_Code {
939939
, lir_alloc_object
940940
, lir_monaddr
941941
, lir_roundfp
942-
, lir_sqrt
943-
, lir_abs
944-
, lir_neg
945-
, lir_f2hf
946-
, lir_hf2f
947942
, lir_safepoint
948943
, lir_unwind
949944
, lir_load_klass
@@ -960,6 +955,13 @@ enum LIR_Code {
960955
, lir_mul
961956
, lir_div
962957
, lir_rem
958+
, lir_sqrt
959+
, lir_abs
960+
, lir_neg
961+
, lir_tan
962+
, lir_f2hf
963+
, lir_hf2f
964+
, lir_log10
963965
, lir_logic_and
964966
, lir_logic_or
965967
, lir_logic_xor
@@ -1355,7 +1357,6 @@ class LIR_Op1: public LIR_Op {
13551357

13561358
protected:
13571359
LIR_Opr _opr; // input operand
1358-
LIR_Opr _tmp;
13591360
BasicType _type; // Operand types
13601361
LIR_PatchCode _patch; // only required with patchin (NEEDS_CLEANUP: do we want a special instruction for patching?)
13611362

@@ -1370,21 +1371,12 @@ class LIR_Op1: public LIR_Op {
13701371
LIR_Op1(LIR_Code code, LIR_Opr opr, LIR_Opr result = LIR_OprFact::illegalOpr, BasicType type = T_ILLEGAL, LIR_PatchCode patch = lir_patch_none, CodeEmitInfo* info = nullptr)
13711372
: LIR_Op(code, result, info)
13721373
, _opr(opr)
1373-
, _tmp(LIR_OprFact::illegalOpr)
1374-
, _type(type)
1375-
, _patch(patch) { assert(is_in_range(code, begin_op1, end_op1), "code check"); }
1376-
1377-
LIR_Op1(LIR_Code code, LIR_Opr opr, LIR_Opr result, LIR_Opr tmp, BasicType type = T_ILLEGAL, LIR_PatchCode patch = lir_patch_none, CodeEmitInfo* info = nullptr)
1378-
: LIR_Op(code, result, info)
1379-
, _opr(opr)
1380-
, _tmp(tmp)
13811374
, _type(type)
13821375
, _patch(patch) { assert(is_in_range(code, begin_op1, end_op1), "code check"); }
13831376

13841377
LIR_Op1(LIR_Code code, LIR_Opr opr, LIR_Opr result, BasicType type, LIR_PatchCode patch, CodeEmitInfo* info, LIR_MoveKind kind)
13851378
: LIR_Op(code, result, info)
13861379
, _opr(opr)
1387-
, _tmp(LIR_OprFact::illegalOpr)
13881380
, _type(type)
13891381
, _patch(patch) {
13901382
assert(code == lir_move, "must be");
@@ -1394,12 +1386,10 @@ class LIR_Op1: public LIR_Op {
13941386
LIR_Op1(LIR_Code code, LIR_Opr opr, CodeEmitInfo* info)
13951387
: LIR_Op(code, LIR_OprFact::illegalOpr, info)
13961388
, _opr(opr)
1397-
, _tmp(LIR_OprFact::illegalOpr)
13981389
, _type(T_ILLEGAL)
13991390
, _patch(lir_patch_none) { assert(is_in_range(code, begin_op1, end_op1), "code check"); }
14001391

14011392
LIR_Opr in_opr() const { return _opr; }
1402-
LIR_Opr tmp_opr() const { return _tmp; }
14031393
LIR_PatchCode patch_code() const { return _patch; }
14041394
BasicType type() const { return _type; }
14051395

@@ -2282,13 +2272,15 @@ class LIR_List: public CompilationResourceObj {
22822272
void cas_int(LIR_Opr addr, LIR_Opr cmp_value, LIR_Opr new_value,
22832273
LIR_Opr t1, LIR_Opr t2, LIR_Opr result = LIR_OprFact::illegalOpr);
22842274

2285-
void abs (LIR_Opr from, LIR_Opr to, LIR_Opr tmp) { append(new LIR_Op1(lir_abs , from, to, tmp)); }
2286-
void negate(LIR_Opr from, LIR_Opr to, LIR_Opr tmp = LIR_OprFact::illegalOpr) { append(new LIR_Op1(lir_neg, from, to, tmp)); }
2287-
void sqrt(LIR_Opr from, LIR_Opr to, LIR_Opr tmp) { append(new LIR_Op1(lir_sqrt, from, to, tmp)); }
2275+
void abs (LIR_Opr from, LIR_Opr to, LIR_Opr tmp) { append(new LIR_Op2(lir_abs , from, tmp, to)); }
2276+
void negate(LIR_Opr from, LIR_Opr to, LIR_Opr tmp = LIR_OprFact::illegalOpr) { append(new LIR_Op2(lir_neg, from, tmp, to)); }
2277+
void sqrt(LIR_Opr from, LIR_Opr to, LIR_Opr tmp) { append(new LIR_Op2(lir_sqrt, from, tmp, to)); }
22882278
void fmad(LIR_Opr from, LIR_Opr from1, LIR_Opr from2, LIR_Opr to) { append(new LIR_Op3(lir_fmad, from, from1, from2, to)); }
22892279
void fmaf(LIR_Opr from, LIR_Opr from1, LIR_Opr from2, LIR_Opr to) { append(new LIR_Op3(lir_fmaf, from, from1, from2, to)); }
2290-
void f2hf(LIR_Opr from, LIR_Opr to, LIR_Opr tmp) { append(new LIR_Op1(lir_f2hf, from, to, tmp)); }
2291-
void hf2f(LIR_Opr from, LIR_Opr to, LIR_Opr tmp) { append(new LIR_Op1(lir_hf2f, from, to, tmp)); }
2280+
void log10 (LIR_Opr from, LIR_Opr to, LIR_Opr tmp) { append(new LIR_Op2(lir_log10, from, LIR_OprFact::illegalOpr, to, tmp)); }
2281+
void tan (LIR_Opr from, LIR_Opr to, LIR_Opr tmp1, LIR_Opr tmp2) { append(new LIR_Op2(lir_tan , from, tmp1, to, tmp2)); }
2282+
void f2hf(LIR_Opr from, LIR_Opr to, LIR_Opr tmp) { append(new LIR_Op2(lir_f2hf, from, tmp, to)); }
2283+
void hf2f(LIR_Opr from, LIR_Opr to, LIR_Opr tmp) { append(new LIR_Op2(lir_hf2f, from, tmp, to)); }
22922284

22932285
void add (LIR_Opr left, LIR_Opr right, LIR_Opr res) { append(new LIR_Op2(lir_add, left, right, res)); }
22942286
void sub (LIR_Opr left, LIR_Opr right, LIR_Opr res, CodeEmitInfo* info = nullptr) { append(new LIR_Op2(lir_sub, left, right, res, info)); }

src/hotspot/share/c1/c1_LIRAssembler.cpp

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -527,17 +527,6 @@ void LIR_Assembler::emit_op1(LIR_Op1* op) {
527527
break;
528528
}
529529

530-
case lir_abs:
531-
case lir_sqrt:
532-
case lir_f2hf:
533-
case lir_hf2f:
534-
intrinsic_op(op->code(), op->in_opr(), op->tmp_opr(), op->result_opr(), op);
535-
break;
536-
537-
case lir_neg:
538-
negate(op->in_opr(), op->result_opr(), op->tmp_opr());
539-
break;
540-
541530
case lir_return: {
542531
assert(op->as_OpReturn() != nullptr, "sanity");
543532
LIR_OpReturn *ret_op = (LIR_OpReturn*)op;
@@ -735,6 +724,19 @@ void LIR_Assembler::emit_op2(LIR_Op2* op) {
735724
op->fpu_pop_count() == 1);
736725
break;
737726

727+
case lir_abs:
728+
case lir_sqrt:
729+
case lir_tan:
730+
case lir_log10:
731+
case lir_f2hf:
732+
case lir_hf2f:
733+
intrinsic_op(op->code(), op->in_opr1(), op->in_opr2(), op->result_opr(), op);
734+
break;
735+
736+
case lir_neg:
737+
negate(op->in_opr1(), op->result_opr(), op->in_opr2());
738+
break;
739+
738740
case lir_logic_and:
739741
case lir_logic_or:
740742
case lir_logic_xor:

src/hotspot/share/c1/c1_LIRAssembler.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2000, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -208,7 +208,7 @@ class LIR_Assembler: public CompilationResourceObj {
208208

209209
void arith_op(LIR_Code code, LIR_Opr left, LIR_Opr right, LIR_Opr dest, CodeEmitInfo* info, bool pop_fpu_stack);
210210
void arithmetic_idiv(LIR_Code code, LIR_Opr left, LIR_Opr right, LIR_Opr temp, LIR_Opr result, CodeEmitInfo* info);
211-
void intrinsic_op(LIR_Code code, LIR_Opr value, LIR_Opr temp, LIR_Opr dest, LIR_Op* op);
211+
void intrinsic_op(LIR_Code code, LIR_Opr value, LIR_Opr unused, LIR_Opr dest, LIR_Op* op);
212212
#ifdef ASSERT
213213
void emit_assert(LIR_OpAssert* op);
214214
#endif

src/hotspot/share/c1/c1_LinearScan.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6739,6 +6739,7 @@ void LinearScanStatistic::collect(LinearScan* allocator) {
67396739
case lir_abs:
67406740
case lir_f2hf:
67416741
case lir_hf2f:
6742+
case lir_log10:
67426743
case lir_logic_and:
67436744
case lir_logic_or:
67446745
case lir_logic_xor:

0 commit comments

Comments
 (0)