From: Richard Kenner Date: Fri, 14 Apr 1995 22:48:49 +0000 (-0400) Subject: (probe_stack): Probe with write, not read. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=13aa593cd623101246e1d2382131a86b8638a562;p=gcc.git (probe_stack): Probe with write, not read. (allocate_stack): Update and correct stack probe code. From-SVN: r9384 --- diff --git a/gcc/config/alpha/alpha.md b/gcc/config/alpha/alpha.md index 0af9cc226c9..350d32bc750 100644 --- a/gcc/config/alpha/alpha.md +++ b/gcc/config/alpha/alpha.md @@ -3654,11 +3654,11 @@ "" " { - operands[0] = gen_rtx (MEM, DImode, plus_constant (stack_pointer_rtx, + operands[1] = gen_rtx (MEM, DImode, plus_constant (stack_pointer_rtx, INTVAL (operands[0]))); - MEM_VOLATILE_P (operands[0]) = 1; + MEM_VOLATILE_P (operands[1]) = 1; - operands[1] = gen_reg_rtx (DImode); + operands[0] = const0_rtx; }") ;; This is how we allocate stack space. If we are allocating a @@ -3689,7 +3689,7 @@ emit_insn (gen_probe_stack (GEN_INT (- (probed += 8192)))); if (probed + 4096 < INTVAL (operands[0])) - emit_insn (gen_probe_stack (GEN_INT (- (probed += 4096)))); + emit_insn (gen_probe_stack (GEN_INT (- INTVAL(operands[0])))); } operands[0] = GEN_INT (- INTVAL (operands[0])); @@ -3698,56 +3698,36 @@ { rtx out_label = 0; rtx loop_label = gen_label_rtx (); - rtx count = gen_reg_rtx (DImode); - rtx access = gen_reg_rtx (Pmode); - rtx memref = gen_rtx (MEM, DImode, access); - - MEM_VOLATILE_P (memref) = 1; + rtx want = gen_reg_rtx (Pmode); + rtx tmp = gen_reg_rtx (Pmode); + rtx memref; - /* If the amount to be allocated is not a constant, we only need to - do something special if it is >= 4096. */ + emit_insn (gen_subdi3 (want, stack_pointer_rtx, + force_reg (Pmode, operands[0]))); + emit_insn (gen_adddi3 (tmp, stack_pointer_rtx, GEN_INT (-4096))); if (GET_CODE (operands[0]) != CONST_INT) { - operands[0] = force_reg (DImode, operands[0]); out_label = gen_label_rtx (); - emit_insn (gen_cmpdi (operands[0], - force_reg (DImode, GEN_INT (4096)))); - emit_jump_insn (gen_ble (out_label)); - - /* Compute COUNT = (N + 4096) / 8192. N is known positive. */ - emit_insn (gen_adddi3 (count, operands[0], GEN_INT (4096))); - emit_insn (gen_lshrdi3 (count, count, GEN_INT (13))); + emit_insn (gen_cmpdi (want, tmp)); + emit_jump_insn (gen_bgeu (out_label)); } - else - emit_move_insn (count, GEN_INT ((INTVAL (operands[0]) + 4096) >> 13)); - /* ACCESS = SP + 4096. */ - emit_insn (gen_adddi3 (access, stack_pointer_rtx, GEN_INT (4096))); emit_label (loop_label); - - /* Each iteration subtracts 8192 from ACCESS and references it. */ - emit_insn (gen_adddi3 (count, count, constm1_rtx)); - emit_insn (gen_adddi3 (access, access, GEN_INT (-8192))); - emit_move_insn (gen_reg_rtx (DImode), memref); - emit_insn (gen_cmpdi (count, const0_rtx)); - emit_jump_insn (gen_bgt (loop_label)); + memref = gen_rtx (MEM, DImode, tmp); + MEM_VOLATILE_P (memref) = 1; + emit_move_insn (memref, const0_rtx); + emit_insn (gen_adddi3 (tmp, tmp, GEN_INT(-8192))); + emit_insn (gen_cmpdi (tmp, want)); + emit_jump_insn (gen_bgtu (loop_label)); + memref = gen_rtx (MEM, DImode, want); + MEM_VOLATILE_P (memref) = 1; + emit_move_insn (memref, const0_rtx); if (out_label) emit_label (out_label); - /* We need to subtract operands[0] from SP. We know it isn't a - constant less than 32768, so we know we have to load it into - a register. */ - - emit_insn (gen_subdi3 (stack_pointer_rtx, stack_pointer_rtx, - force_reg (Pmode, operands[0]))); - - /* Now, unless we have a constant and we know that we are within - 4096 from the end, we need to access sp + 4096. */ - if (! (GET_CODE (operands[0]) == CONST_INT - && (INTVAL (operands[0]) % 8192) < 4096)) - emit_insn (gen_probe_stack (GEN_INT (4096))); + emit_move_insn (stack_pointer_rtx, want); DONE; }