On 09/02/2015 05:02 PM, Georg-Johann Lay wrote:
Anatoliy Sokolov schrieb:
Hi.

The fixed_reg_set contain all fixed and global registers. This patch
change code "fixed_regs[r] || global_regs[r]" with "TEST_HARD_REG_BIT
(fixed_reg_set, r)".

Even though technically a no-op change

   TEST_HARD_REG_BIT (fixed_reg_set, r)

appears to be a test for r being a fixed register and not for being
fixed-or-global register, so the old style

   fixed_regs[r] || global_regs[r]

seems to be less error prone.
Perhaps, but it's always been the case that a global register must always be considered fixed. It'd be fairly difficult to implement global registers with the current semantics without those registers being fixed.

This invariant is currently enforced by globalize_reg. I wouldn't be at all surprised if there are places that are currently just testing fixed_regs.





Johann

Bootstrapped and reg-tested on x86_64-unknown-linux-gnu and
powerpc64le-unknown-linux-gnu.

OK for trunk?

2015-08-24  Anatoly Sokolov  <ae...@post.ru>

    * cse.c (FIXED_REGNO_P): Don't check global_regs. Use fixed_reg_set
    instead of fixed_regs.
    * df-problems.c (can_move_insns_across): Ditto.
    * postreload.c (reload_combine_recognize_pattern): Ditto.
    * recog.c (peep2_find_free_register): Ditto.
    * regcprop.c (copy_value): Ditto.
    * regrename.c (check_new_reg_p, rename_chains): Ditto.
    * sel-sched.c (init_regs_for_mode, mark_unavailable_hard_regs):
Perhaps a better choice would be to use a macro that implies the register is neither fixed nor global, but only checks if its fixed (with an appropriate comment indicating why this is safe). THen in globalize_reg reference add a comment indicating the macro must be changed if we ever want to support global registers that are not fixed.


Ditto.

Index: gcc/cse.c
===================================================================
--- gcc/cse.c    (revision 226953)
+++ gcc/cse.c    (working copy)
@@ -463,7 +463,7 @@
    A reg wins if it is either the frame pointer or designated as
fixed.  */
 #define FIXED_REGNO_P(N)  \
   ((N) == FRAME_POINTER_REGNUM || (N) == HARD_FRAME_POINTER_REGNUM \
-   || fixed_regs[N] || global_regs[N])
+   || TEST_HARD_REG_BIT (fixed_reg_set, N))
So why not continue to test fixed_regs here (ie, just drop the global_regs test)? It's a single memory reference and a test against zero.

Using TEST_HARD_REG_BIT likely still hits memory, but then on many architectures you're then going to have to do masking/shifting to get the bit you want to look at. That seems to me like a step backwards.

Jeff

Reply via email to