public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/18065] usual arithmetic conversion not applying correctly
       [not found] <bug-18065-4@http.gcc.gnu.org/bugzilla/>
@ 2012-05-24 14:03 ` peter777778 at hotmail dot co.uk
  2012-05-24 14:04 ` peter777778 at hotmail dot co.uk
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 17+ messages in thread
From: peter777778 at hotmail dot co.uk @ 2012-05-24 14:03 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18065

--- Comment #36 from online games <peter777778 at hotmail dot co.uk> 2012-05-24 14:02:07 UTC ---
http://free-online-games-mmorpg.blogspot.co.uk/


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [Bug tree-optimization/18065] usual arithmetic conversion not applying correctly
       [not found] <bug-18065-4@http.gcc.gnu.org/bugzilla/>
  2012-05-24 14:03 ` [Bug tree-optimization/18065] usual arithmetic conversion not applying correctly peter777778 at hotmail dot co.uk
@ 2012-05-24 14:04 ` peter777778 at hotmail dot co.uk
  2012-05-24 14:05 ` peter777778 at hotmail dot co.uk
  2012-05-24 14:23 ` peter777778 at hotmail dot co.uk
  3 siblings, 0 replies; 17+ messages in thread
From: peter777778 at hotmail dot co.uk @ 2012-05-24 14:04 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18065

online games <peter777778 at hotmail dot co.uk> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |peter777778 at hotmail dot
                   |                            |co.uk

--- Comment #36 from online games <peter777778 at hotmail dot co.uk> 2012-05-24 14:02:07 UTC ---
http://free-online-games-mmorpg.blogspot.co.uk/

--- Comment #37 from online games <peter777778 at hotmail dot co.uk> 2012-05-24 14:03:12 UTC ---
http://free-online-games-mmorpg.blogspot.co.uk/


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [Bug tree-optimization/18065] usual arithmetic conversion not applying correctly
       [not found] <bug-18065-4@http.gcc.gnu.org/bugzilla/>
  2012-05-24 14:03 ` [Bug tree-optimization/18065] usual arithmetic conversion not applying correctly peter777778 at hotmail dot co.uk
  2012-05-24 14:04 ` peter777778 at hotmail dot co.uk
@ 2012-05-24 14:05 ` peter777778 at hotmail dot co.uk
  2012-05-24 14:23 ` peter777778 at hotmail dot co.uk
  3 siblings, 0 replies; 17+ messages in thread
From: peter777778 at hotmail dot co.uk @ 2012-05-24 14:05 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18065

online games <peter777778 at hotmail dot co.uk> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |peter777778 at hotmail dot
                   |                            |co.uk

--- Comment #37 from online games <peter777778 at hotmail dot co.uk> 2012-05-24 14:03:12 UTC ---
http://free-online-games-mmorpg.blogspot.co.uk/

--- Comment #38 from online games <peter777778 at hotmail dot co.uk> 2012-05-24 14:03:48 UTC ---
http://free-online-games-mmorpg.blogspot.co.uk/


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [Bug tree-optimization/18065] usual arithmetic conversion not applying correctly
       [not found] <bug-18065-4@http.gcc.gnu.org/bugzilla/>
                   ` (2 preceding siblings ...)
  2012-05-24 14:05 ` peter777778 at hotmail dot co.uk
@ 2012-05-24 14:23 ` peter777778 at hotmail dot co.uk
  3 siblings, 0 replies; 17+ messages in thread
From: peter777778 at hotmail dot co.uk @ 2012-05-24 14:23 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18065

online games <peter777778 at hotmail dot co.uk> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |peter777778 at hotmail dot
                   |                            |co.uk

--- Comment #37 from online games <peter777778 at hotmail dot co.uk> 2012-05-24 14:03:12 UTC ---
http://free-online-games-mmorpg.blogspot.co.uk/

--- Comment #38 from online games <peter777778 at hotmail dot co.uk> 2012-05-24 14:03:48 UTC ---
http://free-online-games-mmorpg.blogspot.co.uk/

--- Comment #39 from online games <peter777778 at hotmail dot co.uk> 2012-05-24 14:04:22 UTC ---
http://free-online-games-mmorpg.blogspot.co.uk/


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [Bug tree-optimization/18065] usual arithmetic conversion not applying correctly
       [not found] <bug-18065-9497@http.gcc.gnu.org/bugzilla/>
  2010-09-14  7:06 ` abnikant dot singh at atmel dot com
