[Bug c++/94932] New: ICE in ovl_skip_hidden, at cp/tree.c:2292

2020-05-02 Thread asolokha at gmx dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94932

Bug ID: 94932
   Summary: ICE in ovl_skip_hidden, at cp/tree.c:2292
   Product: gcc
   Version: 10.0
Status: UNCONFIRMED
  Keywords: ice-on-invalid-code
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: asolokha at gmx dot com
  Target Milestone: ---

gcc-10.1.0-RC20200430 ICEs when compiling the following testcase, extracted
from clang/testsuite/CXX/except/except.spec/p11-2a.cpp from the clang 10.0.0
test suite, w/ -std=c++2a:

namespace std {
  struct strong_ordering {
  };
}

namespace Synth {
  struct A {
friend bool operator==(A, A) noexcept;
friend bool operator<(A, A) noexcept;
  };
  struct B {
A a;
friend std::strong_ordering operator<=>(B, B) = default;
  };
  std::strong_ordering operator<=>(B, B) noexcept;
}

% g++-10.1.0 -std=c++2a -c xwwacly6.cpp
xwwacly6.cpp: In function 'constexpr std::strong_ordering
Synth::operator<=>(Synth::B, Synth::B)':
xwwacly6.cpp:13:33: internal compiler error: in ovl_skip_hidden, at
cp/tree.c:2292
   13 | friend std::strong_ordering operator<=>(B, B) = default;
  | ^~~~
0x686390 ovl_skip_hidden(tree_node*)
   
/var/tmp/portage/sys-devel/gcc-10.1.0_rc20200430/work/gcc-10.1.0-RC-20200430/gcc/cp/tree.c:2292
0x96f343 name_lookup::process_binding(tree_node*, tree_node*)
   
/var/tmp/portage/sys-devel/gcc-10.1.0_rc20200430/work/gcc-10.1.0-RC-20200430/gcc/cp/name-lookup.c:497
0x97600b name_lookup::search_unqualified(tree_node*, cp_binding_level*)
   
/var/tmp/portage/sys-devel/gcc-10.1.0_rc20200430/work/gcc-10.1.0-RC-20200430/gcc/cp/name-lookup.c:705
0x977f1c lookup_name_real_1
   
/var/tmp/portage/sys-devel/gcc-10.1.0_rc20200430/work/gcc-10.1.0-RC-20200430/gcc/cp/name-lookup.c:6555
0x9780f6 lookup_name_real(tree_node*, int, int, bool, int, int)
   
/var/tmp/portage/sys-devel/gcc-10.1.0_rc20200430/work/gcc-10.1.0-RC-20200430/gcc/cp/name-lookup.c:6574
0x8746a6 add_operator_candidates
   
/var/tmp/portage/sys-devel/gcc-10.1.0_rc20200430/work/gcc-10.1.0-RC-20200430/gcc/cp/call.c:5955
0x87b68e build_new_op_1
   
/var/tmp/portage/sys-devel/gcc-10.1.0_rc20200430/work/gcc-10.1.0-RC-20200430/gcc/cp/call.c:6180
0x87c2ed build_new_op(op_location_t const&, tree_code, int, tree_node*,
tree_node*, tree_node*, tree_node**, int)
   
/var/tmp/portage/sys-devel/gcc-10.1.0_rc20200430/work/gcc-10.1.0-RC-20200430/gcc/cp/call.c:6570
0x963d2e build_comparison_op
   
/var/tmp/portage/sys-devel/gcc-10.1.0_rc20200430/work/gcc-10.1.0-RC-20200430/gcc/cp/method.c:1373
0x9652d9 synthesize_method(tree_node*)
   
/var/tmp/portage/sys-devel/gcc-10.1.0_rc20200430/work/gcc-10.1.0-RC-20200430/gcc/cp/method.c:1550
0xa02bca maybe_instantiate_noexcept(tree_node*, int)
   
/var/tmp/portage/sys-devel/gcc-10.1.0_rc20200430/work/gcc-10.1.0-RC-20200430/gcc/cp/pt.c:25189
0x8e9469 check_redeclaration_exception_specification
   
/var/tmp/portage/sys-devel/gcc-10.1.0_rc20200430/work/gcc-10.1.0-RC-20200430/gcc/cp/decl.c:1184
0x8fd259 duplicate_decls(tree_node*, tree_node*, bool)
   
/var/tmp/portage/sys-devel/gcc-10.1.0_rc20200430/work/gcc-10.1.0-RC-20200430/gcc/cp/decl.c:2202
0x979360 do_pushdecl
   
/var/tmp/portage/sys-devel/gcc-10.1.0_rc20200430/work/gcc-10.1.0-RC-20200430/gcc/cp/name-lookup.c:3048
0x97c1c2 pushdecl(tree_node*, bool)
   
/var/tmp/portage/sys-devel/gcc-10.1.0_rc20200430/work/gcc-10.1.0-RC-20200430/gcc/cp/name-lookup.c:3177
0x97c1c2 maybe_push_decl(tree_node*)
   
/var/tmp/portage/sys-devel/gcc-10.1.0_rc20200430/work/gcc-10.1.0-RC-20200430/gcc/cp/name-lookup.c:3208
0x90e151 start_decl(cp_declarator const*, cp_decl_specifier_seq*, int,
tree_node*, tree_node*, tree_node**)
   
/var/tmp/portage/sys-devel/gcc-10.1.0_rc20200430/work/gcc-10.1.0-RC-20200430/gcc/cp/decl.c:5400
0x9be161 cp_parser_init_declarator
   
/var/tmp/portage/sys-devel/gcc-10.1.0_rc20200430/work/gcc-10.1.0-RC-20200430/gcc/cp/parser.c:20766
0x99e906 cp_parser_simple_declaration
   
