< prev index next >

src/hotspot/share/c1/c1_LinearScan.cpp

Print this page
*** 1238,15 ***
          }
        }
        break;
      }
      case lir_cmove: {
!       assert(op->as_Op2() != NULL, "lir_cmove must be LIR_Op2");
!       LIR_Op2* cmove = (LIR_Op2*)op;
  
!       LIR_Opr move_from = cmove->in_opr1();
!       LIR_Opr move_to = cmove->result_opr();
  
        if (move_to->is_register() && move_from->is_register()) {
          Interval* from = interval_at(reg_num(move_from));
          Interval* to = interval_at(reg_num(move_to));
          if (from != NULL && to != NULL) {
--- 1238,15 ---
          }
        }
        break;
      }
      case lir_cmove: {
!       assert(op->as_Op4() != NULL, "lir_cmove must be LIR_Op4");
!       LIR_Op4* cmove = (LIR_Op4*)op;
  
!       LIR_Opr move_from = cmove->in_opr3();
!       LIR_Opr move_to   = cmove->result_opr();
  
        if (move_to->is_register() && move_from->is_register()) {
          Interval* from = interval_at(reg_num(move_from));
          Interval* to = interval_at(reg_num(move_to));
          if (from != NULL && to != NULL) {

*** 6086,10 ***
--- 6086,15 ---
    }
  }
  
  
  void EdgeMoveOptimizer::optimize_moves_at_block_begin(BlockBegin* block) {
+ #ifdef RISCV
+   // It is unsafe to schedule moves early before conditional branches, because
+   // moves may destroy the input registers of branches for riscv.
+   return;
+ #endif
    TRACE_LINEAR_SCAN(4, tty->print_cr("optimization moves at begin of block B%d", block->block_id()));
  
    init_instructions();
    int num_sux = block->number_of_sux();
  

*** 6333,10 ***
--- 6338,15 ---
  
    DEBUG_ONLY(verify(code));
  }
  
  void ControlFlowOptimizer::delete_unnecessary_jumps(BlockList* code) {
+ #ifdef RISCV
+   // Disable this optimization on riscv temporarily, because it does not
+   // work when the comparison operands are bound to branches or cmoves.
+   return;
+ #endif
    // skip the last block because there a branch is always necessary
    for (int i = code->length() - 2; i >= 0; i--) {
      BlockBegin* block = code->at(i);
      LIR_OpList* instructions = block->lir()->instructions_list();
  

*** 6366,18 ***
  
                LIR_Op2* prev_cmp = NULL;
                // There might be a cmove inserted for profiling which depends on the same
                // compare. If we change the condition of the respective compare, we have
                // to take care of this cmove as well.
!               LIR_Op2* prev_cmove = NULL;
  
                for(int j = instructions->length() - 3; j >= 0 && prev_cmp == NULL; j--) {
                  prev_op = instructions->at(j);
                  // check for the cmove
                  if (prev_op->code() == lir_cmove) {
!                   assert(prev_op->as_Op2() != NULL, "cmove must be of type LIR_Op2");
!                   prev_cmove = (LIR_Op2*)prev_op;
                    assert(prev_branch->cond() == prev_cmove->condition(), "should be the same");
                  }
                  if (prev_op->code() == lir_cmp) {
                    assert(prev_op->as_Op2() != NULL, "branch must be of type LIR_Op2");
                    prev_cmp = (LIR_Op2*)prev_op;
--- 6376,18 ---
  
                LIR_Op2* prev_cmp = NULL;
                // There might be a cmove inserted for profiling which depends on the same
                // compare. If we change the condition of the respective compare, we have
                // to take care of this cmove as well.
!               LIR_Op4* prev_cmove = NULL;
  
                for(int j = instructions->length() - 3; j >= 0 && prev_cmp == NULL; j--) {
                  prev_op = instructions->at(j);
                  // check for the cmove
                  if (prev_op->code() == lir_cmove) {
!                   assert(prev_op->as_Op4() != NULL, "cmove must be of type LIR_Op4");
!                   prev_cmove = (LIR_Op4*)prev_op;
                    assert(prev_branch->cond() == prev_cmove->condition(), "should be the same");
                  }
                  if (prev_op->code() == lir_cmp) {
                    assert(prev_op->as_Op2() != NULL, "branch must be of type LIR_Op2");
                    prev_cmp = (LIR_Op2*)prev_op;
< prev index next >