[Bug ipa/114703] New: Missed devirtualization in rather simple case

2024-04-12 Thread konstantin.vladimirov at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114703

Bug ID: 114703
   Summary: Missed devirtualization in rather simple case
   Product: gcc
   Version: 13.2.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: ipa
  Assignee: unassigned at gcc dot gnu.org
  Reporter: konstantin.vladimirov at gmail dot com
  Target Milestone: ---

See code here:

https://godbolt.org/z/T9Ma7qe3E

struct A {
  virtual int foo() { return 1; }
};

struct B : A {
  int foo() override { return 2; }
  virtual int foo(int i) { return i + 1; }
};

int use(int, int, int);

int main() {
  B *p = new B;
#if 0
  A* q = p;
#else
  A* q = new B;
#endif  
  int result1 = p->foo(1);
  int result2 = p->foo();
  int result3 = q->foo();
  use(result1, result2, result3);
}

clang devirtualizes just fine, gcc lacks this one.

Interesting that if you flip preprocessor switch, everything works with gcc
either.

[Bug c++/97220] New: Overload resolution works wrong when implicit conversion not exists

2020-09-27 Thread konstantin.vladimirov at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97220

Bug ID: 97220
   Summary: Overload resolution works wrong when implicit
conversion not exists
   Product: gcc
   Version: unknown
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: konstantin.vladimirov at gmail dot com
  Target Milestone: ---

Minimal reproducer is here: https://godbolt.org/z/rd4e9a

struct S {
  explicit S(int, int, int) {}
};

struct T {
  T(int, int, int) {}
};

void foo(struct S) {} // 1
void foo(struct T) {} // 2

int main() {
  S s{1, 2, 3};

  foo({1, 2, 3});
}

By C++ standard, [over.match.viable], "for F to be a viable function, there
shall exist for each argument an implicit conversion sequence (12.4.3.1) that
converts that argument to the corresponding parameter of F"

So 1 is not viable overload and resolution shall peek 2

But in reality now error produced:

error: call of overloaded 'foo()' is ambiguous

[Bug middle-end/90796] New: GCC: O2 vs O3 output differs on simple test

2019-06-09 Thread konstantin.vladimirov at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90796

Bug ID: 90796
   Summary: GCC: O2 vs O3 output differs on simple test
   Product: gcc
   Version: 10.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: middle-end
  Assignee: unassigned at gcc dot gnu.org
  Reporter: konstantin.vladimirov at gmail dot com
  Target Milestone: ---

Reproduction:

---
#include 
unsigned b[11];
unsigned c;
int d, e, f;
char en;
int main() {
  for (; e < 100; e += 3) {
printf("b[0] = %u\n", b[0]);
for (; c < 9; c++)
  for (d = 2; d < 11; d++) {
f = b[c + 2] ^ 9;
b[c] = f;
  }
  }
}
---

Compiler information:

---
> gcc -v
Using built-in specs.
COLLECT_GCC=/apps/bin/gcc
COLLECT_LTO_WRAPPER=/apps/9fafffe/bin/../libexec/gcc/x86_64-pc-linux-gnu/10.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /srcs/gcc/configure --disable-bootstrap --prefix=/apps/9fafffe
Thread model: posix
gcc version 10.0.0 20190608 (experimental) (GCC)
---

Compile and run like this:

> gcc -O2 min.c -o corr
> ./corr >& corr.log
> gcc -O3 min.c -o wrong
> ./wrong >& wrong.log

Correct output:

b[0] = 0
b[0] = 9

b[0] = 9

Wrong output:

b[0] = 0
b[0] = 0

b[0] = 0

O0 and O1 modes agree with O2.

[Bug middle-end/89677] New: internal compiler error: in wide_int_to_tree_1, at tree.c:1549

2019-03-12 Thread konstantin.vladimirov at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89677

Bug ID: 89677
   Summary: internal compiler error: in wide_int_to_tree_1, at
tree.c:1549
   Product: gcc
   Version: 8.1.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: middle-end
  Assignee: unassigned at gcc dot gnu.org
  Reporter: konstantin.vladimirov at gmail dot com
  Target Milestone: ---

Reproduction after creduce:

---
a, b, d;
unsigned c;
float e, f, g;
h() {
  float *i = 
  for (; c < 10; c += 3)
for (; d; d += 3) {
  a = *i;
  g = f + 0;
  f = b + *i + (b - e + 305219) + -b + 3;
}
}
---

Compiler information:

