[Bug tree-optimization/97967] New: Missed optimization opportunity for VRP

2020-11-24 Thread ishiura-compiler at ml dot kwansei.ac.jp via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97967

Bug ID: 97967
   Summary: Missed optimization opportunity for VRP
   Product: gcc
   Version: 10.2.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: ishiura-compiler at ml dot kwansei.ac.jp
  Target Milestone: ---

We have another VRP related test case for GCC-10.2.0. 

We expect A1.c and A2.c should compile to the same codes, but they did
not.

+-+-+
|A1.c |  A2.c   |
+-+-+
|int main (void)  |int main (void)  |
|{|{|
|  volatile int a = 1;|  volatile int a = 1;|
| | |
|  int b = a%2;   |  a; |
|  int t = 200<(short)(-50*b);|  int t = 0; |
| | |
|  if (t != 0) __builtin_abort(); |  if (t != 0) __builtin_abort(); |
| | |
|  return 0;  |  return 0;  |
|}|}|
+-+-+

+---+--+
| A1.s (gcc-10.2.0 A1.c -O3 -S) | A2.s (gcc-10.2.0 A2.c -O3 -S)|
+---+--+
|main:  |main: |
|.LFB0: |.LFB0:|
|   .cfi_startproc  |   .cfi_startproc |
|   subq$24, %rsp   |   movl$1, -4(%rsp)   |
|   .cfi_def_cfa_offset 32  |   movl-4(%rsp), %eax |
|   movl$1, 12(%rsp)|  |
|   movl12(%rsp), %eax  |  |
|   movl%eax, %edx  |  |
|   shrl$31, %edx   |  |
|   addl%edx, %eax  |  |
|   andl$1, %eax|  |
|   subl%edx, %eax  |  |
|   imull   $-50, %eax, %eax|  |
|   cmpw$200, %ax   |  |
|   jg  .L3 |  |
|   xorl%eax, %eax  |   xorl%eax, %eax |
|   addq$24, %rsp   |  |
|   .cfi_def_cfa_offset 8   |  |
|   ret |   ret|
|   .cfi_endproc|   .cfi_endproc   |
|   .section   .text.unlikely   |  |
|   .cfi_startproc  |  |
|   .type   main.cold, @function|  |
|main.cold: |  |
|.LFSB0:|  |
|.L3:   |  |
|.cfi_def_cfa_offset 32 |  |
|callabort  |  |
|.cfi_endproc   |  |
|.LFE0: |.LFE0:|
|.section  text.startup |  |
|.size   main, .-main   |   .size   main, .-main   |
|.section  .text.unlikely   |  |
|.size   main.cold, .-mai...|  |
|.LCOLDE0:  |  |
|.section  .text.startup|  |
|.LHOTE0:   |  |
|.ident  "GCC: (GNU) 10.2.0"|   .ident  "GCC: (GNU) 10.2.0"|
|.section  .note.GNU-stac...|   .section  .note.GNU-stac...|
+--+

$ gcc -v
using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/x86_64-pc-linux-gnu/10.2.0/lto-wrapper
target: x86_64-pc-linux-gnu
configure woth: ../configure --enable-languages=c,c++ --prefix=/usr/local
--disable-bootstrap --disable-multilib
thred model: posix
Supported LTO compression algorithms: zlib
gcc version 10.2.0 (GCC)

[Bug tree-optimization/97964] New: Missed optimization opportunity for VRP

2020-11-23 Thread ishiura-compiler at ml dot kwansei.ac.jp via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97964

Bug ID: 97964
   Summary: Missed optimization opportunity for VRP
   Product: gcc
   Version: 10.2.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: ishiura-compiler at ml dot kwansei.ac.jp
  Target Milestone: ---

We compiled two programs (A1.c, A2.c) by gcc-10.2.0 with -O3 option.
The two programs are equivalent, but resulted in different assembly codes.
Although varialbe a is volatile, the value of variable t can be 
determined at compile time via VRP optimization.  

Note that gcc-7.5.0 or older versions compiled the both code into the
same minimum assebmly codes.  For more precise: 

  gcc-10.2.0  diff
  gcc-9.3.0   diff
  gcc-8.0.1   diff
  gcc-7.5.0   OK
  gcc-6.5.0   OK
  gcc-5.5.0   OK


+-+-+
|A1.c |  A2.c   |
+-+-+
|int main (void)  |int main (void)  |
|{|{|
|  volatile int a = -1;   |  volatile int a = 1;|
|  long b = -2;   | |
| | |
|  int c = a>0;   | |
|  int d = b*c;   | |
|  int e = 1-d;   |  a; |
|  int t = (-1/(int)e)==1;|  int t = 0; |
| | |
|  if (t != 0) __builtin_abort(); |  if (t != 0) __builtin_abort(); |
| | |
|  return 0;  |  return 0;  |
|}|}|
+-+-+

gcc-10.2.0
+---+--+
| A1.s (gcc-10.2.0 A1.c -O3 -S) | A2.s (gcc-10.2.0 A2.c -O3 -S)|
+---+--+
|main:  |main: |
|.LFB0: |.LFB0:|
|   .cfi_startproc  |   .cfi_startproc |
|   subq$24, %rsp   |   movl$1, -4(%rsp)   |
|   .cfi_def_cfa_offset 32  |   movl-4(%rsp), %eax |
|   movl$1, 12(%ecx)|  |
|   movl$-1, 12(%rsp)   |  |
|   movl12(%rsp), %eax  |  |
|   testl   %eax, %eax  |  |
|   setle   %al |  |
|   movzbl  %al, %eax   |  |
|   leal-2(%rax,%rax), %eax |  |
|   subl%eax, %ecx  |  |
|   movl$-1, %eax   |  |
|   cltd|  |
|   idiv%ecx|  |
|   cmpl$1, %eax|  |
|   je  .L3 |  |
|   xorl%eax, %eax  |   xorl%eax, %eax |
|   addq$24, %rsp   |  |
|   .cfi_def_cfa_offset 8   |  |
|   ret |   ret|
|   .cfi_endproc|   .cfi_endproc   |
|   .section   .text.unlikely   |  |
|   .cfi_startproc  |  |
|   .type   main.cold, @function|  |
|main.cold: |  |
|.LFSB0:|  |
|.L3:   |  |
|.cfi_def_cfa_offset 32 |  |
|callabort  |  |
|.cfi_endproc   |  |
|.LFE0: |.LFE0:|
|.section  text.startup |  |
|.size   main, .-main   |   .size   main, .-main   |
|.section  .text.unlikely   |  |
|.size   main.cold, .-mai...|  |
|.LCOLDE0:  |  |
|.section  .text.startup|  |
|.LHO

[Bug tree-optimization/83580] New: Wrong constant folding

2017-12-24 Thread ishiura-compiler at ml dot kwansei.ac.jp
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83580

Bug ID: 83580
   Summary: Wrong constant folding
   Product: gcc
   Version: 8.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: ishiura-compiler at ml dot kwansei.ac.jp
  Target Milestone: ---

GCC 8.0.0 for x86_64 miscompiles the following code.

% cat test.c
int a[2] =  {0,1};
int x =  129;
int main (void)
{
  volatile int v = 0;
  int t = x;
  for (int i = 0; i < (1+v+v+v+v+v+v+v+v+a[a[0]]); i++) {
t = a[(signed char)(130-x)];
  }
  if (t != 1) __builtin_abort();
  return 0;
}

% gcc-8.0.0 test.c
% ./a.out

% gcc-8.0.0 test.c -O3
% ./a.out
zsh: abort (core dumped)  ./a.out

% gcc-8.0.0 -v
Using built-in specs.
COLLECT_GCC=gcc-8.0.0
COLLECT_LTO_WRAPPER=/home/cappie/opt/gcc-8.0.0/libexec/gcc/x86_64-pc-linux-gnu/8.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../configure --prefix=/home/cappie/opt/gcc-8.0.0 --disable-nls
--disable-multilib --program-suffix=-8.0.0 --enable-languages=c
Thread model: posix
gcc version 8.0.0 20171215 (experimental) (GCC)

[Bug tree-optimization/83573] New: Wrong constant folding

2017-12-23 Thread ishiura-compiler at ml dot kwansei.ac.jp
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83573

Bug ID: 83573
   Summary: Wrong constant folding
   Product: gcc
   Version: 8.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: ishiura-compiler at ml dot kwansei.ac.jp
  Target Milestone: ---

GCC 8.0 for x86_64 miscompiles the following code.

% cat test.c
int a[2] =  {0,1};
int x =  129;
int main (void)
{
  volatile int v = 0;
  int t = x;
  for (int i = 0; i < (1+v+v+v+v+v+v+v+v+a[a[0]]); i++) {
t = a[(signed char)(130-x)];
  }
  if (t != 1) __builtin_abort();
  return 0;
}

% gcc-8.0.0 test.c
% ./a.out

% gcc-8.0.0 test.c -O3
% ./a.out
zsh: abort (core dumped)  ./a.out

% gcc-8.0.0 -v
Using built-in specs.
COLLECT_GCC=gcc-8.0.0
COLLECT_LTO_WRAPPER=/home/cappie/opt/gcc-8.0.0/libexec/gcc/x86_64-pc-linux-gnu/8.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../configure --prefix=/home/cappie/opt/gcc-8.0.0 --disable-nls
--disable-multilib --program-suffix=-8.0.0 --enable-languages=c
Thread model: posix
gcc version 8.0.0 20171215 (experimental) (GCC)

[Bug tree-optimization/83544] New: Missed optimization opportunity for constant folding

2017-12-21 Thread ishiura-compiler at ml dot kwansei.ac.jp
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83544

Bug ID: 83544
   Summary: Missed optimization opportunity for constant folding
   Product: gcc
   Version: 8.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: ishiura-compiler at ml dot kwansei.ac.jp
  Target Milestone: ---

We compiled two programs (A1.c, A2.c) by GCC-8.0.0 with -O3 option.
We expect the resulting assembly codes would be the same, or at least
A1.c would result in simpler code.  However, the result was the opposite.


+-+-+
|A1.c |  A2.c   |
+-+-+
|int main (void)  |int main (void)  |
|{|{|
|  volatile int x = 1;|  volatile int x = 1;|
| |  int a = 1; |
| | |
|  int t = 1 / ( 0 < ( 1/x ) );   |  int t = a / ( 0 < ( 1/x ) );   |
|  if (t != 1) __builtin_abort(); |  if (t != 1) __builtin_abort(); |
|  return 0;  |  return 0;  |
|}|}|
+-+-+

+++
|A1.s (gcc-8.0.0 A1.c -O3 -S)|A2.s (gcc-8.0.0 A2.c -O3 -S)|
+++
|main:   |main:   |
|.LFB0:  |.LFB0:  |
|  .cfi_startproc|  .cfi_startproc|
|  movl  $1, %eax||
|  movl  $1, -4(%rsp)|  movl  $1, -4(%rsp)|
|  movl  -4(%rsp), %ecx  |  movl  -4(%rsp), %eax  |
|  cltd  ||
|  idivl %ecx||
|  cmpl  $1, %eax||
|  je.L2 ||
|  ud2   ||
|  .p2align 4,,10||
|  .p2align 3||
|.L2:||
|  xorl  %eax, %eax  |  xorl  %eax, %eax  |
|  ret   |  ret   |
|  .cfi_endproc  |  .cfi_endproc  |
|.LFE0:  |.LFE0:  |
|  .size  main, .-main   |   .size  main, .-main  |
+++

gcc-8.0 (GCC) 8.0.0 20171215 (experimental)
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

[Bug tree-optimization/83269] New: Wrong constant folding

2017-12-04 Thread ishiura-compiler at ml dot kwansei.ac.jp
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83269

Bug ID: 83269
   Summary: Wrong constant folding
   Product: gcc
   Version: 8.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: ishiura-compiler at ml dot kwansei.ac.jp
  Target Milestone: ---

GCC 8.0.0 for x86_64 miscompiles the following code.

Reproduces on gcc-5.1.0 to gcc-6.3.0 and gcc-8.0.0 with -O1, and on gcc-4.4.7
or later with -O2.

% cat test.c
int main (void)
{
  volatile unsigned char a = 1;
  long b = 0x8000L;
  int c = - ( (int)(-b) - (-0x7FFF*a) );
  if (c != 1) __builtin_abort();
  return 0;
}

% gcc-8.0 test.c -O1
% ./a.out
zsh: abort (core dumped)  ./a.out
% gcc-8.0 -v
Using built-in specs.
COLLECT_GCC=gcc-8.0
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/x86_64-pc-linux-gnu/8.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc/configure --program-suffix=-8.0 --disable-multilib
--enable-languages=c
Thread model: posix
gcc version 8.0.0 20171109 (experimental) (GCC)

[Bug tree-optimization/82188] New: Missed optimization opportunity for constant folding

2017-09-12 Thread ishiura-compiler at ml dot kwansei.ac.jp
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82188

Bug ID: 82188
   Summary: Missed optimization opportunity for constant folding
   Product: gcc
   Version: 8.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: ishiura-compiler at ml dot kwansei.ac.jp
  Target Milestone: ---

We compiled two programs (A1.c, A2.c) by GCC-8.0.0 with -O3 option.
Though the two programs are equivalent, GCC outputs different assembly codes.


+-+-+
| A1.c| A2.c|
+-+-+
|int main (void)  |int main (void)  |
|{|{|
|  volatile int x = 1;|  volatile int x = 1;|
| | |
|  long t1 = 1/(2U-x);|  long t1 = 1/(2U-x);|
|  int t2 = 0!=(((int)(2%(2+t1)))/2); |  int t2 = 0!=(int)t1;   |
| | |
|  if (t1 != 1) __builtin_abort();|  if (t1 != 1) __builtin_abort();|
|  if (t2 != 1) __builtin_abort();|  if (t2 != 1) __builtin_abort();|
| | |
|  return 0;  |  return 0;  |
|}|}|
+-+-+

