[Bug c/42544] Bad codegen with signed short cast to unsigned int, then promoted to unsigned long long

2011-05-05 Thread jakub at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42544

Jakub Jelinek jakub at gcc dot gnu.org changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 CC||jakub at gcc dot gnu.org
 Resolution||FIXED

--- Comment #9 from Jakub Jelinek jakub at gcc dot gnu.org 2011-05-05 
10:27:04 UTC ---
Fixed for 4.6+.


[Bug c/42544] Bad codegen with signed short cast to unsigned int, then promoted to unsigned long long

2011-03-26 Thread jakub at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42544

--- Comment #8 from Jakub Jelinek jakub at gcc dot gnu.org 2011-03-26 
09:23:03 UTC ---
Author: jakub
Date: Sat Mar 26 09:23:01 2011
New Revision: 171548

URL: http://gcc.gnu.org/viewcvs?root=gccview=revrev=171548
Log:
Backport from mainline
2011-03-20  Jakub Jelinek  ja...@redhat.com

PR c/42544
PR c/48197
* c-common.c (shorten_compare): If primopN is first sign-extended
to opN and then zero-extended to result type, set primopN to opN.

* gcc.c-torture/execute/pr42544.c: New test.
* gcc.c-torture/execute/pr48197.c: New test.

Added:
branches/gcc-4_6-branch/gcc/testsuite/gcc.c-torture/execute/pr42544.c
branches/gcc-4_6-branch/gcc/testsuite/gcc.c-torture/execute/pr48197.c
Modified:
branches/gcc-4_6-branch/gcc/ChangeLog
branches/gcc-4_6-branch/gcc/c-family/c-common.c
branches/gcc-4_6-branch/gcc/testsuite/ChangeLog


[Bug c/42544] Bad codegen with signed short cast to unsigned int, then promoted to unsigned long long

2011-03-21 Thread jakub at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42544

--- Comment #7 from Jakub Jelinek jakub at gcc dot gnu.org 2011-03-21 
17:57:40 UTC ---
Author: jakub
Date: Mon Mar 21 17:57:34 2011
New Revision: 171252

URL: http://gcc.gnu.org/viewcvs?root=gccview=revrev=171252
Log:
PR c/42544
PR c/48197
* c-common.c (shorten_compare): If primopN is first sign-extended
to opN and then zero-extended to result type, set primopN to opN.

* gcc.c-torture/execute/pr42544.c: New test.
* gcc.c-torture/execute/pr48197.c: New test.

Added:
trunk/gcc/testsuite/gcc.c-torture/execute/pr42544.c
trunk/gcc/testsuite/gcc.c-torture/execute/pr48197.c
Modified:
trunk/gcc/ChangeLog
trunk/gcc/c-family/c-common.c
trunk/gcc/testsuite/ChangeLog


[Bug c/42544] Bad codegen with signed short cast to unsigned int, then promoted to unsigned long long

2010-01-16 Thread rguenth at gcc dot gnu dot org


--- Comment #6 from rguenth at gcc dot gnu dot org  2010-01-16 13:45 ---
I'm not working on this anymore.  The proper thing to do is to move most if not
all of shorten-compare to the middle-end (by re-implementing the little pieces
that are missing there).  The hard thing about this is retaining the
-Wconversion warnings.


-- 


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



[Bug c/42544] Bad codegen with signed short cast to unsigned int, then promoted to unsigned long long

2010-01-01 Thread rguenth at gcc dot gnu dot org


--- Comment #4 from rguenth at gcc dot gnu dot org  2010-01-01 17:09 ---
I can't make sens of

  /* If primop0 was sign-extended and unsigned comparison specd,
 we did a signed comparison above using the signed type bounds.
 But the comparison we output must be unsigned.

 Also, for inequalities, VAL is no good; but if the signed
 comparison had *any* fixed result, it follows that the
 unsigned comparison just tests the sign in reverse
 (positive values are LE, negative ones GE).
 So we can generate an unsigned comparison
 against an extreme value of the signed type.  */

  if (unsignedp  !unsignedp0)
{
  if (val != 0)
switch (code)
  {
  case LT_EXPR:
  case GE_EXPR:
primop1 = TYPE_MIN_VALUE (type);
val = 0;
break;

  case LE_EXPR:
  case GT_EXPR:
primop1 = TYPE_MAX_VALUE (type);
val = 0;
break;

  default:
break;
  }
  type = c_common_unsigned_type (type);
}

but the code dates back to rev. 278 and is from rms ...