/var/tmp/portage/sys-devel/gcc-10.1.0_rc20200430/work/gcc-10.1.0-RC-20200430/gcc/cp/parser.c:13734
0x9c8ff2 cp_parser_declaration
   
/var/tmp/portage/sys-devel/gcc-10.1.0_rc20200430/work/gcc-10.1.0-RC-20200430/gcc/cp/parser.c:13433

[Bug fortran/94931] New: request: print include path

2020-05-02 Thread ryofurue at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94931

Bug ID: 94931
   Summary: request: print include path
   Product: gcc
   Version: unknown
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: fortran
  Assignee: unassigned at gcc dot gnu.org
  Reporter: ryofurue at gmail dot com
  Target Milestone: ---

I'm not familiar with this bug tracker. I mean to submit a request, not a bug
report.

Sorry if I missed anything, but it seems to me that there is no (official) way
to print the list of paths which gfortran searches for include files. If that
is correct, my request would be to provide a means to print the paths.

The `--print-search-dirs` option indicates paths only for the installation,
executables, and libraries (It seems to me).

This discussion applies to the INCLUDE statement of the Fortran language, not
the `#include` directive of the preprocessor.

Off-topic: I wonder if there is a discussion available online about why
/usr/include or something like that is not searched by default? Is there a
common (more or less standard) place for gfortran to search?

[Bug c++/94922] Functional cast from base class to derived class incorrectly accepted with -std=c++2a

2020-05-02 Thread ppalka at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94922

Patrick Palka  changed:

   What|Removed |Added

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

--- Comment #3 from Patrick Palka  ---
Upon closer investigation I think we're correct to accept these testcases.  As
I understand it the construction 'Derived(Base())' is valid in C++20 as a
direct consequence of C++17's aggregate init of classes with base classes
(P0017R1) in conjunction with C++20's parenthesized init of aggregates
(P0960R3).

Thus closing this bug as invalid, sorry for the noise.

[Bug tree-optimization/94930] New: Failure to optimize out subvsi in expansion of __builtin_memcmp with 1 as the operand with -ftrapv

2020-05-02 Thread gabravier at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94930

Bug ID: 94930
   Summary: Failure to optimize out subvsi in expansion of
__builtin_memcmp with 1 as the operand with -ftrapv
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: gabravier at gmail dot com
  Target Milestone: ---

int memcmp1(const void *s, const void *c)
{
return __builtin_memcmp(s, c, 1);
}

With -O3 -ftrapv, LLVM outputs this :

memcmp1(void const*, void const*): # @memcmp1(void const*, void const*)
  movzx eax, byte ptr [rdi]
  movzx ecx, byte ptr [rsi]
  sub eax, ecx
  ret

GCC outputs this :

memcmp1(void const*, void const*):
  sub rsp, 8
  movzx edi, BYTE PTR [rdi]
  movzx esi, BYTE PTR [rsi]
  call __subvsi3
  add rsp, 8
  ret

[Bug c++/94923] False positive -Wclass-memaccess with trivially copyable std::optional

2020-05-02 Thread msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94923

Martin Sebor  changed:

   What|Removed |Added

  Known to fail||10.0, 8.4.0, 9.3.0
   Assignee|unassigned at gcc dot gnu.org  |msebor at gcc dot 
gnu.org
 Status|NEW |ASSIGNED

[Bug c++/94929] New: GCC 8 chokes on std::max in alignas

2020-05-02 Thread soap at gentoo dot org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94929

Bug ID: 94929
   Summary: GCC 8 chokes on std::max in alignas
   Product: gcc
   Version: 8.4.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: soap at gentoo dot org
  Target Milestone: ---

The following snippet

  #include 

  struct One {};
  struct Two {};
  struct Foo { alignas(std::max(alignof(One), alignof(Two))) char value; };

compiles fine in GCC 9.3, but in GCC 8.4 fails with

test.cpp:5:65: error: requested alignment is not an integer constant
 struct Foo { alignas(std::max(alignof(One), alignof(Two))) char value; };
 ^

[Bug c++/94923] False positive -Wclass-memaccess with trivially copyable std::optional

2020-05-02 Thread msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94923

Martin Sebor  changed:

   What|Removed |Added

   Keywords||diagnostic
 Status|UNCONFIRMED |NEW
   Last reconfirmed||2020-05-02
 Ever confirmed|0   |1
 CC||msebor at gcc dot gnu.org

--- Comment #3 from Martin Sebor  ---
The warning code treats character types as special in this context but there's
no such handling for std::byte.  It probably makes sense to extend the same
treatment to it.

[Bug gcov-profile/94928] New: Doc comments in gcov-io.h do not show cwd and unexec blocks in the Notes file format

2020-05-02 Thread myron.walker at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94928

Bug ID: 94928
   Summary: Doc comments in gcov-io.h do not show cwd and unexec
blocks in the Notes file format
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: gcov-profile
  Assignee: unassigned at gcc dot gnu.org
  Reporter: myron.walker at gmail dot com
CC: marxin at gcc dot gnu.org
  Target Milestone: ---

The documentation of the notes file format below do not show the cwd or
unexec_blocks data items.

note: unit function-graph*
unit: header int32:checksum string:source
function-graph: announce_function basic_blocks {arcs | lines}*
announce_function: header int32:ident
int32:lineno_checksum int32:cfg_checksum
string:name string:source int32:start_lineno int32:start_column 
int32:end_lineno
basic_block: header int32:flags*
arcs: header int32:block_no arc*
arc:  int32:dest_block int32:flags
lines: header int32:block_no line*
   int32:0 string:NULL
line:  int32:line_no | int32:0 string:filename


