public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/110508] New: ICE (Segfault) during widening_mul, in match_uaddc_usubc
@ 2023-06-30 21:48 ali.mpfard at gmail dot com
  2023-06-30 21:49 ` [Bug c++/110508] " ali.mpfard at gmail dot com
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: ali.mpfard at gmail dot com @ 2023-06-30 21:48 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110508

            Bug ID: 110508
           Summary: ICE (Segfault) during widening_mul, in
                    match_uaddc_usubc
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ali.mpfard at gmail dot com
  Target Milestone: ---

Created attachment 55437
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=55437&action=edit
Original preprocessed source

GCC trunk (commit db38b285ba61c5b888adc0d117177bfd774c1153, not bisected)
segfaults when compiling the reduced source below (also attached: full
preprocessed source), also related to #79173
<https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79173>. 

// Target: x86_64-pc-linux-gnu
// Configured with: ./configure --prefix=/opt/gcc --disable-nls
--disable-libstdcxx-pch --enable-shared --enable-languages=c,c++
--enable-default-pie --enable-lto --enable-threads=posix
// Thread model: posix
// Supported LTO compression algorithms: zlib zstd
// gcc version 14.0.0 20230630 (experimental) (GCC)
//
// secp.cpp: In instantiation of 'static void
Detail::StorageOperations::add(auto:1) [with int <anonymous> = 0; auto:1 =
int]':
// secp.cpp:23:34:   required from 'void Detail::UFixedBigInt::addc(T, bool)
[with T = Detail::UFixedBigInt]'
// secp.cpp:31:12:   required from here
// secp.cpp:9:11: error: reference 'carry' is initialized with itself
[-Werror=init-self]
//     9 |     bool &carry = carry;
//       |           ^~~~~
// secp.cpp:11:9: error: unused variable 'outputoutput'
[-Werror=unused-variable]
//    11 |         outputoutput =
//       |         ^~~~~~~~~~~~
// secp.cpp: In static member function 'static void
Detail::StorageOperations::add(auto:1) [with int <anonymous> = 0; auto:1 =
int]':
// secp.cpp:9:11: error: 'carry' is used uninitialized [-Werror=uninitialized]
//     9 |     bool &carry = carry;
//       |           ^~~~~
// secp.cpp:9:11: note: 'carry' was declared here
//     9 |     bool &carry = carry;
//       |           ^~~~~
// during GIMPLE pass: widening_mul
// secp.cpp: In function 'void modular_multiply()':
// secp.cpp:29:6: internal compiler error: Segmentation fault
//    29 | void modular_multiply() {
//       |      ^~~~~~~~~~~~~~~~
// 0x149fb7f crash_signal
//      ../.././gcc/toplev.cc:314
// 0xe80858 gimple_bb(gimple const*)
//      ../.././gcc/gimple.h:1905
// 0x114529c gsi_for_stmt(gimple*)
//      ../.././gcc/gimple-iterator.cc:617
// 0x1640ff7 match_uaddc_usubc
//      ../.././gcc/tree-ssa-math-opts.cc:4864
// 0x164b6ce after_dom_children
//      ../.././gcc/tree-ssa-math-opts.cc:5589
// 0x217dbba dom_walker::walk(basic_block_def*)
//      ../.././gcc/domwalk.cc:354
// 0x163c836 execute
//      ../.././gcc/tree-ssa-math-opts.cc:5666
// Please submit a full bug report, with preprocessed source.
// Please include the complete backtrace with any bug report.
// See <https://gcc.gnu.org/bugs/> for instructions.

// /opt/gcc/libexec/gcc/x86_64-pc-linux-gnu/14.0.0/cc1plus -quiet -D_GNU_SOURCE
secp.cpp -quiet -dumpdir a- -dumpbase secp.cpp -dumpbase-ext .cpp
-mtune=generic -march=x86-64 -g1 -O2 -Wall -Wextra -Wno-unknown-warning-option
-Wno-unused-command-line-argument -Werror -Wno-expansion-to-defined
-Wno-literal-suffix -Wno-dangling-reference -Wno-maybe-uninitialized
-Wno-shorten-64-to-32 -Wvla -std=c++20 -fno-exceptions -fsigned-char
-fno-semantic-interposition -fPIC -freport-bug -o - -frandom-seed=0
-fdump-noaddr

# 0 "secp.cpp"
# 1 "/home/test/Workspace/serenity/reduce//"
# 0 "<built-in>"
# 0 "<command-line>"
# 1 "/usr/include/stdc-predef.h" 1 3 4
# 0 "<command-line>" 2
# 1 "secp.cpp"
template <typename, typename> constexpr bool IsSame = false;
namespace Detail {
typedef long NativeWord;
struct IntegerWrapper;
long add_words_word1;
long add_words_word2;
struct StorageOperations {
  template <int> static void add(auto) {
    bool &carry = carry;
    NativeWord ncarry,
        outputoutput =
            __builtin_addcl(add_words_word1, add_words_word2, carry,
                            reinterpret_cast<unsigned long *>(&ncarry));
    carry = ncarry;
  }
};
template <typename T>
concept UFixedInt = !
IsSame<T, IntegerWrapper>;
int m_data;
struct UFixedBigInt {
  template <UFixedInt T> void addc(T, bool) {
    StorageOperations::add<false>(m_data);
  }
};
}
using Detail::UFixedBigInt;
bool modular_multiply_carry;
void modular_multiply() {
  UFixedBigInt mult, mp;
  mult.addc(mp, modular_multiply_carry);
}

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug c++/110508] ICE (Segfault) during widening_mul, in match_uaddc_usubc
  2023-06-30 21:48 [Bug c++/110508] New: ICE (Segfault) during widening_mul, in match_uaddc_usubc ali.mpfard at gmail dot com
@ 2023-06-30 21:49 ` ali.mpfard at gmail dot com
  2023-06-30 22:26 ` [Bug c++/110508] [14 Regression] " jakub at gcc dot gnu.org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: ali.mpfard at gmail dot com @ 2023-06-30 21:49 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110508

--- Comment #1 from Ali Mohammad Pur Fard <ali.mpfard at gmail dot com> ---
Created attachment 55438
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=55438&action=edit
Reduced source

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug c++/110508] [14 Regression] ICE (Segfault) during widening_mul, in match_uaddc_usubc
  2023-06-30 21:48 [Bug c++/110508] New: ICE (Segfault) during widening_mul, in match_uaddc_usubc ali.mpfard at gmail dot com
  2023-06-30 21:49 ` [Bug c++/110508] " ali.mpfard at gmail dot com
