public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/31679] Incorrect result of multiplication long long by 0xFFFFFFFFLL constant.
       [not found] <bug-31679-4@http.gcc.gnu.org/bugzilla/>
@ 2021-07-21  5:03 ` pinskia at gcc dot gnu.org
  2024-02-15  8:54 ` pinskia at gcc dot gnu.org
  1 sibling, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-07-21  5:03 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=31679

--- Comment #7 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
HWI is always 64bit these days so I doubt this can be reproduced.

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

* [Bug target/31679] Incorrect result of multiplication long long by 0xFFFFFFFFLL constant.
       [not found] <bug-31679-4@http.gcc.gnu.org/bugzilla/>
  2021-07-21  5:03 ` [Bug target/31679] Incorrect result of multiplication long long by 0xFFFFFFFFLL constant pinskia at gcc dot gnu.org
@ 2024-02-15  8:54 ` pinskia at gcc dot gnu.org
  1 sibling, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-02-15  8:54 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=31679

--- Comment #8 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #7)
> HWI is always 64bit these days so I doubt this can be reproduced.

Plus The tree level uses wide_int so maybe this was fixed ....

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

* [Bug target/31679] Incorrect result of multiplication long long by 0xFFFFFFFFLL constant.
  2007-04-24  8:23 [Bug c/31679] New: " vlasenko at bifit dot com dot ua
                   ` (4 preceding siblings ...)
  2007-05-16 13:02 ` ian dot rogers at manchester dot ac dot uk
@ 2007-06-02 21:52 ` tromey at gcc dot gnu dot org
  5 siblings, 0 replies; 8+ messages in thread
From: tromey at gcc dot gnu dot org @ 2007-06-02 21:52 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from tromey at gcc dot gnu dot org  2007-06-02 21:52 -------
I see this bug when I compile the test case without -O.
I tried svn trunk and also 4.1.1 20070105 (Red Hat 4.1.1-51)


-- 

tromey at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |tromey at gcc dot gnu dot
                   |                            |org
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2007-06-02 21:52:46
               date|                            |


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


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

* [Bug target/31679] Incorrect result of multiplication long long by 0xFFFFFFFFLL constant.
  2007-04-24  8:23 [Bug c/31679] New: " vlasenko at bifit dot com dot ua
                   ` (3 preceding siblings ...)
  2007-04-24 14:17 ` rguenth at gcc dot gnu dot org
@ 2007-05-16 13:02 ` ian dot rogers at manchester dot ac dot uk
  2007-06-02 21:52 ` tromey at gcc dot gnu dot org
  5 siblings, 0 replies; 8+ messages in thread
From: ian dot rogers at manchester dot ac dot uk @ 2007-05-16 13:02 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from ian dot rogers at manchester dot ac dot uk  2007-05-16 14:01 -------
For the following code given in [1] GCC produces identical multiplication by
constant code [2]. I think as 0x0FFFFFFFF is one of the parameters in this bug
the fact we generate identical multiplication code for 0x1FFFFFFFF means this
is another example of this error.

Thanks,
Ian Rogers

[1]
test.c:
extern long long x;
long long foo() {
   return x * ((((long long)0) << 32) + -1);
}
long long foo2() {
   return x * ((((long long)1) << 32) + -1);
}

[2]
test.s:
        .file   "test.c"
        .text
        .p2align 4,,15
.globl foo
        .type   foo, @function
foo:
        movl    x, %eax
        movl    x+4, %edx
        pushl   %ebp
        movl    %esp, %ebp
        negl    %eax
        popl    %ebp
        adcl    $0, %edx
        negl    %edx
        ret
        .size   foo, .-foo
        .p2align 4,,15
.globl foo2
        .type   foo2, @function
foo2:
        movl    x, %eax
        movl    x+4, %edx
        pushl   %ebp
        movl    %esp, %ebp
        negl    %eax
        popl    %ebp
        adcl    $0, %edx
        negl    %edx
        ret
        .size   foo2, .-foo2
        .ident  "GCC: (GNU) 4.1.2 20061115 (prerelease) (SUSE Linux)"
        .section        .note.GNU-stack,"",@progbits 


-- 


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


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

* [Bug target/31679] Incorrect result of multiplication long long by 0xFFFFFFFFLL constant.
  2007-04-24  8:23 [Bug c/31679] New: " vlasenko at bifit dot com dot ua
                   ` (2 preceding siblings ...)
  2007-04-24 13:21 ` vlasenko at bifit dot com dot ua
@ 2007-04-24 14:17 ` rguenth at gcc dot gnu dot org
  2007-05-16 13:02 ` ian dot rogers at manchester dot ac dot uk
  2007-06-02 21:52 ` tromey at gcc dot gnu dot org
  5 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2007-04-24 14:17 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from rguenth at gcc dot gnu dot org  2007-04-24 15:17 -------
