[Bug middle-end/96326] Incorrect loop optimization at -O3

2020-07-26 Thread pterjan at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96326

--- Comment #2 from Pascal Terjan  ---
No:

$ gcc -O3 -Wall -fno-strict-aliasing  t.c; ./a.out 
24

However -fno-tree-loop-vectorize fixes it:

$ gcc -O3 -Wall -fno-tree-loop-vectorize t.c; ./a.out 
68

[Bug c/96326] New: Incorrect loop optimization at -O3

2020-07-26 Thread pterjan at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96326

Bug ID: 96326
   Summary: Incorrect loop optimization at -O3
   Product: gcc
   Version: 10.2.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
  Assignee: unassigned at gcc dot gnu.org
  Reporter: pterjan at gmail dot com
  Target Milestone: ---

Found in https://github.com/Sereal/Sereal/issues/229

#include 
#include 

int main() {
char buf[128];
char *src = buf;
char *op = buf + 3;
int len = 64;
strcpy(buf, "abc");
while (op - src < 8) {
*(unsigned long*)op = *(const unsigned long*)src;
len -= op - src;
op += op - src;
}
while (len > 0) {
*(unsigned long*)op = *(const unsigned long*)src;
src += 8;
op += 8;
len -= 8;
}
printf("%ld\n", strlen(buf));
}

$ gcc -O2 -Wall t.c; ./a.out 
68

$ gcc -O3 -Wall t.c; ./a.out 
24

Adding a printf in the second loop also fixes it.

[Bug c/52310] New: Internal Compiler Error when building lesstif with -Wp,-D_FORTIFY_SOURCE=2

2012-02-19 Thread pterjan at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52310

 Bug #: 52310
   Summary: Internal Compiler Error when building lesstif with
-Wp,-D_FORTIFY_SOURCE=2
Classification: Unclassified
   Product: gcc
   Version: 4.6.2
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
AssignedTo: unassig...@gcc.gnu.org
ReportedBy: pter...@gmail.com


Created attachment 26701
  -- http://gcc.gnu.org/bugzilla/attachment.cgi?id=26701
Preprocessed source

[pterjan@jonund Xm-2.1]$ gcc -DHAVE_CONFIG_H -I. -I. -I../../include
-I../../include/Motif-2.1 -I../../include/Motif-2.1 -I/usr/include
-I/usr/include -O2 -g -pipe -Wformat -Werror=format-security
-Wp,-D_FORTIFY_SOURCE=2 -fstack-protector --param=ssp-buffer-size=4
-DMWM_DDIR=\/usr/share/X11/mwm\ -c XmString.c  -fPIC -DPIC -o
.libs/XmString.o
{standard input}: Assembler messages:
{standard input}: Warning: end of file not at end of a line; newline inserted
{standard input}:2041: Error: unbalanced parenthesis in operand 2.
{standard input}: Error: open CFI at the end of file; missing .cfi_endproc
directive
gcc: internal compiler error: Segmentation fault (program cc1)

I attached the preprocessed source, it crashes here (x86_64) when using gcc -g
-c XmStringE.c with gcc-4.6.2

This preprocessed source builds fine using gcc-4.5.1 (even if it gives a lot of
warning about casting pointers to int).


[Bug c/52310] Internal Compiler Error when building lesstif with -Wp,-D_FORTIFY_SOURCE=2

2012-02-19 Thread pterjan at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52310

--- Comment #1 from Pascal Terjan pterjan at gmail dot com 2012-02-19 
20:23:15 UTC ---
Created attachment 26703
  -- http://gcc.gnu.org/bugzilla/attachment.cgi?id=26703
Reduce source code leading to the crash

Here is the minimal code I managed to trigger the crash


[Bug c/52310] Internal Compiler Error when building lesstif with -Wp,-D_FORTIFY_SOURCE=2

2012-02-19 Thread pterjan at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52310

Pascal Terjan pterjan at gmail dot com changed:

   What|Removed |Added

  Attachment #26701|0   |1
is obsolete||

--- Comment #2 from Pascal Terjan pterjan at gmail dot com 2012-02-19 
20:23:58 UTC ---
Created attachment 26704
  -- http://gcc.gnu.org/bugzilla/attachment.cgi?id=26704
Preprocessed code for the minimal code


[Bug rtl-optimization/23518] New: some gcc optimizations do not take overflow into account

2005-08-22 Thread pterjan at gmail dot com
This has been tested on 3.3.6, 3.4.1 and 4.0.1

The following test is considered always false and the block is dropped but a
being int, (a + 1  0) is true.

[EMAIL PROTECTED] tmp]$ cat lim.c
#include stdio.h
#include limits.h

int main (void)
{
int a = INT_MAX;
if ((a  0) || (a + 1  0)) {
printf(Hello !\n);
}
return 0;
}
[EMAIL PROTECTED] tmp]$ gcc -O0 lim.c ; ./a.out
Hello !
[EMAIL PROTECTED] tmp]$ gcc -O1 lim.c ; ./a.out
[EMAIL PROTECTED] tmp]$

-- 
   Summary: some gcc optimizations do not take overflow into account
   Product: gcc
   Version: 4.0.1
Status: UNCONFIRMED
  Severity: normal
  Priority: P2
 Component: rtl-optimization
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: pterjan at gmail dot com
CC: gcc-bugs at gcc dot gnu dot org


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