[Bug c++/96634] New: missing documentation for __builtin_addressof()

2020-08-16 Thread mirq-gccboogs at rere dot qmqm.pl
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96634

Bug ID: 96634
   Summary: missing documentation for __builtin_addressof()
   Product: gcc
   Version: unknown
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: mirq-gccboogs at rere dot qmqm.pl
  Target Milestone: ---

The __builtin_addressof() function is not documented. It is available in gcc
since r240873 (git commit be845b04a8e1).

[Bug tree-optimization/51513] Only partially optimizes away __builtin_unreachable switch default case

2020-04-07 Thread mirq-gccboogs at rere dot qmqm.pl
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=51513

Michał Mirosław  changed:

   What|Removed |Added

 CC||mirq-gccboogs at rere dot 
qmqm.pl

--- Comment #12 from Michał Mirosław  ---
Created attachment 48236
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=48236=edit
testcase

This bug reoccurred in gcc-8. gcc-7 and gcc-9+ seem not affected.

$ gcc-8 -O3 -S b.c -o -
[...]
foo:
.LFB0:
.cfi_startproc
cmpl$1, %edi
jne .L10
movslq  %esi, %rsi
leaqfoz(%rip), %rax
movl(%rax,%rsi,4), %eax
movl%eax, (%rdx)
xorl%eax, %eax
ret
.p2align 4,,10
.p2align 3
.L10:
cmpl$2, %edi
jne .L11
.L3:
movslq  %esi, %rsi
leaqbaz(%rip), %rax
movl(%rax,%rsi,4), %eax
movl%eax, (%rdx)
xorl%eax, %eax
ret
.p2align 4,,10
.p2align 3
.L11:
testl   %edi, %edi
je  .L3
.cfi_endproc
[...]

$ gcc-8 -O -S b.c -o -
[...]
foo:
.LFB0:
.cfi_startproc
cmpl$1, %edi
je  .L2
cmpl$2, %edi
je  .L3
testl   %edi, %edi
jne .L4
.L3:
movslq  %esi, %rsi
leaqbaz(%rip), %rax
movl(%rax,%rsi,4), %eax
movl%eax, (%rdx)
.L5:
movl$0, %eax
ret
.L2:
movslq  %esi, %rsi
leaqfoz(%rip), %rax
movl(%rax,%rsi,4), %eax
movl%eax, (%rdx)
jmp .L5
.L4:
.cfi_endproc

[Bug c/92507] False positives with -Wsign-compare

2020-03-31 Thread mirq-gccboogs at rere dot qmqm.pl
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92507

Michał Mirosław  changed:

   What|Removed |Added

 CC||mirq-gccboogs at rere dot 
qmqm.pl

--- Comment #4 from Michał Mirosław  ---
Created attachment 48152
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=48152=edit
testcase

A simple testcase.

[Bug c++/66586] Template backtrace is truncated/absent after 'template argument deduction/substitution failed:'

2018-07-10 Thread mirq-gccboogs at rere dot qmqm.pl
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66586

Michał Mirosław  changed:

   What|Removed |Added

 CC||mirq-gccboogs at rere dot 
qmqm.pl

--- Comment #3 from Michał Mirosław  ---
Created attachment 44379
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=44379=edit
Testcase with enable_if_t

Happens also in 6.3.0, 7.3.0, 8.1.0 (same messages generated for those
versions).

Slightly different testcase, with enable_if_t.

$ g++ -c -std=c++17 a.cc

a.cc: In function ‘void bar()’:
a.cc:22:7: error: no matching function for call to ‘foo(A&)’
  foo(a);
   ^
a.cc:6:6: note: candidate: template void foo(S&)
 void foo(S&);
  ^~~
a.cc:6:6: note:   template argument deduction/substitution failed:
a.cc:9:6: note: candidate: template void foo(S&)
 void foo(S&);
  ^~~
a.cc:9:6: note:   template argument deduction/substitution failed:
a.cc:8:23: error: no type named ‘other’ in ‘struct A’
 template >
   ^~~~

[Bug target/68014] ICE when using Flag Output Operands

2017-09-24 Thread mirq-gccboogs at rere dot qmqm.pl
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68014

Michał Mirosław  changed:

   What|Removed |Added

 CC||mirq-gccboogs at rere dot 
qmqm.pl