@ 2023-06-30 22:26 ` jakub at gcc dot gnu.org
  2023-06-30 22:36 ` [Bug tree-optimization/110508] " jakub at gcc dot gnu.org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-06-30 22:26 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110508

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
            Summary|ICE (Segfault) during       |[14 Regression] ICE
                   |widening_mul, in            |(Segfault) during
                   |match_uaddc_usubc           |widening_mul, in
                   |                            |match_uaddc_usubc
             Status|UNCONFIRMED                 |ASSIGNED
                 CC|                            |jakub at gcc dot gnu.org
   Last reconfirmed|                            |2023-06-30
   Target Milestone|---                         |14.0
           Priority|P3                          |P1
           Assignee|unassigned at gcc dot gnu.org      |jakub at gcc dot gnu.org

--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Reduced testcase for -O2:

void
foo (unsigned long a, unsigned long b, unsigned long *c, _Bool d)
{
  __builtin_addcl (a, b, d, c);
}

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug tree-optimization/110508] [14 Regression] ICE (Segfault) during widening_mul, in match_uaddc_usubc
  2023-06-30 21:48 [Bug c++/110508] New: ICE (Segfault) during widening_mul, in match_uaddc_usubc ali.mpfard at gmail dot com
  2023-06-30 21:49 ` [Bug c++/110508] " ali.mpfard at gmail dot com
  2023-06-30 22:26 ` [Bug c++/110508] [14 Regression] " jakub at gcc dot gnu.org
@ 2023-06-30 22:36 ` jakub at gcc dot gnu.org
  2023-07-01  0:33 ` ali.mpfard at gmail dot com
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-06-30 22:36 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110508

