public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/49186] New: optimize problem with unsigned long long value.
@ 2011-05-27  7:54 iwamatsu at nigauri dot org
  2011-05-27  8:59 ` [Bug target/49186] " rguenth at gcc dot gnu.org
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: iwamatsu at nigauri dot org @ 2011-05-27  7:54 UTC (permalink / raw)
  To: gcc-bugs

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

           Summary: optimize problem with unsigned long long value.
           Product: gcc
           Version: 4.6.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: iwamatsu@nigauri.org
                CC: kkojima@gcc.gnu.org
              Host: sh4-linux-gnu
            Target: sh4-linux-gnu
             Build: sh4-linux-gnu


Hi,

I found optimize problem with unsigned long long value.
I confirmed on gcc-4.4 and 4.6 on debian.


$ gcc-4.4 -v
Using built-in specs.
Target: sh4-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 4.4.6-3'
--with-bugurl=file:///usr/share/doc/gcc-4.4/README.Bugs
--enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr
--program-suffix=-4.4 --enable-shared --enable-multiarch
--with-multiarch-defaults=sh4-linux-gnu --enable-linker-build-id
--with-system-zlib --libexecdir=/usr/lib --without-included-gettext
--enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.4
--libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug
--enable-objc-gc --with-multilib-list=m4,m4-nofpu --with-cpu=sh4
--enable-checking=release --build=sh4-linux-gnu --host=sh4-linux-gnu
--target=sh4-linux-gnu
Thread model: posix
gcc version 4.4.6 (Debian 4.4.6-3) 
$ gcc-4.6 -v
Using built-in specs.
COLLECT_GCC=gcc-4.6
COLLECT_LTO_WRAPPER=/usr/lib/gcc/sh4-linux-gnu/4.6.1/lto-wrapper
Target: sh4-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 4.6.0-6'
--with-bugurl=file:///usr/share/doc/gcc-4.6/README.Bugs
--enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr
--program-suffix=-4.6 --enable-shared --enable-multiarch
--with-multiarch-defaults=sh4-linux-gnu --enable-linker-build-id
--with-system-zlib --libexecdir=/usr/lib --without-included-gettext
--enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.6
--libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug
--enable-libstdcxx-time=yes --enable-plugin --enable-objc-gc
--with-multilib-list=m4,m4-nofpu --with-cpu=sh4 --enable-checking=release
--build=sh4-linux-gnu --host=sh4-linux-gnu --target=sh4-linux-gnu
Thread model: posix
gcc version 4.6.1 20110428 (prerelease) (Debian 4.6.0-6) 

$ cat a.c
#include <stdio.h>
#define Size_t size_t
#define MEM_SIZE Size_t
typedef MEM_SIZE STRLEN;

int main(void)
{
  int x = 13;
  unsigned long long uv = 0x1000000001ULL;
  if (x > (STRLEN)( (uv) < 0x80 ? 1 : (uv) < 0x800 ? 2 : (uv) < 0x10000 ? 3 :
(uv) < 0x200000 ? 4 : (uv) < 0x4000000 ? 5 : (uv) < 0x80000000 ? 6 : (uv) <
0x1000000000ULL ? 7 : 13 ))
    return 1;

  return 0;
}
$ gcc-4.4 -o a a.c 
$ ./a ; echo $?
1
$ gcc-4.4 -o a a.c -O1
$ ./a ; echo $?
0
$ gcc-4.6 -o a a.c     
$ ./a ; echo $?
1
$ gcc-4.6 -o a a.c -O2
$ ./a ; echo $?
0


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

* [Bug target/49186] optimize problem with unsigned long long value.
  2011-05-27  7:54 [Bug c/49186] New: optimize problem with unsigned long long value iwamatsu at nigauri dot org
@ 2011-05-27  8:59 ` rguenth at gcc dot gnu.org
  2011-05-27 21:50 ` kkojima at gcc dot gnu.org
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu.org @ 2011-05-27  8:59 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Guenther <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|c                           |target

--- Comment #1 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-05-27 08:55:34 UTC ---
Works ok on x86-64 and i?86.


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

* [Bug target/49186] optimize problem with unsigned long long value.
  2011-05-27  7:54 [Bug c/49186] New: optimize problem with unsigned long long value iwamatsu at nigauri dot org
  2011-05-27  8:59 ` [Bug target/49186] " rguenth at gcc dot gnu.org
@ 2011-05-27 21:50 ` kkojima at gcc dot gnu.org
  2011-05-27 21:59 ` kkojima at gcc dot gnu.org
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: kkojima at gcc dot gnu.org @ 2011-05-27 21:50 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Kazumoto Kojima <kkojima at gcc dot gnu.org> 2011-05-27 21:42:59 UTC ---
Created attachment 24382
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=24382
A reduced testcase


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

* [Bug target/49186] optimize problem with unsigned long long value.
  2011-05-27  7:54 [Bug c/49186] New: optimize problem with unsigned long long value iwamatsu at nigauri dot org
  2011-05-27  8:59 ` [Bug target/49186] " rguenth at gcc dot gnu.org
  2011-05-27 21:50 ` kkojima at gcc dot gnu.org