@ 2010-09-14  7:13 ` abnikant dot singh at atmel dot com
  1 sibling, 0 replies; 17+ messages in thread
From: abnikant dot singh at atmel dot com @ 2010-09-14  7:13 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #35 from abnikant dot singh at atmel dot com  2010-09-14 07:13 -------
In the head c-common.c is placed in gcc/c-family/c-common.c


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18065


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [Bug tree-optimization/18065] usual arithmetic conversion not applying correctly
       [not found] <bug-18065-9497@http.gcc.gnu.org/bugzilla/>
@ 2010-09-14  7:06 ` abnikant dot singh at atmel dot com
  2010-09-14  7:13 ` abnikant dot singh at atmel dot com
  1 sibling, 0 replies; 17+ messages in thread
From: abnikant dot singh at atmel dot com @ 2010-09-14  7:06 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #34 from abnikant dot singh at atmel dot com  2010-09-14 07:06 -------
Yeah, this is happening because of the type promotion in gcc/c-common.c in the
function c_promoting_integer_type_p. See this:

/* Nonzero if the type T promotes to int.  This is (nearly) the
   integral promotions defined in ISO C99 6.3.1.1/2.  */

bool
c_promoting_integer_type_p (const_tree t)
{
  switch (TREE_CODE (t))
    {
    case INTEGER_TYPE:
      return (TYPE_MAIN_VARIANT (t) == char_type_node
              || TYPE_MAIN_VARIANT (t) == signed_char_type_node
              || TYPE_MAIN_VARIANT (t) == unsigned_char_type_node
              || TYPE_MAIN_VARIANT (t) == short_integer_type_node
              || TYPE_MAIN_VARIANT (t) == short_unsigned_type_node
              || TYPE_PRECISION (t) < TYPE_PRECISION (integer_type_node));

    case ENUMERAL_TYPE:
      /* ??? Technically all enumerations not larger than an int
         promote to an int.  But this is used along code paths
         that only want to notice a size change.  */
      return TYPE_PRECISION (t) < TYPE_PRECISION (integer_type_node);

    case BOOLEAN_TYPE:
      return 1;

    default:
      return 0;
    }
}

So by commenting the case INTEGER_TYPE, we will get the call to _divmodqi4, but
I don't think this is the right thing to do.


-- 

abnikant dot singh at atmel dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |abnikant dot singh at atmel
                   |                            |dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18065


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [Bug tree-optimization/18065] usual arithmetic conversion not applying correctly
  2004-10-19 20:22 [Bug c/18065] New: wrong built-in functions selected schlie at comcast dot net
                   ` (9 preceding siblings ...)
  2005-01-16  7:17 ` schlie at comcast dot net
@ 2005-01-16 17:39 ` schlie at comcast dot net
  10 siblings, 0 replies; 17+ messages in thread
From: schlie at comcast dot net @ 2005-01-16 17:39 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From schlie at comcast dot net  2005-01-16 17:39 -------
Subject: Re:  usual arithmetic conversion not
 applying correctly