+-+-+
|A1.s (gcc-8.0.0 A1.c -O3 -S) |A2.s (gcc-8.0.0 A2.c -O3 -S) |
+-+-+
|main:|main:|
|.LFB0:   |.LFB0:   |
|   .cfi_startproc|   .cfi_startproc|
|   subq   $24, %rsp  |   subq   $24, %rsp  |
|   .cfi_def_cfa_offset 32|   .cfi_def_cfa_offset 32|
|   movl   $2, %esi   |   movl   $2, %ecx   |
|   xorl   %edx, %edx |   xorl   %edx, %edx |
|   movl   $1, 12(%rsp)   |   movl   $1, 12(%rsp)   |
|   movl   12(%rsp), %eax |   movl   12(%rsp), %eax |
|   subl   %eax, %esi |   subl   %eax, %ecx |
|   movl   $1, %eax   |   movl   $1, %eax   |
|   divl   %esi   |   divl   %ecx   |
|   movl   %eax, %esi |   testl  %eax, %eax |
|   movl   $2, %eax   |   je .L3|
|   movq   %rsi, %rcx | |
|   cqto  | |
|   addq   $2, %rsi   | |
|   idivq  %rsi   | |
|   cmpl   $1, %ecx   | |
|   jne.L3| |
|   cmpq   $2, %rdx   | |
|   jne.L3| |
|   xorl   %eax, %eax |   xorl   %eax, %eax |
|   addq   $24, %rsp  |   addq   $24, %rsp  |
|   .cfi_def_cfa_offset 8 |   .cfi_def_cfa_offset 8 |
|   ret   |   ret   |
|   .cfi_endproc  |   .cfi_endproc  |
|   .section   .text.unlikely |   .section   .text.unlikely |
|   .cfi_startproc|   .cfi_startproc|
|   .type   main.cold.0, @function|   .type   main.cold.0, @function|
|main.cold.0: |main.cold.0: |
|.L3: |.L3: |
|   .cfi_def_cfa_offset 32|   .cfi_def_cfa_offset 32|
|   call   abort  |   call   abort  |
|   .cfi_endproc  |   .cfi_endproc  |
|.LFE0:   |.LFE0:   |
|   .section   .text.startup  |   .section   .text.startup  |
|   .size   main, .-main  |   .size   main, .-main  |
|   .section

[Bug tree-optimization/81165] New: Regression in GCC-8.0.0's optimizer

2017-06-21 Thread ishiura-compiler at ml dot kwansei.ac.jp
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81165

Bug ID: 81165
   Summary: Regression in GCC-8.0.0's optimizer
   Product: gcc
   Version: 8.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: ishiura-compiler at ml dot kwansei.ac.jp
  Target Milestone: ---

We compiled the following program by GCC-8.0.0 and GCC-7.0.1 with -O3 option.
GCC-7.0.1 performed better optimization than GCC-8.0.0.

$ cat test.c
void func() __attribute__((noinline));
short x0 = 15;

int main (void){
  long i;
  for(i = 0; i < 1; i++){
func();
  }
  return 0;
}