@ 2011-05-27 21:59 ` kkojima at gcc dot gnu.org
  2011-05-30  5:37 ` iwamatsu at nigauri dot org
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: kkojima at gcc dot gnu.org @ 2011-05-27 21:59 UTC (permalink / raw)
  To: gcc-bugs

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

Kazumoto Kojima <kkojima at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Target|sh4-linux-gnu               |sh*-*-*
             Status|UNCONFIRMED                 |NEW
      Known to work|                            |4.2.5
           Keywords|                            |wrong-code
   Last reconfirmed|                            |2011.05.27 21:50:14
               Host|sh4-linux-gnu               |
     Ever Confirmed|0                           |1
      Known to fail|                            |4.3.5, 4.4.5, 4.6.1, 4.7.0
              Build|sh4-linux-gnu               |

--- Comment #3 from Kazumoto Kojima <kkojima at gcc dot gnu.org> 2011-05-27 21:50:14 UTC ---
The patch below should fix the problem.

--- ORIG/trunk/gcc/config/sh/sh.c    2011-05-27 14:51:19.000000000 +0900
+++ trunk/gcc/config/sh/sh.c    2011-05-27 19:28:06.000000000 +0900
@@ -2143,7 +2143,10 @@ expand_cbranchdi4 (rtx *operands, enum r
       else if (op2h != CONST0_RTX (SImode))
         msw_taken = LTU;
       else
-        break;
+        {
+          msw_skip = swap_condition (LTU);
+          break;
+        }
       msw_skip = swap_condition (msw_taken);
     }
       break;


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

* [Bug target/49186] optimize problem with unsigned long long value.
  2011-05-27  7:54 [Bug c/49186] New: optimize problem with unsigned long long value iwamatsu at nigauri dot org
                   ` (2 preceding siblings ...)
  2011-05-27 21:59 ` kkojima at gcc dot gnu.org
@ 2011-05-30  5:37 ` iwamatsu at nigauri dot org
  2011-05-30  6:14 ` kkojima at gcc dot gnu.org
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: iwamatsu at nigauri dot org @ 2011-05-30  5:37 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Nobuhiro Iwamatsu <iwamatsu at nigauri dot org> 2011-05-30 05:33:52 UTC ---
Hi,

Thanks!
I confirmed resolved this problem by this patch on gcc-4.4, 4.5, 4.6 and trunk.
Could you backport each branches?


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

* [Bug target/49186] optimize problem with unsigned long long value.
  2011-05-27  7:54 [Bug c/49186] New: optimize problem with unsigned long long value iwamatsu at nigauri dot org
                   ` (3 preceding siblings ...)
  2011-05-30  5:37 ` iwamatsu at nigauri dot org