> From: schlie at comcast dot net <gcc-bugzilla@gcc.gnu.org>
> ------- Additional Comments From schlie at comcast dot net  2005-01-16 07:16
> Subject: Re:  usual arithmetic conversion not applying correctly
> 
> Wonder if this PR could still be considered a missed optimization, as the
> present logic which determines if an / or % expression's operands may be
> shortened, misses the case where if the lhs operand is a constant, it may
> be verified as not being INT_MIN; as if it's not, then it's impossible for
> the operation to overflow, i.e. INT_MIN / -1  => INT_MAX+1, therefore
> may be shortened. As noted as being absent in it's comment on shortening:
> 
>   /* Although it would be tempting to shorten always here, that loses
>      on some targets, since the modulo instruction is undefined if the
>      quotient can't be represented in the computation mode.  We shorten
>      only if unsigned or if dividing by something we know != -1.  */

- It would be unfortunate if / and % couldn't be somewhat further optimized
  prior to 4.0 when their lhs operands are known not to be INT_MIN, as they
  tend to be typically relatively expensive operations, likely benefiting
  from shortening more than most.

> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18065
> 
> ------- You are receiving this mail because: -------
> You reported the bug, or are watching the reporter.




-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18065


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [Bug tree-optimization/18065] usual arithmetic conversion not applying correctly
  2004-10-19 20:22 [Bug c/18065] New: wrong built-in functions selected schlie at comcast dot net
                   ` (8 preceding siblings ...)
  2005-01-16  1:39 ` pinskia at gcc dot gnu dot org
@ 2005-01-16  7:17 ` schlie at comcast dot net
  2005-01-16 17:39 ` schlie at comcast dot net
  10 siblings, 0 replies; 17+ messages in thread
From: schlie at comcast dot net @ 2005-01-16  7:17 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From schlie at comcast dot net  2005-01-16 07:16 -------
Subject: Re:  usual arithmetic conversion not
 applying correctly

Wonder if this PR could still be considered a missed optimization, as the
present logic which determines if an / or % expression's operands may be
shortened, misses the case where if the lhs operand is a constant, it may
be verified as not being INT_MIN; as if it's not, then it's impossible for
the operation to overflow, i.e. INT_MIN / -1  => INT_MAX+1, therefore
may be shortened. As noted as being absent in it's comment on shortening:

  /* Although it would be tempting to shorten always here, that loses
     on some targets, since the modulo instruction is undefined if the
     quotient can't be represented in the computation mode.  We shorten
     only if unsigned or if dividing by something we know != -1.  */

> From: pinskia at gcc dot gnu dot org <gcc-bugzilla@gcc.gnu.org>
> Subject: [Bug tree-optimization/18065] usual arithmetic conversion not
> applying correctly
> 
> -- 
>            What    |Removed                     |Added
> ----------------------------------------------------------------------------
>            Severity|normal                      |enhancement
>            Priority|P1                          |P3
> 
> 
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18065




-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18065


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [Bug tree-optimization/18065] usual arithmetic conversion not applying correctly
  2004-10-19 20:22 [Bug c/18065] New: wrong built-in functions selected schlie at comcast dot net
                   ` (7 preceding siblings ...)
  2004-12-21 20:50 ` schlie at comcast dot net