When you look at the gcov.c file, you can see that at the beginning of the
notes file right after the stamp, there is an item for cwd and unexec blocks.

  bbg_stamp = gcov_read_unsigned();
  bbg_cwd = xstrdup(gcov_read_string()); < Not documented
  bbg_supports_has_unexecuted_blocks = gcov_read_unsigned();   << Not
documented


There also is a missing int32:artificial that should be between the function
name and function source file.

  function_name = xstrdup(gcov_read_string());
  unsigned artificial = gcov_read_unsigned();   Not documented
  unsigned src_idx = find_source(gcov_read_string());

[Bug c++/94912] Non-consistent behaviour of VLAs in C++ mode compared to C

2020-05-02 Thread msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94912

Martin Sebor  changed:

   What|Removed |Added

 Resolution|--- |DUPLICATE
 Status|UNCONFIRMED |RESOLVED
 CC||msebor at gcc dot gnu.org

--- Comment #1 from Martin Sebor  ---
I think this is the same bug as reported in pr68531.

*** This bug has been marked as a duplicate of bug 68531 ***

[Bug c++/68531] changing bound variable of a VLA type changes type size

2020-05-02 Thread msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68531

Martin Sebor  changed:

   What|Removed |Added

 CC||gabravier at gmail dot com

--- Comment #3 from Martin Sebor  ---
*** Bug 94912 has been marked as a duplicate of this bug. ***

[Bug rtl-optimization/94927] New: cortex-m7: Incorrect insn_reservation for vmaxnm/vminnm instructions

2020-05-02 Thread stas.ibragimov at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94927

Bug ID: 94927
   Summary: cortex-m7: Incorrect insn_reservation for
vmaxnm/vminnm instructions
   Product: gcc
   Version: 7.3.1
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: rtl-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: stas.ibragimov at gmail dot com
  Target Milestone: ---

There is no any pipeline usage description for vmaxnm and vminnm instructions
in cortex-m7.md. This instruction is described as smax3 and smin3
in vfp.md and has type f_minmax. But in cortex-m7.md there is not any
insn_reservations for this type. 

So, pipeline usage for code with this instructions is calculated wrong. 
For example:
//test.c
#include 
float test(int a, int b) {
float max = fmaxf(a,b);
float min = fminf(a,b);
float x=min+1;
return max/min-x;
}

Compile:
arm-none-eabi-gcc test.c -c -da -O3 -mcpu=cortex-m7 -mfpu=fpv5-d16
-mfloat-abi=hard -mthumb -ffinite-math-only -fno-signed-zeros -save-temps

test.c.293r.sched2 (wrong places is marked with (!!)):

;;0--> b  0: i  24 s15=r0 
:cm7_i0|cm7_i1,cm7_a0|cm7_a1
;;0--> b  0: i  12 s12=1.0e+0 
:cm7_i0|cm7_i1,cm7_fpu
;;2--> b  0: i   7 s14=flt(s15)   
:cm7_i0|cm7_i1,cm7_fpu
;;2--> b  0: i  25 s15=r1 
:cm7_i0|cm7_i1,cm7_a0|cm7_a1
;;4--> b  0: i   8 s13=flt(s15)   
:cm7_i0|cm7_i1,cm7_fpu
;;7--> b  0: i   9 s15=smin(s14,s13)   :nothing
(!!)
;;7--> b  0: i  10 s14=smax(s14,s13)   :nothing
(!!)
;;8--> b  0: i  11 s0=s14/s15 
:cm7_i0|cm7_i1,cm7_fpu*5
;;   13--> b  0: i  13 s15=s15+s12
:cm7_i0|cm7_i1,cm7_fpu
;;   24--> b  0: i  19 s0=s0-s15  
:cm7_i0|cm7_i1,cm7_fpu
;;   24--> b  0: i  20 use s0  :nothing
;;   24--> b  0: i  28 simple_return  
:cm7_i0|cm7_i1,cm7_branch

[Bug c++/94926] New: [9 regression] invalid use of incomplete type not recogniced for static self reference of templated struct

2020-05-02 Thread max.kan...@nu-cost.com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94926

Bug ID: 94926
   Summary: [9 regression] invalid use of incomplete type not
recogniced for static self reference of templated
struct
   Product: gcc
   Version: 9.1.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: max.kan...@nu-cost.com
  Target Milestone: ---

The following illegal code, correctly rejected by GCC 8.3, compiles from GCC
9.1 onwards (only checking compiler version available on Compiler Explorer),
see https://godbolt.org/z/rfD8sF


template
struct A {
static auto self_reference = A{};
};

int main() {
A{};
}


When specifying the injected class name or removing all templates, the code is
rejected as expected.

[Bug fortran/94788] [8/9 Regression] Severe regression leading to double free in tcache

2020-05-02 Thread cvs-commit at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94788

--- Comment #44 from CVS Commits  ---
The master branch has been updated by H.J. Lu :

https://gcc.gnu.org/g:6abe1c3084798d3e5f32926c352643e557073e01

commit r11-27-g6abe1c3084798d3e5f32926c352643e557073e01
Author: H.J. Lu 
Date:   Sat May 2 12:46:44 2020 -0700

gfortran: Get asan library from TEST_ALWAYS_FLAGS

Update gfortran_target_compile to get the newly built asan library from
TEST_ALWAYS_FLAGS to avoid:

/usr/bin/ld: cannot find libasan_preinit.o: No such file or directory
/usr/bin/ld: cannot find -lasan
collect2: error: ld returned 1 exit status
compiler exited with status 1
FAIL: gfortran.dg/asan/pointer_assign_16.f90 -fsanitize=address  -O0  (test
for excess errors)

PR fortran/94788
* lib/gfortran.exp (gfortran_target_compile): Get asan library
from TEST_ALWAYS_FLAGS.

[Bug bootstrap/94918] Ada bootstrap errors on Cygwin64

