[PATCH] Optimize ((c>=1)&&(c<=127)) into ((signed char)c>0)
Lars Brinkhoff
lars.spam@nocrew.org
Thu May 9 02:14:00 GMT 2002
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
More information about the Gcc-patches
mailing list