@ 2005-01-16  1:39 ` pinskia at gcc dot gnu dot org
  2005-01-16  7:17 ` schlie at comcast dot net
  2005-01-16 17:39 ` schlie at comcast dot net
  10 siblings, 0 replies; 17+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-01-16  1:39 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |enhancement
           Priority|P1                          |P3


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18065


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [Bug tree-optimization/18065] usual arithmetic conversion not applying correctly
  2004-10-19 20:22 [Bug c/18065] New: wrong built-in functions selected schlie at comcast dot net
                   ` (6 preceding siblings ...)
  2004-10-21 12:47 ` bangerth at dealii dot org
@ 2004-12-21 20:50 ` schlie at comcast dot net
  2005-01-16  1:39 ` pinskia at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 17+ messages in thread
From: schlie at comcast dot net @ 2004-12-21 20:50 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From schlie at comcast dot net  2004-12-21 20:50 -------
(although not the most elegant fix)

This fixes the rest of the problem, as there's no reaon to default promote smaller than int sized
integers to int, they will end up being promoted if required by the back-end if the target requires
them to be (also should not need to litterally promote enum's and bool beyond the smallest int
type with suffecient to represent it's value range):

(called via default_conversion() to determine if an expression should be converted by default to int)

*** In File: c-common.c ***

  bool
  c_promoting_integer_type_p (tree t)
  {
    switch (TREE_CODE (t))
      {
-    case INTEGER_TYPE:
-     return (TYPE_MAIN_VARIANT (t) == char_type_node
-         || TYPE_MAIN_VARIANT (t) == signed_char_type_node
-         || TYPE_MAIN_VARIANT (t) == unsigned_char_type_node
-         || TYPE_MAIN_VARIANT (t) == short_integer_type_node
-         || TYPE_MAIN_VARIANT (t) == short_unsigned_type_node
-         || TYPE_PRECISION (t) < TYPE_PRECISION (integer_type_node)); pws--*/
-
      case ENUMERAL_TYPE:
        /* ??? Technically all enumerations not larger than an int
       promote to an int.  But this is used along code paths
       that only want to notice a size change.  */
        return TYPE_PRECISION (t) < TYPE_PRECISION (integer_type_node);
  
      case BOOLEAN_TYPE:
        return 1;
  
      default:
        return 0;
      }
  }

*** end ***


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18065


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [Bug tree-optimization/18065] usual arithmetic conversion not applying correctly
  2004-10-19 20:22 [Bug c/18065] New: wrong built-in functions selected schlie at comcast dot net
                   ` (5 preceding siblings ...)
  2004-10-21  1:28 ` schlie at comcast dot net
@ 2004-10-21 12:47 ` bangerth at dealii dot org
  2004-12-21 20:50 ` schlie at comcast dot net
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 17+ messages in thread
From: bangerth at dealii dot org @ 2004-10-21 12:47 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From bangerth at dealii dot org  2004-10-21 12:47 -------
> And for what little it may be worth, for good or bad, the factual reality 
> is that there are 100's of times more small processors programmed and 
> deployed in products than there are 32+ bit processors, therefore it would 
> be nice if GCC didn't needless restrict itself to being most optimally 
> applicable to larger machines at the expense of smaller machines (as there 
> far more commercial 8 and 16 bit processors available from companies 
> interested in support than their are 32-64 bit processor companies, and 
> likely to remain that way, so it's not likely good business to bite the 
> hand that may feed you). 
 
Just to have this (obvious) fact mentioned in this thread also: as a 
developer starved project, we are always grateful for patches people may 
send that improve the behavior of gcc. Your company may also be interested 
in hiring gcc developers to implement features you need. 
 
W. 

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18065


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [Bug tree-optimization/18065] usual arithmetic conversion not applying correctly
  2004-10-19 20:22 [Bug c/18065] New: wrong built-in functions selected schlie at comcast dot net
                   ` (4 preceding siblings ...)
  2004-10-21  1:04 ` schlie at comcast dot net
@ 2004-10-21  1:28 ` schlie at comcast dot net
  2004-10-21 12:47 ` bangerth at dealii dot org
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 17+ messages in thread
From: schlie at comcast dot net @ 2004-10-21  1:28 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From schlie at comcast dot net  2004-10-21 01:28 -------
Subject: Re:  usual arithmetic conversion not applying
 correctly

Andrew,

So regardless of the all other things, it seems minimally clear that
the promotion code as it stands now should allow the required result type
to be shortened to the size and type of the modulus operand for modulus
operations; and to the size and type of the dividend operand if the divisor
is unsigned, and the required result precision promoted to the next larger
signed type otherwise (although not strictly required if the true
destination's precision requirement is less). Which should address the short
term problem associated with type promotion being done by the front end.

-paul-

> From: Paul Schlie <schlie@comcast.net>
> Date: Wed, 20 Oct 2004 17:19:24 -0400
> To: <gcc-bugzilla@gcc.gnu.org>
> Subject: Re: [Bug c/18065] usual arithmetic conversion not applying correctly
> 
> Andrew,
> 
> Yes, and with respect to / and % operations:
> 
> - the modulo/reminder result can always be represented in the same type
>   and size as its divisor/modulus operand, regardless of the dividend's
>   type and size.
> 
> - the quotient result can always be represented in the same type and size
>   as it's dividend, if it's divisor/modulus operand is unsigned, otherwise
>   ideally to be promoted to it's next larger signed type to preserve
>   accuracy if useful, but typically irrelevant, as operator result
>   precision is in most practical circumstances determined by the precision
>   of the result's need, therefore in typical cases like int = int / int
>   no value is derived from pretending to preserve idealized accuracy,
>   therefore CPU's typically implement instructions to yield the equivalent
>   results that would have been attained if the precision were maintained,
>   and then simply truncated when assigned to it's destination type for
>   typical integer operations but mark an under or overflow flag, just as
>   int = int + int; would overflow; therefore for all practical purposes,
>   integer operands should never be promoted beyond their need, nor should
>   operation precision be required beyond it's result's need.
> 
> (and just to double check, this needs to get fixed on 3.4.3 too, which
>  I honestly suspect is related to the rtl interpretation, as other QI
>  mode instruction specifications are properly matched as expected.)
> 
> (also it's likely that these type of problems predominantly express
>  themselves on small target machines, as on larger 32/64 bit machines,
>  operations physically occur on correspondingly wide cpu's, therefore
>  don't enable inappropriate operand promotion errors to be easily
>  observable.)
> 
> -paul-
> 
>> From: pinskia at gcc dot gnu dot org <gcc-bugzilla@gcc.gnu.org>
>> Reply-To: <gcc-bugzilla@gcc.gnu.org>
>> Date: 20 Oct 2004 19:29:13 -0000
>> To: <schlie@comcast.net>
>> Subject: [Bug c/18065] usual arithmetic conversion not applying correctly
>> 
>> 
>> ------- Additional Comments From pinskia at gcc dot gnu dot org  2004-10-20
>> 19:29 -------
>> And the reason why we don't shoten back to signed char % signed char:
>> 
>>  /* Although it would be tempting to shorten always here, that loses
>>     on some targets, since the modulo instruction is undefined if the
>>     quotient can't be represented in the computation mode.  We shorten
>>     only if unsigned or if dividing by something we know != -1.  */
>> 
>> So maybe this is correct.
>> 
>> -- 
>> 
>> 
>> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18065
>> 
>> ------- You are receiving this mail because: -------
>> You reported the bug, or are watching the reporter.




-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18065


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [Bug tree-optimization/18065] usual arithmetic conversion not applying correctly
  2004-10-19 20:22 [Bug c/18065] New: wrong built-in functions selected schlie at comcast dot net
                   ` (3 preceding siblings ...)
  2004-10-20 23:28 ` schlie at comcast dot net
@ 2004-10-21  1:04 ` schlie at comcast dot net
  2004-10-21  1:28 ` schlie at comcast dot net
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 17+ messages in thread
From: schlie at comcast dot net @ 2004-10-21  1:04 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From schlie at comcast dot net  2004-10-21 01:04 -------
Subject: Re:  usual arithmetic conversion not
 applying correctly

Ok, a more basic observation/recommendation: the front end should not be
masking true operand types by promoting them prematurely, as it generates
very little value, while needlessly complicating the back-end's ability to
easily generate optimal code for non-integer width machines; as with
efficient access to the true source operand precision, and true operation
result precision requirements, the back end can then easily and directly
leverage the target's rtl machine description to generate fully conforming
precision code, with out the burden of having to back-out prematurely
applied type conversions (which seem wholly counterproductive).

(which of course is the point of being able to specify optimal QI, and in
many cases HI mode rtl instruction mappings, which have been made much less
efficient by the front-end's choice to needlessly prematurely type promote
operands prior to the literal requirement to do so.)

Thanks for hearing me out, and by the way this whole discussion began by
observing that GCC was not utilizing efficient rtl QI mode instruction
descriptions, resulting in the classification of the bug as a "missed
optimization" bug, as opposed to an "incorrect code" bug, with the
explanation that although the source and destination operands specified
in C could be implemented as specified in the rtl instruction mapping
specification and be fully conforming, it wasn't recognized because the
back-end didn't find the "optimization" because the front-end needlessly
prematurely type converted all operands passed to the back-end.

And for what little it may be worth, for good or bad, the factual reality
is that there are 100's of times more small processors programmed and
deployed in products than there are 32+ bit processors, therefore it would
be nice if GCC didn't needless restrict itself to being most optimally
applicable to larger machines at the expense of smaller machines (as there
far more commercial 8 and 16 bit processors available from companies
interested in support than their are 32-64 bit processor companies, and
likely to remain that way, so it's not likely good business to bite the
hand that may feed you).

-paul-


> From: jsm at polyomino dot org dot uk <gcc-bugzilla@gcc.gnu.org>
> Reply-To: <gcc-bugzilla@gcc.gnu.org>
> Date: 20 Oct 2004 23:03:15 -0000
> To: <schlie@comcast.net>
> Subject: [Bug tree-optimization/18065] usual arithmetic conversion not
> applying correctly
> 
> 
> ------- Additional Comments From jsm at polyomino dot org dot uk  2004-10-20
> 23:03 -------
> Subject:  Re: C integer promotion semantics /
>  front end problems.
> 
> I presume you sent your message directly to me by mistake, so am sending
> the reply back to the bug database so it can benefit more than one person.
> Technical messages about public GCC versions should, absent any more
> specific support arrangements in a particular case, go to the mailing
> lists, not individuals; questions are answered in public GCC development
> for the benefit of the public.
> 
> On Wed, 20 Oct 2004, Paul Schlie wrote:
> 
>> Sorry to do this to you again, but where do you see in the standard the
>> requirement to promote, or license to needlessly promote all operands
>> to int?
> 
> C99 subclause 6.3.1.1 paragraph 2.  signed char has rank less than that of
> int, so it *must* be promoted to int.  What happens afterwards is nothing
> to do with the front end.  The front end does *too many* optimisations; it
> should purely generate GIMPLE representing the standard meaning of the
> code and leave it to the later stages to tell that such conversions - or
> indeed conversions between int and long where they are the same size - can
> be optimised away in some cases.
> 
> -- 
> 
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18065
> 
> ------- You are receiving this mail because: -------
> You reported the bug, or are watching the reporter.




-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18065


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [Bug tree-optimization/18065] usual arithmetic conversion not applying correctly
  2004-10-19 20:22 [Bug c/18065] New: wrong built-in functions selected schlie at comcast dot net
                   ` (2 preceding siblings ...)
  2004-10-20 23:03 ` jsm at polyomino dot org dot uk
@ 2004-10-20 23:28 ` schlie at comcast dot net
  2004-10-21  1:04 ` schlie at comcast dot net
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 17+ messages in thread
From: schlie at comcast dot net @ 2004-10-20 23:28 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From schlie at comcast dot net  2004-10-20 23:28 -------
Subject: Re:  usual arithmetic conversion not
 applying correctly

What size promotion is required for char sized integer operations?

 I see none?

What size promotion is required for short sized integer operations?

 I see none?

The standard's refers to (as below earlier already referenced by Andrew):

- "integer" promotion is performed on both operands, and then further size
and/or sign-type converted as required if the operands aren't already of the
same "integer" type.

"integer type" not "int"; char, short, int, long are "integer types" of
different rank, yes?

The only primitive storage classes in C which aren't intrinsically an
"integer type" are: bool, enum, and bit-fields to my knowledge, which
require implicit promotion to an "integer type" to be operated on.

Even if you said that char's aren't "integer types" it's easy enough to
define short as having the same size as char, thereby promote char->short
which is surely an "integer type", although char's already are.

Where am I missing it?

>From C99
(6.5.5/3): The usual arithmetic conversions are performed on the operands.

6.3.1.8 Usual arithmetic conversions
Otherwise, the integer promotions are performed on both operands. Then the
following rules are
applied to the promoted operands: If both operands have the same type, then
no further conversion is
needed. Otherwise, if both operands have signed integer types or both have
unsigned integer types, the
operand with the type of lesser integer conversion rank is converted to the
type of the operand with
greater rank. Otherwise, if the operand that has unsigned integer type has
rank greater or equal to the
rank of the type of the other operand, then the operand with signed integer
type is converted to the
type of the operand with unsigned integer type. Otherwise, if the type of
the operand with signed
integer type can represent all of the values of the type of the operand with
unsigned integer type, then
the operand with unsigned integer type is converted to the type of the
operand with signed integer
type. Otherwise, both operands are converted to the unsigned integer type
corresponding to the type of
the operand with signed integer type.


> From: jsm at polyomino dot org dot uk <gcc-bugzilla@gcc.gnu.org>
> Reply-To: <gcc-bugzilla@gcc.gnu.org>
> Date: 20 Oct 2004 22:41:59 -0000
> To: <schlie@comcast.net>
> Subject: [Bug tree-optimization/18065] usual arithmetic conversion not
> applying correctly
> 
> 
> ------- Additional Comments From jsm at polyomino dot org dot uk  2004-10-20
> 22:41 -------
> Subject: Re:  usual arithmetic conversion not applying correctly
> 
> On Wed, 20 Oct 2004, schlie at comcast dot net wrote:
> 
>>  It's a pretty major screw-up to presume
>>  all target machines are large, and then to encode that presumption into
>>  C's front end; not to mention it seems pretty stupid to do, and then
> 
> This is not a GCC presumption, it is a property of the C language that
> there are certain promotions that may not be optimally efficient for 8-bit
> targets.  If there is a "major screw-up", it is either in the choice to
> use a language designed for systems that are at least 16-bit on an 8-bit
> target, or in the language design if you think 8-bit targets should have
> been given greater importance when the language was being standardised in
> the 1980s; it is nothing to do with the front end.  The AVR target has a
> -mint8 option which puts the compiler in a nonconforming mode with 8-bit
> int, which might however give you better code than you can get with
> standard C on an 8-bit target.
> 
> 
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18065
> 
> ------- You are receiving this mail because: -------
> You reported the bug, or are watching the reporter.




-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18065


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [Bug tree-optimization/18065] usual arithmetic conversion not applying correctly
  2004-10-19 20:22 [Bug c/18065] New: wrong built-in functions selected schlie at comcast dot net
  2004-10-20 22:31 ` [Bug tree-optimization/18065] usual arithmetic conversion not applying correctly pinskia at gcc dot gnu dot org
  2004-10-20 22:42 ` jsm at polyomino dot org dot uk
@ 2004-10-20 23:03 ` jsm at polyomino dot org dot uk
  2004-10-20 23:28 ` schlie at comcast dot net
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 17+ messages in thread
From: jsm at polyomino dot org dot uk @ 2004-10-20 23:03 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From jsm at polyomino dot org dot uk  2004-10-20 23:03 -------
Subject:  Re: C integer promotion semantics /
 front end problems.

I presume you sent your message directly to me by mistake, so am sending 
the reply back to the bug database so it can benefit more than one person.  
Technical messages about public GCC versions should, absent any more 
specific support arrangements in a particular case, go to the mailing 
lists, not individuals; questions are answered in public GCC development 
for the benefit of the public.

On Wed, 20 Oct 2004, Paul Schlie wrote:

> Sorry to do this to you again, but where do you see in the standard the
> requirement to promote, or license to needlessly promote all operands
> to int?

C99 subclause 6.3.1.1 paragraph 2.  signed char has rank less than that of 
int, so it *must* be promoted to int.  What happens afterwards is nothing 
to do with the front end.  The front end does *too many* optimisations; it 
should purely generate GIMPLE representing the standard meaning of the 
code and leave it to the later stages to tell that such conversions - or 
indeed conversions between int and long where they are the same size - can 
be optimised away in some cases.



-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18065


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [Bug tree-optimization/18065] usual arithmetic conversion not applying correctly
  2004-10-19 20:22 [Bug c/18065] New: wrong built-in functions selected schlie at comcast dot net
  2004-10-20 22:31 ` [Bug tree-optimization/18065] usual arithmetic conversion not applying correctly pinskia at gcc dot gnu dot org