I can reproduce this on i?86 with 32bit HWI (even with optimization if you
trick around CCP):

int one(void) { return 1; }
int printf (const char *, ...);
int main()
{
    long long qhat = one();
    long long res = qhat * 0xffffffffLL;
    printf("res = %llx\n", res);
    return 0;
}

But only with 4.1.1, at least gcc (GCC) 4.1.3 20070413 and
gcc (GCC) 4.1.2 20061115 (prerelease) are ok.  Also
some gcc (GCC) 4.1.0 (SUSE Linux) is ok.


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  GCC build triplet|i686-pc-cygwin              |
   GCC host triplet|i686-pc-cygwin              |
 GCC target triplet|i686-pc-cygwin              |i686-*-*


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


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

* [Bug target/31679] Incorrect result of multiplication long long by 0xFFFFFFFFLL constant.
  2007-04-24  8:23 [Bug c/31679] New: " vlasenko at bifit dot com dot ua
  2007-04-24 11:39 ` [Bug target/31679] " rguenth at gcc dot gnu dot org
  2007-04-24 12:16 ` vlasenko at bifit dot com dot ua
@ 2007-04-24 13:21 ` vlasenko at bifit dot com dot ua
  2007-04-24 14:17 ` rguenth at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 8+ messages in thread
From: vlasenko at bifit dot com dot ua @ 2007-04-24 13:21 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from vlasenko at bifit dot com dot ua  2007-04-24 14:21 -------
The bug also reproduces with GCC 4.1.2 compiled under FreeBSD:

gcc -save-temps -v test.c -o test
Using built-in specs.
Target: i386-unknown-freebsd6.0
Configured with: ../gcc-4.1.2/configure --enable-languages=c
--prefix=/usr/local --enable-libmudflap
Thread model: posix
gcc version 4.1.2
 /usr/local/libexec/gcc/i386-unknown-freebsd6.0/4.1.2/cc1 -E -quiet -v test.c
-fpch-preprocess -o test.i
ignoring nonexistent directory
"/usr/local/lib/gcc/i386-unknown-freebsd6.0/4.1.2/../../../../i386-unknown-freebsd6.0/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/include
 /usr/local/lib/gcc/i386-unknown-freebsd6.0/4.1.2/include
 /usr/include
End of search list.
 /usr/local/libexec/gcc/i386-unknown-freebsd6.0/4.1.2/cc1 -fpreprocessed test.i
-quiet -dumpbase test.c -auxbase test -version -o test.s
GNU C version 4.1.2 (i386-unknown-freebsd6.0)
        compiled by GNU C version 3.4.4 [FreeBSD] 20050518.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 78c0349a459b0e74d78db4c5d7784698
 as -o test.o test.s
 /usr/local/libexec/gcc/i386-unknown-freebsd6.0/4.1.2/collect2 -V
