On Fri, 13 Mar 2009, Richard Guenther wrote:

> Last time I sent a patch to remove the SHIFT_COUNT_TRUNCATED check
> from fold-const.c the reason that this was rejected was that we want to
> be consistend with target behavior...

I would disagree with such a rejection.  If we want to provide any sort of 
consistency I think it should be optional (an option like -fwrapv) and 
define the semantics at the language level rather than depending on the 
target.

> > As I understand it, SHIFT_COUNT_TRUNCATED is about the semantics of RTL,
> > and has no bearing on the implemented semantics of any source language or
> > of GENERIC or GIMPLE; GENERIC and GIMPLE both follow the rule that
> > out-of-range shifts (or rotates?), including those by negative amounts,
> > are undefined.
> 
> "Undefined" is a bad semantic for GIMPLE.  If the frontends want the 
> middle-end
> to take advantage of undefinedness it needs to translate it to a useful 
> defined
> state.

By undefined I mean that the middle-end may assume that the value is 
within range [0, number of value and sign bits in type) and transform on 
the basis of that assumption (including value range propagation).

-- 
Joseph S. Myers
jos...@codesourcery.com

Reply via email to