public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/111495] New: [14 regression] ICE in lower_bound, at value-range.h:1078 when building LLVM 17.0.1
@ 2023-09-20 11:39 sjames at gcc dot gnu.org
  2023-09-20 12:19 ` [Bug tree-optimization/111495] " rguenth at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: sjames at gcc dot gnu.org @ 2023-09-20 11:39 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 111495
           Summary: [14 regression] ICE in lower_bound, at
                    value-range.h:1078 when building LLVM 17.0.1
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: sjames at gcc dot gnu.org
  Target Milestone: ---

Created attachment 55947
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=55947&action=edit
InstructionSimplify.cpp.ii

```
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/aarch64-unknown-linux-gnu/14/lto-wrapper
Target: aarch64-unknown-linux-gnu
Configured with:
/var/tmp/portage/sys-devel/gcc-14.0.0.9999/work/gcc-14.0.0.9999/configure
--host=aarch64-unknown-linux-gnu --build=aarch64-unknown-linux-gnu
--prefix=/usr --bindir=/usr/aarch64-unknown-linux-gnu/gcc-bin/14
--includedir=/usr/lib/gcc/aarch64-unknown-linux-gnu/14/include
--datadir=/usr/share/gcc-data/aarch64-unknown-linux-gnu/14
--mandir=/usr/share/gcc-data/aarch64-unknown-linux-gnu/14/man
--infodir=/usr/share/gcc-data/aarch64-unknown-linux-gnu/14/info
--with-gxx-include-dir=/usr/lib/gcc/aarch64-unknown-linux-gnu/14/include/g++-v14
--disable-silent-rules --disable-dependency-tracking
--with-python-dir=/share/gcc-data/aarch64-unknown-linux-gnu/14/python
--enable-languages=c,c++,fortran --enable-obsolete --enable-secureplt
--disable-werror --with-system-zlib --enable-nls --without-included-gettext
--disable-libunwind-exceptions --enable-checking=yes,extra,rtl
--with-bugurl=https://bugs.gentoo.org/ --with-pkgversion='Gentoo 14.0.0 p,
commit d0b55776a4e1d2f293db5ba0e4a04aefed055ec4' --with-gcc-major-version-only
--enable-libstdcxx-time --enable-lto --disable-libstdcxx-pch --enable-shared
--enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu
--disable-multilib --disable-fixed-point --enable-libgomp --disable-libssp
--disable-libada --disable-cet --disable-systemtap
--disable-valgrind-annotations --disable-vtable-verify --disable-libvtv
--with-zstd --without-isl --enable-default-pie --enable-host-pie
--disable-host-bind-now --enable-default-ssp
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 14.0.0 20230920 (experimental)
2e36eedb244badaaf2a70388071115c851b8db9b (Gentoo 14.0.0 p, commit
d0b55776a4e1d2f293db5ba0e4a04aefed055ec4)
```


```
FAILED: lib/Analysis/CMakeFiles/LLVMAnalysis.dir/InstructionSimplify.cpp.o
/usr/bin/aarch64-unknown-linux-gnu-g++ -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS
-D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
-I/var/tmp/portage/sys-devel/llvm-17.0.1/work/llvm_build-.arm64/lib/Analysis
-I/var/tmp/portage/sys-devel/llvm-17.0.1/work/llvm/lib/Analysis
-I/var/tmp/portage/sys-devel/llvm-17.0.1/work/llvm_build-.arm64/include
-I/var/tmp/portage/sys-devel/llvm-17.0.1/work/llvm/include  -DNDEBUG -O3 -pipe
-mcpu=native -fdiagnostics-color=always -ggdb3 -fPIC
-fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time
-fno-lifetime-dse -Wall -Wextra -Wno-unused-parameter -Wwrite-strings
-Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long
-Wimplicit-fallthrough -Wno-maybe-uninitialized -Wno-nonnull
-Wno-class-memaccess -Wno-redundant-move -Wno-pessimizing-move
-Wno-noexcept-type -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment
-Wno-misleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color
-ffunction-sections -fdata-sections -std=c++17 -fdiagnostics-color=always -MD
-MT lib/Analysis/CMakeFiles/LLVMAnalysis.dir/InstructionSimplify.cpp.o -MF
lib/Analysis/CMakeFiles/LLVMAnalysis.dir/InstructionSimplify.cpp.o.d -o
lib/Analysis/CMakeFiles/LLVMAnalysis.dir/InstructionSimplify.cpp.o -c
/var/tmp/portage/sys-devel/llvm-17.0.1/work/llvm/lib/Analysis/InstructionSimplify.cpp
during GIMPLE pass: vrp
/var/tmp/portage/sys-devel/llvm-17.0.1/work/llvm/lib/Analysis/InstructionSimplify.cpp:
In function ‘llvm::Value* simplifyInstructionWithOperands(llvm::Instruction*,
llvm::ArrayRef<llvm::Value*>, const llvm::SimplifyQuery&, unsigned int)’:
/var/tmp/portage/sys-devel/llvm-17.0.1/work/llvm/lib/Analysis/InstructionSimplify.cpp:6809:15:
internal compiler error: in lower_bound, at value-range.h:1078
 6809 | static Value *simplifyInstructionWithOperands(Instruction *I,
      |               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
0xaaaaae7fa197 irange::lower_bound(unsigned int) const
       
/usr/src/debug/sys-devel/gcc-14.0.0.9999/gcc-14.0.0.9999/gcc/value-range.h:1078
0xaaaaae7fa197 gimple_simplify_EXACT_DIV_EXPR(gimple_match_op*, gimple**,
tree_node* (*)(tree_node*), code_helper, tree_node*, tree_node*, tree_node*)
       
/usr/src/debug/sys-devel/gcc-14.0.0.9999/build/gcc/gimple-match-2.cc:8278
0xaaaaadcbc307 gimple_resimplify2
       
/usr/src/debug/sys-devel/gcc-14.0.0.9999/gcc-14.0.0.9999/gcc/gimple-match-exports.cc:1001
0xaaaaadcbcf2f gimple_simplify(gimple*, gimple_match_op*, gimple**, tree_node*
(*)(tree_node*), tree_node* (*)(tree_node*))
       
/usr/src/debug/sys-devel/gcc-14.0.0.9999/gcc-14.0.0.9999/gcc/gimple-match-exports.cc:868
0xaaaaad1fa8b7 fold_stmt_1
       
/usr/src/debug/sys-devel/gcc-14.0.0.9999/gcc-14.0.0.9999/gcc/gimple-fold.cc:6355
0xaaaaae56b1c7 gimple_ranger::fold_stmt(gimple_stmt_iterator*, tree_node*
(*)(tree_node*))
       
/usr/src/debug/sys-devel/gcc-14.0.0.9999/gcc-14.0.0.9999/gcc/gimple-range.cc:470
0xaaaaad94be7b rvrp_folder::fold_stmt(gimple_stmt_iterator*)
       
/usr/src/debug/sys-devel/gcc-14.0.0.9999/gcc-14.0.0.9999/gcc/tree-vrp.cc:1032
0xaaaaad82107b
substitute_and_fold_dom_walker::before_dom_children(basic_block_def*)
       
/usr/src/debug/sys-devel/gcc-14.0.0.9999/gcc-14.0.0.9999/gcc/tree-ssa-propagate.cc:876
0xaaaaae51619b dom_walker::walk(basic_block_def*)
       
/usr/src/debug/sys-devel/gcc-14.0.0.9999/gcc-14.0.0.9999/gcc/domwalk.cc:311
0xaaaaad8200bf
substitute_and_fold_engine::substitute_and_fold(basic_block_def*)
       
/usr/src/debug/sys-devel/gcc-14.0.0.9999/gcc-14.0.0.9999/gcc/tree-ssa-propagate.cc:999
0xaaaaad948a0f execute_ranger_vrp(function*, bool, bool)
       
/usr/src/debug/sys-devel/gcc-14.0.0.9999/gcc-14.0.0.9999/gcc/tree-vrp.cc:1062
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See <https://bugs.gentoo.org/> for instructions.
```

Might be a dupe of PR111482. Maybe the test case is still useful if it is.

I can reproduce with just 'g++ -c InstructionSimplify.cpp.ii -O3'.

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

* [Bug tree-optimization/111495] [14 regression] ICE in lower_bound, at value-range.h:1078 when building LLVM 17.0.1
  2023-09-20 11:39 [Bug tree-optimization/111495] New: [14 regression] ICE in lower_bound, at value-range.h:1078 when building LLVM 17.0.1 sjames at gcc dot gnu.org
@ 2023-09-20 12:19 ` rguenth at gcc dot gnu.org
  2023-09-21  5:12 ` sjames at gcc dot gnu.org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-09-20 12:19 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |14.0

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

* [Bug tree-optimization/111495] [14 regression] ICE in lower_bound, at value-range.h:1078 when building LLVM 17.0.1
  2023-09-20 11:39 [Bug tree-optimization/111495] New: [14 regression] ICE in lower_bound, at value-range.h:1078 when building LLVM 17.0.1 sjames at gcc dot gnu.org
  2023-09-20 12:19 ` [Bug tree-optimization/111495] " rguenth at gcc dot gnu.org
@ 2023-09-21  5:12 ` sjames at gcc dot gnu.org
  2023-09-21  7:06 ` sjames at gcc dot gnu.org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: sjames at gcc dot gnu.org @ 2023-09-21  5:12 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Sam James <sjames at gcc dot gnu.org> ---
Created attachment 55956
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=55956&action=edit
reduced.ii

Attached minimised reproducer fails with -O3, works with -O2, per original.

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

* [Bug tree-optimization/111495] [14 regression] ICE in lower_bound, at value-range.h:1078 when building LLVM 17.0.1
  2023-09-20 11:39 [Bug tree-optimization/111495] New: [14 regression] ICE in lower_bound, at value-range.h:1078 when building LLVM 17.0.1 sjames at gcc dot gnu.org
  2023-09-20 12:19 ` [Bug tree-optimization/111495] " rguenth at gcc dot gnu.org
  2023-09-21  5:12 ` sjames at gcc dot gnu.org
@ 2023-09-21  7:06 ` sjames at gcc dot gnu.org
  2023-09-21  7:22 ` [Bug tree-optimization/111495] [14 regression] ICE in lower_bound, at value-range.h:1078 when building LLVM 17.0.1 since r14-3644-g1aceceb1e2d6e8 pinskia at gcc dot gnu.org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: sjames at gcc dot gnu.org @ 2023-09-21  7:06 UTC (permalink / raw)
  To: gcc-bugs

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

Sam James <sjames at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |guojiufu at gcc dot gnu.org

--- Comment #2 from Sam James <sjames at gcc dot gnu.org> ---
1aceceb1e2d6e86ce183c8cc448750fa03b6f79e is the first bad commit
commit 1aceceb1e2d6e86ce183c8cc448750fa03b6f79e
Author: Jiufu Guo <guojiufu@linux.ibm.com>
Date:   Mon Sep 4 10:31:04 2023 +0800

    Optimize '(X - N * M) / N' to 'X / N - M' if valid

    Integer expression "(X - N * M) / N" can be optimized to "X / N - M" with
    the below conditions:
    1. There is no wrap/overflow/underflow.
       wrap/overflow/underflow breaks the arithmetic operation.
    2. "X - N * M" and "X" are not of opposite sign.
       Here, the operation "/" would be "trunc_div", the fractional part is
       discarded. If "X - N * M" and "X" are in different signs, then trunc_div
       discards the fractional parts (of /N) in different directions.

            PR tree-optimization/108757

    gcc/ChangeLog:

            * match.pd ((X - N * M) / N): New pattern.
            ((X + N * M) / N): New pattern.
            ((X + C) div_rshift N): New pattern.

    gcc/testsuite/ChangeLog:

            * gcc.dg/pr108757-1.c: New test.
            * gcc.dg/pr108757-2.c: New test.
            * gcc.dg/pr108757.h: New test.

 gcc/match.pd                      |  80 +++++++++++++
 gcc/testsuite/gcc.dg/pr108757-1.c |  18 +++
 gcc/testsuite/gcc.dg/pr108757-2.c |  19 ++++
 gcc/testsuite/gcc.dg/pr108757.h   | 233 ++++++++++++++++++++++++++++++++++++++
 4 files changed, 350 insertions(+)
 create mode 100644 gcc/testsuite/gcc.dg/pr108757-1.c
 create mode 100644 gcc/testsuite/gcc.dg/pr108757-2.c
 create mode 100644 gcc/testsuite/gcc.dg/pr108757.h
bisect found first bad commit

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

* [Bug tree-optimization/111495] [14 regression] ICE in lower_bound, at value-range.h:1078 when building LLVM 17.0.1 since r14-3644-g1aceceb1e2d6e8
  2023-09-20 11:39 [Bug tree-optimization/111495] New: [14 regression] ICE in lower_bound, at value-range.h:1078 when building LLVM 17.0.1 sjames at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2023-09-21  7:06 ` sjames at gcc dot gnu.org
@ 2023-09-21  7:22 ` pinskia at gcc dot gnu.org
  2023-09-21  7:30 ` sjames at gcc dot gnu.org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-09-21  7:22 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
I suspect r14-4192-g4d80863d7f93c0a839d1fe5 fixed this ...

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

* [Bug tree-optimization/111495] [14 regression] ICE in lower_bound, at value-range.h:1078 when building LLVM 17.0.1 since r14-3644-g1aceceb1e2d6e8
  2023-09-20 11:39 [Bug tree-optimization/111495] New: [14 regression] ICE in lower_bound, at value-range.h:1078 when building LLVM 17.0.1 sjames at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2023-09-21  7:22 ` [Bug tree-optimization/111495] [14 regression] ICE in lower_bound, at value-range.h:1078 when building LLVM 17.0.1 since r14-3644-g1aceceb1e2d6e8 pinskia at gcc dot gnu.org
@ 2023-09-21  7:30 ` sjames at gcc dot gnu.org
  2023-09-21  7:37 ` guojiufu at gcc dot gnu.org
  2023-09-21  8:00 ` sjames at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: sjames at gcc dot gnu.org @ 2023-09-21  7:30 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Sam James <sjames at gcc dot gnu.org> ---
trying..

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

* [Bug tree-optimization/111495] [14 regression] ICE in lower_bound, at value-range.h:1078 when building LLVM 17.0.1 since r14-3644-g1aceceb1e2d6e8
  2023-09-20 11:39 [Bug tree-optimization/111495] New: [14 regression] ICE in lower_bound, at value-range.h:1078 when building LLVM 17.0.1 sjames at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2023-09-21  7:30 ` sjames at gcc dot gnu.org
@ 2023-09-21  7:37 ` guojiufu at gcc dot gnu.org
  2023-09-21  8:00 ` sjames at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: guojiufu at gcc dot gnu.org @ 2023-09-21  7:37 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Jiu Fu Guo <guojiufu at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #3)
> I suspect r14-4192-g4d80863d7f93c0a839d1fe5 fixed this ...

Yes, I reproduced this issue on ppc64le, and the fix r14-4192 seems to work
fine.

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

* [Bug tree-optimization/111495] [14 regression] ICE in lower_bound, at value-range.h:1078 when building LLVM 17.0.1 since r14-3644-g1aceceb1e2d6e8
  2023-09-20 11:39 [Bug tree-optimization/111495] New: [14 regression] ICE in lower_bound, at value-range.h:1078 when building LLVM 17.0.1 sjames at gcc dot gnu.org
                   ` (5 preceding siblings ...)
  2023-09-21  7:37 ` guojiufu at gcc dot gnu.org
@ 2023-09-21  8:00 ` sjames at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: sjames at gcc dot gnu.org @ 2023-09-21  8:00 UTC (permalink / raw)
  To: gcc-bugs

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

Sam James <sjames at gcc dot gnu.org> changed:

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

--- Comment #6 from Sam James <sjames at gcc dot gnu.org> ---
Yeah, all fine now. Thanks!

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

end of thread, other threads:[~2023-09-21  8:00 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-20 11:39 [Bug tree-optimization/111495] New: [14 regression] ICE in lower_bound, at value-range.h:1078 when building LLVM 17.0.1 sjames at gcc dot gnu.org
2023-09-20 12:19 ` [Bug tree-optimization/111495] " rguenth at gcc dot gnu.org
2023-09-21  5:12 ` sjames at gcc dot gnu.org
2023-09-21  7:06 ` sjames at gcc dot gnu.org
2023-09-21  7:22 ` [Bug tree-optimization/111495] [14 regression] ICE in lower_bound, at value-range.h:1078 when building LLVM 17.0.1 since r14-3644-g1aceceb1e2d6e8 pinskia at gcc dot gnu.org
2023-09-21  7:30 ` sjames at gcc dot gnu.org
2023-09-21  7:37 ` guojiufu at gcc dot gnu.org
2023-09-21  8:00 ` sjames 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).