-dynamic-linker /libexec/ld-elf.so.1 -o test /usr/lib/crt1.o /usr/lib/crti.o
/usr/local/lib/gcc/i386-unknown-freebsd6.0/4.1.2/crtbegin.o
-L/usr/local/lib/gcc/i386-unknown-freebsd6.0/4.1.2
-L/usr/local/lib/gcc/i386-unknown-freebsd6.0/4.1.2/../../.. test.o -lgcc
-lgcc_eh -lc -lgcc -lgcc_eh
/usr/local/lib/gcc/i386-unknown-freebsd6.0/4.1.2/crtend.o /usr/lib/crtn.o
GNU ld version 2.15 [FreeBSD] 2004-05-23
  Supported emulations:
   elf_i386_fbsd

test.c:
int __attribute__((__cdecl__)) printf (const char *, ...);

int main()
{
    long long qhat = 1;
    long long res = qhat * 0xffffffffLL;
    printf("res = %llx\n", res);
}

output:
res = ffffffffffffffff


-- 


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


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

* [Bug target/31679] Incorrect result of multiplication long long by 0xFFFFFFFFLL constant.
  2007-04-24  8:23 [Bug c/31679] New: " vlasenko at bifit dot com dot ua
  2007-04-24 11:39 ` [Bug target/31679] " rguenth at gcc dot gnu dot org
@ 2007-04-24 12:16 ` vlasenko at bifit dot com dot ua
  2007-04-24 13:21 ` vlasenko at bifit dot com dot ua
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 8+ messages in thread
From: vlasenko at bifit dot com dot ua @ 2007-04-24 12:16 UTC (permalink / raw)
  To: gcc-bugs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 982 bytes --]



------- Comment #2 from vlasenko at bifit dot com dot ua  2007-04-24 13:16 -------
Yes, it compiles with warning... so what? The bug is not in the warning. If you
insert #include <stdio.h> in the top of source the bug reproduces and the
problem will not leave.
ÎÊ, if you want to play in bureaucracy, than here is a source that compiles
without warnings:

int __attribute__((__cdecl__)) printf (const char *, ...);

int main()
{
    long long qhat = 1;
    long long res = qhat * 0xffffffffLL;
    printf("res = %llx\n", res);
}

P.S. I simply didn't want to include the source of cygwin's stdio.h, to keep
things simplier for YOU.


-- 

vlasenko at bifit dot com dot ua changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |UNCONFIRMED
         Resolution|INVALID                     |


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


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

* [Bug target/31679] Incorrect result of multiplication long long by 0xFFFFFFFFLL constant.
  2007-04-24  8:23 [Bug c/31679] New: " vlasenko at bifit dot com dot ua
@ 2007-04-24 11:39 ` rguenth at gcc dot gnu dot org
  2007-04-24 12:16 ` vlasenko at bifit dot com dot ua
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2007-04-24 11:39 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from rguenth at gcc dot gnu dot org  2007-04-24 12:39 -------
test.c: In function 'main':
test.c:5: warning: incompatible implicit declaration of built-in function
'printf'

include stdio.h


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID


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


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

end of thread, other threads:[~2024-02-15  8:54 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-31679-4@http.gcc.gnu.org/bugzilla/>
2021-07-21  5:03 ` [Bug target/31679] Incorrect result of multiplication long long by 0xFFFFFFFFLL constant pinskia at gcc dot gnu.org
2024-02-15  8:54 ` pinskia at gcc dot gnu.org
2007-04-24  8:23 [Bug c/31679] New: " vlasenko at bifit dot com dot ua
2007-04-24 11:39 ` [Bug target/31679] " rguenth at gcc dot gnu dot org
2007-04-24 12:16 ` vlasenko at bifit dot com dot ua
2007-04-24 13:21 ` vlasenko at bifit dot com dot ua
2007-04-24 14:17 ` rguenth at gcc dot gnu dot org
2007-05-16 13:02 ` ian dot rogers at manchester dot ac dot uk
2007-06-02 21:52 ` tromey at gcc dot gnu dot 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).