This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Optimize ((c>=1)&&(c<=127)) into ((signed char)c>0)
- From: Lars Brinkhoff <lars dot spam at nocrew dot org>
- To: Roger Sayle <roger at eyesopen dot com>
- Cc: <gcc-patches at gcc dot gnu dot org>
- Date: 09 May 2002 09:05:11 +0200
- Subject: Re: [PATCH] Optimize ((c>=1)&&(c<=127)) into ((signed char)c>0)
- Organization: nocrew
- References: <Pine.LNX.4.33.0205081903490.12421-100000@www.eyesopen.com>
Roger Sayle <roger@eyesopen.com> writes:
> + void
> + test (unsigned char c, int ok)
> + {
> + if ((c>=1) && (c<=127))
> + {
> + if (!ok) abort ();
> + }
> + else
> + if (ok) abort ();
> + }
> +
> + int
> + main ()
> + {
> + test ( 0, 0);
> + test ( 1, 1);
> + test ( 64, 1);
> + test (127, 1);
> + test (128, 0);
> + test (192, 0);
> + test (255, 0);
> + return 0;
> + }
Perhaps consider CHAR_BIT in <limits.h>?
--
Lars Brinkhoff http://lars.nocrew.org/ Linux, GCC, PDP-10,
Brinkhoff Consulting http://www.brinkhoff.se/ HTTP programming