--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Created attachment 55439
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=55439&action=edit
gcc14-pr110508.patch

Untested fix.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug tree-optimization/110508] [14 Regression] ICE (Segfault) during widening_mul, in match_uaddc_usubc
  2023-06-30 21:48 [Bug c++/110508] New: ICE (Segfault) during widening_mul, in match_uaddc_usubc ali.mpfard at gmail dot com
                   ` (2 preceding siblings ...)
  2023-06-30 22:36 ` [Bug tree-optimization/110508] " jakub at gcc dot gnu.org
@ 2023-07-01  0:33 ` ali.mpfard at gmail dot com
  2023-07-02 15:37 ` cvs-commit at gcc dot gnu.org
  2023-07-02 15:39 ` jakub at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: ali.mpfard at gmail dot com @ 2023-07-01  0:33 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110508

--- Comment #4 from Ali Mohammad Pur Fard <ali.mpfard at gmail dot com> ---
Can confirm that the patch
(<https://gcc.gnu.org/bugzilla/attachment.cgi?id=55439>) fixes the original
reproducer.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug tree-optimization/110508] [14 Regression] ICE (Segfault) during widening_mul, in match_uaddc_usubc
  2023-06-30 21:48 [Bug c++/110508] New: ICE (Segfault) during widening_mul, in match_uaddc_usubc ali.mpfard at gmail dot com
                   ` (3 preceding siblings ...)
  2023-07-01  0:33 ` ali.mpfard at gmail dot com
@ 2023-07-02 15:37 ` cvs-commit at gcc dot gnu.org
  2023-07-02 15:39 ` jakub at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-07-02 15:37 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110508

--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jakub Jelinek <jakub@gcc.gnu.org>:

https://gcc.gnu.org/g:83733be3f7583f75f626c57e49679cfb9d877c5f

commit r14-2242-g83733be3f7583f75f626c57e49679cfb9d877c5f
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Sun Jul 2 17:36:33 2023 +0200

    tree-ssa-math-opts: Fix up ICE in match_uaddc_usubc [PR110508]

    The match_uaddc_usubc matching doesn't require that the second
    .{ADD,SUB}_OVERFLOW has REALPART_EXPR of its lhs used, only that there is
    at most one.  So, in the weird case where the REALPART_EXPR of it isn't
    present, we shouldn't ICE trying to replace that REALPART_EXPR with
    REALPART_EXPR of .U{ADD,SUB}C result.

    2023-07-02  Jakub Jelinek  <jakub@redhat.com>

            PR tree-optimization/110508
            * tree-ssa-math-opts.cc (match_uaddc_usubc): Only replace re2 with
            REALPART_EXPR opf nlhs if re2 is non-NULL.

            * gcc.dg/pr110508.c: New test.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug tree-optimization/110508] [14 Regression] ICE (Segfault) during widening_mul, in match_uaddc_usubc
  2023-06-30 21:48 [Bug c++/110508] New: ICE (Segfault) during widening_mul, in match_uaddc_usubc ali.mpfard at gmail dot com
                   ` (4 preceding siblings ...)
  2023-07-02 15:37 ` cvs-commit at gcc dot gnu.org
@ 2023-07-02 15:39 ` jakub at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-07-02 15:39 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110508

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|ASSIGNED                    |RESOLVED

--- Comment #6 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Fixed.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2023-07-02 15:39 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-30 21:48 [Bug c++/110508] New: ICE (Segfault) during widening_mul, in match_uaddc_usubc ali.mpfard at gmail dot com
2023-06-30 21:49 ` [Bug c++/110508] " ali.mpfard at gmail dot com
2023-06-30 22:26 ` [Bug c++/110508] [14 Regression] " jakub at gcc dot gnu.org
2023-06-30 22:36 ` [Bug tree-optimization/110508] " jakub at gcc dot gnu.org
2023-07-01  0:33 ` ali.mpfard at gmail dot com
2023-07-02 15:37 ` cvs-commit at gcc dot gnu.org
2023-07-02 15:39 ` jakub at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).