2020-05-02 Thread mikpelinux at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94918

Mikael Pettersson  changed:

   What|Removed |Added

  Known to fail||10.0, 8.4.0, 9.3.0

--- Comment #1 from Mikael Pettersson  ---
The first two problems also affect gcc-9 and gcc-8.

[Bug translation/93861] typo in warning: %qs is not valid for %

2020-05-02 Thread iains at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93861

Iain Sandoe  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |FIXED

--- Comment #2 from Iain Sandoe  ---
thus, fixed, thanks for the report!

[Bug translation/93861] typo in warning: %qs is not valid for %

2020-05-02 Thread cvs-commit at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93861

--- Comment #1 from CVS Commits  ---
The master branch has been updated by Iain D Sandoe :

https://gcc.gnu.org/g:7df457899078c5889194c1736cffcfd4d50f5305

commit r11-26-g7df457899078c5889194c1736cffcfd4d50f5305
Author: Iain Sandoe 
Date:   Sat May 2 19:20:02 2020 +0100

Darwin: Fix a diagnostic spelling [PR93861]

Add a missing '-' to a diagnostic.

gcc/ChangeLog:

2020-05-02  Iain Sandoe  

PR translation/93861
* config/darwin-driver.c (darwin_driver_init): Adjust spelling in
a warning.

[Bug translation/93861] typo in warning: %qs is not valid for %

2020-05-02 Thread iains at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93861

Iain Sandoe  changed:

   What|Removed |Added

 Target||*-darwin*
 Status|UNCONFIRMED |NEW
 Ever confirmed|0   |1
   Target Milestone|--- |11.0
   Last reconfirmed||2020-05-02

[Bug fortran/94925] New: Undesired runtime warning message

2020-05-02 Thread siteg at mathalacarte dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94925

Bug ID: 94925
   Summary: Undesired runtime warning message
   Product: gcc
   Version: 10.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: fortran
  Assignee: unassigned at gcc dot gnu.org
  Reporter: siteg at mathalacarte dot com
  Target Milestone: ---

Just upgraded to GNU Fortran (GCC) 10.0.1 20200328 (Red Hat 10.0.1-0.11), and
am getting this warning at runtime:
"Fortran runtime warning: An array temporary was created"
This did not happen in the past.  I have tried adding the flags
-fcheck=no-array-temps -Wno-array-temporaries
to no effect.  These occur in a large program where these temporary arrays are
used for debugging information that would not be used in production.  I have
not managed to create a small program that illustrates the problem.  I'm hoping
that the fact that this problem occurred between the 9.3.1 compiler and the
current one may help in getting it tracked down.

[Bug c++/94923] False positive -Wclass-memaccess with trivially copyable std::optional

2020-05-02 Thread dawid_jurek at vp dot pl
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94923

--- Comment #2 from dawid_jurek at vp dot pl ---
Yeah, that's the correct reproducer of issue I reported. 
I noticed missing bracket after pasting it from godbolt but unfortunately
couldn't edit my comment after posting.

[Bug c++/94923] False positive -Wclass-memaccess with trivially copyable std::optional

2020-05-02 Thread daniel.kruegler at googlemail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94923

Daniel Krügler  changed:

   What|Removed |Added

 CC||daniel.kruegler@googlemail.
   ||com

--- Comment #1 from Daniel Krügler  ---
Corrected code without typos and including the necessary header files:

```
#include 
#include 
#include 
#include 

static_assert(std::is_trivially_copyable_v>);

void not_ok() {
  std::optional value;
  std::byte buf[128];
  std::memcpy(&buf[0], &value, sizeof value);
  std::memcpy(&value, &buf[0], sizeof value);
}

int main() {}
```

[Bug fortran/94788] [8/9 Regression] Severe regression leading to double free in tcache

2020-05-02 Thread cvs-commit at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94788

--- Comment #43 from CVS Commits  ---
The master branch has been updated by Thomas Kथà¤nig :

https://gcc.gnu.org/g:116784bbde9ed391393320d936ae2fff37442779

commit r11-25-g116784bbde9ed391393320d936ae2fff37442779
Author: Thomas Koenig 
Date:   Sat May 2 17:30:01 2020 +0200

Add asan subdirectory for gfortran.dg.

Because the test case for PR 94788 requires -fsanitize=address to expose
the double free, I have created a subdirectory under gfortran.dg
where such test cases can go.

I have tested this with

make check-fortran RUNTESTFLAGS="asan.exp=*"

and it works; with a compiler that introduces the double free bug
into the test case, the result is as expected

2020-05-02  Thomas Koenig  

PR fortran/94788
* gfortran.dg/asan: New directory.
* gfortran.dg/asan/asan.exp: New file.
* gfortran.dg/asan/pointer_assign_16.f90: New test case.

[Bug middle-end/61577] [4.9.0 Regression] can't compile on hp-ux v3 ia64

2020-05-02 Thread dave.anglin at bell dot net
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61577

--- Comment #210 from dave.anglin at bell dot net ---
On 2020-05-02 12:14 a.m., peter.bisroev at groundlabs dot com wrote:
> Looks like we might have to get the fix into GNU AS first to get PCREL60B
> working. I will try to look into how we can get this done hopefully next
> weekend.
I agree.

[Bug c++/94924] New: Default equality operator for C-array compares addresses, not data

2020-05-02 Thread rhalbersma at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94924

Bug ID: 94924
   Summary: Default equality operator for C-array compares
addresses, not data
   Product: gcc
   Version: 10.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: rhalbersma at gmail dot com
  Target Milestone: ---

It appears that the default op== for a C-array has array-to-pointer decay
applied and does not compare the underlying array data.

struct S {
int data[1];
bool operator==(const S&) const = default;
};