void func (){
  volatile int x1 = 1U;
  volatile char x2 = 0;
  char t0 = 0;
  unsigned long t1 = 2LU;
  int i = 0;

  if(1>>x2) {
t0 = -1;
t1 = (1&(short)(x1^8U))-1;
  }

  while(i > (int)((1U>>t1)+(char)(128%(10*(25LU&(29%x0)) {
i += (int)(12L/(1!=(int)t1));
  }

  if (t0 != -1) __builtin_abort();
  if (t1 != 0L) __builtin_abort();
}

$ gcc-8.0 test.c -O3 -o test.out && time ./test.out  
./test.out  1.50s user 0.00s system 99% cpu 1.506 total

$ gcc-7.0.1 test.c -O3 -o test.out && time ./test.out
./test.out  0.26s user 0.00s system 98% cpu 0.264 total

+-+---+
|gcc-8.0.s(gcc-8.0 test.c -O3 -S) |gcc-7.0.1.s  (gcc-7.0.1 test.c -O3 -S) |
+-+---+
| .cfi_startproc  |  .cfi_startproc   | 
| subq $24, %rsp  |  subq  $24, %rsp  | 
| .cfi_def_cfa_offset 32  |  .cfi_def_cfa_offset 32   | 
| movl $1, %edi   |  movl  $1, %eax   | 
| movl $1, 12(%rsp)   |  movl  $1, 12(%rsp)   | 
| movb $0, 11(%rsp)   |  movb  $0, 11(%rsp)   | 
| movl %edi, %eax |   |
| movzbl 11(%rsp), %ecx   |  movzbl  11(%rsp), %ecx   |
| sarl %cl, %eax  |  sarl  %cl, %eax  |
| testl %eax, %eax|  testl  %eax, %eax|
| je .L7  |  jne  .L12|
| movl 12(%rsp), %ecx |   |
| movl $-1, %r9d  |   |
| andl $1, %ecx   |   |
| subl $1, %ecx   |   |
| movslq %ecx, %r8|   |
| shrl %cl, %edi  |   |
|.L2: |.L2:   |
| movswl x0(%rip), %esi   |  call  abort  |
| movl $29, %eax  |  .p2align 4,,10   |
| cltd|  .p2align 3   |
| idivl %esi  |.L12:  |
| movl $128, %eax |  movl  12(%rsp), %eax |
| andl $25, %edx  |  andl  $1, %eax   |
| leaq (%rdx,%rdx,4), %rsi|  subl  $1, %eax   |
| xorl %edx, %edx |  testl  %eax, %eax|
| addq %rsi, %rsi |  jne  .L2 |
| divq %rsi   |   |
| movsbl %dl, %edx|   | 
| addl %edi, %edx |   |
| jns .L3 |   | 
| cmpl $1, %ecx   |   |
| je .L10 |   |
|.L3: |   |
| cmpb $-1, %r9b  |   |
| jne .L6 |   |
| testq %r8, %r8  |   |
| jne .L6 |   |
| addq $24, %rsp  |  addq  $24, %rsp  |
| .cfi_remember_state |   |
| .cfi_def_cfa_offset 8   |  .cfi_def_cfa_offset 8|
| ret |  ret  

[Bug tree-optimization/80541] New: Wrong constant folding

2017-04-27 Thread ishiura-compiler at ml dot kwansei.ac.jp
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80541

Bug ID: 80541
   Summary: Wrong constant folding
   Product: gcc
   Version: 7.0.1
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: ishiura-compiler at ml dot kwansei.ac.jp
  Target Milestone: ---

GCC 7.0.1 for x86_64 miscompiles the following code.

Reproduces on gcc-4.6.4 or later with -O2, -O3 and -Os.

% cat test.c

int main (void)
{
  volatile int a = 0;
  int b = -( a == 0 );
  int x = 1 % ( b + ( b * 0x7fff ) + 0x7fff );

  if (x != 0) __builtin_abort();

  return 0;
}


% gcc-7.0 test.c -O2
% ./a.out
zsh: abort (core dumped)  ./a.out
% gcc-7.0 test.c -O3
% ./a.out
zsh: abort (core dumped)  ./a.out
% gcc-7.0 test.c -Os
% ./a.out
zsh: abort (core dumped)  ./a.out
% gcc-7.0 -v
Using built-in specs.
COLLECT_GCC=gcc-7.0
COLLECT_LTO_WRAPPER=/home/cappie/opt/gcc-7.0.1/libexec/gcc/x86_64-pc-linux-gnu/7.0.1/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../configure --prefix=/home/cappie/opt/gcc-7.0.1 --disable-nls
--disable-multilib --program-suffix=-7.0 --enable-languages=c
Thread model: posix
gcc version 7.0.1 20170405 (experimental) (GCC)

[Bug tree-optimization/80426] New: Wrong constant folding

2017-04-14 Thread ishiura-compiler at ml dot kwansei.ac.jp
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80426

Bug ID: 80426
   Summary: Wrong constant folding
   Product: gcc
   Version: 7.0.1
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: ishiura-compiler at ml dot kwansei.ac.jp
  Target Milestone: ---

GCC 7.0.1 for x86_64 miscompiles the following code.

% cat test.c

#define INT_MAX 0x7fff
#define INT_MIN (-INT_MAX-1)

int x;

int main (void)
{
  volatile int a = 0;
  volatile int b = -INT_MAX;
  int j;
  for( j = 0; j < 18; j += 1 ) {
x = ( (a == 0) != (b - (int)(INT_MIN) ) );
  }

  if (x != 0) __builtin_abort();

  return 0;
}

% gcc-7.0 test.c -O2
% ./a.out
zsh: abort (core dumped)  ./a.out
% gcc-7.0 test.c -O3
% ./a.out
zsh: abort (core dumped)  ./a.out
% gcc-7.0 test.c -Os
% ./a.out
zsh: abort (core dumped)  ./a.out
% gcc-7.0 -v
Using built-in specs.
COLLECT_GCC=gcc-7.0
COLLECT_LTO_WRAPPER=/home/cappie/opt/gcc-7.0.1/libexec/gcc/x86_64-pc-linux-gnu/7.0.1/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../configure --prefix=/home/cappie/opt/gcc-7.0.1 --disable-nls
--disable-multilib --program-suffix=-7.0 --enable-languages=c
Thread model: posix
gcc version 7.0.1 20170330 (experimental) (GCC)

[Bug tree-optimization/80281] New: Wrong constant folding

2017-04-01 Thread ishiura-compiler at ml dot kwansei.ac.jp
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80281

Bug ID: 80281
   Summary: Wrong constant folding
   Product: gcc
   Version: 7.0.1
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: ishiura-compiler at ml dot kwansei.ac.jp
  Target Milestone: ---

GCC 7.0.1 for x86_64 miscompiles the following code.

% cat test.c

int main (void)
{
volatile int a = 0;
long b = 2147483648L;

int c = a % 2;
int x = ( (int)( -b ) + c  ) % -2147483647;

if (x != -1) __builtin_abort();

return 0;
}
% gcc-7.0 test.c -O3
% ./a.out
zsh: abort (core dumped)  ./a.out
% gcc-7.0 test.c -Os
% ./a.out
zsh: abort (core dumped)  ./a.out
% gcc-7.0 -v
Using built-in specs.
COLLECT_GCC=gcc-7.0
COLLECT_LTO_WRAPPER=/home/cappie/opt/gcc-7.0.1/libexec/gcc/x86_64-pc-linux-gnu/7.0.1/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../configure --prefix=/home/cappie/opt/gcc-7.0.1 --disable-nls
--disable-multilib --program-suffix=-7.0 --enable-languages=c
Thread model: posix
gcc version 7.0.1 20170330 (experimental) (GCC)

[Bug tree-optimization/78305] New: Wrong constant folding

2016-11-10 Thread ishiura-compiler at ml dot kwansei.ac.jp
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78305

Bug ID: 78305
   Summary: Wrong constant folding
   Product: gcc
   Version: 7.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: ishiura-compiler at ml dot kwansei.ac.jp
  Target Milestone: ---

GCC 7.0.0 for x86_64 miscompiles the following code.


% cat test.c
int main (void)
{
int a = 2;
int b = 1;

int t = -1 * ( -0x4000 * a / ( -0x2000 + b ) )  / -1;

if (t != 4) __builtin_abort();

return 0;
}
% gcc-7.0 test.c
% ./a.out
zsh: abort (core dumped)  ./a.out
% gcc-7.0 -v
Using built-in specs.
COLLECT_GCC=gcc-7.0
COLLECT_LTO_WRAPPER=/home/cappie/opt/gcc-7.0.0/libexec/gcc/x86_64-pc-linux-gnu/7.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../configure --prefix=/home/cappie/opt/gcc-7.0.0 --disable-nls
--disable-multilib --program-suffix=-7.0 --enable-languages=c
Thread model: posix
gcc version 7.0.0 20161108 (experimental) (GCC)

[Bug tree-optimization/77980] New: Regression in GCC-7.0.0's optimizer.

2016-10-13 Thread ishiura-compiler at ml dot kwansei.ac.jp
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77980

Bug ID: 77980
   Summary: Regression in GCC-7.0.0's optimizer.
   Product: gcc
   Version: 7.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: ishiura-compiler at ml dot kwansei.ac.jp
  Target Milestone: ---

We compiled a program (A.c) by GCC-7.0.0 and clang-3.8.0 with -O3 option.
clang-3.8.0 performed better optimization than GCC-7.0.0.

(A.c)
#include 

int x1 = 0;
unsigned int x2 = 1;

int main ()
{   
  int t1 = x1*(1/(x2+x2));
  if (t1 != 0) __builtin_abort();
return 0;
}
/*
+---+--+
|gcc-7.0.s(gcc-7.0.0 A.c -O3 -S)|clang.s(clang-3.8.0 A.c -O3 -S)  
|
+---+--+
|main:  |\t.type\tmain,@function  
|
|.LFB11:|main:
|
|.cfi_startproc |.cfi_startproc   
|
|\tmovl\tx2(%rip), %eax |# BB#0:  
|
|xorl%edx, %edx | 
|
|leal(%rax,%rax), %ecx  | 
|
|movl$1, %eax   | 
|
|divl%ecx   | 
|
|imull   x1(%rip), %eax | 
|
|testl   %eax, %eax | 
|
|jne .L7| 
|
|xorl%eax, %eax |xorl%eax, %eax   
|
|ret|retq 
|
|.L7:   |.Lfunc_end0: 
|
|subq$8, %rsp   |.size   main,
.Lfunc_end0-main|
|.cfi_def_cfa_offset 16 | 
|
|callabort  | 
|
|.cfi_endproc   |.cfi_endproc 
|
|.LFE11:\n  |\n   
|
|.size   main, .-main   |.type   x1,@object   
|
|.globl  x2 | 
|
|.data  | 
|
|.align 4   | 
|
|.type   x2, @object| 
|
|.size   x2, 4  | 
|
|x2:| 
|
|.long   1  | 
|
|.globl  x1 | 
|
|.bss   |.bss 
|
|.align 4   |.globl  x1   
|
|.type   x1, @object|.align  4
|
|.size   x1, 4  | 
|
|x1:|x1:  
|
|.zero   4  |.long   0
|
|.ident  "GCC: (GNU) 7.0.0 20...|.size   x1, 4
|
|\t.section\t.note.GNU-stack,"",@prog...|\n   
|
|   |.type   x2,@object   
|
|   |.data
|
|   |.globl  x2   
|
|   |.align  4
|
|   |x2:  
|
|   |.long   1
|
|   |.size   x2, 4
|
|   |\n   
|
|   |\n   
|
|   |.ident  "clang version
3.8|
|   |.section   
".note.GNU-...|
+---+--+
/*
using built-in specs.
COLLECT_GCC=gcc-7.0
COLLECT_LTO_WRAPPER=/home/kota/opt/gcc/libexec/gcc/x86_64-pc-linux-gnu

[Bug tree-optimization/71631] New: Wrong constant folding

2016-06-23 Thread ishiura-compiler at ml dot kwansei.ac.jp
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71631

Bug ID: 71631
   Summary: Wrong constant folding
   Product: gcc
   Version: 7.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: ishiura-compiler at ml dot kwansei.ac.jp
  Target Milestone: ---

GCC 7.0.0 for x86_64 miscompiles the following code.

% cat test.c 

volatile char buff = 0;
void PRINTF(const char* s)
{
while(*s++) buff = *s;
}

int a = 1;
int b = 1;
int c = 1;

int main (void)
{
volatile int d = 1;
volatile int e = 1;

int f =  1 / a;
int g = 1U < f;
int h =  2 + g;
int i =  3 % h;
int j =  e && b;
int k =  1 == c;
int l =  d != 0;
short m = (short)( -1 * i * l );

short x =  j * ( k * m );


if (i == 1)  {PRINTF("OK");}
if (x != -1) __builtin_abort();

return 0;
}

% gcc-7.0 test.c -O3 
% ./a.out
zsh: abort (core dumped)  ./a.out

% gcc-7.0 -v
Using built-in specs.
COLLECT_GCC=gcc-7.0
COLLECT_LTO_WRAPPER=/home/cappie/opt/gcc-7.0.0/libexec/gcc/x86_64-pc-linux-gnu/7.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../configure --prefix=/home/cappie/opt/gcc-7.0.0 --disable-nls
--disable-multilib --program-suffix=-7.0 --enable-languages=c
Thread model: posix
gcc version 7.0.0 20160621 (experimental) (GCC)

[Bug tree-optimization/71608] New: Wrong constant folding

2016-06-21 Thread ishiura-compiler at ml dot kwansei.ac.jp
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71608

Bug ID: 71608
   Summary: Wrong constant folding
   Product: gcc
   Version: 7.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: ishiura-compiler at ml dot kwansei.ac.jp
  Target Milestone: ---

GCC 7.0.0 for x86_64 miscompiles the following code.

% cat test.c  

int x = 0x4000;

int main (void)
{
  int t = - 0x7FFF - ( -2 * x ) ;
  if (t != 1) __builtin_abort();
  return 0;
}

% gcc-7.0 test.c -O3  
% ./a.out 
zsh: abort (core dumped)  ./a.out

% gcc-7.0 -v  
Using built-in specs.
COLLECT_GCC=gcc-7.0
COLLECT_LTO_WRAPPER=/home/cappie/opt/gcc-7.0.0/libexec/gcc/x86_64-pc-linux-gnu/7.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../configure --prefix=/home/cappie/opt/gcc-7.0.0 --disable-nls
--disable-multilib --program-suffix=-7.0 --enable-languages=c
Thread model: posix
gcc version 7.0.0 20160621 (experimental) (GCC) 

Reproduces on gcc-4.3.6 or later with -O3.
Also reproduces on 5.1.0 or later with -O1.

[Bug tree-optimization/71563] New: Regression in GCC-7.0.0's optimizer.

2016-06-16 Thread ishiura-compiler at ml dot kwansei.ac.jp
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71563

Bug ID: 71563
   Summary: Regression in GCC-7.0.0's optimizer.
   Product: gcc
   Version: 7.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: ishiura-compiler at ml dot kwansei.ac.jp
  Target Milestone: ---

We compiled a program (A.c) by GCC-7.0.0 and GCC-5.2.1 with -O3 option.
GCC-5.2.1 performed better optimization than GCC-7.0.0.

(A.c)
int main ()
{
  volatile int k = 2;
  int t = 1<<((1/k)<<8);
  if (t != 1) __builtin_abort();
  return 0;
}

+--++
|gcc-7.0.0.s (gcc-7.0.0 A.c -O3 -S)|gcc-5.2.1.s (gcc-5.2.1 A.c -O3 -S)  |
+--++
|main: |main:   |
|.LFB11:   |.LFB23: |
|.cfi_startproc|.cfi_startproc  |
|subq$24, %rsp |movl$2, -12(%rsp)   |
|.cfi_def_cfa_offset 32|movl-12(%rsp), %eax |
|xorl%edx, %edx||
|movl$1, %eax  ||
|movl$2, 12(%rsp)  ||
|movl12(%rsp), %ecx||
|divl%ecx  ||
|testl   %eax, %eax||
|jne .L5   ||
|xorl%eax, %eax|xorl%eax, %eax  |
|addq$24, %rsp ||
|.cfi_remember_state   ||
|.cfi_def_cfa_offset 8 ||
|ret   |ret |
|.L5:  ||
|.cfi_restore_state||
|callabort ||
|.cfi_endproc  |.cfi_endproc|
|.LFE11:   |.LFE23: |
|.size   main, .-main  |.size   main, .-main|
|.ident  "GCC: (GNU) 7.0.0 2...|.section.text.unl...|
|  |.LCOLDE0:   |
|  |.section.text.sta...|
|  |.LHOTE0:|
|  |.ident  "GCC: (Ubuntu 5.2...|
|.section.note.GNU-s...|.section.note.GNU...|
+--++

using built-in spacs.
COLLECT_GCC=gcc-7.0-0615
COLLECT_LTO_WRAPPER=/home/kota_kitaura/opt/gcc-7.0-0615/libexec/gcc/x86_64-pc-linux-gnu/7.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
configure with: ../gcc/configure --prefix=/home/kota_kitaura/opt/gcc-7.0-0615
--program-suffix=-7.0-0615 --enable-languages=c
Thread model: posix
gcc version 7.0.0 20160615 (experimental) (GCC) 

Using built-in specs.
COLLECT_GCC=gcc-5
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/5/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu
5.2.1-23ubuntu1~15.10' --with-bugurl=file:///usr/share/doc/gcc-5/README.Bugs
--enable-languages=c,ada,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr
--program-suffix=-5 --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu
--enable-libstdcxx-debug --enable-libstdcxx-time=yes
--with-default-libstdcxx-abi=new --enable-gnu-unique-object
--disable-vtable-verify --enable-libmpx --enable-plugin --with-system-zlib
--disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo
--with-java-home=/usr/lib/jvm/java-1.5.0-gcj-5-amd64/jre --enable-java-home
--with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-5-amd64
--with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-5-amd64
--with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar
--enable-objc-gc --enable-multiarch --disable-werror --with-arch-32=i686
--with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib
--with-tune=generic --enable-checking=release --build=x86_64-linux-gnu
--host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread mo

[Bug tree-optimization/71521] New: Regression in GCC-7.0.0's optimizer

2016-06-13 Thread ishiura-compiler at ml dot kwansei.ac.jp
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71521

Bug ID: 71521
   Summary: Regression in GCC-7.0.0's optimizer
   Product: gcc
   Version: 7.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: ishiura-compiler at ml dot kwansei.ac.jp
  Target Milestone: ---

We compiled a program (A.c) by GCC-7.0.0 and GCC-5.2.1 with -O3 option.
GCC-5.2.1 performed better optimization than GCC-7.0.0.

(A.c)
int x = 1;

int main ()
{
int t = (1/(1>=x))>>1;
if (t != 0) __builtin_abort();
return 0;
}

+--++
|gcc-7.0.0.s (gcc-7.0.0 A.c -O3 -S)|gcc-5.2.1.s (gcc-5.2.1 A.c -O3 -S)  |
+--++
|main: |main:   |
|.LFB0:|.LFB0:  |
|.cfi_startproc|.cfi_startproc  |
|cmpl$1, x(%rip)   ||
|jle .L2   ||
|movl$1, %eax  ||
|xorl%ecx, %ecx||
|cltd  ||
|idivl   %ecx  ||
|testl   %eax, %eax||
|js  .L10  ||
|.L2:  ||
|xorl%eax, %eax|xorl%eax, %eax  |
|ret   |ret |
|.L10: ||
|subq$8, %rsp  ||
|.cfi_def_cfa_offset 16||
|callabort ||
|.cfi_endproc  |.cfi_endproc|
|.LFE0:|.LFE0:  |
|.size   main, .-main  |.size   main, .-main|
|  |.section.text.unl...|
|  |.LCOLDE0:   |
|  |.section.text.sta...|
|  |.LHOTE0:|
|.globl  x |.globl  x   |
|.data |.data   |
|.align 4  |.align 4|
+--++
|.size   x, 4  |.size   x, 4|
|x:|x:  |
|.long   1 |.long   1   |
|.ident  "GCC: (GNU) 7.0.0 ... |.ident  "GCC: (Ubuntu 5.2...|
|.section.note.GNU-... |.section.note.GNU...|
+--++


using built-in spacs.
COLLECT_GCC=gcc-7.0-0612
COLLECT_LTO_WRAPPER=/home/kota_kitaura/opt/gcc-7.0-0612/libexec/gcc/x86_64-pc-linux-gnu/7.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
configure with: ../gcc/configure --prefix=/home/kota_kitaura/opt/gcc-7.0-0612
--program-suffix=-7.0-0612 --enable-languages=c
Thread model: posix
gcc version 7.0.0 20160612 (experimental) (GCC) 

Using built-in specs.
COLLECT_GCC=gcc-5
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/5/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu
5.2.1-23ubuntu1~15.10' --with-bugurl=file:///usr/share/doc/gcc-5/README.Bugs
--enable-languages=c,ada,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr
--program-suffix=-5 --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu
--enable-libstdcxx-debug --enable-libstdcxx-time=yes
--with-default-libstdcxx-abi=new --enable-gnu-unique-object
--disable-vtable-verify --enable-libmpx --enable-plugin --with-system-zlib
--disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo
--with-java-home=/usr/lib/jvm/java-1.5.0-gcj-5-amd64/jre --enable-java-home
--with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-5-amd64
--with-jvm-j

[Bug tree-optimization/68528] New: Wrong constant folding

2015-11-24 Thread ishiura-compiler at ml dot kwansei.ac.jp
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68528

Bug ID: 68528
   Summary: Wrong constant folding
   Product: gcc
   Version: 6.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: ishiura-compiler at ml dot kwansei.ac.jp
  Target Milestone: ---

GCC-6.0 for x86_64 miscompiles the following code.

$ cat test.c
#define INT_MIN ( -2147483647 - 1 )

int main (void)
{
int  x0 = INT_MIN;
long x1 = 0L;
int  x2 = 0;
int  t  = ( 0 || ( INT_MIN - (int) ( x0 - x1 ) ) );

if ( t != 0 ) { x2 = t; __builtin_abort(); }

return 0;
}

$ gcc-6.0 test.c -O2

$ ./a.out
zsh: abort  ./a.out

$ gcc-6.0 -v
Using built-in specs.
COLLECT_GCC=gcc-6.0
COLLECT_LTO_WRAPPER=/home/ishiuraken/opt/gcc-6.0/libexec/gcc/x86_64-pc-linux-gnu/6.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../configure --prefix=/home/ishiuraken/opt/gcc-6.0
--program-suffix=-6.0 --enable-laungages=c --disable-bootstrap
Thread model: posix
gcc version 6.0.0 20151112 (experimental) (GCC)

[Bug c/68431] New: Regression in GCC-6.0.0's optimizer

2015-11-18 Thread ishiura-compiler at ml dot kwansei.ac.jp
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68431

Bug ID: 68431
   Summary: Regression in GCC-6.0.0's optimizer
   Product: gcc
   Version: 6.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
  Assignee: unassigned at gcc dot gnu.org
  Reporter: ishiura-compiler at ml dot kwansei.ac.jp
  Target Milestone: ---

We compiled a program (A.c) by GCC-5.2.1 and GCC-6.0.0 with -O3 option.
GCC-5.2.1 performed better optimization than GCC-6.0.0.
Note that "unsigned int" is 32 bit and "long long int" is 64 bit.

(A.c)
unsigned int x = 1;
int main (void)
{
long long int a = -2LL;
int t = 1<=(a/x);
if (t != 0) { __builtin_abort(); }

return 0;
}

+---+--+
|   gcc-5.2.1s (gcc-5.2.1 A.c -O3 -S)   |  gcc-6.0.0.s (gcc-6.0.0 A.c -O3 -S) 
|
+---+--+
|main:  |main:
|
|.LFB0: |.LFB0:   
|
|.cfi_startproc |.cfi_startproc   
|
|   |movlx(%rip), %ecx
|
|   |movq$-2, %rax
|
|   |cqto 
|
|   |idivq   %rcx 
|
|   |testq   %rax, %rax   
|
|   |jg  .L7  
|
|xorl%eax, %eax |xorl%eax, %eax   
|
|ret|ret  
|
|   |.L7: 
|
|   |pushq   %rax 
|
|   |.cfi_def_cfa_offset 16   
|
|   |callabort
|
|.cfi_endproc   |.cfi_endproc 
|
|.LFE0: |.LFE0:   
|
|.size   main, .-main   |.size   main, .-main 
|
|.section.text.unlikely | 
|
|.LCOLDE0:  | 
|
|.section.text.startup  | 
|
|.LHOTE0:   | 
|
|.globl  x  |.globl  x
|
|.data  |.data
|
|.align 4   |.align 4 
|
|.size   x, 4   |.size   x, 4 
|
|x: |x:   
|
|.long   1  |.long   1
|
|.ident  "GCC: (Ubuntu 5.2.1 ...|.ident  "GCC: (GNU) 6.0.0 
...|
|.section.note.GNU-  ...|.section.note.GNU-
...|
+---+--+



$ gcc-6.0 -v
Using built-in specs.
COLLECT_GCC=gcc-6.0
COLLECT_LTO_WRAPPER=/home/iwatsuji/opt/gcc-6.0.0/libexec/gcc/x86_64-pc-linux-gnu/6.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
configured with: ../gcc/configure --prefix=/home/iwatsuji/opt/gcc-6.0.0
--program-suffix=-6.0 --disable-multilib --enable-languages=c
Thread model: posix
gcc versin 6.0.0 20151119 (experimental) (GCC) 

$ gcc-5 -v
Using built-in specs.
COLLECT_GCC=gcc-5
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/5/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu
5.2.1-23ubuntu1~14.04.2' --with-bugurl=file:///usr/share/doc/gcc-5/README.Bugs
--enable-languages=c,ada,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr
--program-suffix=-5 --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu
--enable-libstdcxx-debug --enable-libstdcxx-time=yes
--with-default-libstdcxx-abi=gcc4-compatible --disable-libstdcxx-dual-abi
--enable-gnu-unique-object --disable-vtable-verify --enable-libmpx
--enable-plugin --with-system-zlib --disable-browser-plugin
--enable-java-awt=gtk --enable-gtk-cairo
--with-java-home=/usr/lib/jvm/java-1.5.0-gcj-5-amd64/jre --enable-java-home
--with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-5-amd64
--with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-

[Bug c/68217] New: Wrong constant folding

2015-11-04 Thread ishiura-compiler at ml dot kwansei.ac.jp
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68217

Bug ID: 68217
   Summary: Wrong constant folding
   Product: gcc
   Version: 6.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
  Assignee: unassigned at gcc dot gnu.org
  Reporter: ishiura-compiler at ml dot kwansei.ac.jp
  Target Milestone: ---

GCC-6.0.0 miscompiles the following code.

$ cat error.c

int main(void){
volatile int a = -1;
long long b = -9223372036854775807LL-1; // LLONG_MIN
long long x = (a & b); // x == 0x8000
if ( x < 1LL ) { ; } else { __builtin_abort(); }
return 0;
}

$ gcc-6.0 error.c -O3 && ./a.out
[1]26572 abort (core dumped)  ./a.out

$ gcc-6.0 -v
Using built-in specs.
COLLECT_GCC=gcc-6.0
COLLECT_LTO_WRAPPER=$HOME/opt/gcc-6.0.0/libexec/gcc/x86_64-pc-linux-gnu/6.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc/configure --prefix=$HOME/opt/gcc-6.0.0
--enable-languages=c --program-suffix=-6.0
Thread model: posix
gcc version 6.0.0 20151105 (experimental) (GCC)

[Bug c/68067] New: Wrong constant folding

2015-10-23 Thread ishiura-compiler at ml dot kwansei.ac.jp
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68067

Bug ID: 68067
   Summary: Wrong constant folding
   Product: gcc
   Version: trans-mem
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
  Assignee: unassigned at gcc dot gnu.org
  Reporter: ishiura-compiler at ml dot kwansei.ac.jp
  Target Milestone: ---

GCC-6.0.0 miscompiles the following code.
GCC-4.3.6 or later versions miscompile too.


$cat error.c

int main(void) {
  int a = -1;
  static int b = -2147483647 - 1;
  static int c = 0;
  int t = a - (b - c);
  if (t != 2147483647) { __builtin_abort(); }
  return 0;
}


$gcc-6.0 error.c -O3 && ./a.out
[1]25603 abort (core dumped)  ./a.out


$gcc-6.0 -v
Using built-in specs.
COLLECT_GCC=gcc-6.0
COLLECT_LTO_WRAPPER=$HOME/opt/gcc-6.0.0/libexec/gcc/x86_64-pc-linux-gnu/6.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc/configure --prefix=$HOME/opt/gcc-6.0.0
--enable-languages=c --disable-multilib --program-suffix=-6.0
Thread model: posix
gcc version 6.0.0 20151022 (experimental) (GCC)


[Bug c/68026] New: Regression in GCC-6.0.0's optimizer

2015-10-19 Thread ishiura-compiler at ml dot kwansei.ac.jp
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68026

Bug ID: 68026
   Summary: Regression in GCC-6.0.0's optimizer
   Product: gcc
   Version: 6.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
  Assignee: unassigned at gcc dot gnu.org
  Reporter: ishiura-compiler at ml dot kwansei.ac.jp
  Target Milestone: ---

We compiled a program (A.c) by GCC-5.1.0 and GCC-6.0.0 with -O3 option.
GCC-5.1.0 performed better optimization than GCC-6.0.0.

(A.c)
int main (void)
{
volatile int x1 = 1;
volatile int x2 = 1;
int x3 = 2;
int t = 1;

t = 3<=(x2|1|x3|x1-1U);

if (t == 1) {} 
else { __builtin_abort(); }

return 0;
}

+--+--+
|  gcc-5.1.0.s (gcc-5.1.0 A.c -O3 -S)  |  gcc-6.0.0.s (gcc-6.0.0 A.c -O3 -S)  |
+--+--+
|main: |main: |
|.LFB0:|.LFB0:|
|.cfi_startproc|.cfi_startproc|
|movl$1, -8(%rsp)  |subq$24, %rsp |
|movl$1, -4(%rsp)  |.cfi_def_cfa_offset 32|
|movl-4(%rsp), %eax|movl$1, 8(%rsp)   |
|movl-8(%rsp), %eax|movl$1, 12(%rsp)  |
|  |movl12(%rsp), %eax|
|  |movl8(%rsp), %edx |
|  |orl $3, %eax  |
|  |movl%eax, %ecx|
|  |leal-1(%rdx), %eax|
|  |orl %ecx, %eax|
|  |cmpl$2, %eax  |
|  |jbe .L5   |
|xorl%eax, %eax|xorl%eax, %eax|
|  |addq$24, %rsp |
|  |.cfi_remember_state   |
|  |.cfi_def_cfa_offset 8 |
|ret   |ret   |
|  |.L5:  |
|  |.cfi_restore_state|
|  |callabort |
|.cfi_endproc  |.cfi_endproc  |
|.LFE0:|.LFE0:|
|.size   main, .-main  |.size   main, .-main  |
|.section.text.unlikely|.ident  "GCC: (GNU) 6.0.0  ...|
|.LCOLDE0: |  |
|.section.text.startup |  |
|.LHOTE0:  |  |
|.ident  "GCC: (Ubuntu 5.1.0...|  |
|.section.note.GNU-s...|.section.note.GNU-s...|
+--+--+

Using built-in specs.
COLLECT_GCC=gcc-5
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/5/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu
5.1.0-0ubuntu11~14.04.1' --with-bugurl=file:///usr/share/doc/gcc-5/README.Bugs
--enable-languages=c,ada,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr
--program-suffix=-5 --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu
--enable-libstdcxx-debug --enable-libstdcxx-time=yes
--with-default-libstdcxx-abi=c++98 --enable-gnu-unique-object
--disable-vtable-verify --enable-libmpx --enable-plugin --with-system-zlib
--disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo
--with-java-home=/usr/lib/jvm/java-1.5.0-gcj-5-amd64/jre --enable-java-home
--with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-5-amd64
--with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-5-amd64
--with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar
--enable-objc-gc --enable-multiarch --disable-werror --with-arch-32=i686
--with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib
--with-tune=generic --enable-checking=release --build=x86_64-linux-gnu
--host=x86_64-linux-gnu --target

[Bug tree-optimization/67949] Regression in GCC-6.0.0's optimizer

2015-10-14 Thread ishiura-compiler at ml dot kwansei.ac.jp
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67949

--- Comment #3 from Ishiura Lab Compiler Team  ---
We are very sorry that somehow we failed to do final check with the latest
trunk before submitting the report.


[Bug tree-optimization/67949] New: Regression in GCC-6.0.0's optimizer

2015-10-13 Thread ishiura-compiler at ml dot kwansei.ac.jp
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67949

Bug ID: 67949
   Summary: Regression in GCC-6.0.0's optimizer
   Product: gcc
   Version: 6.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: ishiura-compiler at ml dot kwansei.ac.jp
  Target Milestone: ---

We compiled a program (A.c) by GCC-5.1.0 and GCC-6.0.0 with -O3 option.
GCC-5.1.0 performed better optimization than GCC-6.0.0.

(A.c)
#include 
int x110 = 0;
int main (void)
{
volatile int x129 = 1;
int t0 = 1;

t0 = (x129==1)<=(2U^(-(1-x110<<2)));

if (t0 == 1) { } 
else { __builtin_abort(); }

return 0;
}

+-+-+
|gcc-5.1.0.s (gcc-5.1.0 A.c -O3 -S)   |   gcc-6.0.0.s (gcc-6.0.0 A.c -O3
-S)|
+-+-+
|.globl  main |.globl  main
|
|.type   main, @function  |.type   main, @function 
|
|main:|main:   
|
|.LFB23:  |.LFB11: 
|
|.cfi_startproc   |.cfi_startproc  
|
|movl$1, -4(%rsp) |subq$24, %rsp   
|
|movl-4(%rsp), %eax   |.cfi_def_cfa_offset 32  
|
| |xorl%edx, %edx  
|
| |movl$1, 12(%rsp)
|
| |movl12(%rsp), %eax  
|
| |cmpl$1, %eax
|
| |movl$1, %eax
|
| |sete%dl 
|
| |sublx110(%rip), %eax
|
| |sall$2, %eax
|
| |negl%eax
|
| |xorl$2, %eax
|
| |cmpl%eax, %edx  
|
| |ja  .L5 
|
|xorl%eax, %eax   |xorl%eax, %eax  
|
| |addq$24, %rsp   
|
| |.cfi_remember_state 
|
| |.cfi_def_cfa_offset 8   
|
|ret  |ret 
|
| |.L5:
|
| |.cfi_restore_state  
|
| |callabort   
|
|.cfi_endproc |.cfi_endproc
|
|.LFE23:  |.LFE11: 
|
|.size   main, .-main |.size   main, .-main
|
|.section.text.unlikely   |.section   
.text.unlikely   |
|.LCOLDE0:|.LCOLDE0:   
|
|.size   x110, 4  |.size   x110, 4 
|
|x110:|x110:   
|
|.zero   4|.zero   4   
|
+-+-+

Using built-in specs.
COLLECT_GCC=gcc-5
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/5/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu
5.1.0-0ubuntu11~14.04.1' --with-bugurl=file:///usr/share/doc/gcc-5/README.Bugs
--enable-languages=c,ada,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr
--program-suffix=-5 --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu
--enable-libstdcxx-debug --enable-libstdcxx-time=yes
--with-default-libstdcxx-abi=c++98 --enable-gnu-unique-object
--disable-vtable-verify --enable-libmpx --enable-plugin --with-system-zlib
--disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo
--with-java-home=/usr/lib/jvm/java-1.

[Bug tree-optimization/66299] New: more optimize oppotunity

2015-05-27 Thread ishiura-compiler at ml dot kwansei.ac.jp
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66299

Bug ID: 66299
   Summary: more optimize oppotunity
   Product: gcc
   Version: 6.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: ishiura-compiler at ml dot kwansei.ac.jp
  Target Milestone: ---

We compiled a program (A.c) by GCC-6.0.0 and LLVM/Clang-3.7.0 with -O3 option.
LLVM/Clang worked better on this test case, where the shift operation is
optimized out. 

(A.c)
int main (void)
{
volatile signed int x = 1;
unsigned int t = ((unsigned int)1Ux);

if (t == 2U) ;
else __builtin_abort();

return 0;
}

++--+
|gcc.s (gcc A.c -O3 -S)  | clang.s
(clang A.c -O3 -S)   |
++--+
|main:   | 
*
|.LFB11: |main:
  # @main   *
|.cfi_startproc  |   
.cfi_startproc|
|subq  $24, %rsp |# BB#0:  
  # %entry  *
|.cfi_def_cfa_offset 32  |pushq   %rax 
*
|movl  $1, %eax  |.Ltmp0:  
*
|movl$1, 12(%rsp)|   
.cfi_def_cfa_offset 16*
|movl12(%rsp), %ecx  |movl$1,
4(%rsp)   *
|sall%cl, %eax   |movl   
4(%rsp), %eax *
|cmpl$2, %eax|cmpl$1,
%eax  *
|jne .L5 |jne
.LBB0_2   *
||# BB#1:  
  # %if.end *
|xorl%eax, %eax  |xorl%eax,
%eax|
|addq$24, %rsp   |popq%rdx 
*
|.cfi_remember_state |retq 
*
|.cfi_def_cfa_offset 8   |.LBB0_2: 
  # %if.else*
|ret |callq   abort
*
|.L5:|.Ltmp1:  
*
|.cfi_restore_state  |.size   main,
.Ltmp1-main *
|callabort   | 
|
|.cfi_endproc|.cfi_endproc 
|
|.LFE11: | 
*
|.size\tmain, .-main | 
*
|.section.text.unlikely  | 
*
|.LCOLDE0:   | 
*
|.section.text.startup   | 
|
|.LHOTE0:| 
|
++--+


gcc (GCC) 6.0.0 20150416 (experimental)
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

clang version 3.7.0 (trunk 237801)
Target: x86_64-unknown-linux-gnu
Thread model: posix


[Bug tree-optimization/64992] More optimize opportunity

2015-02-15 Thread ishiura-compiler at ml dot kwansei.ac.jp
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64992

--- Comment #4 from Ishiura Lab Compiler Team ishiura-compiler at ml dot 
kwansei.ac.jp ---
FYI, clang-3.6 -O3 seems to do the same optimization on org.c as well as on
opt.c.


[Bug tree-optimization/64992] More optimize opportunity

2015-02-14 Thread ishiura-compiler at ml dot kwansei.ac.jp
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64992

--- Comment #3 from Ishiura Lab Compiler Team ishiura-compiler at ml dot 
kwansei.ac.jp ---
Looking only from outside, the two programs are virtually equal, so we
just wondered what hinders the optimization on one of the programs. 

The Optimization on opt.c seems very strong, so we think it would be
nice if the same transformation would work on org.c.


[Bug tree-optimization/64992] New: More optimize opportunity

2015-02-09 Thread ishiura-compiler at ml dot kwansei.ac.jp
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64992

Bug ID: 64992
   Summary: More optimize opportunity
   Product: gcc
   Version: 5.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: ishiura-compiler at ml dot kwansei.ac.jp

The two programs (A.c) and (B.c) only differ by one line (marked by //
---HERE),
where (B.c) simply replace local variable b by its initial value 2U.
The code (A.s) for (A.c) is less optimized than (B.s) for (B.c).

(org.c)
int main (void)
{
  volatile int a = -1;
  unsigned int b = 2U;

  int  c = a + 0;
  unsigned d = b * (1 == c); //---HERE

  if (c == -1) ;
  else __builtin_abort();
  if (d == 0U) ;
  else __builtin_abort();

  return 0;
}

(opt.c)
int main (void)
{
  volatile int a = -1;
  unsigned int b = 2U;

  int  c = a + 0;
  unsigned d = 2U * (1 == c);//---HERE

  if (c == -1) ;
  else __builtin_abort();
  if (d == 0U) ;
  else __builtin_abort();

  return 0;
}

(org.s)
main:
.LFB0:
  .cfi_startproc
  subq   $24, %rsp
  .cfi_def_cfa_offset 32
  xorl   %eax, %eax
  movl   $-1, 12(%rsp)
  movl   12(%rsp), %edx
  cmpl   $1, %edx
  sete   %al
  addl   %eax, %eax
  cmpl   $-1, %edx
  jne.L3
  testl  %eax, %eax
  jne.L3
  addq   $24, %rsp
  .cfi_remember_state
  .cfi_def_cfa_offset 8
  ret
.L3:
  .cfi_restore_state
  call  abort
  .cfi_endproc
.LFE0:
  .size  main, .-main
  .section  .text.unlikely
.LCOLDE0:
  .section  .text.startup
.LHOTE0:
  .ident  GCC: (GNU) 5.0.0 20150205 (experimental)
  .section  .note.GNU-stack,,@progbits

(opt.s)
main:
.LFB0:
  .cfi_startproc
  subq   $24, %rsp
  .cfi_def_cfa_offset 32
  movl   $-1, 12(%rsp)
  movl   12(%rsp), %eax
  cmpl   $-1, %eax
  jne.L5
  xorl   %eax, %eax
  addq   $24, %rsp
  .cfi_remember_state
  .cfi_def_cfa_offset 8
  ret
.L5:
  .cfi_restore_state
  call  abort
  .cfi_endproc
.LFE0:
  .size  main, .-main
  .section  .text.unlikely
.LCOLDE0:
  .section  .text.startup
.LHOTE0:
  .ident  GCC: (GNU) 5.0.0 20150205 (experimental)
  .section  .note.GNU-stack,,@progbits


$ x86_64-unknown-linux-gnu-gcc-5.0.0 -v
Using built-in specs.
COLLECT_GCC=x86_64-unknown-linux-gnu-gcc-5.0.0
COLLECT_LTO_WRAPPER=/usr/local/x86_64-tools/gcc-5.0.0/libexec/gcc/x86_64-unknown-linux-gnu/5.0.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: /home/iwatsuji/gcc/configure
--prefix=/usr/local/x86_64-tools/gcc-5.0.0/
--with-gmp=/usr/local/gmp-5.1.1/ --with-mpfr=/usr/local/mpfr-3.1.2/
--with-mpc=/usr/local/mpc-1.0.1/ --disable-multilib --disable-nls
--enable-languages=c
Thread model: posix
gcc version 5.0.0 20150205 (experimental) (GCC)


[Bug tree-optimization/61931] Wrong Constant Folding

2014-12-17 Thread ishiura-compiler at ml dot kwansei.ac.jp
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61931

--- Comment #2 from Ishiura Lab Compiler Team ishiura-compiler at ml dot 
kwansei.ac.jp ---
We are sorry for having reported an error program with undefined behavior.
We have redone minimization. The resulting program is as follows.

$ cat test.c

int a = 1;
int b = 0;
int c = 1;
int d = 1;
long long e = 2LL;
long long f = 1LL;
unsigned long long g = 0xLLU;

int main (void)
{
  int   h = 1;
  int   i = (1 / a) - 1;   
  int   j = h  (i = 1U);
  long long k = 1LL  (g + 3LLU); 
  long long l = k  1;
  long long m = (b | l) / 3;   
  long long n = (a - m) | 1;   
  long long o = 1 - ((0 | n) ^ j); 
  long long p = 1 | (3 * f);   
  long long q = p  (a = 0); 
  long long r = (e  2) % 3;   
c = r = (q || d); 
  long long s = (1LL % d) * a; 

  if (o != -2LL) __builtin_printf (o = %lld\n, o);
  if (s !=  0LL) __builtin_printf (%lld, 0LL);

  return 0;
}

$ arm-none-eabi-gcc-4.8.4 test.c -o test.out -O2 --specs=rdimon.specs
$ qemu-arm -L /usr/arm-linux-gnueabihf/ ./test.out
o = 164686225997822

$ arm-none-eabi-gcc-4.8.4 test.c -o test.out -O1 --specs=rdimon.specs
$ qemu-arm -L /usr/arm-linux-gnueabihf/ ./test.out


[Bug tree-optimization/64322] New: More optimize opportunity for constant folding

2014-12-15 Thread ishiura-compiler at ml dot kwansei.ac.jp
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64322

Bug ID: 64322
   Summary: More optimize opportunity for constant folding
   Product: gcc
   Version: 5.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: ishiura-compiler at ml dot kwansei.ac.jp

The two programs (A.c) and (B.c) only differ by one line
(marked by // ---HERE), where (B.c) change 0x1L to 0L.

Resulting codes by x86_64-unknown-linux-gnu-gcc-5.0.0 -Os -S
are different;
the code (A.s) for (A.c) is less optimized than (B.s) for (B.c).
Note that variable c is not referenced at all in this program.

(A.c)
int main (void)
{
  long a = -1L;
 volatile long b =  0L;
 volatile long c = 0x1L;  // ---HERE
 a = (1+b  63  1) / 0x1L;

 if (a == 0L);
 else __builtin_abort();

 return 0;
}

(B.c)
int main (void)
{
  long a = -1L;
 volatile long b =  0L;
 volatile long c =  0L;   // ---HERE
 a = (1+b  63  1) / 0x1L;

 if (a == 0L);
 else __builtin_abort();

 return 0;
}

+-+-+
|(A.s)|(B.s)|
+-+-+
|main:|main:|
|.LFB0:   |.LFB0:   |
|  .cfi_startproc |  .cfi_startproc |
|  subq  $24, %rsp|  movq  $0, -24(%rsp)|
|  .cfi_def_cfa_offset 32 |  movq  $0, -16(%rsp)|
|  movabsq  $4294967296, %rcx |  movq  -24(%rsp), %rax  |
|  movq  $0, (%rsp)   | |
|  movq  %rcx, 8(%rsp)| |
|  movq  (%rsp), %rax | |
|  incq  %rax | |
|  sarq  $63, %rax| |
|  addq  %rax, %rax   | |
|  cqto   | |
|  idivq  %rcx| |
|  testq  %rax, %rax  | |
|  je  .L2| |
|  call  abort| |
|.L2: | |
|  xorl  %eax, %eax   |  xorl  %eax, %eax   |
|  addq  $24, %rsp| |
|  .cfi_def_cfa_offset 8  | |
|  ret|  ret|
|  .cfi_endproc   |  .cfi_endproc   |
|.LHOTE0: |.LHOTE0: |
+-+-+

$ x86_64-unknown-linux-gnu-gcc-5.0.0 -v
Using built-in specs.
COLLECT_GCC=x86_64-unknown-linux-gnu-gcc-5.0.0
COLLECT_LTO_WRAPPER=/usr/local/x86_64-tools/gcc-5.0.0/libexec/gcc/x86_64-unknown-linux-gnu/5.0.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: /home/hassy/gcc/configure
--prefix=/usr/local/x86_64-tools/gcc-5.0.0/
--with-gmp=/usr/local/gmp-5.1.1/ --with-mpfr=/usr/local/mpfr-3.1.2/
--with-mpc=/usr/local/mpc-1.0.1/ --disable-multilib --disable-nls
--enable-languages=c
Thread model: posix
gcc version 5.0.0 20141215 (experimental) (GCC)


[Bug tree-optimization/63947] New: Wrong assembly code generation

2014-11-18 Thread ishiura-compiler at ml dot kwansei.ac.jp
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63947

Bug ID: 63947
   Summary: Wrong assembly code generation
   Product: gcc
   Version: 4.9.2
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: ishiura-compiler at ml dot kwansei.ac.jp

GCC 4.9.2 for x86_64 miscompiles the following code with optimize option -Os.

$ cat error.c 
unsigned int a = 0U;
int t = 0;

int main (void)
{
  int b = 0;
  volatile int c = 0;
  long double d = 1.0L;
  int e = 0;

  t = (((b+e)/d)-(a(c+a)));

  return 0;
}

$ x86_64-unknown-linux-gnu-gcc-4.9.2 error.c -Os
/tmp/ccjhNwLd.s: Assembler messages:
/tmp/ccjhNwLd.s:18: Error: no such instruction: `fcmovnc %st(1),%st'

$ x86_64-unknown-linux-gnu-gcc-4.9.2 -v 
Using built-in specs.
COLLECT_GCC=x86_64-unknown-linux-gnu-gcc-4.9.2
COLLECT_LTO_WRAPPER=/usr/local/x86_64-tools/gcc-4.9.2/libexec/gcc/x86_64-unknown-linux-gnu/4.9.2/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../configure --prefix=/usr/local/x86_64-tools/gcc-4.9.2/
--with-gmp=/usr/local/gmp-5.0.5/ --with-mpfr=/usr/local/mpfr-3.1.0/
--with-mpc=/usr/local/mpc-0.9/ --disable-multilib --disable-nls
--enable-languages=c
Thread model: posix
gcc version 4.9.2 (GCC)


[Bug tree-optimization/63380] New: Wrong constant folding

2014-09-26 Thread ishiura-compiler at ml dot kwansei.ac.jp
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63380

Bug ID: 63380
   Summary: Wrong constant folding
   Product: gcc
   Version: 5.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: ishiura-compiler at ml dot kwansei.ac.jp

GCC 5.0.0 for x86_64 miscompiles the following code.

   $ cat test.c

int a = 0, b = 1, c = 0, d = 1, e, f, g, h;
int
main ()
{
  e = 1  d;
  f = ((31 / (1  e)) || c) / 2;
  g = b || a;
  h = 31 / g;
  if (!h)
__builtin_abort();
  return 0;
}

   $ x86_64-unknown-linux-gnu-gcc-5.0.0 test.c -O2
   $ ./a.out
   Floating point exception (core dumped)

   $ x86_64-unknown-linux-gnu-gcc-5.0.0 -v
Using built-in specs.
COLLECT_GCC=x86_64-unknown-linux-gnu-gcc-5.0.0
COLLECT_LTO_WRAPPER=/usr/local/x86_64-tools/gcc-
5.0.0/libexec/gcc/x86_64-unknown-linux-gnu/5.0.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: /home/orange3/gcc-master/configure --
prefix=/usr/local/x86_64-tools/gcc-5.0.0/ --with-gmp=/usr/local/gmp-
5.1.1/ --with-mpfr=/usr/local/mpfr-3.1.2/ --with-mpc=/usr/local/mpc-
1.0.1/ --disable-multilib --disable-nls --enable-languages=c
Thread model: posix
gcc version 5.0.0 20140922 (experimental) (GCC)


[Bug tree-optimization/63381] New: Wrong constant folding

2014-09-26 Thread ishiura-compiler at ml dot kwansei.ac.jp
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63381

Bug ID: 63381
   Summary: Wrong constant folding
   Product: gcc
   Version: 5.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: ishiura-compiler at ml dot kwansei.ac.jp

GCC 5.0.0 for x86_64 miscompiles the following code.

   $ cat test.c

int a = 0, b = 0, c = 0, d, e;
int
main (void)
{
d = ((20 % (1 != b))  c) + 2147483647;
e = 20 % (a = 0);
return 0;
}

   $ x86_64-unknown-linux-gnu-gcc-5.0.0 test.c -Os
   $ ./a.out
   Floating point exception (core dumped)

   $ x86_64-unknown-linux-gnu-gcc-5.0.0 -v
Using built-in specs.
COLLECT_GCC=x86_64-unknown-linux-gnu-gcc-5.0.0
COLLECT_LTO_WRAPPER=/usr/local/x86_64-tools/gcc-
5.0.0/libexec/gcc/x86_64-unknown-linux-gnu/5.0.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: /home/orange3/gcc-master/configure --
prefix=/usr/local/x86_64-tools/gcc-5.0.0/ --with-gmp=/usr/local/gmp-
5.1.1/ --with-mpfr=/usr/local/mpfr-3.1.2/ --with-mpc=/usr/local/mpc-
1.0.1/ --disable-multilib --disable-nls --enable-languages=c
Thread model: posix
gcc version 5.0.0 20140922 (experimental) (GCC)


[Bug tree-optimization/61931] New: Wrong Constant Folding

2014-07-27 Thread ishiura-compiler at ml dot kwansei.ac.jp
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61931

Bug ID: 61931
   Summary: Wrong Constant Folding
   Product: gcc
   Version: 4.8.4
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: ishiura-compiler at ml dot kwansei.ac.jp

GCC 4.8.4 for arm miscompiles the following code.

  $ cat test.c

  int a, b, c, d, e, f, g, h;
  long long i;
  int
  main (void)
  {
int j;
i = a - b | ((1LL * c)  1)) / 3) | (1  (1 / (e + 1 | 1);
j = 1 % (1LLU  f))  (((1LLU  h)) - (63LLU * d  1) == ((1LL %
(g + 1)) * a);
if (i == 1);
else
__builtin_printf (%lld, j = %lld\n, 0, j);
  }

  $ arm-none-eabi-gcc-4.8.4 test.c -o test.out -O1 --specs=rdimon.specs
  $ qemu-arm -L /usr/arm-linux-gnueabihf/ ./test.out
  1, j = 0

  $ arm-none-eabi-gcc-4.8.4 test.c -o test.out -O0 --specs=rdimon.specs
  $ qemu-arm -L /usr/arm-linux-gnueabihf/ ./test.out
  -12884901887, j = 0

  $ arm-none-eabi-gcc-4.8.4 -v
  Using built-in specs.
  COLLECT_GCC=arm-none-eabi-gcc-4.8.4
 
COLLECT_LTO_WRAPPER=/home/ishiuraken/gcc-arm-none-eabi/bin/../lib/gcc/arm-none-eabi/4.8.4/lto-wrapper
  Target: arm-none-eabi
  Configured with: /home/build/work/GCC-4-8-build/src/gcc/configure
--target=arm-none-eabi --prefix=/home/build/work/GCC-4-8-build/install-native
--libexecdir=/home/build/work/GCC-4-8-build/install-native/lib
--infodir=/home/build/work/GCC-4-8-build/install-native/share/doc/gcc-arm-none-eabi/info
--mandir=/home/build/work/GCC-4-8-build/install-native/share/doc/gcc-arm-none-eabi/man
--htmldir=/home/build/work/GCC-4-8-build/install-native/share/doc/gcc-arm-none-eabi/html
--pdfdir=/home/build/work/GCC-4-8-build/install-native/share/doc/gcc-arm-none-eabi/pdf
--enable-languages=c,c++ --enable-plugins --disable-decimal-float
--disable-libffi --disable-libgomp --disable-libmudflap --disable-libquadmath
--disable-libssp --disable-libstdcxx-pch --disable-nls --disable-shared
--disable-threads --disable-tls --with-gnu-as --with-gnu-ld --with-newlib
--with-headers=yes --with-python-dir=share/gcc-arm-none-eabi
--with-sysroot=/home/build/work/GCC-4-8-build/install-native/arm-none-eabi
--build=i686-linux-gnu --host=i686-linux-gnu
--with-gmp=/home/build/work/GCC-4-8-build/build-native/host-libs/usr
--with-mpfr=/home/build/work/GCC-4-8-build/build-native/host-libs/usr
--with-mpc=/home/build/work/GCC-4-8-build/build-native/host-libs/usr
--with-isl=/home/build/work/GCC-4-8-build/build-native/host-libs/usr
--with-cloog=/home/build/work/GCC-4-8-build/build-native/host-libs/usr
--with-libelf=/home/build/work/GCC-4-8-build/build-native/host-libs/usr
--with-host-libstdcxx='-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm'
--with-pkgversion='GNU Tools for ARM Embedded Processors'
--with-multilib-list=armv6-m,armv7-m,armv7e-m,armv7-r
  Thread model: single
  gcc version 4.8.4 20140526 (release) [ARM/embedded-4_8-branch revision
211358] (GNU Tools for ARM Embedded Processors)


[Bug tree-optimization/61839] New: More optimize opportunity

2014-07-18 Thread ishiura-compiler at ml dot kwansei.ac.jp
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61839

Bug ID: 61839
   Summary: More optimize opportunity
   Product: gcc
   Version: 4.8.4
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: ishiura-compiler at ml dot kwansei.ac.jp

We have two equvalent programs (A) and (B), which only differ by one line
(marked by // ---HERE), where (B) simply folds a+972195718 to 972195717,
for local variable a=-1.

Resulting code by x86_64-unknown-linux-gnu-gcc-4.8.4 -Os -S is
different; the code for (A) is less optimized than that of (B).

(A)
int main (void)
{
int a = -1;
volatile unsigned b = 1U;
int c = 1;

c = (a + 972195718)  (1LU = b);  // ---HERE

if (c == 486097858);
else __builtin_abort();
return 0;
}

(B)
int main (void)
{
int a = -1;
volatile unsigned b = 1U;
int c = 1;

c = 972195717  (1LU = b);// ---HERE

if (c == 486097858);
else __builtin_abort();
return 0;
}

+-+-+
|(A)  |(B)  |
+-+-+
|main:|main:|
|.LFB0:   |.LFB0:   |
|.cfi_startproc   |.cfi_startproc   |
|subq$24, %rsp|subq$24, %rsp|
|.cfi_def_cfa_offset 32   |.cfi_def_cfa_offset 32   |
|movl$1, 12(%rsp) |movl$1, 12(%rsp) |
|movl12(%rsp), %eax   |movl12(%rsp), %eax   |
|testl   %eax, %eax   |testl   %eax, %eax   |
|movl$972195717, %eax | |
|setne   %cl  | |
|sarl%cl, %eax| |
|cmpl$486097858, %eax | |
|jne .L5  |jne .L2  |
|xorl%eax, %eax   |callabort|
|addq$24, %rsp|.L2: |
|.cfi_remember_state  |xorl%eax, %eax   |
|.cfi_def_cfa_offset 8|addq$24, %rsp|
|ret  |.cfi_def_cfa_offset 8|
|.L5: |ret  |
|.cfi_restore_state   |.cfi_endproc |
|callabort| |
|.cfi_endproc | |
+-+-+

$ x86_64-unknown-linux-gnu-gcc-4.8.4 -v
Using built-in specs. 
COLLECT_GCC=x86_64-unknown-linux-gnu-gcc-4.8.4
COLLECT_LTO_WRAPPER=/usr/local/x86_64-tools/gcc-4.8.4/libexec/gcc/x86_64-unknown-linux-gnu/4.8.4/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: /home/hassy/gcc/configure
--prefix=/usr/local/x86_64-tools/gcc-4.8.4/ --with-gmp=/usr/local/gmp-5.1.1/
--with-mpfr=/usr/local/mpfr-3.1.2/ --with-mpc=/usr/local/mpc-1.0.1/
--disable-multilib --disable-nls --enable-languages=c
Thread model: posix
gcc version 4.8.4 20140622 (prerelease) (GCC)


[Bug tree-optimization/61224] New: ICE in rtl.h

2014-05-18 Thread ishiura-compiler at ml dot kwansei.ac.jp
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61224

Bug ID: 61224
   Summary: ICE in rtl.h
   Product: gcc
   Version: 4.10.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: ishiura-compiler at ml dot kwansei.ac.jp

GCC 4.10.0 ICEs on the following code. (x86_64)


 $ cat test.c

 int a, b, d;
 int main (void)
 {
   int c = a  1;
   d = 1  (((c | (b - 842))  1) + 1);
   return 0;
 }


 $ x86_64-unknown-linux-gnu-gcc-4.10.0 test.c -O2
 test.c: In function 'main':
 test.c:8:1: internal compiler error: in decompose, at rtl.h:1456
  }
  ^
 0x4f1296 wi::int_traitsstd::pairrtx_def*, machine_mode ::decompose(long*,
unsigned int, std::pairrtx_def*, machine_mode const)
  /home/hassy/gcc/gcc/rtl.h:1454
 0x9ac619 wi::int_traitsstd::pairrtx_def*, machine_mode ::decompose(long*,
unsigned int, std::pairrtx_def*, machine_mode const)
  /home/hassy/gcc/gcc/rtl.h:1454
 0x9ac619 wide_int_ref_storagestd::pairrtx_def*, machine_mode 
  /home/hassy/gcc/gcc/wide-int.h:959
 0x9ac619 generic_wide_intstd::pairrtx_def*, machine_mode 
  /home/hassy/gcc/gcc/wide-int.h:735
 0x9ac619 substd::pairrtx_def*, machine_mode, std::pairrtx_def*,
machine_mode 
  /home/hassy/gcc/gcc/wide-int.h:2349
 0x9ac619 simplify_const_binary_operation(rtx_code, machine_mode, rtx_def*,
rtx_def*)
  /home/hassy/gcc/gcc/simplify-rtx.c:3732
 0xe7153b simplify_shift_const_1
  /home/hassy/gcc/gcc/combine.c:10352
 0xe71875 simplify_shift_const
  /home/hassy/gcc/gcc/combine.c:10526
 0xe798cd combine_simplify_rtx
  /home/hassy/gcc/gcc/combine.c:5873
 0xe7bcda subst
  /home/hassy/gcc/gcc/combine.c:5170
 0xe794fb combine_simplify_rtx
  /home/hassy/gcc/gcc/combine.c:5250
 0xe7bcda subst
  /home/hassy/gcc/gcc/combine.c:5170
 0xe7b9f8 subst
  /home/hassy/gcc/gcc/combine.c:5115
 0xe7b9f8 subst
  /home/hassy/gcc/gcc/combine.c:5115
 0xe7b9f8 subst
  /home/hassy/gcc/gcc/combine.c:5115
 0xe7b82a subst
  /home/hassy/gcc/gcc/combine.c:5036
 0xe7cfce try_combine
  /home/hassy/gcc/gcc/combine.c:3138
 0xe82d03 combine_instructions
  /home/hassy/gcc/gcc/combine.c:1370
 0xe82d03 rest_of_handle_combine
  /home/hassy/gcc/gcc/combine.c:13865
 0xe82d03 execute
  /home/hassy/gcc/gcc/combine.c:13909
 Please submit a full bug report,
 with preprocessed source if appropriate.
 Please include the complete backtrace with any bug report.
 See http://gcc.gnu.org/bugs.html for instructions.


 $ x86_64-unknown-linux-gnu-gcc-4.10.0 -v
 Using built-in specs.
 COLLECT_GCC=x86_64-unknown-linux-gnu-gcc-4.10.0

COLLECT_LTO_WRAPPER=/usr/local/x86_64-tools/gcc-4.10.0/libexec/gcc/x86_64-unknown-linux-gnu/4.10.0/lto-wrapper
 Target: x86_64-unknown-linux-gnu
 Configured with: /home/hassy/gcc/configure
--prefix=/usr/local/x86_64-tools/gcc-4.10.0/ --with-gmp=/usr/local/gmp-5.1.1/
--with-mpfr=/usr/local/mpfr-3.1.2/ --with-mpc=/usr/local/mpc-1.0.1/
--disable-multilib --disable-nls --enable-languages=c
 Thread model: posix
 gcc version 4.10.0 20140518 (experimental) (GCC)


[Bug tree-optimization/61045] New: Wrong constant folding

2014-05-03 Thread ishiura-compiler at ml dot kwansei.ac.jp
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=61045

Bug ID: 61045
   Summary: Wrong constant folding
   Product: gcc
   Version: 4.10.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: ishiura-compiler at ml dot kwansei.ac.jp

GCC 4.4.7 - 4.10.0 for x86_64 miscompiles the following code.

   $ cat test.c

   int main (void)
   {
  long a = 0;
  long b = 0x7FFFL;
  int t = (a - 2)  (b - 1);
  if (t != 0) { __builtin_abort(); };
  return 0;
   }

   $ x86_64-unknown-linux-gnu-gcc-4.10.0 test.c -O2
   $ ./a.out 
   Aborted (core dumped)

   $ x86_64-unknown-linux-gnu-gcc-4.10.0 -v
   Using built-in specs.
   COLLECT_GCC=x86_64-unknown-linux-gnu-gcc-4.10.0
  
COLLECT_LTO_WRAPPER=/usr/local/x86_64-tools/gcc-4.10.0/libexec/gcc/x86_64-unknown-linux-gnu/4.10.0/lto-wrapper
   Target: x86_64-unknown-linux-gnu
   Configured with: /home/hassy/gcc/configure
   --prefix=/usr/local/x86_64-tools/gcc-4.10.0/
   --with-gmp=/usr/local/gmp-5.1.1/ --with-mpfr=/usr/local/mpfr-3.1.2/
   --with-mpc=/usr/local/mpc-1.0.1/ --disable-multilib
   --disable-nls --enable-languages=c
   Thread model: posix
   gcc version 4.10.0 20140502 (experimental) (GCC)


[Bug tree-optimization/61010] New: ICE in gcc.c

2014-04-29 Thread ishiura-compiler at ml dot kwansei.ac.jp
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=61010

Bug ID: 61010
   Summary: ICE in gcc.c
   Product: gcc
   Version: 4.10.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: ishiura-compiler at ml dot kwansei.ac.jp

GCC 4.8 - 4.10 for i686 and x86_64 ICE the following code.

  /*

  $ x86_64-unknown-linux-gnu-gcc-4.10.0 test.c
  x86_64-unknown-linux-gnu-gcc-4.10.0: internal compiler error:
  Segmentation fault (program cc1)
  0x40ce59 execute
  /home/hassy/gcc-master/gcc/gcc.c:2848
  0x40d0c9 do_spec_1
  /home/hassy/gcc-master/gcc/gcc.c:4652
  0x40fd76 process_brace_body
  /home/hassy/gcc-master/gcc/gcc.c:5935
  0x40fd76 handle_braces
  /home/hassy/gcc-master/gcc/gcc.c:5849
  0x40deb7 do_spec_1
  /home/hassy/gcc-master/gcc/gcc.c:5306
  0x40fd76 process_brace_body
  /home/hassy/gcc-master/gcc/gcc.c:5935
  0x40fd76 handle_braces
  /home/hassy/gcc-master/gcc/gcc.c:5849
  0x40deb7 do_spec_1
  /home/hassy/gcc-master/gcc/gcc.c:5306
  0x40ddbe do_spec_1
  /home/hassy/gcc-master/gcc/gcc.c:5421
  0x40fd76 process_brace_body
  /home/hassy/gcc-master/gcc/gcc.c:5935
  0x40fd76 handle_braces
  /home/hassy/gcc-master/gcc/gcc.c:5849
  0x40deb7 do_spec_1
  /home/hassy/gcc-master/gcc/gcc.c:5306
  0x40fd76 process_brace_body
  /home/hassy/gcc-master/gcc/gcc.c:5935
  0x40fd76 handle_braces
  /home/hassy/gcc-master/gcc/gcc.c:5849
  0x40deb7 do_spec_1
  /home/hassy/gcc-master/gcc/gcc.c:5306
  0x40fd76 process_brace_body
  /home/hassy/gcc-master/gcc/gcc.c:5935
  0x40fd76 handle_braces
  /home/hassy/gcc-master/gcc/gcc.c:5849
  0x40deb7 do_spec_1
  /home/hassy/gcc-master/gcc/gcc.c:5306
  0x40fd76 process_brace_body
  /home/hassy/gcc-master/gcc/gcc.c:5935
  0x40fd76 handle_braces
  /home/hassy/gcc-master/gcc/gcc.c:5849
  Please submit a full bug report,
  with preprocessed source if appropriate.
  Please include the complete backtrace with any bug report.
  See http://gcc.gnu.org/bugs.html for instructions.

  $ x86_64-unknown-linux-gnu-gcc-4.10.0 -v
  Using built-in specs.
  COLLECT_GCC=x86_64-unknown-linux-gnu-gcc-4.10.0
 
COLLECT_LTO_WRAPPER=/usr/local/x86_64-tools/gcc-4.10.0/libexec/gcc/x86_64-unknown-linux-gnu/4.10.0/lto-wrapper
  Target: x86_64-unknown-linux-gnu
  Configured with: /home/hassy/gcc-master/configure
  --prefix=/usr/local/x86_64-tools/gcc-4.10.0/
  --with-gmp=/usr/local/gmp-5.1.1/ --with-mpfr=/usr/local/mpfr-3.1.2/
  --with-mpc=/usr/local/mpc-1.0.2/ --disable-multilib --disable-nls
  --enable-languages=c
  Thread model: posix
  gcc version 4.10.0 20140429 (experimental) (GCC)

  */

  int main (void)
  {
  int a = 0;
  unsigned b = (a * 64  192) | 63U;
  return 0;
  }


[Bug tree-optimization/60930] New: Wrong constant folding

2014-04-22 Thread ishiura-compiler at ml dot kwansei.ac.jp
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60930

Bug ID: 60930
   Summary: Wrong constant folding
   Product: gcc
   Version: 4.10.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: ishiura-compiler at ml dot kwansei.ac.jp

GCC 4.7 - 4.10 for i686 and x86_64 miscompiles the following code.

$ cat error.c

#include stdio.h
int x = 1;
main ()
{
unsigned long long t = 0xLLU * (0xLU * x);
if (t != 0x0001LLU) {
printf (Error (t == %llu)\n, t);
}
return 0;
}

$ x86_64-unknown-linux-gnu-gcc-4.10.0 error.c -O1
$ ./a.out
Error 1

$ x86_64-unknown-linux-gnu-gcc-4.10.0 -v
Using built-in specs.
COLLECT_GCC=x86_64-unknown-linux-gnu-gcc-4.10.0
   
COLLECT_LTO_WRAPPER=/usr/local/x86_64-tools/gcc-4.10.0/libexec/gcc/x86_64-unknown-linux-gnu/4.10.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: /home/hassy/gcc-master/configure
--prefix=/usr/local/x86_64-tools/gcc-4.10.0/
--with-gmp=/usr/local/gmp-5.1.1/ --with-mpfr=/usr/local/mpfr-3.1.2/
--with-mpc=/usr/local/mpc-1.0.2/ --disable-multilib
--disable-nls --enable-languages=c
Thread model: posix
gcc version 4.10.0 20140422 (experimental) (GCC)

The status of the other versions are as follows:

(x86_64)
GCC-4.7.3 OK
GCC-4.8.3 (prerelease) Error
GCC-4.9.1 (prerelease) Error
GCC-4.10.0 (experimental) Error

(i686)
GCC-4.7.3 Error
GCC-4.8.3 (prerelease) Error
GCC-4.9.1 (prerelease) Error
GCC-4.10.0 (experimental) Error


[Bug c/60017] New: Struct not returned correctly

2014-01-31 Thread ishiura-compiler at ml dot kwansei.ac.jp
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60017

Bug ID: 60017
   Summary: Struct not returned correctly
   Product: gcc
   Version: 4.9.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
  Assignee: unassigned at gcc dot gnu.org
  Reporter: ishiura-compiler at ml dot kwansei.ac.jp

GCC 4.9.0 for x86_64 miscompiles the following code.

$ cat error.c

struct S0 { short m0; short m1; };
struct S1 { unsigned m0 : 1; char m1[2][2]; struct S0 m2[2]; };

struct S1 x = {1,{{1,1},{1,1}},{{1,1},{1,1}}};

struct S1 func(void) { return x; }

int main(void)
{
struct S1 ret = func();
if( ret.m2[1].m1 != 1 ) { __builtin_abort(); }

return 0;
}

$ gcc-4.9 error.c 

$ ./a.out
Abort trap: 6

The value of ret.m2[1].m1 was 32767 instead of 1.
There was no problem with an i686 target.

$ gcc-4.9 -v
Using built-in specs.
COLLECT_GCC=gcc-4.9
   
COLLECT_LTO_WRAPPER=/usr/local/Cellar/gcc49/4.9-20140126/gcc/libexec/gcc/x86_64-apple-darwin13.0.0/4.9.0/lto-wrapper
Target: x86_64-apple-darwin13.0.0
Configured with: ../configure --build=x86_64-apple-darwin13.0.0
--prefix=/usr/local/Cellar/gcc49/4.9-20140126/gcc
--datarootdir=/usr/local/Cellar/gcc49/4.9-20140126/share
--bindir=/usr/local/Cellar/gcc49/4.9-20140126/bin --enable-languages=c
--program-suffix=-4.9 --with-gmp=/usr/local/opt/gmp
--with-mpfr=/usr/local/opt/mpfr --with-mpc=/usr/local/opt/libmpc
--with-cloog=/usr/local/opt/cloog --with-isl=/usr/local/opt/isl
--with-system-zlib --enable-libstdcxx-time=yes --enable-stage1-checking
--enable-checking=release --enable-plugin --enable-lto --disable-werror
--disable-nls --disable-multilib --with-native-system-header-dir=/usr/include
--with-sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk
Thread model: posix
gcc version 4.9.0 20140126 (experimental) (GCC)


[Bug tree-optimization/58494] New: ICE (verify_ssa failed)

2013-09-21 Thread ishiura-compiler at ml dot kwansei.ac.jp
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58494

Bug ID: 58494
   Summary: ICE (verify_ssa failed)
   Product: gcc
   Version: 4.9.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: ishiura-compiler at ml dot kwansei.ac.jp
Target: x86_64-pc-linux-gnu

GCC 4.9.0 ICEs on the following code. (x86_64)


  $ cat test.c

  int  g0 = 1;
  long g1 = 0;

  int main (void)
  {
int x0 = 1;
int x1 = 1;

int a = g0 != 1;  /* a = 0 */
int t = x0 - g1;  /* t = 1 */
int b = x1  t;   /* b = 1 */
int c = a   b;   /* c = 0 */
int s = g0 * 1;   /* s = 1 */
int d = s  1;   /* d = 1 */
int e = c   d;   /* e = 0 */

if (e != 0) __builtin_abort();

return 0;
  }


  $ x86_64-unknown-linux-gnu-gcc-4.9.0 test.c -O1
  test.c: In function 'main':
  test.c:4:5: error: definition in block 2 follows the use
   int main (void)
 ^
  for SSA_NAME: _16 in statement:
  c_10 = _16  1;
  test.c:4:5: internal compiler error: verify_ssa failed
  0xaa4779 verify_ssa(bool)
/home/hassy/gcc/gcc/tree-ssa.c:1046
  0x87f3c1 execute_function_todo
/home/hassy/gcc/gcc/passes.c:1834
  0x87fb17 execute_todo
/home/hassy/gcc/gcc/passes.c:1866
  Please submit a full bug report,
  with preprocessed source if appropriate.
  Please include the complete backtrace with any bug report.
  See http://gcc.gnu.org/bugs.html for instructions.


  $ x86_64-unknown-linux-gnu-gcc-4.9.0 -v
  Using built-in specs.
  COLLECT_GCC=x86_64-unknown-linux-gnu-gcc-4.9.0
 
COLLECT_LTO_WRAPPER=/usr/local/x86_64-tools/gcc-4.9.0/libexec/gcc/x86_64-unknown-linux-gnu/4.9.0/lto-wrapper
  Target: x86_64-unknown-linux-gnu
  Configured with: /home/hassy/gcc/configure
--prefix=/usr/local/x86_64-tools/gcc-4.9.0/
--with-gmp=/usr/local/gmp-5.1.1/ --with-mpfr=/usr/local/mpfr-3.1.2/
--with-mpc=/usr/local/mpc-1.0.1/ --disable-multilib --disable-nls
--enable-languages=c
  Thread model: posix
  gcc version 4.9.0 20130919 (experimental) (GCC)


[Bug tree-optimization/58088] New: ICE in gcc.c

2013-08-05 Thread ishiura-compiler at ml dot kwansei.ac.jp
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58088

Bug ID: 58088
   Summary: ICE in gcc.c
   Product: gcc
   Version: 4.9.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: ishiura-compiler at ml dot kwansei.ac.jp

GCC 4.9.0 ICEs on the following code. (i686 and x86_64)

  $ cat error.c

  int main (void)
  {
int x = 0;
int y = 127 | ( 128  ( 2 * x ));

return 0;
  }

  $ i686-pc-linux-gnu-gcc-4.9.0 error.c

  i686-pc-linux-gnu-gcc-4.9.0: internal compiler error: Segmentation
fault (program cc1)
  0x8053b4e execute
../../../../../gcc/gcc/gcc.c:2824
  0x8053e1a do_spec_1
../../../../../gcc/gcc/gcc.c:4616
  0x80565bd process_brace_body
../../../../../gcc/gcc/gcc.c:5873
  0x80565bd handle_braces
../../../../../gcc/gcc/gcc.c:5787
  0x8054a2a do_spec_1
../../../../../gcc/gcc/gcc.c:5270
  0x80565bd process_brace_body
../../../../../gcc/gcc/gcc.c:5873
  0x80565bd handle_braces
../../../../../gcc/gcc/gcc.c:5787
  0x8054a2a do_spec_1
../../../../../gcc/gcc/gcc.c:5270
  0x805414e do_spec_1
../../../../../gcc/gcc/gcc.c:5375
  0x80565bd process_brace_body
../../../../../gcc/gcc/gcc.c:5873
  0x80565bd handle_braces
../../../../../gcc/gcc/gcc.c:5787
  0x8054a2a do_spec_1
../../../../../gcc/gcc/gcc.c:5270
  0x80565bd process_brace_body
../../../../../gcc/gcc/gcc.c:5873
  0x80565bd handle_braces
../../../../../gcc/gcc/gcc.c:5787
  0x8054a2a do_spec_1
../../../../../gcc/gcc/gcc.c:5270
  0x80565bd process_brace_body
../../../../../gcc/gcc/gcc.c:5873
  0x80565bd handle_braces
../../../../../gcc/gcc/gcc.c:5787
  0x8054a2a do_spec_1
../../../../../gcc/gcc/gcc.c:5270
  0x80565bd process_brace_body
../../../../../gcc/gcc/gcc.c:5873
  0x80565bd handle_braces
../../../../../gcc/gcc/gcc.c:5787
  Please submit a full bug report,
  with preprocessed source if appropriate.
  Please include the complete backtrace with any bug report.
  See http://gcc.gnu.org/bugs.html for instructions.

  $ i686-pc-linux-gnu-gcc-4.9.0 -v
  Using built-in specs.
  COLLECT_GCC=i686-pc-linux-gnu-gcc-4.9.0
 
COLLECT_LTO_WRAPPER=/usr/local/i686-tools/gcc-4.9.0/libexec/gcc/i686-pc-linux-gnu/4.9.0/lto-wrapper
  Target: i686-pc-linux-gnu
  Configured with: ../../../../gcc/configure
--prefix=/usr/local/i686-tools/gcc-4.9.0/
--with-gmp=/usr/local/gmp-5.1.1/ --with-mpfr=/usr/local/mpfr-3.1.2/
--with-mpc=/usr/local/mpc-1.0.1/ --disable-multilib --disable-nls
--enable-languages=c
  Thread model: posix
  gcc version 4.9.0 20130805 (experimental) (GCC)


[Bug tree-optimization/57829] New: Wrong constant folding

2013-07-05 Thread ishiura-compiler at ml dot kwansei.ac.jp
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57829

Bug ID: 57829
   Summary: Wrong constant folding
   Product: gcc
   Version: 4.9.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: ishiura-compiler at ml dot kwansei.ac.jp

GCC 4.7.2 - 4.9.0 for i686 and x86_64 miscompiles the following code.

$ cat error.c

int main (void)
{
  volatile int k = 1;
  int t = 2 | ( ( k - 1)  31 );
  if (t != 2) __builtin_abort();
  return 0;
}

$ x86_64-unknown-linux-gnu-gcc-4.9.0 error.c -O1
$ ./a.out
Aborted (core dumped)

$ x86_64-unknown-linux-gnu-gcc-4.9.0 -v
Using built-in specs.
COLLECT_GCC=x86_64-unknown-linux-gnu-gcc-4.9.0
   
COLLECT_LTO_WRAPPER=/usr/local/x86_64-tools/gcc-4.9.0/libexec/gcc/x86_64-unknown-linux-gnu/4.9.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: /home/hassy/gcc/configure
--prefix=/usr/local/x86_64-tools/gcc-4.9.0/
--with-gmp=/usr/local/gmp-5.1.1/ --with-mpfr=/usr/local/mpfr-3.1.2/
--with-mpc=/usr/local/mpc-1.0.1/ --disable-multilib --disable-nls
--enable-languages=c
Thread model: posix
gcc version 4.9.0 20130704 (experimental) (GCC)

The status of the other versions are as follows:

(x86_64)
GCC-4.7.2 Error
GCC-4.8.2 (prerelease) OK
GCC-4.9.0 (experimental) Error

(i686)
GCC-4.7.2 Error
GCC-4.8.2 (prerelease) Error
GCC-4.9.0 (experimental) Error


[Bug tree-optimization/57656] New: Wrong constant folding

2013-06-19 Thread ishiura-compiler at ml dot kwansei.ac.jp
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57656

Bug ID: 57656
   Summary: Wrong constant folding
   Product: gcc
   Version: 4.8.2
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: ishiura-compiler at ml dot kwansei.ac.jp

GCC 4.8.2 for i686 miscompiles the following code.

$ cat error.c

int main (void)
{
int a = -1;
int b = 2147483647;
int c = 2;
int t = 1 - ((a - b) / c);   // t = 1 - ( -2147483648 / 2 )

if (t != 1073741825) { __builtin_abort(); }
return 0;
}

$ i686-pc-linux-gnu-gcc-4.8.2 error.c -O2
$ ./a.out
Aborted (core dumped)

There was no problem with an x86_64 target.

$ i686-pc-linux-gnu-gcc-4.8.2 -v
Using built-in specs.
COLLECT_GCC=i686-pc-linux-gnu-gcc-4.8.2
   
COLLECT_LTO_WRAPPER=/usr/local/i686-tools/gcc-4.8.2/libexec/gcc/i686-pc-linux-gnu/4.8.2/lto-wrapper
Target: i686-pc-linux-gnu
Configured with: /home/hassy/gcc/configure
--prefix=/usr/local/i686-tools/gcc-4.8.2/
--with-gmp=/usr/local/gmp-5.1.1/ --with-mpfr=/usr/local/mpfr-3.1.2/
--with-mpc=/usr/local/mpc-1.0.1/ --disable-multilib --disable-nls
--enable-languages=c
Thread model: posix
gcc version 4.8.2 20130607 (prerelease) (GCC)


[Bug c/57209] New: Wrong code of print statement

2013-05-08 Thread ishiura-compiler at ml dot kwansei.ac.jp


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



 Bug #: 57209

   Summary: Wrong code of print statement

Classification: Unclassified

   Product: gcc

   Version: 4.8.1

Status: UNCONFIRMED

  Severity: normal

  Priority: P3

 Component: c

AssignedTo: unassig...@gcc.gnu.org

ReportedBy: ishiura-compi...@ml.kwansei.ac.jp





The following code is miscompiled by GCC 4.8.1 20130508 (prerelease)

for x86_64 (as well as for i686).  The option in question is

-funsafe-math-optimizations.



  $ cat error.c



  volatile char buff = 0;

  void PRINTF(const char* s)

  {

while(*s++) buff = *s;

  }



  int main (void)

  {

int k = -1;

int t = 1 % (int)(( 942.0 + k ) / -941.0F );

if (t == 0) { PRINTF(OK); }

return 0;

  }



  $ x86_64-unknown-linux-gnu-gcc-4.8.1 error.c -O1 -funsafe-math-optimizations

  $ ./a.out

  Floating point exception (core dumped)



-



$ x86_64-unknown-linux-gnu-gcc-4.8.1 -v

Using built-in specs.

COLLECT_GCC=x86_64-unknown-linux-gnu-gcc-4.8.1

COLLECT_LTO_WRAPPER=/usr/local/x86_64-tools/gcc-4.8.1/libexec/gcc/x86_64-unknown-linux-gnu/4.8.1/lto-wrapper

Target: x86_64-unknown-linux-gnu

Configured with: /home/hassy/gcc/configure

--prefix=/usr/local/x86_64-tools/gcc-4.8.1/

--with-gmp=/usr/local/gmp-5.1.1/ --with-mpfr=/usr/local/mpfr-3.1.2/

--with-mpc=/usr/local/mpc-1.0.1/ --disable-multilib --disable-nls

--enable-languages=c

Thread model: posix

gcc version 4.8.1 20130508 (prerelease) (GCC)


[Bug rtl-optimization/57131] New: Wong register assignment?

2013-05-01 Thread ishiura-compiler at ml dot kwansei.ac.jp


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



 Bug #: 57131

   Summary: Wong register assignment?

Classification: Unclassified

   Product: gcc

   Version: 4.8.1

Status: UNCONFIRMED

  Severity: normal

  Priority: P3

 Component: rtl-optimization

AssignedTo: unassig...@gcc.gnu.org

ReportedBy: ishiura-compi...@ml.kwansei.ac.jp





This miscompile occurs only on 32bit x86 (i686) target of GCC 4.8.1

(prerelease).  

(There is no problem with x86_64 target or GCC 4.7.3.) 

A dubious option is -foptimize-register-move.



  $ cat error.c



  int main (void)

  {

volatile int x1 = 0;

volatile long long x2 = 0;

volatile int x3 = 0;

volatile int x4 = 1;

volatile int x5 = 1;

volatile long long x6 = 1;



long long t = ( ( x1 * ( x2  x3 ) ) / (x4 * x5) ) + x6 ;



return (t == 1); 

  }



  $ i686-pc-linux-gnu-gcc-4.8.1 error.c -O1 -fexpensive-optimizations

-foptimize-register-move

  $ ./a.out

  Floating point exception (core dumped)



-



$ i686-pc-linux-gnu-gcc-4.8.1 -v

Using built-in specs.

COLLECT_GCC=i686-pc-linux-gnu-gcc-4.8.1

COLLECT_LTO_WRAPPER=/usr/local/i686-tools/gcc-4.8.1/libexec/gcc/i686-pc-linux-gnu/4.8.1/lto-wrapper

Target: i686-pc-linux-gnu

Configured with: /home/hassy-i686-linux/gcc/configure

--prefix=/usr/local/i686-tools/gcc-4.8.1/

--with-gmp=/usr/local/gmp-5.1.1/ --with-mpfr=/usr/local/mpfr-3.1.2/

--with-mpc=/usr/local/mpc-1.0.1/ --disable-multilib --disable-nls

--enable-languages=c

Thread model: posix

gcc version 4.8.1 20130428 (prerelease) (GCC)


[Bug tree-optimization/57083] New: Wrong constant folding

2013-04-26 Thread ishiura-compiler at ml dot kwansei.ac.jp


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



 Bug #: 57083

   Summary: Wrong constant folding

Classification: Unclassified

   Product: gcc

   Version: 4.8.1

Status: UNCONFIRMED

  Severity: normal

  Priority: P3

 Component: tree-optimization

AssignedTo: unassig...@gcc.gnu.org

ReportedBy: ishiura-compi...@ml.kwansei.ac.jp





GCC 4.8.1 prerelease (x86_64 for both linux and darwin12) miscompiles

the following code with optimize option -O1 -ftree-vrp.





  $ cat error.c



  /* UINT_MAX == 4294967295 */

  short x = 1;

  int y = 0;



  int main (void)

  {

unsigned t = ( 2147450881U - (unsigned) x )  ( y == 0 );

if ( t != 4294901760U ) { __builtin_abort(); }

return 0;

  }



  $ x86_64-unknown-linux-gnu-gcc-4.8.1 error.c -O1 -ftree-vrp

  $ ./a.out

  Aborted (core dumped)





There was no problem with GCC 4.7.3.  



-



$ x86_64-unknown-linux-gnu-gcc-4.8.1 -v

Target: x86_64-unknown-linux-gnu

Configured with: /home/hassy/gcc/configure

--prefix=/usr/local/x86_64-tools/gcc-4.8.0/

--with-gmp=/usr/local/gmp-5.1.1/ --with-mpfr=/usr/local/mpfr-3.1.2/

--with-mpc=/usr/local/mpc-1.0.1/ --disable-multilib --disable-nls

--enable-languages=c

Thread model: posix

gcc version 4.8.1 20130422 (prerelease) (GCC)



$ gcc-mp-4.8 -v

Using built-in specs.

COLLECT_GCC=gcc-mp-4.8

COLLECT_LTO_WRAPPER=/opt/local/libexec/gcc/x86_64-apple-darwin12/4.8.1/lto-wrapper

Target: x86_64-apple-darwin12

Configured with: ../gcc-4.8-20130411/configure --prefix=/opt/local

--build=x86_64-apple-darwin12

--enable-languages=c,c++,objc,obj-c++,lto,fortran,java

--libdir=/opt/local/lib/gcc48 --includedir=/opt/local/include/gcc48

--infodir=/opt/local/share/info --mandir=/opt/local/share/man

--datarootdir=/opt/local/share/gcc-4.8 --with-local-prefix=/opt/local

--with-system-zlib --disable-nls --program-suffix=-mp-4.8

--with-gxx-include-dir=/opt/local/include/gcc48/c++/ --with-gmp=/opt/local

--with-mpfr=/opt/local --with-mpc=/opt/local --with-ppl=/opt/local

--with-cloog=/opt/local --enable-cloog-backend=isl

--disable-cloog-version-check --enable-stage1-checking --disable-multilib

--enable-lto --enable-libstdcxx-time --with-as=/opt/local/bin/as

--with-ld=/opt/local/bin/ld --with-ar=/opt/local/bin/ar

--with-bugurl=https://trac.macports.org/newticket --with-pkgversion='MacPorts

gcc48 4.8-20130411_0'

Thread model: posix

gcc version 4.8.1 20130411 (prerelease) (MacPorts gcc48 4.8-20130411_0)


[Bug c/56984] New: GCC-4.8.0 ICE in tree_vrp.c

2013-04-16 Thread ishiura-compiler at ml dot kwansei.ac.jp


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



 Bug #: 56984

   Summary: GCC-4.8.0 ICE in tree_vrp.c

Classification: Unclassified

   Product: gcc

   Version: 4.8.0

Status: UNCONFIRMED

  Severity: normal

  Priority: P3

 Component: c

AssignedTo: unassig...@gcc.gnu.org

ReportedBy: ishiura-compi...@ml.kwansei.ac.jp





GCC 4.8.0 with -O1 -ftree-vrp option ICEs on 

the following code where sizeof(int) == 4.

The failure occurs in Linux (x86_64 and i686)

and Mac OS X (x86_64).



  $ cat error.c



  int g = 0;

  int main(void)

{

if ( (g31)  -1 ) { g++; }

return 0;

  }



  $ x86_64-unknown-linux-gnu-gcc-4.8.0 error.c -O1 -ftree-vrp

  error.c: In function 'main':

  error.c:3:5: internal compiler error: in remove_range_assertions, at

  tree-vrp.c:6276

   int main(void)

   ^

  0x936e7e remove_range_assertions

  ../../gcc/tree-vrp.c:6276

  0x936e7e execute_vrp

  ../../gcc/tree-vrp.c:9299

  Please submit a full bug report,

  with preprocessed source if appropriate.

  Please include the complete backtrace with any bug report.

  See http://gcc.gnu.org/bugs.html for instructions.


[Bug tree-optimization/56899] New: Wrong constant folding

2013-04-10 Thread ishiura-compiler at ml dot kwansei.ac.jp


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



 Bug #: 56899

   Summary: Wrong constant folding

Classification: Unclassified

   Product: gcc

   Version: 4.8.0

Status: UNCONFIRMED

  Severity: normal

  Priority: P3

 Component: tree-optimization

AssignedTo: unassig...@gcc.gnu.org

ReportedBy: ishiura-compi...@ml.kwansei.ac.jp





GCC 4.7.2 and 4.8.0 with -O2 option miscompile the following code where

INT_MIN == -2147483648.



  $ cat error.c

  int main (void)

  {

volatile int v = 10;

int x =  -214748365 * ( v - 1 );

return ( x == -1932735285 );/* should return 1 */

  }

  $ gcc error.c -O2

  $ ./a.out

  $ echo $?

  0



The following code, with volatile removed from variable v, is

correctly compiled.



  $ cat noerror.c

  int main(void)

  {

int v = 10;

int x =  -214748365 * ( v - 1 );

return ( x == -1932735285 );/* should return 1 */

  }

  $ gcc noerror.c -O2

  $ ./a.out

  $ echo $?

  1



The miscompile occurs on options -O1 -fstrict-overflow.


[Bug c/56250] New: Wrong constant folding on unsigned int

2013-02-07 Thread ishiura-compiler at ml dot kwansei.ac.jp


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



 Bug #: 56250

   Summary: Wrong constant folding on unsigned int

Classification: Unclassified

   Product: gcc

   Version: 4.7.2

Status: UNCONFIRMED

  Severity: normal

  Priority: P3

 Component: c

AssignedTo: unassig...@gcc.gnu.org

ReportedBy: ishiura-compi...@ml.kwansei.ac.jp





GCC 4.7.2 and 4.8.0 miscompile the following code where UINT_MAX ==

4294967295.



  $ cat bug.c

  int main(void)

  {

 unsigned x = 2;

 return ((unsigned) 0 - ( x / 2 ) ) / 2;

  }

  $ gcc bug.c

  $ ./a.out

  $ echo $?

  0



Unsigned (0-(x/2))/2 should evaluate to 2147483647 instead of 0.  

The following code with variable x replaced by (unsigned) 2 is

correctly compiled.



  $ cat nobug.c

  int main(void)

  {

 return ((unsigned) 0 - ( (unsigned) 2 / 2 ) ) / 2;

  }

  $ gcc nobug.c

  $ ./a.out

  $ echo $?

  255



The miscompile seems to occur on many versions of gcc (4.2 - 4.8, and

even 4.0 and 3.1 on i686-apple-darwin, 4.4 - 4.6 on

i686-linux-gnu-gcc, etc.)


[Bug middle-end/56250] Wrong constant folding on unsigned int

2013-02-07 Thread ishiura-compiler at ml dot kwansei.ac.jp


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



--- Comment #3 from Ishiura Lab Compiler Team ishiura-compiler at ml dot 
kwansei.ac.jp 2013-02-08 01:59:18 UTC ---

(In reply to comment #1)

 When I do this:

  unsigned x = 2;

  unsigned t = (x/2);

  unsigned t1 = -t;

  unsigned t2 = t2/2;

 

 t2 is 0 which is correct.  I don't see why 2147483647 is correct.



The last line should be

unsigned t2 = t1/2;