--- Comment #3 from Michał Mirosław  ---
Just accidentally tripped on this one using gcc 6.3.0.

[Bug c/77331] incorrect range location in -Wformat with a concatenated format literal

2017-05-01 Thread mirq-gccboogs at rere dot qmqm.pl
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77331

Michał Mirosław  changed:

   What|Removed |Added

 CC||mirq-gccboogs at rere dot 
qmqm.pl

--- Comment #1 from Michał Mirosław  ---
This looks similar (related to PR#52952?): when showing error for concatenated
format string, caret does not point to the triggering format.

void foo(const char *fmt, ...) __attribute__((format(printf, 1, 2)));

#define PREFIX "a:"
#define A(fmt, args...) foo(PREFIX fmt ".", ##args)

void bar()
{
A("%");
}

$ arm-linux-gnueabihf-gcc-7 -fsyntax-only -Wformat foo.c 

foo.c: In function ‘bar’:
foo.c:3:16: warning: conversion lacks type at end of format [-Wformat=]
 #define PREFIX "a:"
^
foo.c:4:29: note: in expansion of macro ‘PREFIX’
 #define A(fmt, args...) foo(PREFIX fmt ".", ##args)
 ^~
foo.c:8:2: note: in expansion of macro ‘A’
  A("%");
  ^
foo.c:4:41: note: format string is defined here
 #define A(fmt, args...) foo(PREFIX fmt ".", ##args)
 ^

The same happens with gcc-6.3.0.

[Bug c/80585] -Wformat location

2017-05-01 Thread mirq-gccboogs at rere dot qmqm.pl
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80585

Michał Mirosław  changed:

   What|Removed |Added

 Status|UNCONFIRMED |RESOLVED
 Resolution|--- |INVALID

--- Comment #1 from Michał Mirosław  ---
Missclick, sorry for the noise.

[Bug c/80585] New: -Wformat location

2017-05-01 Thread mirq-gccboogs at rere dot qmqm.pl
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80585

Bug ID: 80585
   Summary: -Wformat location
   Product: gcc
   Version: 6.3.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
  Assignee: unassigned at gcc dot gnu.org
  Reporter: mirq-gccboogs at rere dot qmqm.pl
  Target Milestone: ---

[Bug target/79355] New: poor code for AVX vector compare

2017-02-03 Thread mirq-gccboogs at rere dot qmqm.pl
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79355

Bug ID: 79355
   Summary: poor code for AVX vector compare
   Product: gcc
   Version: 6.3.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: target
  Assignee: unassigned at gcc dot gnu.org
  Reporter: mirq-gccboogs at rere dot qmqm.pl
  Target Milestone: ---

gcc-6.2 (and previous versions) generates a very inefficient code for AVX when
comparing 32-byte vectors:

$ cat a.c
#include 

__v8su eq2(__v8su a, __v8su b)
{
return a == b;
}

$ gcc -S -Ofast -mavx a.c -o -
.file   "a.c"
.text   
.p2align 4,,15
.globl  eq2
.type   eq2, @function
eq2:
.LFB4856:
.cfi_startproc
vmovd   %xmm0, %edx
vmovd   %xmm1, %eax
leaq8(%rsp), %r10
.cfi_def_cfa 10, 0
vpextrd $1, %xmm0, %ecx
andq$-32, %rsp
cmpl%eax, %edx
[... extracting and comparing every element here ...]
vpinsrd $1, %r11d, %xmm5, %xmm1
vpinsrd $1, %r9d, %xmm7, %xmm0
popq%r10
.cfi_def_cfa 10, 0
vpunpcklqdq %xmm3, %xmm0, %xmm0
vpunpcklqdq %xmm2, %xmm1, %xmm1
popq%rbp
leaq-8(%r10), %rsp
.cfi_def_cfa 7, 8
vinsertf128 $0x1, %xmm1, %ymm0, %ymm0
ret

When it could instead generate (i.e. split vector in half and combine
afterwards):

vextractf128$0x1, %ymm0, %xmm2
vextractf128$0x1, %ymm1, %xmm3
vpcmpeqd%xmm1, %xmm0, %xmm0
vpcmpeqd%xmm3, %xmm2, %xmm2
vinsertf128 $0x1, %xmm2, %ymm0, %ymm0
ret

$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/6/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 6.3.0-5'
--with-bugurl=file:///usr/share/doc/gcc-6/README.Bugs
--enable-languages=c,ada,c++,java
,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-6
--program-prefix=x86_64-linux-gnu- --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 --enable-default-pie
--with-system-zlib --disable-browser-plugin --enable-java-awt=gtk
--enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-6-amd64/jre
--enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-6-amd64
--with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-6-amd64
--with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar
--with-target-system-zlib --enable-objc-gc=auto --enable-multiarch
--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 model: posix
gcc version 6.3.0 20170124 (Debian 6.3.0-5)

[Bug middle-end/71927] stack alignment prologue not optimized out when no local variables remain

2016-07-19 Thread mirq-gccboogs at rere dot qmqm.pl
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71927

Micha³ Miros³aw  changed:

   What|Removed |Added

  Attachment #38926|0   |1
is obsolete||

--- Comment #3 from Micha³ Miros³aw  ---
Created attachment 38927
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=38927=edit
test case

It seems that just the asm and array length > 2 are needed.

$ gcc -O3 -S -o - c.c
[...]
x:
.LFB0:
.cfi_startproc
ret
.cfi_endproc
[...]
y:
.LFB1:
.cfi_startproc
leaq8(%rsp), %r10
.cfi_def_cfa 10, 0
andq$-32, %rsp
pushq   -8(%r10)
pushq   %rbp
.cfi_escape 0x10,0x6,0x2,0x76,0
movq%rsp, %rbp
pushq   %r10
.cfi_escape 0xf,0x3,0x76,0x78,0x6
popq%r10
.cfi_def_cfa 10, 0
popq%rbp
leaq-8(%r10), %rsp
.cfi_def_cfa 7, 8
ret
.cfi_endproc

[Bug middle-end/71927] stack alignment prologue not optimized out when no local variables remain

2016-07-19 Thread mirq-gccboogs at rere dot qmqm.pl
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71927

--- Comment #2 from Micha³ Miros³aw  ---
gcc 4.9.3 generates the same code.

$ gcc-4.9 -v
Using built-in specs.
COLLECT_GCC=gcc-4.9
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.9/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 4.9.3-14'
--with-bugurl=file:///usr/share/doc/gcc-4.9/README.Bugs
--enable-languages=c,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr
--program-suffix=-4.9 --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--with-gxx-include-dir=/usr/include/c++/4.9 --libdir=/usr/lib --enable-nls
--with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug
--enable-libstdcxx-time=yes --enable-gnu-unique-object --disable-vtable-verify
--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-4.9-amd64/jre --enable-java-home
--with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-4.9-amd64
--with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-4.9-amd64
--with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar
--enable-objc-gc --enable-multiarch --with-arch-32=i586 --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 model: posix
gcc version 4.9.3 (Debian 4.9.3-14)

[Bug middle-end/71927] stack alignment prologue not optimized out when no local variables remain

2016-07-19 Thread mirq-gccboogs at rere dot qmqm.pl
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71927

Micha³ Miros³aw  changed:

   What|Removed |Added

  Attachment #38925|0   |1
is obsolete||

--- Comment #1 from Micha³ Miros³aw  ---
Created attachment 38926
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=38926=edit
test case 2

Fails the same way when using non-SSE registers, but when requesting alignment
of the local variable.

$ gcc -O3 -S -o - b.c
[...]
y:
.LFB1:  
.cfi_startproc
leaq8(%rsp), %r10
.cfi_def_cfa 10, 0
andq$-32, %rsp
pushq   -8(%r10)
pushq   %rbp
.cfi_escape 0x10,0x6,0x2,0x76,0
movq%rsp, %rbp
pushq   %r10
.cfi_escape 0xf,0x3,0x76,0x78,0x6
movl(%rdi), %eax
movl%edx, (%rdi)
movl4(%rdi), %edx
movl%ecx, 4(%rdi)
movl8(%rdi), %ecx
movl%esi, 8(%rdi)
popq%r10
.cfi_def_cfa 10, 0
popq%rbp
leaq-8(%r10), %rsp
.cfi_def_cfa 7, 8
ret
.cfi_endproc

[Bug middle-end/71927] New: stack alignment prologue not optimized out when no local variables remain

2016-07-19 Thread mirq-gccboogs at rere dot qmqm.pl
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71927

Bug ID: 71927
   Summary: stack alignment prologue not optimized out when no
local variables remain
   Product: gcc
   Version: 5.4.0
Status: UNCONFIRMED
  Keywords: missed-optimization
  Severity: normal
  Priority: P3
 Component: middle-end
  Assignee: unassigned at gcc dot gnu.org
  Reporter: mirq-gccboogs at rere dot qmqm.pl
  Target Milestone: ---

Created attachment 38925
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=38925=edit
test case

gcc 5.4 optimizes out local array, but does not remove stack-alignment code.

x() has 2-element __m256i array - get's optimized out correctly
y() has 3-element __m256i array - stack alignment is left in place

for the y() case, at -O2 the loop is not unrolled (unlike x())

$ gcc -mavx2 -O3 -S -o - a.c
[...]
x:
.LFB4854:
.cfi_startproc
vmovdqa (%rdi), %ymm2
vpminud %ymm1, %ymm2, %ymm3
vpmaxud %ymm1, %ymm2, %ymm1
vmovdqa %ymm1, (%rdi)
vmovdqa 32(%rdi), %ymm1
vpminud %ymm0, %ymm1, %ymm2
vpmaxud %ymm0, %ymm1, %ymm0
vmovdqa %ymm0, 32(%rdi)
vzeroupper
ret
.cfi_endproc
[...]
y:
.LFB4855:
.cfi_startproc
leaq8(%rsp), %r10
.cfi_def_cfa 10, 0
andq$-32, %rsp
pushq   -8(%r10)
pushq   %rbp
.cfi_escape 0x10,0x6,0x2,0x76,0   
movq%rsp, %rbp
pushq   %r10
.cfi_escape 0xf,0x3,0x76,0x78,0x6 
vmovdqa (%rdi), %ymm0
vpminud %ymm0, %ymm3, %ymm4
vpmaxud %ymm0, %ymm3, %ymm0
vmovdqa %ymm0, (%rdi)
vmovdqa 32(%rdi), %ymm0
vpminud %ymm0, %ymm2, %ymm3
vpmaxud %ymm0, %ymm2, %ymm0
vmovdqa %ymm0, 32(%rdi)
vmovdqa 64(%rdi), %ymm0
vpminud %ymm0, %ymm1, %ymm2
vpmaxud %ymm0, %ymm1, %ymm0
vmovdqa %ymm0, 64(%rdi)
vzeroupper
popq%r10
.cfi_def_cfa 10, 0
popq%rbp
leaq-8(%r10), %rsp
.cfi_def_cfa 7, 8
ret
.cfi_endproc

$ gcc -mavx2 -O2 -S -o - a.c
[... x() - same as -O3]
y:
.LFB4855:
.cfi_startproc
leaq8(%rsp), %r10
.cfi_def_cfa 10, 0
andq$-32, %rsp
pushq   -8(%r10)
pushq   %rbp
.cfi_escape 0x10,0x6,0x2,0x76,0
movq%rsp, %rbp
pushq   %r10
.cfi_escape 0xf,0x3,0x76,0x78,0x6
vmovdqa %ymm2, -112(%rbp)
xorl%eax, %eax
vmovdqa %ymm1, -80(%rbp)
vmovdqa %ymm0, -48(%rbp)
.L3:
vmovdqa (%rdi,%rax), %ymm0
vmovdqa -112(%rbp,%rax), %ymm1
vpminud %ymm0, %ymm1, %ymm2
vpmaxud %ymm0, %ymm1, %ymm0
vmovdqa %ymm2, -112(%rbp,%rax)
vmovdqa %ymm0, (%rdi,%rax)
addq$32, %rax
cmpq$96, %rax
jne .L3
vmovdqa -48(%rbp), %ymm2
vmovdqa -80(%rbp), %ymm1
vmovdqa -112(%rbp), %ymm0
vzeroupper
popq%r10
.cfi_def_cfa 10, 0
popq%rbp
leaq-8(%r10), %rsp
.cfi_def_cfa 7, 8
ret
.cfi_endproc

$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
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='Debian 5.4.0-6'
--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 --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 model: posix
gcc version 5.4.0 20160609 (Debian 5.4.0-6)

[Bug c++/71871] ICE on mixing templates and vector extensions ternary operator

2016-07-13 Thread mirq-gccboogs at rere dot qmqm.pl
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71871

--- Comment #1 from Micha³ Miros³aw  ---
Created attachment 38894
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=38894=edit
test case 2

Small change (second variable instead of constant) changes the ICE to:

$ g++  -c b.cc
b.cc: In function ‘void foo() [with unsigned int N = 0u]’:
b.cc:7:2: internal compiler error: in make_decl_rtl, at varasm.c:1313
  x = x ? x : y;
  ^
0x94b229 make_decl_rtl(tree_node*)
../../src/gcc/varasm.c:1309
0xea0272 expand_expr_real_1(tree_node*, rtx_def*, machine_mode,
expand_modifier, rtx_def**, bool)
../../src/gcc/expr.c:9581
0xea17b8 expand_expr_real(tree_node*, rtx_def*, machine_mode, expand_modifier,
rtx_def**, bool)
../../src/gcc/expr.c:8018
0xea17b8 store_expr_with_bounds(tree_node*, rtx_def*, int, bool, tree_node*)
../../src/gcc/expr.c:5382
0xea0fbc expand_assignment(tree_node*, tree_node*, bool)
../../src/gcc/expr.c:5154
0xdfbf10 expand_gimple_stmt_1
../../src/gcc/cfgexpand.c:3426
0xdfbf10 expand_gimple_stmt
../../src/gcc/cfgexpand.c:3522
0xdf4f18 expand_gimple_basic_block
../../src/gcc/cfgexpand.c:5534
0xdf4f18 execute
../../src/gcc/cfgexpand.c:6152
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See  for instructions.

[Bug c++/71871] New: ICE on mixing templates and vector extensions ternary operator

2016-07-13 Thread mirq-gccboogs at rere dot qmqm.pl
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71871

Bug ID: 71871
   Summary: ICE on mixing templates and vector extensions ternary
operator
   Product: gcc
   Version: 5.4.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: mirq-gccboogs at rere dot qmqm.pl
  Target Milestone: ---

Created attachment 38893
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=38893=edit
test case

Attached causes an ICE.

$ g++ -c a.cc
a.cc: In function ‘void foo() [with unsigned int N = 0u]’:
a.cc:7:2: internal compiler error: in gimplify_expr, at gimplify.c:8858
  x = x ? x : -1;
  ^
0x74c6d9 gimplify_expr(tree_node**, gimple_statement_base**,
gimple_statement_base**, bool (*)(tree_node*), int)
../../src/gcc/gimplify.c:8858
0xefc41c internal_get_tmp_var
../../src/gcc/gimplify.c:555
0x12b62d1 get_initialized_tmp_var(tree_node*, gimple_statement_base**,
gimple_statement_base**)
../../src/gcc/gimplify.c:598
0x12b62d1 gimplify_save_expr
../../src/gcc/gimplify.c:4887
0xef8d54 gimplify_expr(tree_node**, gimple_statement_base**,
gimple_statement_base**, bool (*)(tree_node*), int)
../../src/gcc/gimplify.c:8412
0xef80cf gimplify_expr(tree_node**, gimple_statement_base**,
gimple_statement_base**, bool (*)(tree_node*), int)
../../src/gcc/gimplify.c:8228
0x7516c5 gimplify_init_constructor
../../src/gcc/gimplify.c:4103
0xefbeb0 gimplify_modify_expr_rhs
../../src/gcc/gimplify.c:4274
0xefb4a9 gimplify_modify_expr
../../src/gcc/gimplify.c:4603
0xef778f gimplify_expr(tree_node**, gimple_statement_base**,
gimple_statement_base**, bool (*)(tree_node*), int)
../../src/gcc/gimplify.c:8126
0xefc82b gimplify_stmt(tree_node**, gimple_statement_base**)
../../src/gcc/gimplify.c:5545
0xefc82b gimplify_and_add(tree_node*, gimple_statement_base**)
../../src/gcc/gimplify.c:423
0xefc82b internal_get_tmp_var
../../src/gcc/gimplify.c:568
0xef7c8c get_formal_tmp_var(tree_node*, gimple_statement_base**)
../../src/gcc/gimplify.c:589
0xef7c8c gimplify_expr(tree_node**, gimple_statement_base**,
gimple_statement_base**, bool (*)(tree_node*), int)
../../src/gcc/gimplify.c:9050
0x74b6d6 gimplify_expr(tree_node**, gimple_statement_base**,
gimple_statement_base**, bool (*)(tree_node*), int)
../../src/gcc/gimplify.c:8844
0xefb54b gimplify_modify_expr
../../src/gcc/gimplify.c:4644
0xef778f gimplify_expr(tree_node**, gimple_statement_base**,
gimple_statement_base**, bool (*)(tree_node*), int)
../../src/gcc/gimplify.c:8126
0xef716e gimplify_stmt(tree_node**, gimple_statement_base**)
../../src/gcc/gimplify.c:5545
0xef8570 gimplify_cleanup_point_expr
../../src/gcc/gimplify.c:5321
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See  for instructions.

$ g++ -v
Using built-in specs.
COLLECT_GCC=g++
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='Debian 5.4.0-6'
--with-bugurl=file:///usr/share/doc/gcc-5/README.Bugs
--enable-languages=c,ada,c++,jau
Thread model: posix
gcc version 5.4.0 20160609 (Debian 5.4.0-6) 

also fails on:

$ g++ -v
Using built-in specs.
COLLECT_GCC=/usr/bin/g++-4.9.real
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.9/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 4.9.2-10'
--with-bugurl=file:///usr/share/doc/gcc-4.9/README.Bugs
--enable-languages=c,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr
--program-suffix=-4.9 --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--with-gxx-include-dir=/usr/include/c++/4.9 --libdir=/usr/lib --enable-nls
--with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug
--enable-libstdcxx-time=yes --enable-gnu-unique-object --disable-vtable-verify
--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-4.9-amd64/jre --enable-java-home
--with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-4.9-amd64
--with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-4.9-amd64
--with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar
--enable-objc-gc --enable-multiarch --with-arch-32=i586 --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 model: posix
gcc version 4.9.2 (Debian 4.9.2-10)

[Bug target/71467] extra store for -mavx -mno-avx

2016-06-09 Thread mirq-gccboogs at rere dot qmqm.pl
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71467

--- Comment #1 from Micha³ Miros³aw  ---
It gets even worse with AVX also disabled.

$ gcc -O3 -mno-avx -mno-avx2 -S -o - a.c

[Bug target/71467] New: extra store for -mavx -mno-avx

2016-06-09 Thread mirq-gccboogs at rere dot qmqm.pl
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71467

Bug ID: 71467
   Summary: extra store for -mavx -mno-avx
   Product: gcc
   Version: 5.3.1
Status: UNCONFIRMED
  Keywords: missed-optimization, ssemmx
  Severity: minor
  Priority: P3
 Component: target
  Assignee: unassigned at gcc dot gnu.org
  Reporter: mirq-gccboogs at rere dot qmqm.pl
  Target Milestone: ---
  Host: x86_64-linux-gnu
Target: x86_64-linux-gnu

Created attachment 38664
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=38664=edit
test case

Code:

typedef int __v8si __attribute__ ((__vector_size__ (32)));

void vz(__v8si *v)
{
*v <<= 1;
}

Compiles to:

vz:
.LFB0:
.cfi_startproc
leaq8(%rsp), %r10
.cfi_def_cfa 10, 0
andq$-32, %rsp
pushq   -8(%r10)
pushq   %rbp
.cfi_escape 0x10,0x6,0x2,0x76,0
movq%rsp, %rbp
pushq   %r10
.cfi_escape 0xf,0x3,0x76,0x78,0x6
vmovdqa (%rdi), %xmm2
vmovdqa 16(%rdi), %xmm4
vpslld  $1, %xmm2, %xmm1
vpslld  $1, %xmm4, %xmm3
vmovaps %xmm1, -48(%rbp)
vmovaps %xmm3, -32(%rbp)
vmovdqa -48(%rbp), %ymm5
vmovdqa %ymm5, (%rdi)
vzeroupper
popq%r10
.cfi_def_cfa 10, 0
popq%rbp
leaq-8(%r10), %rsp
.cfi_def_cfa 7, 8
ret
.cfi_endproc
.LFE0:
.size   vz, .-vz

This should be no more than:

vmovdqa (%rdi), %xmm2
vmovdqa 16(%rdi), %xmm4
vpslld  $1, %xmm2, %xmm1
vpslld  $1, %xmm4, %xmm3
vmovaps %xmm1, (%rdi)
vmovaps %xmm3, 16(%rdi)
ret

Compiled with:

$ gcc -O3 -mavx -mno-avx2 -S -o - a.c

$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
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='Debian 5.3.1-21'
--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 --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 model: posix
gcc version 5.3.1 20160528 (Debian 5.3.1-21) 

Same with:

Using built-in specs.
COLLECT_GCC=gcc-4.9
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.9/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 4.9.3-14'
--with-bugurl=file:///usr/share/doc/gcc-4.9/README.Bugs
--enable-languages=c,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr
--program-suffix=-4.9 --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--with-gxx-include-dir=/usr/include/c++/4.9 --libdir=/usr/lib --enable-nls
--with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug
--enable-libstdcxx-time=yes --enable-gnu-unique-object --disable-vtable-verify
--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-4.9-amd64/jre --enable-java-home
--with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-4.9-amd64
--with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-4.9-amd64
--with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar
--enable-objc-gc --enable-multiarch --with-arch-32=i586 --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 model: posix
gcc version 4.9.3 (Debian 4.9.3-14)

[Bug inline-asm/71086] New: miscompiled inline-asm + alternative constraints + __builtin_expect + always_inline

2016-05-12 Thread mirq-gccboogs at rere dot qmqm.pl
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71086

Bug ID: 71086
   Summary: miscompiled inline-asm + alternative constraints +
__builtin_expect + always_inline
   Product: gcc
   Version: 4.9.3
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: inline-asm
  Assignee: unassigned at gcc dot gnu.org
  Reporter: mirq-gccboogs at rere dot qmqm.pl
  Target Milestone: ---

Created attachment 38474
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=38474=edit
test case source

The attached code get's miscompiled when -DNO_EXPECT is not passed. With
__builtin_expect used, the operand to inline asm in inc_overflow() get's
replaced with uninitialized stack entry. This happens only with exact
combination of: -O1, inline-asm has multiple alternative constraints,
__builtin_expect is used in inc_overflow(), there are other not-optimized-out
variables on stack.

gcc versions 4.9.2 (-10 Debian) and 4.9.3 (-13ubuntu2) miscompile, gcc 5.3.1
generates correct code.

--- good: g++ -O1 -S -DNO_EXCEPT bug_inline.cc -o -
+++ bad:  g++ -O1 -S bug_inline.cc -o -
@@ -5,55 +5,49 @@
 _Z6test_smj:
 .LFB2: 
.cfi_startproc
-   pushq   %rbp
-   .cfi_def_cfa_offset 16
-   .cfi_offset 6, -16
pushq   %rbx
-   .cfi_def_cfa_offset 24
-   .cfi_offset 3, -24
-   subq$40, %rsp
+   .cfi_def_cfa_offset 16
+   .cfi_offset 3, -16
+   subq$48, %rsp
.cfi_def_cfa_offset 64
-   movq%rdi, %rbp
+   movq%rdi, 8(%rsp)
movq%fs:40, %rax
-   movq%rax, 24(%rsp)
+   movq%rax, 40(%rsp)
xorl%eax, %eax
cmpl$10, %esi
jbe .L2
movl%esi, %ebx
-   leaq8(%rsp), %rdi
+   leaq24(%rsp), %rdi
call_Z3xdoRm
-.L5:
-   movq%rbp, %rdi
+.L4:
 #APP
 # 18 "bug_inline.cpp" 1
-   add %rbx, %rdi
+   add %rbx, 32(%rsp)<--- 32(%rsp) is not initialized, but
should be with 'v' (saved at 8(%rsp), or in %rbp in good code)
setc %sil
 # 0 "" 2
 #NO_APP
testb   %sil, %sil
-   movq$-1, %rax
-   cmovne  %rax, %rdi
-   movq%rdi, 16(%rsp)
-   leaq16(%rsp), %rdi
+   je  .L3
+   movq$-1, 32(%rsp)
+.L3:
+   leaq32(%rsp), %rdi
call_Z3xdoRm
-   movq8(%rsp), %rax
-   movq24(%rsp), %rdx
+   movq24(%rsp), %rax
+   movq40(%rsp), %rdx
xorq%fs:40, %rdx
-   je  .L6
-   jmp .L7
+   je  .L5
+   jmp .L6
 .L2:
-   leaq8(%rsp), %rdi
+   leaq24(%rsp), %rdi
call_Z3xdoRm
movl$4294967295, %ebx
-   jmp .L5
-.L7:
-   call__stack_chk_fail
+   jmp .L4
 .L6:
-   addq$40, %rsp
-   .cfi_def_cfa_offset 24
-   popq%rbx
+   call__stack_chk_fail
+.L5:
+   addq$48, %rsp
.cfi_def_cfa_offset 16
-   popq%rbp
+   popq%rbx
.cfi_def_cfa_offset 8
ret
.cfi_endproc

# Debian 4.9.2
$ gcc -v
Using built-in specs.
COLLECT_GCC=/usr/bin/gcc-4.9.real
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.9/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 4.9.2-10'
--with-bugurl=file:///usr/share/doc/gcc-4.9/README.Bugs
--enable-languages=c,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr
--program-suffix=-4.9 --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--with-gxx-include-dir=/usr/include/c++/4.9 --libdir=/usr/lib --enable-nls
--with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug
--enable-libstdcxx-time=yes --enable-gnu-unique-object --disable-vtable-verify
--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-4.9-amd64/jre --enable-java-home
--with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-4.9-amd64
--with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-4.9-amd64
--with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar
--enable-objc-gc --enable-multiarch --with-arch-32=i586 --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 model: posix
gcc version 4.9.2 (Debian 4.9.2-10) 

# Ubuntu 4.9.3
$ g++-4.9 -v
Using built-in specs.
COLLECT_GCC=g++-4.9
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.9/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 4.9.3-13ubuntu2'
--with-bugurl=file:///usr/share/doc/gcc-4.9/README.Bugs
--enable-languages=c,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr
--program-suffix=-4.9 --enable-shared --enable-linker-build-id
--lib

[Bug target/68228] __builtin_ia32_pbroadcastd256 generates wrong insn at >= -O1

2015-11-10 Thread mirq-gccboogs at rere dot qmqm.pl
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68228

--- Comment #4 from Micha³ Miros³aw  ---
Created attachment 36673
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=36673=edit
gcc 4.8 assembler output for -O1

gcc-4.8 also generates correct VPBROADCASTD, though with VMOVD before it.

[Bug target/68228] New: __builtin_ia32_pbroadcastd256 generates wrong insn at >= -O1

2015-11-05 Thread mirq-gccboogs at rere dot qmqm.pl
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68228

Bug ID: 68228
   Summary: __builtin_ia32_pbroadcastd256 generates wrong insn at
>= -O1
   Product: gcc
   Version: 4.9.2
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: target
  Assignee: unassigned at gcc dot gnu.org
  Reporter: mirq-gccboogs at rere dot qmqm.pl
  Target Milestone: ---

Created attachment 36656
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=36656=edit
test source

__builtin_ia32_pbroadcastd256() generates VBROADCASTSS instead of VPBROADCASTD
with optimization turned on. At -O0 there's a lot of useless moving data
to/from stack, but in the end the correct VPBROADCASTD is issued.

command line: gcc -march=core-avx2 -O1 -S test.c

$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.9/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 4.9.2-10'
--with-bugurl=file:///usr/share/doc/gcc-4.9/README.Bugs
--enable-languages=c,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr
--program-suffix=-4.9 --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--with-gxx-include-dir=/usr/include/c++/4.9 --libdir=/usr/lib --enable-nls
--with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug
--enable-libstdcxx-time=yes --enable-gnu-unique-object --disable-vtable-verify
--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-4.9-amd64/jre --enable-java-home
--with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-4.9-amd64
--with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-4.9-amd64
--with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar
--enable-objc-gc --enable-multiarch --with-arch-32=i586 --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 model: posix
gcc version 4.9.2 (Debian 4.9.2-10)

[Bug target/68228] __builtin_ia32_pbroadcastd256 generates wrong insn at >= -O1

2015-11-05 Thread mirq-gccboogs at rere dot qmqm.pl
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68228

--- Comment #1 from Micha³ Miros³aw  ---
Created attachment 36657
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=36657=edit
gcc assembler output for -O1

[Bug target/68228] __builtin_ia32_pbroadcastd256 generates wrong insn at >= -O1

2015-11-05 Thread mirq-gccboogs at rere dot qmqm.pl
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68228

--- Comment #2 from Micha³ Miros³aw  ---
Created attachment 36658
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=36658=edit
gcc assembler output for -O0