int main()
{
static_assert(S{1} != S{1});
constexpr auto s = S{1};
static_assert(s == s);
}

Tested on tip-of-trunk at Wandbox:
https://wandbox.org/permlink/YxUv5dFs7mSGlNBx

Works correctly on Clang >= 10.

[Bug c++/94923] New: False positive -Wclass-memaccess with trivially copyable std::optional

2020-05-02 Thread dawid_jurek at vp dot pl
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94923

Bug ID: 94923
   Summary: False positive -Wclass-memaccess with trivially
copyable std::optional
   Product: gcc
   Version: 9.3.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: dawid_jurek at vp dot pl
  Target Milestone: ---

Consider following C++ snippet:

static_assert(std::is_trivially_copyable_v>);
static void not_ok() {
  std::optional value;
  std::byte buf[128;
  std::memcpy(&buf[0], &value, sizeof value);
  std::memcpy(&value, &buf[0], sizeof value);
}

With above snippet fresh x86-64 gcc trunk reports following warning:

source>: In function 'void not_ok()':

:27:46: warning: 'void* memcpy(void*, const void*, size_t)' copying an
object of non-trivial type 'class std::optional' from an array of 'enum
class std::byte' [-Wclass-memaccess]

   27 | std::memcpy(&value, &buf[0], sizeof value);

[basic.types]/2 explicitly permits for such round trip for every trivially
copyable T via std::memcpy even if T is not trivial.
Also clang accept such code without complains (take a look at link below).
Changing std::byte buf[128; to char buf[128]; suppress the warning so seems
that std::byte is relevant.
You can find full source code here https://godbolt.org/z/JrcnS5

Regards,
Dawid

[Bug tree-optimization/94921] Failure to optimize nots with sub into single add

2020-05-02 Thread glisse at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94921

--- Comment #1 from Marc Glisse  ---
x + y ?

[Bug c++/94922] Functional cast from base class to derived class incorrectly accepted with -std=c++2a

2020-05-02 Thread ppalka at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94922

--- Comment #2 from Patrick Palka  ---
Another testcase that exhibits the 10/11 regression:

struct base {};
struct derived : base {};

void
foo()
{
  derived a = derived(base());
}

[Bug c++/94922] Functional cast from base class to derived class incorrectly accepted with -std=c++2a

2020-05-02 Thread ppalka at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94922

--- Comment #1 from Patrick Palka  ---
The above appears to be a 10/11 regression, but note that all versions of GCC
>= 4.7 also incorrectly accept the following testcase:

struct base {};
struct derived : base {};

template 
void foo();

void
bar()
{
  foo();
}

[Bug c++/94922] New: Functional cast from base class to derived class incorrectly accepted with -std=c++2a

2020-05-02 Thread ppalka at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94922

Bug ID: 94922
   Summary: Functional cast from base class to derived class
incorrectly accepted with -std=c++2a
   Product: gcc
   Version: 10.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: ppalka at gcc dot gnu.org
  Target Milestone: ---

$ cat testcase.C
struct base {};
struct derived : base {};

template 
void foo();

void
bar()
{
  foo();
}

$ g++-10 -std=c++2a testcase.C
$ g++-10 -std=c++17 testcase.C
testcase.C: In function ‘void bar()’:
testcase.C:10:22: error: no matching function for call to ‘foo()’
   13 |   foo();
  |  ^
...

[Bug tree-optimization/94921] New: Failure to optimize nots with sub into single add

2020-05-02 Thread gabravier at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94921

Bug ID: 94921
   Summary: Failure to optimize nots with sub into single add
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: gabravier at gmail dot com
  Target Milestone: ---

int f(int x, int y)
{
return ~(~x - y);
}

This can be optimized to `x - y`. This transformation is done by LLVM, but not
by GCC

[Bug fortran/83118] [8/9/10/11 Regression] Bad intrinsic assignment of class(*) array component of derived type

2020-05-02 Thread pault at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83118

--- Comment #34 from Paul Thomas  ---
(In reply to Rainer Orth from comment #33)
> What's going to happen with the fix?  It works for me on
> sparc-sun-solaris2.11
> and obviously several other targets.  This has been open for months now with
> a
> known fix, and it seems we're going to release GCC 10.1 with this bug.

Hi Rainer,

Tobias commented on it (see comment #30), I went in pursuit and then ran into
an intensely busy spell of daytime work.

I am sorry that the patch will miss the 10.1.0 release but there is nothing
that I can do about it now.


Paul

[Bug tree-optimization/94919] Failure to recognize max pattern

2020-05-02 Thread glisse at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94919

--- Comment #1 from Marc Glisse  ---
This seems related to another one you reported, in the category: i&-b == b?i:0
(for b∈{0,1}). The first form has the advantage of no branch, while the second
is less obfuscated and simplifies more naturally (like when we combine x<0||y<0
to (x|y)<0 we get something shorter, but more obfuscated which can hinder other
optimizations). Here this equivalence gives the intermediate step of
(x>=y?x^y:0)^y.

I didn't see if you posted it somewhere, but I assume those tests come from the
llvm testsuite? Did people really hit such weird code in the wild and add them
one by one to llvm? Or was there some automated process involved ? I could
imagine looking at all the expressions of a certain size using some list of
operators and only 2 variables (and maybe a few constants), compute the table
of values for a small type (a 3-bit integer?), put them in a hash table, and
study collisions? Generating completely automatically the list of
transformations may be a bit hard though. And handling undefined cases (like
signed overflow) complicates things, since we are not looking for exact matches
there.

[Bug tree-optimization/94920] New: Failure to optimize abs pattern from arithmetic with selected operands based on comparisons with 0

2020-05-02 Thread gabravier at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94920

Bug ID: 94920
   Summary: Failure to optimize abs pattern from arithmetic with
selected operands based on comparisons with 0
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: gabravier at gmail dot com
  Target Milestone: ---

unsigned f(int x)
{
return (x >= 0 ? x : 0) + (x <= 0 ? -x : 0);
}

This can be optimized to `return abs(x)`. LLVM does this transformation, but
GCC does not.

[Bug tree-optimization/94919] New: Failure to recognize max pattern

2020-05-02 Thread gabravier at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94919

Bug ID: 94919
   Summary: Failure to recognize max pattern
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: gabravier at gmail dot com
  Target Milestone: ---

int f(int x, int y)
{
return ((x ^ y) & -(x >= y)) ^ y;
}

This can be optimized to `x >= y ? x : y`. LLVM makes this transformation, but
GCC does not.

[Bug bootstrap/94918] New: Ada bootstrap errors on Cygwin64

2020-05-02 Thread mikpelinux at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94918

Bug ID: 94918
   Summary: Ada bootstrap errors on Cygwin64
   Product: gcc
   Version: 10.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: bootstrap
  Assignee: unassigned at gcc dot gnu.org
  Reporter: mikpelinux at gmail dot com
  Target Milestone: ---

Attempting to bootstrap gcc-10.1.0-RC-20200430 with Ada on Cygwin64
fails with several errors.

The first is:

g++ -std=gnu++98 -fno-PIE -c  -DIN_GCC_FRONTEND -g -DIN_GCC -fno-exceptions
-fno-rtti -fasynchronous-unwind-tables -W -Wall -Wno-narrowing -Wwrite-strings
-Wcast-qual -Wno-format  -Wmissing-format-attribute -Woverloaded-virtual
-Wno-long-long -Wno-variadic-macros -Wno-overlength-strings  -Wno-error
-DHAVE_CONFIG_H -I. -Iada -I/tmp/gcc-10.1.0-RC-20200430/gcc
-I/tmp/gcc-10.1.0-RC-20200430/gcc/ada
-I/tmp/gcc-10.1.0-RC-20200430/gcc/../include
-I/tmp/gcc-10.1.0-RC-20200430/gcc/../libcpp/include
-I/home/mikpe/pkgs/cygwin-x86_64/gmp-6.2.0/include
-I/home/mikpe/pkgs/cygwin-x86_64/mpfr-4.0.2/include
-I/home/mikpe/pkgs/cygwin-x86_64/mpc-1.1.0/include 
-I/tmp/gcc-10.1.0-RC-20200430/gcc/../libdecnumber
-I/tmp/gcc-10.1.0-RC-20200430/gcc/../libdecnumber/bid -I../libdecnumber
-I/tmp/gcc-10.1.0-RC-20200430/gcc/../libbacktrace   -o ada/adaint.o -MT
ada/adaint.o -MMD -MP -MF ada/.deps/adaint.TPo
/tmp/gcc-10.1.0-RC-20200430/gcc/ada/adaint.c
In file included from
/home/mikpe/pkgs/cygwin-x86_64/gcc-9.3.1/lib/gcc/x86_64-pc-cygwin/9.3.1/include/xmmintrin.h:34,
 from
/home/mikpe/pkgs/cygwin-x86_64/gcc-9.3.1/lib/gcc/x86_64-pc-cygwin/9.3.1/include/emmintrin.h:31,
 from /usr/include/w32api/winnt.h:1558,
 from /usr/include/w32api/minwindef.h:163,
 from /usr/include/w32api/windef.h:8,
 from /usr/include/w32api/windows.h:69,
 from /tmp/gcc-10.1.0-RC-20200430/gcc/ada/mingw32.h:60,
 from /tmp/gcc-10.1.0-RC-20200430/gcc/ada/adaint.c:164:
/home/mikpe/pkgs/cygwin-x86_64/gcc-9.3.1/lib/gcc/x86_64-pc-cygwin/9.3.1/include/mm_malloc.h:53:18:
error: attempt to use poisoned "malloc"
   53 |   __malloc_ptr = malloc (__size + __align);
  |  ^
/tmp/gcc-10.1.0-RC-20200430/gcc/ada/adaint.c: In function 'int
__gnat_open_new_temp(char*, int)':
/tmp/gcc-10.1.0-RC-20200430/gcc/ada/adaint.c:1064:19: warning: 'char*
mktemp(char*)' is deprecated: the use of `mktemp' is dangerous; use `mkstemp'
instead [-Wdeprecated-declarations]
 1064 |   if (mktemp (path) == NULL)
  |   ^
In file included from /tmp/gcc-10.1.0-RC-20200430/gcc/ada/adaint.c:237:
/tmp/gcc-10.1.0-RC-20200430/gcc/ada/adaint.h:280:15: note: declared here
  280 | extern char  *mktemp   (char *);
  |   ^~
/tmp/gcc-10.1.0-RC-20200430/gcc/ada/adaint.c:1064:19: warning: 'char*
mktemp(char*)' is deprecated: the use of `mktemp' is dangerous; use `mkstemp'
instead [-Wdeprecated-declarations]
 1064 |   if (mktemp (path) == NULL)
  |   ^
In file included from /tmp/gcc-10.1.0-RC-20200430/gcc/ada/adaint.c:237:
/tmp/gcc-10.1.0-RC-20200430/gcc/ada/adaint.h:280:15: note: declared here
  280 | extern char  *mktemp   (char *);
  |   ^~
make[3]: *** [Makefile:1117: ada/adaint.o] Error 1
make[3]: Leaving directory '/tmp/objdir/gcc'
make[2]: *** [Makefile:4741: all-stage1-gcc] Error 2
make[2]: Leaving directory '/tmp/objdir'
make[1]: *** [Makefile:20804: stage1-bubble] Error 2
make[1]: Leaving directory '/tmp/objdir'
make: *** [Makefile:21125: bootstrap] Error 2

mingw32.h has this at line 60:

 /* Note: windows.h on cygwin-64 includes x86intrin.h which uses malloc.
That fails to compile, if malloc is poisoned, i.e. if !IN_RTS.  */
 #define _X86INTRIN_H_INCLUDED
 #endif
 #include 

 now also drags in , so the fix is to add:

  #define _EMMINTRIN_H_INCLUDED

The second error is:

g++ -std=gnu++98 -fno-PIE -c  -I/tmp/gcc-10.1.0-RC-20200430/gcc/../libgcc
-DEH_MECHANISM_gcc -DIN_GCC_FRONTEND -g -DIN_GCC -fno-exceptions -fno-rtti
-fasynchronous-unwind-tables -W -Wall -Wno-narrowing -Wwrite-strings
-Wcast-qual -Wno-format  -Wmissing-format-attribute -Woverloaded-virtual
-Wno-long-long -Wno-variadic-macros -Wno-overlength-strings   -DHAVE_CONFIG_H
-I. -Iada -I/tmp/gcc-10.1.0-RC-20200430/gcc
-I/tmp/gcc-10.1.0-RC-20200430/gcc/ada
-I/tmp/gcc-10.1.0-RC-20200430/gcc/../include
-I/tmp/gcc-10.1.0-RC-20200430/gcc/../libcpp/include
-I/home/mikpe/pkgs/cygwin-x86_64/gmp-6.2.0/include
-I/home/mikpe/pkgs/cygwin-x86_64/mpfr-4.0.2/include
-I/home/mikpe/pkgs/cygwin-x86_64/mpc-1.1.0/include 
-I/tmp/gcc-10.1.0-RC-20200430/gcc/../libdecnumber
-I/tmp/gcc-10.1.0-RC-20200430/gcc/../libdecnumber/bid -I../libdecnumber
-I/tmp/gcc-10.1.0-RC-20200430/gcc/../libbacktrace   -o ada/raise-gcc.o -MT
ada/raise-gcc.o -MMD -MP -MF ada/.deps/raise-gcc.TPo
/tmp/gcc-10.1.0-RC-20200430/gcc/ada/raise-gcc.c
In file includ

[Bug fortran/93114] Use span passing components of derived types

2020-05-02 Thread tkoenig at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93114

--- Comment #2 from Thomas Koenig  ---
Created attachment 48430
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=48430&action=edit
Preliminary partial patch

Here is a very preliminary implementation, which only looks at
the return values of maxloc et al.

If we look at the arguments too, this will be much larger...

[Bug bootstrap/94917] Ada bootstrap errors on Cygwin64

2020-05-02 Thread mikpelinux at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94917

Mikael Pettersson  changed:

   What|Removed |Added

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

--- Comment #1 from Mikael Pettersson  ---
Sorry, copy-paste error in the description, and I can't seem to edit it, so
rejecting and opening a new one.

[Bug bootstrap/94917] New: Ada bootstrap errors on Cygwin64

2020-05-02 Thread mikpelinux at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94917

Bug ID: 94917
   Summary: Ada bootstrap errors on Cygwin64
   Product: gcc
   Version: 10.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: bootstrap
  Assignee: unassigned at gcc dot gnu.org
  Reporter: mikpelinux at gmail dot com
  Target Milestone: ---

Attempting to bootstrap gcc-10.1.0-RC-20200430 with Ada on Cygwin64
fails with several errors.

The first is:

g++ -std=gnu++98 -fno-PIE -c  -DIN_GCC_FRONTEND -g -DIN_GCC -fno-exceptions
-fno-rtti -fasynchronous-unwind-tables -W -Wall -Wno-narrowing -Wwrite-strings
-Wcast-qual -Wno-format  -Wmissing-format-attribute -Woverloaded-virtual
-Wno-long-long -Wno-variadic-macros -Wno-overlength-strings  -Wno-error
-DHAVE_CONFIG_H -I. -Iada -I/tmp/gcc-10.1.0-RC-20200430/gcc
-I/tmp/gcc-10.1.0-RC-20200430/gcc/ada
-I/tmp/gcc-10.1.0-RC-20200430/gcc/../include
-I/tmp/gcc-10.1.0-RC-20200430/gcc/../libcpp/include
-I/home/mikpe/pkgs/cygwin-x86_64/gmp-6.2.0/include
-I/home/mikpe/pkgs/cygwin-x86_64/mpfr-4.0.2/include
-I/home/mikpe/pkgs/cygwin-x86_64/mpc-1.1.0/include 
-I/tmp/gcc-10.1.0-RC-20200430/gcc/../libdecnumber
-I/tmp/gcc-10.1.0-RC-20200430/gcc/../libdecnumber/bid -I../libdecnumber
-I/tmp/gcc-10.1.0-RC-20200430/gcc/../libbacktrace   -o ada/adaint.o -MT
ada/adaint.o -MMD -MP -MF ada/.deps/adaint.TPo
/tmp/gcc-10.1.0-RC-20200430/gcc/ada/adaint.c
In file included from
/home/mikpe/pkgs/cygwin-x86_64/gcc-9.3.1/lib/gcc/x86_64-pc-cygwin/9.3.1/include/xmmintrin.h:34,
 from
/home/mikpe/pkgs/cygwin-x86_64/gcc-9.3.1/lib/gcc/x86_64-pc-cygwin/9.3.1/include/emmintrin.h:31,
 from /usr/include/w32api/winnt.h:1558,
 from /usr/include/w32api/minwindef.h:163,
 from /usr/include/w32api/windef.h:8,
 from /usr/include/w32api/windows.h:69,
 from /tmp/gcc-10.1.0-RC-20200430/gcc/ada/mingw32.h:60,
 from /tmp/gcc-10.1.0-RC-20200430/gcc/ada/adaint.c:164:
/home/mikpe/pkgs/cygwin-x86_64/gcc-9.3.1/lib/gcc/x86_64-pc-cygwin/9.3.1/include/mm_malloc.h:53:18:
error: attempt to use poisoned "malloc"
   53 |   __malloc_ptr = malloc (__size + __align);
  |  ^
/tmp/gcc-10.1.0-RC-20200430/gcc/ada/adaint.c: In function 'int
__gnat_open_new_temp(char*, int)':
/tmp/gcc-10.1.0-RC-20200430/gcc/ada/adaint.c:1064:19: warning: 'char*
mktemp(char*)' is deprecated: the use of `mktemp' is dangerous; use `mkstemp'
instead [-Wdeprecated-declarations]
 1064 |   if (mktemp (path) == NULL)
  |   ^
In file included from /tmp/gcc-10.1.0-RC-20200430/gcc/ada/adaint.c:237:
/tmp/gcc-10.1.0-RC-20200430/gcc/ada/adaint.h:280:15: note: declared here
  280 | extern char  *mktemp   (char *);
  |   ^~
/tmp/gcc-10.1.0-RC-20200430/gcc/ada/adaint.c:1064:19: warning: 'char*
mktemp(char*)' is deprecated: the use of `mktemp' is dangerous; use `mkstemp'
instead [-Wdeprecated-declarations]
 1064 |   if (mktemp (path) == NULL)
  |   ^
In file included from /tmp/gcc-10.1.0-RC-20200430/gcc/ada/adaint.c:237:
/tmp/gcc-10.1.0-RC-20200430/gcc/ada/adaint.h:280:15: note: declared here
  280 | extern char  *mktemp   (char *);
  |   ^~
make[3]: *** [Makefile:1117: ada/adaint.o] Error 1
make[3]: Leaving directory '/tmp/objdir/gcc'
make[2]: *** [Makefile:4741: all-stage1-gcc] Error 2
make[2]: Leaving directory '/tmp/objdir'
make[1]: *** [Makefile:20804: stage1-bubble] Error 2
make[1]: Leaving directory '/tmp/objdir'
make: *** [Makefile:21125: bootstrap] Error 2

mingw32.h has this at line 60:

 /* Note: windows.h on cygwin-64 includes x86intrin.h which uses malloc.
That fails to compile, if malloc is poisoned, i.e. if !IN_RTS.  */
 #define _X86INTRIN_H_INCLUDED
 #endif
 #include 

 now also drags in , so the fix is to add:

  #define _EMMINTRIN_H_INCLUDED

The second error is:

g++ -std=gnu++98 -fno-PIE -c  -I/tmp/gcc-10.1.0-RC-20200430/gcc/../libgcc
-DEH_MECHANISM_gcc -DIN_GCC_FRONTEND -g -DIN_GCC -fno-exceptions -fno-rtti
-fasynchronous-unwind-tables -W -Wall -Wno-narrowing -Wwrite-strings
-Wcast-qual -Wno-format  -Wmissing-format-attribute -Woverloaded-virtual
-Wno-long-long -Wno-variadic-macros -Wno-overlength-strings   -DHAVE_CONFIG_H
-I. -Iada -I/tmp/gcc-10.1.0-RC-20200430/gcc
-I/tmp/gcc-10.1.0-RC-20200430/gcc/ada
-I/tmp/gcc-10.1.0-RC-20200430/gcc/../include
-I/tmp/gcc-10.1.0-RC-20200430/gcc/../libcpp/include
-I/home/mikpe/pkgs/cygwin-x86_64/gmp-6.2.0/include
-I/home/mikpe/pkgs/cygwin-x86_64/mpfr-4.0.2/include
-I/home/mikpe/pkgs/cygwin-x86_64/mpc-1.1.0/include 
-I/tmp/gcc-10.1.0-RC-20200430/gcc/../libdecnumber
-I/tmp/gcc-10.1.0-RC-20200430/gcc/../libdecnumber/bid -I../libdecnumber
-I/tmp/gcc-10.1.0-RC-20200430/gcc/../libbacktrace   -o ada/raise-gcc.o -MT
ada/raise-gcc.o -MMD -MP -MF ada/.deps/raise-gcc.TPo
/tmp/gcc-10.1.0-RC-20200430/gcc/ada/raise-gcc.c
In file includ

[Bug tree-optimization/94916] New: Failure to optimize pattern into difference or zero selector

2020-05-02 Thread gabravier at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94916

Bug ID: 94916
   Summary: Failure to optimize pattern into difference or zero
selector
   Product: gcc
   Version: 10.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: gabravier at gmail dot com
  Target Milestone: ---

int f(int x, int y)
{
return (x - y) & -(x >= y);
}

This can be optimized to return x >= y ? x - y : 0. LLVM does this
transformation, but GCC does not. (also, GCC fails to optimize the resulting
pattern properly, but this is already reported in
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94898)

[Bug target/94915] New: MAX_EXPR weirdly optimized on x86 with -mtune=core2

2020-05-02 Thread gabravier at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94915

Bug ID: 94915
   Summary: MAX_EXPR weirdly optimized on x86 with -mtune=core2
   Product: gcc
   Version: 10.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: target
  Assignee: unassigned at gcc dot gnu.org
  Reporter: gabravier at gmail dot com
  Target Milestone: ---

int f(int x, int y)
{
return x > y ? x : y;
}

When compiling with -O3 -mtune=core2 -msse4.1, GCC outputs this :

f(int, int):
  movd xmm0, edi
  movd xmm1, esi
  pmaxsd xmm0, xmm1
  movd eax, xmm0
  ret

It would seem rather doubtful that this is the optimal solution for doing max
over a simple compare+cmov