---
> gcc -v
Reading specs from
/apps/gcc/8.1.0/.bin/../lib64/gcc/x86_64-suse-linux/8.1.0/specs
COLLECT_GCC=/apps/gcc/8.1.0/.bin/gcc
COLLECT_LTO_WRAPPER=/apps/gcc/8.1.0/.bin/../libexec/gcc/x86_64-suse-linux/8.1.0/lto-wrapper
Target: x86_64-suse-linux
Configured with: ./configure --prefix=/apps/gcc/8.1.0
--libdir=/apps/gcc/8.1.0/lib64 --libexecdir=/apps/gcc/8.1.0/libexec
--bindir=/apps/gcc/8.1.0/bin --with-isl=/apps/gcc/8.1.0
--with-libelf=/apps/gcc/8.1.0 --with-mpfr=/apps/gcc/8.1.0
--with-gmp=/apps/gcc/8.1.0 --with-mpc=/apps/gcc/8.1.0
--disable-gnu-unique-object --enable-gold=yes --enable-lto
--enable-languages=c,c++,objc,fortran --build=x86_64-suse-linux
--host=x86_64-suse-linux --target=x86_64-suse-linux --enable-libotm
--disable-multilib --disable-bootstrap --disable-libstdcxx-pch
Thread model: posix
gcc version 8.1.0 (GCC)
---

Compile with:

> gcc -w -O1 minimize.c -S

You will see:

---
during GIMPLE pass: cunroll
minimize.c: In function ‘h’:
minimize.c:4:1: internal compiler error: in wide_int_to_tree_1, at tree.c:1549
 h() {
 ^
0x620ba8 ???
../sysdeps/x86_64/elf/start.S:113
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
---

[Bug tree-optimization/86991] [8 Regression] ICE in vectorizable_reduction, at tree-vect-loop.c:6919

2019-02-13 Thread konstantin.vladimirov at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86991

--- Comment #9 from Tilir  ---
One more test case:

int b[11], e[11], c, d;
void f() {
  unsigned g, h;
  for (; g < 11; g += 2) {
c = 2;
for (; c; c += 3) {
  h = 1;
  for (; h < 11; h++)
e[h] = e[h] + d - b[g];
}
  }
}

[Bug tree-optimization/89238] New: cc1 hangs after

2019-02-07 Thread konstantin.vladimirov at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89238

Bug ID: 89238
   Summary: cc1 hangs after 
   Product: gcc
   Version: 8.2.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: konstantin.vladimirov at gmail dot com
  Target Milestone: ---

Reproduction after creduce:

---
a, b, c, d, f, g, h, i, j, k;
unsigned long e;
l(m) {
  unsigned n = 0;
  unsigned long o = g + (e >> 5) - 7;
  for (; j; j++)
g = g + 30 - b;
  for (; k; k++)
h = b * f & i * b * 7 & b;
  for (; n < 9; n += 3) {
j = 0;
for (; j < 14; j++) {
  d = 8 | h & o | g << 1 ^ a & 5 & a + (a << 3);
  o = h * g * 3 + c + ~o;
}
  }
}

p() {
  l(0);
  l(0);
}
---

> gcc  -w -O3 minimize.c

Hangs forever (or at least long enough to make user unhappy, I think for such
simple reproduction "forever" starts from 5 minutes).

Compiler information:

---
> gcc -v
COLLECT_GCC=/apps/gcc/8.2.0/.bin/gcc
COLLECT_LTO_WRAPPER=/apps/gcc/8.2.0/.bin/../libexec/gcc/x86_64-suse-linux/8.2.0/lto-wrapper
Target: x86_64-suse-linux
Configured with: ./configure --prefix=/apps/gcc/8.2.0
--libdir=/apps/gcc/8.2.0/lib64 --libexecdir=/apps/gcc/8.2.0/libexec
--bindir=/apps/gcc/8.2.0/bin --with-isl=/apps/gcc/8.2.0
--with-libelf=/apps/gcc/8.2.0 --with-mpfr=/apps/gcc/8.2.0
--with-gmp=/apps/gcc/8.2.0 --with-mpc=/apps/gcc/8.2.0
--disable-gnu-unique-object --enable-gold=yes --enable-lto
--enable-languages=c,c++,objc,fortran --build=x86_64-suse-linux
--host=x86_64-suse-linux --target=x86_64-suse-linux --enable-libotm
--disable-libstdcxx-pch
Thread model: posix
gcc version 8.2.0 (GCC)
---

I ran cc1 and output is:

---
> cc1 -w -O3 minimize.c
 l p
Analyzing compilation unit
Performing interprocedural optimizations
 <*free_lang_data>   

  
 Assembling functions:
   l
---

I.e. it is hanging after simdclone

[Bug middle-end/89008] New: O2 and O1 results differ for simple test

2019-01-23 Thread konstantin.vladimirov at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89008

Bug ID: 89008
   Summary: O2 and O1 results differ for simple test
   Product: gcc
   Version: 8.1.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: middle-end
  Assignee: unassigned at gcc dot gnu.org
  Reporter: konstantin.vladimirov at gmail dot com
  Target Milestone: ---

Simple test:


#include 

unsigned long a, c;
unsigned b;
int d, e;
long f() {
  unsigned long g = 0;
  for (d = 0; d < 5; d += 2)
for (e = 0; e < 5; e += 3) {
  c = 4 + b;
  g = -b - b;
  b = 5 * (b << 24);
}
  a = g;
  return 0;
}

int main() {
  f();
  if (a)
abort();
}
---

Obviously, b initially 0 and 5*(b<<24) is 0 too on every iteration. But compile
and run it with gcc 8.1

> gcc -O1 min-05.c
> a.out
> gcc -O2 min-05.c
> a.out
Aborted

Compiler information:

> gcc --verbose
COLLECT_GCC=/apps/gcc/8.1.0/.bin/gcc
COLLECT_LTO_WRAPPER=/apps/gcc/8.1.0/.bin/../libexec/gcc/x86_64-suse-linux/8.1.0/lto-wrapper
Target: x86_64-suse-linux
Configured with: ./configure --prefix=/apps/gcc/8.1.0
--libdir=/apps/gcc/8.1.0/lib64 --libexecdir=/apps/gcc/8.1.0/libexec
--bindir=/apps/gcc/8.1.0/bin --with-isl=/apps/gcc/8.1.0
--with-libelf=/apps/gcc/8.1.0 --with-mpfr=/apps/gcc/8.1.0
--with-gmp=/apps/gcc/8.1.0 --with-mpc=/apps/gcc/8.1.0
--disable-gnu-unique-object --enable-gold=yes --enable-lto
--enable-languages=c,c++,objc,fortran --build=x86_64-suse-linux
--host=x86_64-suse-linux --target=x86_64-suse-linux --enable-libotm
--disable-multilib --disable-bootstrap --disable-libstdcxx-pch
Thread model: posix
gcc version 8.1.0 (GCC)

[Bug tree-optimization/87645] New: gcc hangs up on vr_values::vrp_visit_assignment_or_call

2018-10-18 Thread konstantin.vladimirov at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87645

Bug ID: 87645
   Summary: gcc hangs up on
vr_values::vrp_visit_assignment_or_call
   Product: gcc
   Version: 8.1.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: konstantin.vladimirov at gmail dot com
  Target Milestone: ---

Reproduction (after creduce, sorry for that code):

typedef unsigned a[8];
a b, g;
int c, d, e, f;
int h() {
  unsigned i = 2;
  for (; i < 8; i++)
b[i] = 0;
  for (; f;) {
d = 1;
for (; d < 14; d += 3) {
  e = 0;
  for (; e < 8; e++) {
i = 2;
for (; i < 8; i++)
  b[i] = 5 - (c - g[e] + b[i]);
  }
}
  }
}

Compiler:

> gcc -v

Reading specs from
/apps/gcc/8.1.0/.bin/../lib64/gcc/x86_64-suse-linux/8.1.0/specs
COLLECT_GCC=/apps/gcc/8.1.0/.bin/gcc
COLLECT_LTO_WRAPPER=/apps/gcc/8.1.0/.bin/../libexec/gcc/x86_64-suse-linux/8.1.0/lto-wrapper
Target: x86_64-suse-linux
Configured with: ./configure --prefix=/apps/gcc/8.1.0
--libdir=/apps/gcc/8.1.0/lib64 --libexecdir=/apps/gcc/8.1.0/libexec
--bindir=/apps/gcc/8.1.0/bin --with-isl=/apps/gcc/8.1.0
--with-libelf=/apps/gcc/8.1.0 --with-mpfr=/apps/gcc/8.1.0
--with-gmp=/apps/gcc/8.1.0 --with-mpc=/apps/gcc/8.1.0
--disable-gnu-unique-object --enable-gold=yes --enable-lto
--enable-languages=c,c++,objc,fortran --build=x86_64-suse-linux
--host=x86_64-suse-linux --target=x86_64-suse-linux --enable-libotm
--disable-multilib --disable-bootstrap --disable-libstdcxx-pch
Thread model: posix
gcc version 8.1.0 (GCC)

Try to compile like this:

gcc -S -O3 test.c

gcc hangs up

gcc -S -O2 test.c

passes ok

This might look similar with https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87087
but in this case it doesn't consume too much memory and gdb shows vrp, not
unroll.

[Bug tree-optimization/87087] New: Optimization hangs up and consumes over 15Gb of memory

2018-08-24 Thread konstantin.vladimirov at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87087

Bug ID: 87087
   Summary: Optimization hangs up and consumes over 15Gb of memory
   Product: gcc
   Version: 8.1.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: konstantin.vladimirov at gmail dot com
  Target Milestone: ---

Reproduction (after creduce, sorry for that code):

b;
d;
e() {
  unsigned f;
  unsigned g;
  int h;
  long i = 901380;
  for (;;) {
d = 0;
for (; d; d++) {
  h = 50126706678236;
  f = 0;
  for (; f < 15; f += 3) {
g = 0;
for (; g < 9; g++)
  b = h = i - (h << 5) + h;
  }
}
i = 0;
  }
}

Compiler:

> gcc -v

Reading specs from
/apps/gcc/8.1.0/.bin/../lib64/gcc/x86_64-suse-linux/8.1.0/specs
COLLECT_GCC=/apps/gcc/8.1.0/.bin/gcc
COLLECT_LTO_WRAPPER=/apps/gcc/8.1.0/.bin/../libexec/gcc/x86_64-suse-linux/8.1.0/lto-wrapper
Target: x86_64-suse-linux
Configured with: ./configure --prefix=/apps/gcc/8.1.0
--libdir=/apps/gcc/8.1.0/lib64 --libexecdir=/apps/gcc/8.1.0/libexec
--bindir=/apps/gcc/8.1.0/bin --with-isl=/apps/gcc/8.1.0
--with-libelf=/apps/gcc/8.1.0 --with-mpfr=/apps/gcc/8.1.0
--with-gmp=/apps/gcc/8.1.0 --with-mpc=/apps/gcc/8.1.0
--disable-gnu-unique-object --enable-gold=yes --enable-lto
--enable-languages=c,c++,objc,fortran --build=x86_64-suse-linux
--host=x86_64-suse-linux --target=x86_64-suse-linux --enable-libotm
--disable-multilib --disable-bootstrap --disable-libstdcxx-pch
Thread model: posix
gcc version 8.1.0 (GCC)

Try to compile like this:

> gcc -O3 test.c

You will see compiler hanging up and eating all of memory.

> gcc -O2 test.c

This passes ok.

[Bug tree-optimization/87074] New: Vectorization bug: O3 result differ from O2

2018-08-23 Thread konstantin.vladimirov at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87074

Bug ID: 87074
   Summary: Vectorization bug: O3 result differ from O2
   Product: gcc
   Version: 8.1.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: konstantin.vladimirov at gmail dot com
  Target Milestone: ---

Reproduction:

long b;
unsigned c[5];
unsigned long long d = 3;
int e, f, g;

void h() {
  for (; f < 11; f++) {
b = g;
for (e = 0; e < 5; e++) {
  c[e] = e - b - (c[e] >> 5);
  g = c[e];
}
  }
  if (c[0])
d = 0;
}

int main() {
  h();
  return d;
}

Compiler:

> gcc -v

Reading specs from
/apps/gcc/8.1.0/.bin/../lib64/gcc/x86_64-suse-linux/8.1.0/specs
COLLECT_GCC=/apps/gcc/8.1.0/.bin/gcc
COLLECT_LTO_WRAPPER=/apps/gcc/8.1.0/.bin/../libexec/gcc/x86_64-suse-linux/8.1.0/lto-wrapper
Target: x86_64-suse-linux
Configured with: ./configure --prefix=/apps/gcc/8.1.0
--libdir=/apps/gcc/8.1.0/lib64 --libexecdir=/apps/gcc/8.1.0/libexec
--bindir=/apps/gcc/8.1.0/bin --with-isl=/apps/gcc/8.1.0
--with-libelf=/apps/gcc/8.1.0 --with-mpfr=/apps/gcc/8.1.0
--with-gmp=/apps/gcc/8.1.0 --with-mpc=/apps/gcc/8.1.0
--disable-gnu-unique-object --enable-gold=yes --enable-lto
--enable-languages=c,c++,objc,fortran --build=x86_64-suse-linux
--host=x86_64-suse-linux --target=x86_64-suse-linux --enable-libotm
--disable-multilib --disable-bootstrap --disable-libstdcxx-pch
Thread model: posix
gcc version 8.1.0 (GCC)


Compile and run with:

> gcc -O2 minimize.c
> ./a.out
> echo $?
0

> gcc -O3 minimize.c
> ./a.out
> echo $?
3

0 is correct, 3 is incorrect

I also tried with sanitizer, just in case I missed some UB here

> gcc -O2 -fsanitize=undefined minimize.c
> ./a.out

Sanitizer catchs nothing. So if there is really UB (not sure) it is sanitizer
bug.

Clang 6 returns 0 in both cases. GCC 7.3.0 also returns 0 both times.

[Bug tree-optimization/86991] New: internal compiler error: in vectorizable_reduction, at tree-vect-loop.c:6919

2018-08-17 Thread konstantin.vladimirov at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86991

Bug ID: 86991
   Summary: internal compiler error: in vectorizable_reduction, at
tree-vect-loop.c:6919
   Product: gcc
   Version: 8.1.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: konstantin.vladimirov at gmail dot com
  Target Milestone: ---

Minimal reproduction:

int b;
extern unsigned c[];
unsigned d;
long e;

void f() {
  unsigned g, h;
  for (; d; d += 2) {
g = 1;
for (; g; g += 3) {
  h = 2;
  for (; h < 6; h++)
c[h] = c[h] - b - ~e;
}
  }
}

Compiler:

gcc -v
Reading specs from
/apps/gcc/8.1.0/.bin/../lib64/gcc/x86_64-suse-linux/8.1.0/specs
COLLECT_GCC=/apps/gcc/8.1.0/.bin/gcc
COLLECT_LTO_WRAPPER=/apps/gcc/8.1.0/.bin/../libexec/gcc/x86_64-suse-linux/8.1.0/lto-wrapper
Target: x86_64-suse-linux
Configured with: ./configure --prefix=/apps/gcc/8.1.0
--libdir=/apps/gcc/8.1.0/lib64 --libexecdir=/apps/gcc/8.1.0/libexec
--bindir=/apps/gcc/8.1.0/bin --with-isl=/apps/gcc/8.1.0
--with-libelf=/apps/gcc/8.1.0 --with-mpfr=/apps/gcc/8.1.0
--with-gmp=/apps/gcc/8.1.0 --with-mpc=/apps/gcc/8.1.0
--disable-gnu-unique-object --enable-gold=yes --enable-lto
--enable-languages=c,c++,objc,fortran --build=x86_64-suse-linux
--host=x86_64-suse-linux --target=x86_64-suse-linux --enable-libotm
--disable-multilib --disable-bootstrap --disable-libstdcxx-pch
Thread model: posix
gcc version 8.1.0 (GCC)

Compile with:

gcc min.c -O3

You shall see:

during GIMPLE pass: vect
min.c: In function ‘f’:
min.c:7:6: internal compiler error: in vectorizable_reduction, at
tree-vect-loop.c:6919
 void f() {
  ^
0x620ba8 ???
../sysdeps/x86_64/elf/start.S:113

[Bug middle-end/85382] New: code compiled with fno-builtin uses builtin

2018-04-12 Thread konstantin.vladimirov at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85382

Bug ID: 85382
   Summary: code compiled with fno-builtin uses builtin
   Product: gcc
   Version: 7.2.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: middle-end
  Assignee: unassigned at gcc dot gnu.org
  Reporter: konstantin.vladimirov at gmail dot com
  Target Milestone: ---

Minimized reproduction:

double a, b;

void f() {
  a = b * b * (628972 + b - 628972);
}

Compile with:

gcc -msse4 -ffast-math -Os -S minimize.c -fno-builtin -ffreestanding

Remove fast-math to kill reproduction.

Assembler:

f:
.LFB0:
.cfi_startproc
subq$8, %rsp
.cfi_def_cfa_offset 16
movl$3, %edi
movsd   b(%rip), %xmm0
call__powidf2
movsd   %xmm0, a(%rip)
popq%rax
.cfi_def_cfa_offset 8
ret

Compiler version:

Target: x86_64-suse-linux
Thread model: posix
gcc version 7.2.0 (GCC)

[Bug c++/71822] New: [6.0/6.1 Regression] internal compiler error: in gimplify_expr, at gimplify.c:11025

2016-07-09 Thread konstantin.vladimirov at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71822

Bug ID: 71822
   Summary: [6.0/6.1 Regression] internal compiler error: in
gimplify_expr, at gimplify.c:11025
   Product: gcc
   Version: 6.1.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: konstantin.vladimirov at gmail dot com
  Target Milestone: ---

Created attachment 38863
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=38863=edit
minimized reproduction (no specific options required)

Reproduced on GCC 6.1, not reproduced earlier.

 Compiler information

g++ -v

Using built-in specs.
COLLECT_GCC=/home/tilir/Applications/gcc-6.1/bin/g++
COLLECT_LTO_WRAPPER=/home/tilir/Applications/gcc-6.1/libexec/gcc/x86_64-pc-linux-gnu/6.1.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../../Sources/gcc-6.1/configure
--prefix=/home/tilir/Applications/gcc-6.1 --enable-languages=c,c++
--disable-bootstrap
Thread model: posix
gcc version 6.1.0 (GCC) 

 Error details

g++ repro.cpp

repro.cpp: In constructor ‘SchPacketFwk::SchPacketFwk()’:
repro.cpp:12:85: internal compiler error: in gimplify_expr, at gimplify.c:11025
   explicit ListOf (PointerTo  pool = Pools::Self().AppropPoolSame
(sizeof (Unit))) {}
   
 ^
0x899b07 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
../../../Sources/gcc-6.1/gcc/gimplify.c:11025
0x897889 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
../../../Sources/gcc-6.1/gcc/gimplify.c:10221
0x89dd4f gimplify_call_expr
../../../Sources/gcc-6.1/gcc/gimplify.c:2539
0x897c3e gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
../../../Sources/gcc-6.1/gcc/gimplify.c:10252
0x89aa06 gimplify_stmt(tree_node**, gimple**)
../../../Sources/gcc-6.1/gcc/gimplify.c:5688
0x89aa52 gimplify_and_add(tree_node*, gimple**)
../../../Sources/gcc-6.1/gcc/gimplify.c:425
0x6a3b27 cp_gimplify_expr(tree_node**, gimple**, gimple**)
../../../Sources/gcc-6.1/gcc/cp/cp-gimplify.c:668
0x89725e gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
../../../Sources/gcc-6.1/gcc/gimplify.c:10190
0x897a36 gimplify_target_expr
../../../Sources/gcc-6.1/gcc/gimplify.c:5619
0x897a36 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
../../../Sources/gcc-6.1/gcc/gimplify.c:10650
0x89aa06 gimplify_stmt(tree_node**, gimple**)
../../../Sources/gcc-6.1/gcc/gimplify.c:5688
0x89b137 gimplify_compound_expr
../../../Sources/gcc-6.1/gcc/gimplify.c:4952
0x897968 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
../../../Sources/gcc-6.1/gcc/gimplify.c:10270
0x89dd4f gimplify_call_expr
../../../Sources/gcc-6.1/gcc/gimplify.c:2539
0x897c3e gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
../../../Sources/gcc-6.1/gcc/gimplify.c:10252
0x89aa06 gimplify_stmt(tree_node**, gimple**)
../../../Sources/gcc-6.1/gcc/gimplify.c:5688
0x898e1e gimplify_cleanup_point_expr
../../../Sources/gcc-6.1/gcc/gimplify.c:5464
0x898e1e gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
../../../Sources/gcc-6.1/gcc/gimplify.c:10646
0x89aa06 gimplify_stmt(tree_node**, gimple**)
../../../Sources/gcc-6.1/gcc/gimplify.c:5688
0x8983e3 gimplify_statement_list
../../../Sources/gcc-6.1/gcc/gimplify.c:1537



[Bug rtl-optimization/67751] New: redundant zero extension

2015-09-28 Thread konstantin.vladimirov at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67751

Bug ID: 67751
   Summary: redundant zero extension
   Product: gcc
   Version: 5.2.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: rtl-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: konstantin.vladimirov at gmail dot com
  Target Milestone: ---

Simple test:

---
struct U {
  unsigned s: 1;
};

struct V {
  unsigned short o: 7;
  unsigned short u: 1;
};

extern struct U t[];
extern struct V d[];

unsigned
foo ()
{
struct V descr = d[0];
unsigned osize = descr.o;
if ( descr.u )
  {
struct U udata = t[osize];
if (udata.s) osize++;
  }
return osize;
}
---

Compiled with specified gcc:

>gcc -v
Using built-in specs.
COLLECT_GCC=/tools/local/gcc-5.2.0/bin/gcc
COLLECT_LTO_WRAPPER=/tools/local/gcc-5.2.0/libexec/gcc/x86_64-unknown-linux-gnu/5.2.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc-5.2.0/configure
--prefix=/tools/local/gcc-5.2.0 --program-suffix=-5.2.0
--with-as=/tools/local/binutils-2.24/bin/as
--with-ld=/tools/local/binutils-2.24/bin/ld
Thread model: posix
gcc version 5.2.0 (GCC)

---

with options:  -02 -S

---

Yields assembler:

---

foo:
movzbl  d(%rip), %eax
andl$127, %eax
cmpb$0, d(%rip)
movzbl  %al, %eax // <- why this is here?
jns .L2
movl%eax, %edx
movlt(,%rdx,4), %edx
andl$1, %edx
cmpb$1, %dl
sbbl$-1, %eax
.L2:
rep ret
---

Second movzbl looks excessive


[Bug sanitizer/67136] New: sanitizer reports member access within null pointer for correct C++ code

2015-08-06 Thread konstantin.vladimirov at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67136

Bug ID: 67136
   Summary: sanitizer reports member access within null pointer
for correct C++ code
   Product: gcc
   Version: 5.2.0
Status: UNCONFIRMED
  Severity: major
  Priority: P3
 Component: sanitizer
  Assignee: unassigned at gcc dot gnu.org
  Reporter: konstantin.vladimirov at gmail dot com
CC: dodji at gcc dot gnu.org, dvyukov at gcc dot gnu.org,
jakub at gcc dot gnu.org, kcc at gcc dot gnu.org
  Target Milestone: ---

Minimal reproduction:



#include cstdio

using namespace std;

class Base
{
public:
  Base ():m_nl (144) {}
  virtual ~Base() {}
protected:
  const int m_nl;
};

class Derived : public Base
{
  public:
  __attribute__ ((noinline)) Derived ():Base()
  {
fprintf (stderr, error = %d\n, (m_nl/2-1)%m_nl);
  }
};

Base *base;

int
main ()
{
  base = new Derived;
  return 0;
}



Compile with G++ 5.2.0

g++-5.2.0 -fno-sanitize-recover -fsanitize=undefined -O1 -Wall test.cpp
-Wl,-rpath /tools/local/gcc-5.2.0/lib64 -lubsan

---

Yields warning:

test.cpp: In constructor ‘Derived::Derived()’:
test.cpp:20:39: warning: ‘anonymous’ may be used uninitialized in this
function [-Wmaybe-uninitialized]
 fprintf (stderr, error = %d\n, (m_nl/2-1)%m_nl);

---

I suggest, that macro UBSAN_NULL expands incorrectly on sanopt pass, yields
unitialized Gimple anonymous variable and then incorrectly compares with 0.

[Bug middle-end/66876] New: vrp: changing unsigned to signed comparison

2015-07-15 Thread konstantin.vladimirov at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66876

Bug ID: 66876
   Summary: vrp: changing unsigned to signed comparison
   Product: gcc
   Version: 5.1.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: middle-end
  Assignee: unassigned at gcc dot gnu.org
  Reporter: konstantin.vladimirov at gmail dot com
  Target Milestone: ---

Minimized test case (note explicit unsigned long cast):

---
#include stdlib.h

int a = 0xecfb39f5;
unsigned short *d = (unsigned short *) a;

int
main (void)
{
  if ((unsigned long) (65536 * d[1] + d[0])  (1UL  28))
{
  abort ();
}

  return 0;
}
---

Compiler version:

---
$ ~/x86-toolchain-5.1/bin/gcc -v
Using built-in specs.
COLLECT_GCC=/home/tilir/x86-toolchain-5.1/bin/gcc
COLLECT_LTO_WRAPPER=/home/tilir/x86-toolchain-5.1/libexec/gcc/x86_64-unknown-linux-gnu/5.1.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc-5.1-src/gcc_5_1_0_release/configure
--enable-languages=c,c++ --prefix=/home/tilir/x86-toolchain-5.1/
Thread model: posix
gcc version 5.1.0 (GCC) 
---

$ ~/x86-toolchain-5.1/bin/gcc -O2 test.c
$ ./a.out 
Aborted

but

$ ~/x86-toolchain-5.1/bin/gcc -O2 test.c -fno-tree-vrp
$ ./a.out

Everything is ok.

Before VRP:

  _9 = (unsigned int) _8;
  if (_9 = 268435455)
goto bb 3;
  else
goto bb 4;


On VRP stage:

_8 : -- single use.
_9 = (unsigned int) _8;

_9 : -- single use.
if (_9 = 268435455)

After VRP:

  if (_8 = 268435455)
goto bb 3;
  else
goto bb 4;

By C11 standard, the rank of unsigned long is equal to rank of long and higher,
then rank of int, so integer promotions here should make unsigned long from
both sides.


[Bug ipa/66751] New: Inline optimizes away function, keeping call to it in code

2015-07-03 Thread konstantin.vladimirov at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66751

Bug ID: 66751
   Summary: Inline optimizes away function, keeping call to it in
code
   Product: gcc
   Version: 5.1.0
Status: UNCONFIRMED
  Severity: major
  Priority: P3
 Component: ipa
  Assignee: unassigned at gcc dot gnu.org
  Reporter: konstantin.vladimirov at gmail dot com
  Target Milestone: ---

Created attachment 35903
  -- https://gcc.gnu.org/bugzilla/attachment.cgi?id=35903action=edit
reproduction

Using gcc 5.1.0

$ ~/x86-toolchain-5.1/bin/gcc -v
Using built-in specs.
COLLECT_GCC=/home/tilir/x86-toolchain-5.1/bin/gcc
COLLECT_LTO_WRAPPER=/home/tilir/x86-toolchain-5.1/libexec/gcc/x86_64-unknown-linux-gnu/5.1.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc-5.1-src/gcc_5_1_0_release/configure
--enable-languages=c,c++ --prefix=/home/tilir/x86-toolchain-5.1/
Thread model: posix
gcc version 5.1.0 (GCC) 

Trying to compile given file (see attachment)

$ ~/x86-toolchain-5.1/bin/gcc -O1 980608-1.c -fdump-tree-all

yields:

/tmp/cczJo9UK.o: In function `main':
980608-1.c:(.text+0x4b): undefined reference to `debug'

Between 980608-1.c.046t.inline_param2 and 980608-1.c.068t.fixup_cfg4 given
function disappears from gimple source (I suspect inliner) but reference to it
is still inside main.


[Bug tree-optimization/55138] New: [4.7 Regression] inlining fails with -O2 on gcc 4.7.2

2012-10-30 Thread konstantin.vladimirov at gmail dot com


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



 Bug #: 55138

   Summary: [4.7 Regression] inlining fails with -O2 on gcc 4.7.2

Classification: Unclassified

   Product: gcc

   Version: 4.7.2

Status: UNCONFIRMED

  Severity: major

  Priority: P3

 Component: tree-optimization

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

ReportedBy: konstantin.vladimi...@gmail.com





Created attachment 28575

  -- http://gcc.gnu.org/bugzilla/attachment.cgi?id=28575

reproduction



found on private target, but can be easily reproduced on x86, so I think every

target is affected.



Compile attached file on gcc-4.7.2 with -O2 -DBROKEN to make function inlined.



Next run. You will see error. Compile just with -O2, next run and you will see

no error.



This error can not be reproduced on gcc-4.6.3, everything works fine. Problems

starts with 4.7


[Bug c/53541] New: gcc-4.6.2 segfaults on dumping tree information

2012-05-31 Thread konstantin.vladimirov at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53541

 Bug #: 53541
   Summary: gcc-4.6.2 segfaults on dumping tree information
Classification: Unclassified
   Product: gcc
   Version: 4.6.2
Status: UNCONFIRMED
  Severity: major
  Priority: P3
 Component: c
AssignedTo: unassig...@gcc.gnu.org
ReportedBy: konstantin.vladimi...@gmail.com


consider simple reproduction:

{code}
struct atexit {
 struct atexit *next;
};

struct atexit *__atexit;

void *
test(void *dso)
{
  struct atexit *p = 0, *q = 0;
  if (dso == (void *)0)
{
  for (p = __atexit; p != ((void *)0); )
{
  q = p;
  p = p-next;
}
}
  return (void *)p;
}
{code}

We will use gcc-4.6.2 on x86:

tilir@kivladimirov ~/research/5368 $ ~/4.6-toolset/bin/gcc --version
gcc (GCC) 4.6.2
Copyright (C) 2011 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.

Compiling with appropriate command line and see segfault:

$ gcc -m32 -O2 -fomit-frame-pointer -fdump-tree-all-lineno-details -flto
repro.c -S
repro.c: In function ‘test’:
repro.c:20:1: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See http://gcc.gnu.org/bugs.html for instructions.

Lets look some deeper:

run cc1 with

{noformat}
$ /home/tilir/4.6-toolset/libexec/gcc/x86_64-unknown-linux-gnu/4.6.2/cc1 -m32
-march=x86-64 -O2 -fomit-frame-pointer -fdump-tree-all-lineno-details -flto
repro.c

Analyzing compilation unit
Performing interprocedural optimizations
 *free_lang_data visibility early_local_cleanups
repro.c: In function ‘test’:
repro.c:20:1: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See http://gcc.gnu.org/bugs.html for instructions.
{noformat}

using GDB it is easy to see, that segfault is on line tree-pretty-print.c:1176
When GCC trying to calculate TREE_TYPE (TREE_TYPE (TREE_OPERAND (op0, 0)) it
segfaults because TREE_CODE( TREE_OPERAND (op0, 0)) is SSA_NAME, thus TREE_TYPE
(TREE_OPERAND (op0, 0) is 0, thus double TREE_TYPE is segfault.

I not sure how to correct it better -- may be add explicit check of SSA_NAME
case? But what is reason of SSA_NAME node arising here?