@ 2011-05-30  6:14 ` kkojima at gcc dot gnu.org
  2011-06-05 21:48 ` kkojima at gcc dot gnu.org
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: kkojima at gcc dot gnu.org @ 2011-05-30  6:14 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Kazumoto Kojima <kkojima at gcc dot gnu.org> 2011-05-30 06:05:04 UTC ---
(In reply to comment #4)
> Could you backport each branches?

I'll do so.


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

* [Bug target/49186] optimize problem with unsigned long long value.
  2011-05-27  7:54 [Bug c/49186] New: optimize problem with unsigned long long value iwamatsu at nigauri dot org
                   ` (4 preceding siblings ...)
  2011-05-30  6:14 ` kkojima at gcc dot gnu.org
@ 2011-06-05 21:48 ` kkojima at gcc dot gnu.org
  2011-06-05 21:51 ` kkojima at gcc dot gnu.org
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: kkojima at gcc dot gnu.org @ 2011-06-05 21:48 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from Kazumoto Kojima <kkojima at gcc dot gnu.org> 2011-06-05 21:47:44 UTC ---
Author: kkojima
Date: Sun Jun  5 21:47:42 2011
New Revision: 174665

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=174665
Log:
    PR target/49186
    * config/sh/sh.c (expand_cbranchdi4): Set msw_skip when the high
    part of the second operand is 0.
    * gcc.c-torture/execute/pr49186.c: New.


Added:
    branches/gcc-4_6-branch/gcc/testsuite/gcc.c-torture/execute/pr49186.c
Modified:
    branches/gcc-4_6-branch/gcc/ChangeLog
    branches/gcc-4_6-branch/gcc/config/sh/sh.c
    branches/gcc-4_6-branch/gcc/testsuite/ChangeLog


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

* [Bug target/49186] optimize problem with unsigned long long value.
  2011-05-27  7:54 [Bug c/49186] New: optimize problem with unsigned long long value iwamatsu at nigauri dot org
                   ` (5 preceding siblings ...)
  2011-06-05 21:48 ` kkojima at gcc dot gnu.org
@ 2011-06-05 21:51 ` kkojima at gcc dot gnu.org
  2011-06-05 21:54 ` kkojima at gcc dot gnu.org
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: kkojima at gcc dot gnu.org @ 2011-06-05 21:51 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from Kazumoto Kojima <kkojima at gcc dot gnu.org> 2011-06-05 21:50:32 UTC ---
Author: kkojima
Date: Sun Jun  5 21:50:29 2011
New Revision: 174666

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=174666
Log:
    PR target/49186
    * config/sh/sh.c (expand_cbranchdi4): Set msw_skip when the high
    part of the second operand is 0.
    * gcc.c-torture/execute/pr49186.c: New.


Added:
    branches/gcc-4_5-branch/gcc/testsuite/gcc.c-torture/execute/pr49186.c
Modified:
    branches/gcc-4_5-branch/gcc/ChangeLog
    branches/gcc-4_5-branch/gcc/config/sh/sh.c
    branches/gcc-4_5-branch/gcc/testsuite/ChangeLog


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

* [Bug target/49186] optimize problem with unsigned long long value.
  2011-05-27  7:54 [Bug c/49186] New: optimize problem with unsigned long long value iwamatsu at nigauri dot org
                   ` (6 preceding siblings ...)
  2011-06-05 21:51 ` kkojima at gcc dot gnu.org
@ 2011-06-05 21:54 ` kkojima at gcc dot gnu.org
  2011-06-05 21:56 ` kkojima at gcc dot gnu.org
  2011-06-05 21:57 ` kkojima at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: kkojima at gcc dot gnu.org @ 2011-06-05 21:54 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 from Kazumoto Kojima <kkojima at gcc dot gnu.org> 2011-06-05 21:53:27 UTC ---
Author: kkojima
Date: Sun Jun  5 21:53:25 2011
New Revision: 174667

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=174667
Log:
    PR target/49186
    * config/sh/sh.c (expand_cbranchdi4): Set msw_skip when the high
    part of the second operand is 0.
    * gcc.c-torture/execute/pr49186.c: New.


Added:
    branches/gcc-4_4-branch/gcc/testsuite/gcc.c-torture/execute/pr49186.c
Modified:
    branches/gcc-4_4-branch/gcc/ChangeLog
    branches/gcc-4_4-branch/gcc/config/sh/sh.c
    branches/gcc-4_4-branch/gcc/testsuite/ChangeLog


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

* [Bug target/49186] optimize problem with unsigned long long value.
  2011-05-27  7:54 [Bug c/49186] New: optimize problem with unsigned long long value iwamatsu at nigauri dot org
                   ` (7 preceding siblings ...)
  2011-06-05 21:54 ` kkojima at gcc dot gnu.org
@ 2011-06-05 21:56 ` kkojima at gcc dot gnu.org
  2011-06-05 21:57 ` kkojima at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: kkojima at gcc dot gnu.org @ 2011-06-05 21:56 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #9 from Kazumoto Kojima <kkojima at gcc dot gnu.org> 2011-06-05 21:55:49 UTC ---
Author: kkojima
Date: Sun Jun  5 21:55:46 2011
New Revision: 174668

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=174668
Log:
    PR target/49186
    * config/sh/sh.c (expand_cbranchdi4): Set msw_skip when the high
    part of the second operand is 0.
    * gcc.c-torture/execute/pr49186.c: New.


Added:
    branches/gcc-4_3-branch/gcc/testsuite/gcc.c-torture/execute/pr49186.c
Modified:
    branches/gcc-4_3-branch/gcc/ChangeLog
    branches/gcc-4_3-branch/gcc/config/sh/sh.c
    branches/gcc-4_3-branch/gcc/testsuite/ChangeLog


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

* [Bug target/49186] optimize problem with unsigned long long value.
  2011-05-27  7:54 [Bug c/49186] New: optimize problem with unsigned long long value iwamatsu at nigauri dot org
                   ` (8 preceding siblings ...)
  2011-06-05 21:56 ` kkojima at gcc dot gnu.org
@ 2011-06-05 21:57 ` kkojima at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: kkojima at gcc dot gnu.org @ 2011-06-05 21:57 UTC (permalink / raw)
  To: gcc-bugs

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

Kazumoto Kojima <kkojima at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED

--- Comment #10 from Kazumoto Kojima <kkojima at gcc dot gnu.org> 2011-06-05 21:57:12 UTC ---
Fixed.


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

end of thread, other threads:[~2011-06-05 21:57 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-27  7:54 [Bug c/49186] New: optimize problem with unsigned long long value iwamatsu at nigauri dot org
2011-05-27  8:59 ` [Bug target/49186] " rguenth at gcc dot gnu.org
2011-05-27 21:50 ` kkojima at gcc dot gnu.org
2011-05-27 21:59 ` kkojima at gcc dot gnu.org
2011-05-30  5:37 ` iwamatsu at nigauri dot org
2011-05-30  6:14 ` kkojima at gcc dot gnu.org
2011-06-05 21:48 ` kkojima at gcc dot gnu.org
2011-06-05 21:51 ` kkojima at gcc dot gnu.org
2011-06-05 21:54 ` kkojima at gcc dot gnu.org
2011-06-05 21:56 ` kkojima at gcc dot gnu.org
2011-06-05 21:57 ` kkojima at gcc dot gnu.org

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).