So I'm testing a remove of that code.


-- 


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



[Bug c/42544] Bad codegen with signed short cast to unsigned int, then promoted to unsigned long long

2010-01-01 Thread rguenth at gcc dot gnu dot org


--- Comment #5 from rguenth at gcc dot gnu dot org  2010-01-01 18:55 ---
Completely removing the offending code regresses in diagnostics.  I'll try
removing the code that doesn't make sense to me, but I fear test coverage is
low in this area.


-- 


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



[Bug c/42544] Bad codegen with signed short cast to unsigned int, then promoted to unsigned long long

2009-12-31 Thread rguenth at gcc dot gnu dot org


--- Comment #1 from rguenth at gcc dot gnu dot org  2009-12-31 16:50 ---
Hum.  Looks like the C FE somehow munges the uLL constant.

c_parser_cast_expression (parser=0xb77b0b44, after=0x0)
at /home/richard/src/trunk/gcc/c-parser.c:5000
(gdb) call c_parser_peek_token (parser)
$8 = (c_token *) 0xb77b0b44
(gdb) p *$8
$9 = {type = CPP_NUMBER, id_kind = C_ID_NONE, keyword = RID_MAX, 
  pragma_kind = PRAGMA_NONE, value = 0xb77a3750, location = 479}
(gdb) p $8-value
$10 = (tree) 0xb77a3750
(gdb) call debug_tree ($10)
 integer_cst 0xb77a3750 type integer_type 0xb7742480 long long unsigned int
constant 0x1

thus ok from the lexer, but

Run till exit from #0  c_parser_binary_expression (parser=0xb77b0b44, 
after=0x0) at /home/richard/src/trunk/gcc/c-parser.c:4984
0x0818a327 in c_parser_conditional_expression (parser=0xb77b0b44, after=0x0)
at /home/richard/src/trunk/gcc/c-parser.c:4645
4645  cond = c_parser_binary_expression (parser, after);
Value returned is $16 = 
  {value = 0xb7740740, original_code = GE_EXPR, original_type = 0x0}
(gdb) call debug_tree ($16-value)
 ge_expr 0xb7740740
type integer_type 0xb77422a0 int public SI
size integer_cst 0xb772e258 constant 32
unit size integer_cst 0xb772e090 constant 4
align 32 symtab 0 alias set -1 canonical type 0xb77422a0 precision 32
min integer_cst 0xb772e210 -2147483648 max integer_cst 0xb772e228
2147483647
pointer_to_this pointer_type 0xb7742c00

arg 0 c_maybe_const_expr 0xb7740720
type integer_type 0xb7742300 unsigned int public unsigned SI size
integer_cst 0xb772e258 32 unit size integer_cst 0xb772e090 4
align 32 symtab 0 alias set -1 canonical type 0xb7742300 precision
32 min integer_cst 0xb772e270 0 max integer_cst 0xb772e240 4294967295
pointer_to_this pointer_type 0xb774d360

arg 1 nop_expr 0xb77b0c08 type integer_type 0xb7742300 unsigned int
arg 0 var_decl 0xb77b1000 8000
arg 1 integer_cst 0xb77a37e0 type integer_type 0xb7742300 unsigned int
constant 2147483648
t.c:4:18

here the constant is alrady munged and thus the promotion doesn't happen.


-- 

rguenth at gcc dot gnu dot org changed:

   What|Removed |Added

 CC||jsm28 at gcc dot gnu dot org
 Status|UNCONFIRMED |NEW
 Ever Confirmed|0   |1
   Keywords||wrong-code
   Last reconfirmed|-00-00 00:00:00 |2009-12-31 16:50:18
   date||
Version|unknown |4.4.3


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



[Bug c/42544] Bad codegen with signed short cast to unsigned int, then promoted to unsigned long long

2009-12-31 Thread joseph at codesourcery dot com


--- Comment #2 from joseph at codesourcery dot com  2009-12-31 17:03 ---
Subject: Re:  Bad codegen with signed short cast to unsigned
 int, then promoted to unsigned long long

The first place to look for a problem would be shorten_compare.


-- 


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



[Bug c/42544] Bad codegen with signed short cast to unsigned int, then promoted to unsigned long long

2009-12-31 Thread rguenth at gcc dot gnu dot org


--- Comment #3 from rguenth at gcc dot gnu dot org  2009-12-31 17:21 ---
It's indeed at fault.  But instead of trying to fix it I'd ditch it completely
as premature optimization.

I consider c-common.c C frontend specific anyway ;)


-- 


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