[patch] change TEST_HARD_REG_BIT to return 0 or 1
Marek Michalkiewicz
marekm@amelek.gda.pl
Sat Jul 13 07:18:00 GMT 2002
Hello,
Please consider this patch - wrap the definition of TEST_HARD_REG_BIT
in (!! ... ), so that the result is 0 or 1 (instead of the value of
the bit being tested). This can avoid possible bugs like the 2 years
old one I've just fixed in the AVR target on 64-bit hosts, where the
high bits of the result were lost by assigning to an "int" - the test
was always false for register numbers >= 32.
Bootstrapped on i686-pc-linux-gnu with no errors. Please tell me if
it's OK to commit - thanks.
2002-07-13 Marek Michalkiewicz <marekm@amelek.gda.pl>
* hard-reg-set.h (TEST_HARD_REG_BIT): Return 1 if the bit is set.
Index: hard-reg-set.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/hard-reg-set.h,v
retrieving revision 1.14
diff -c -3 -p -r1.14 hard-reg-set.h
*** hard-reg-set.h 23 Dec 2001 04:59:05 -0000 1.14
--- hard-reg-set.h 13 Jul 2002 13:29:20 -0000
*************** typedef HARD_REG_ELT_TYPE HARD_REG_SET[H
*** 92,98 ****
#define CLEAR_HARD_REG_BIT(SET, BIT) \
((SET) &= ~(HARD_CONST (1) << (BIT)))
#define TEST_HARD_REG_BIT(SET, BIT) \
! ((SET) & (HARD_CONST (1) << (BIT)))
#define CLEAR_HARD_REG_SET(TO) ((TO) = HARD_CONST (0))
#define SET_HARD_REG_SET(TO) ((TO) = ~ HARD_CONST (0))
--- 92,98 ----
#define CLEAR_HARD_REG_BIT(SET, BIT) \
((SET) &= ~(HARD_CONST (1) << (BIT)))
#define TEST_HARD_REG_BIT(SET, BIT) \
! (!!((SET) & (HARD_CONST (1) << (BIT))))
#define CLEAR_HARD_REG_SET(TO) ((TO) = HARD_CONST (0))
#define SET_HARD_REG_SET(TO) ((TO) = ~ HARD_CONST (0))
*************** typedef HARD_REG_ELT_TYPE HARD_REG_SET[H
*** 122,129 ****
&= ~(HARD_CONST (1) << ((BIT) % UHOST_BITS_PER_WIDE_INT)))
#define TEST_HARD_REG_BIT(SET, BIT) \
! ((SET)[(BIT) / UHOST_BITS_PER_WIDE_INT] \
! & (HARD_CONST (1) << ((BIT) % UHOST_BITS_PER_WIDE_INT)))
#if FIRST_PSEUDO_REGISTER <= 2*HOST_BITS_PER_WIDE_INT
#define CLEAR_HARD_REG_SET(TO) \
--- 122,129 ----
&= ~(HARD_CONST (1) << ((BIT) % UHOST_BITS_PER_WIDE_INT)))
#define TEST_HARD_REG_BIT(SET, BIT) \
! (!!((SET)[(BIT) / UHOST_BITS_PER_WIDE_INT] \
! & (HARD_CONST (1) << ((BIT) % UHOST_BITS_PER_WIDE_INT))))
#if FIRST_PSEUDO_REGISTER <= 2*HOST_BITS_PER_WIDE_INT
#define CLEAR_HARD_REG_SET(TO) \
More information about the Gcc-patches
mailing list