@ 2004-10-20 22:42 ` jsm at polyomino dot org dot uk
  2004-10-20 23:03 ` jsm at polyomino dot org dot uk
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 17+ messages in thread
From: jsm at polyomino dot org dot uk @ 2004-10-20 22:42 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From jsm at polyomino dot org dot uk  2004-10-20 22:41 -------
Subject: Re:  usual arithmetic conversion not applying correctly

On Wed, 20 Oct 2004, schlie at comcast dot net wrote:

>  It's a pretty major screw-up to presume
>  all target machines are large, and then to encode that presumption into
>  C's front end; not to mention it seems pretty stupid to do, and then

This is not a GCC presumption, it is a property of the C language that 
there are certain promotions that may not be optimally efficient for 8-bit 
targets.  If there is a "major screw-up", it is either in the choice to 
use a language designed for systems that are at least 16-bit on an 8-bit 
target, or in the language design if you think 8-bit targets should have 
been given greater importance when the language was being standardised in 
the 1980s; it is nothing to do with the front end.  The AVR target has a 
-mint8 option which puts the compiler in a nonconforming mode with 8-bit 
int, which might however give you better code than you can get with 
standard C on an 8-bit target.



-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18065


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [Bug tree-optimization/18065] usual arithmetic conversion not applying correctly
  2004-10-19 20:22 [Bug c/18065] New: wrong built-in functions selected schlie at comcast dot net
