[PATCH] Fix A < 0 ? <sign bit of A> : 0 optimization (PR middle-end/29695)

Roger Sayle roger@eyesopen.com
Sat Nov 4 02:04:00 GMT 2006

On Fri, 3 Nov 2006, Jakub Jelinek wrote:
> 2006-11-03  Jakub Jelinek  <jakub@redhat.com>
> 	PR middle-end/29695
> 	* fold-const.c (fold_ternary): Fix A < 0 ? <sign bit of A> : 0
> 	simplification.
> 	* gcc.c-torture/execute/pr29695-1.c: New test.
> 	* gcc.c-torture/execute/pr29695-2.c: New test.

This is OK for mainline, and affected branches.  Thanks.

I do appreciate the extra effort you've gone to, identifing and
implementing the situations where this transformation is valid based
upon sign or zero extension.  A lesser fix would have been to simply
limit this transformation to the case where A and <sign bit of A>
have the same size/type.  Thanks again for going the extra mile,
and generalizing this optimization.


More information about the Gcc-patches mailing list