@ 2004-10-20 22:31 ` pinskia at gcc dot gnu dot org
  2004-10-20 22:42 ` jsm at polyomino dot org dot uk
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 17+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-10-20 22:31 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-10-20 22:31 -------
That was not me writting that but a C front-end person so why did you write Andrew?

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|c                           |tree-optimization


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18065


^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2012-05-24 14:05 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-18065-4@http.gcc.gnu.org/bugzilla/>
2012-05-24 14:03 ` [Bug tree-optimization/18065] usual arithmetic conversion not applying correctly peter777778 at hotmail dot co.uk
2012-05-24 14:04 ` peter777778 at hotmail dot co.uk
2012-05-24 14:05 ` peter777778 at hotmail dot co.uk
2012-05-24 14:23 ` peter777778 at hotmail dot co.uk
     [not found] <bug-18065-9497@http.gcc.gnu.org/bugzilla/>
2010-09-14  7:06 ` abnikant dot singh at atmel dot com
2010-09-14  7:13 ` abnikant dot singh at atmel dot com
2004-10-19 20:22 [Bug c/18065] New: wrong built-in functions selected schlie at comcast dot net
2004-10-20 22:31 ` [Bug tree-optimization/18065] usual arithmetic conversion not applying correctly pinskia at gcc dot gnu dot org
2004-10-20 22:42 ` jsm at polyomino dot org dot uk
2004-10-20 23:03 ` jsm at polyomino dot org dot uk
2004-10-20 23:28 ` schlie at comcast dot net
2004-10-21  1:04 ` schlie at comcast dot net
2004-10-21  1:28 ` schlie at comcast dot net
2004-10-21 12:47 ` bangerth at dealii dot org
2004-12-21 20:50 ` schlie at comcast dot net
2005-01-16  1:39 ` pinskia at gcc dot gnu dot org
2005-01-16  7:17 ` schlie at comcast dot net
2005-01-16 17:39 ` schlie at comcast dot net

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).