public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/112552] New: [14 Regression] ICE: in require, at machmode.h:313
@ 2023-11-15 18:15 patrick at rivosinc dot com
  2023-11-16  1:18 ` [Bug target/112552] " juzhe.zhong at rivai dot ai
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: patrick at rivosinc dot com @ 2023-11-15 18:15 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 112552
           Summary: [14 Regression] ICE: in require, at machmode.h:313
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: patrick at rivosinc dot com
  Target Milestone: ---

Created attachment 56596
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=56596&action=edit
-freport-bug output

./bin/riscv64-unknown-linux-gnu-gcc -march=rv64gcv -O3 --param
riscv-autovec-preference=fixed-vlmax -S ../testcase.c -freport-bug
../testcase.c: In function 'h':
../testcase.c:7:15: warning: initialization of 'char *' from incompatible
pointer type 'void (*)()' [-Wincompatible-pointer-types]
    7 |     char *f = h;
      |               ^
../testcase.c:8:16: warning: comparison between pointer and integer
    8 |     e = b || g > 1 ? g : b;
      |                ^
during RTL pass: expand
../testcase.c:5:6: internal compiler error: in require, at machmode.h:313
    5 | void h() {
      |      ^
0x9acb6e opt_mode<machine_mode>::require() const
        ../../../gcc/gcc/machmode.h:313
0x9acb6e opt_mode<machine_mode>::require() const
        ../../../gcc/gcc/machmode.h:311
0x9acb6e riscv_legitimize_move(machine_mode, rtx_def*, rtx_def*)
        ../../../gcc/gcc/config/riscv/riscv.cc:2543
0x19c8c62 gen_movqi(rtx_def*, rtx_def*)
        ../../../gcc/gcc/config/riscv/riscv.md:2132
0xd35d27 rtx_insn* insn_gen_fn::operator()<rtx_def*, rtx_def*>(rtx_def*,
rtx_def*) const
        ../../../gcc/gcc/recog.h:411
0xd35d27 emit_move_insn_1(rtx_def*, rtx_def*)
        ../../../gcc/gcc/expr.cc:4164
0xd36174 emit_move_insn(rtx_def*, rtx_def*)
        ../../../gcc/gcc/expr.cc:4334
0xd0aca1 force_reg(machine_mode, rtx_def*)
        ../../../gcc/gcc/explow.cc:683
0xd15581 store_fixed_bit_field_1
        ../../../gcc/gcc/expmed.cc:1320
0xd19700 store_fixed_bit_field
        ../../../gcc/gcc/expmed.cc:1245
0xd1a408 store_integral_bit_field
        ../../../gcc/gcc/expmed.cc:1103
0xd1a408 store_bit_field_1
        ../../../gcc/gcc/expmed.cc:884
0xd1a9bb store_bit_field(rtx_def*, poly_int<2u, unsigned long>, poly_int<2u,
unsigned long>, poly_int<2u, unsigned long>, poly_int<2u, unsigned long>,
machine_mode, rtx_def*, bool, bool)
        ../../../gcc/gcc/expmed.cc:1193
0xd4552e store_field
        ../../../gcc/gcc/expr.cc:7833
0xd439c7 store_constructor(tree_node*, rtx_def*, int, poly_int<2u, long>, bool)
        ../../../gcc/gcc/expr.cc:7588
0xd46398 expand_constructor
        ../../../gcc/gcc/expr.cc:8931
0xd320d7 expand_expr_real_1(tree_node*, rtx_def*, machine_mode,
expand_modifier, rtx_def**, bool)
        ../../../gcc/gcc/expr.cc:11219
0xd32857 expand_expr_real_1(tree_node*, rtx_def*, machine_mode,
expand_modifier, rtx_def**, bool)
        ../../../gcc/gcc/expr.cc:10828
0xe590f2 expand_normal(tree_node*)
        ../../../gcc/gcc/expr.h:316
0xe590f2 expand_vec_cond_mask_optab_fn
        ../../../gcc/gcc/internal-fn.cc:3111
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.
Preprocessed source stored into /tmp/ccOhxn1n.out file, please attach this to
your bugreport.

Testcase:
int a, c, d;
void (*b)();
void (*e)();
void g();
void h() {
  for (; a; --a) {
    char *f = h;
    e = b || g > 1 ? g : b;
    d |= !e;
    *f ^= c;
  }
}

Bisected to r14-4077-g86451305d8b

Attached -freport-bug output

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

* [Bug target/112552] [14 Regression] ICE: in require, at machmode.h:313
  2023-11-15 18:15 [Bug target/112552] New: [14 Regression] ICE: in require, at machmode.h:313 patrick at rivosinc dot com
@ 2023-11-16  1:18 ` juzhe.zhong at rivai dot ai
  2023-11-16  1:27 ` patrick at rivosinc dot com
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: juzhe.zhong at rivai dot ai @ 2023-11-16  1:18 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from JuzheZhong <juzhe.zhong at rivai dot ai> ---
I didn't reproduce this issue but I reproduce another ICE:

during RTL pass: expand
bug.c:5:6: internal compiler error: in expand_insn, at optabs.cc:8305
    5 | void h() {
      |      ^
0x15fea05 expand_insn(insn_code, unsigned int, expand_operand*)
        ../../../../gcc/gcc/optabs.cc:8305
0x13fd50b expand_fn_using_insn
        ../../../../gcc/gcc/internal-fn.cc:263
0x1409a02 expand_direct_optab_fn
        ../../../../gcc/gcc/internal-fn.cc:3869
0x140e4b1 expand_COND_IOR
        ../../../../gcc/gcc/internal-fn.def:283
0x14106ed expand_internal_call(internal_fn, gcall*)
        ../../../../gcc/gcc/internal-fn.cc:4983
0x1410718 expand_internal_call(gcall*)
        ../../../../gcc/gcc/internal-fn.cc:4991
0x10e140f expand_call_stmt
        ../../../../gcc/gcc/cfgexpand.cc:2737
0x10e5426 expand_gimple_stmt_1
        ../../../../gcc/gcc/cfgexpand.cc:3880
0x10e5a2a expand_gimple_stmt
        ../../../../gcc/gcc/cfgexpand.cc:4044
0x10ee0a7 expand_gimple_basic_block
        ../../../../gcc/gcc/cfgexpand.cc:6100
0x10efd60 execute
        ../../../../gcc/gcc/cfgexpand.cc:6835


Could you use latest upstream GCC to verify it ?

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

* [Bug target/112552] [14 Regression] ICE: in require, at machmode.h:313
  2023-11-15 18:15 [Bug target/112552] New: [14 Regression] ICE: in require, at machmode.h:313 patrick at rivosinc dot com
  2023-11-16  1:18 ` [Bug target/112552] " juzhe.zhong at rivai dot ai
@ 2023-11-16  1:27 ` patrick at rivosinc dot com
  2023-11-16  1:33 ` juzhe.zhong at rivai dot ai
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: patrick at rivosinc dot com @ 2023-11-16  1:27 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Patrick O'Neill <patrick at rivosinc dot com> ---
Created attachment 56598
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=56598&action=edit
-freport-bug output tip-of-tree gcc

I bisected with `grep "internal compiler error"` so it seems like the ICE has
changed from tip of tree.

Using r14-5509-g026d9454b1d I get the same ICE as you:
> /scratch/tc-testing/tc-nov-15-trunk/build-rv64gcv/bin/riscv64-unknown-linux-gnu-gcc -march=rv64gcv -O3 --param riscv-autovec-preference=fixed-vlmax -S red.c -freport-bug
red.c: In function 'h':
red.c:7:15: warning: initialization of 'char *' from incompatible pointer type
'void (*)()' [-Wincompatible-pointer-types]
    7 |     char *f = h;
      |               ^
red.c:8:16: warning: comparison between pointer and integer
    8 |     e = b || g > 1 ? g : b;
      |                ^
during RTL pass: expand
red.c:5:6: internal compiler error: in expand_insn, at optabs.cc:8305
    5 | void h() {
      |      ^
0xa0ef2b expand_insn(insn_code, unsigned int, expand_operand*)
        ../../../gcc/gcc/optabs.cc:8305
0xa0f874 expand_insn(insn_code, unsigned int, expand_operand*)
        ../../../gcc/gcc/optabs.cc:8276
0xf8b11b expand_fn_using_insn
        ../../../gcc/gcc/internal-fn.cc:261
0xd1e9b7 expand_call_stmt
        ../../../gcc/gcc/cfgexpand.cc:2737
0xd1e9b7 expand_gimple_stmt_1
        ../../../gcc/gcc/cfgexpand.cc:3880
0xd1e9b7 expand_gimple_stmt
        ../../../gcc/gcc/cfgexpand.cc:4044
0xd23940 expand_gimple_basic_block
        ../../../gcc/gcc/cfgexpand.cc:6100
0xd25a06 execute
        ../../../gcc/gcc/cfgexpand.cc:6835
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.

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

* [Bug target/112552] [14 Regression] ICE: in require, at machmode.h:313
  2023-11-15 18:15 [Bug target/112552] New: [14 Regression] ICE: in require, at machmode.h:313 patrick at rivosinc dot com
  2023-11-16  1:18 ` [Bug target/112552] " juzhe.zhong at rivai dot ai
  2023-11-16  1:27 ` patrick at rivosinc dot com
@ 2023-11-16  1:33 ` juzhe.zhong at rivai dot ai
  2023-11-16  1:44 ` [Bug middle-end/112552] [14 Regression] ICE: in expand_insn, at optabs.cc:8305 juzhe.zhong at rivai dot ai
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: juzhe.zhong at rivai dot ai @ 2023-11-16  1:33 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from JuzheZhong <juzhe.zhong at rivai dot ai> ---
Plz update the title. And bug type. It's middle-end bug.

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

* [Bug middle-end/112552] [14 Regression] ICE: in expand_insn, at optabs.cc:8305
  2023-11-15 18:15 [Bug target/112552] New: [14 Regression] ICE: in require, at machmode.h:313 patrick at rivosinc dot com
                   ` (2 preceding siblings ...)
  2023-11-16  1:33 ` juzhe.zhong at rivai dot ai
@ 2023-11-16  1:44 ` juzhe.zhong at rivai dot ai
  2023-11-16  5:34 ` pinskia at gcc dot gnu.org
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: juzhe.zhong at rivai dot ai @ 2023-11-16  1:44 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from JuzheZhong <juzhe.zhong at rivai dot ai> ---
I see.

https://godbolt.org/z/cbW8535W1

The ifcvt is incorrect.

  iftmp.0_11 = _40 ? 0B : g;
  _ifc__51 = .COND_IOR (_40, d_lsm.11_10, 1, d_lsm.11_10);

_40 is QImode. The later loop vectorizer vectorize _40 into vector QImode
which is wrong for mask argument. 

The later OPTAB expand ICE.


It's obvious, the correct should be:

  iftmp.0_11 = _40 ? 0B : g;
  _ifc__51 = .COND_IOR (iftmp.0_11, d_lsm.11_10, 1, d_lsm.11_10);

It's odd that ARM SVE didn't generate COND_IOR in ifcvt:

https://godbolt.org/z/83xcWorPa

I think it's very likely caused by Robin's ifcvt patch.

CCing Robin who should know the best.

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

* [Bug middle-end/112552] [14 Regression] ICE: in expand_insn, at optabs.cc:8305
  2023-11-15 18:15 [Bug target/112552] New: [14 Regression] ICE: in require, at machmode.h:313 patrick at rivosinc dot com
                   ` (3 preceding siblings ...)
  2023-11-16  1:44 ` [Bug middle-end/112552] [14 Regression] ICE: in expand_insn, at optabs.cc:8305 juzhe.zhong at rivai dot ai
@ 2023-11-16  5:34 ` pinskia at gcc dot gnu.org
  2023-11-16  6:21 ` juzhe.zhong at rivai dot ai
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-11-16  5:34 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           See Also|                            |https://gcc.gnu.org/bugzill
                   |                            |a/show_bug.cgi?id=112406

--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to JuzheZhong from comment #4)
> 
> I think it's very likely caused by Robin's ifcvt patch.
> 
> CCing Robin who should know the best.

And most likely a dup of bug 112406 .

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

* [Bug middle-end/112552] [14 Regression] ICE: in expand_insn, at optabs.cc:8305
  2023-11-15 18:15 [Bug target/112552] New: [14 Regression] ICE: in require, at machmode.h:313 patrick at rivosinc dot com
                   ` (4 preceding siblings ...)
  2023-11-16  5:34 ` pinskia at gcc dot gnu.org
@ 2023-11-16  6:21 ` juzhe.zhong at rivai dot ai
  2023-11-16  7:31 ` [Bug target/112552] " rguenth at gcc dot gnu.org
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: juzhe.zhong at rivai dot ai @ 2023-11-16  6:21 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from JuzheZhong <juzhe.zhong at rivai dot ai> ---
(In reply to Andrew Pinski from comment #5)
> (In reply to JuzheZhong from comment #4)
> > 
> > I think it's very likely caused by Robin's ifcvt patch.
> > 
> > CCing Robin who should know the best.
> 
> And most likely a dup of bug 112406 .

Yes. I think they are the same bug.

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

* [Bug target/112552] [14 Regression] ICE: in expand_insn, at optabs.cc:8305
  2023-11-15 18:15 [Bug target/112552] New: [14 Regression] ICE: in require, at machmode.h:313 patrick at rivosinc dot com
                   ` (5 preceding siblings ...)
  2023-11-16  6:21 ` juzhe.zhong at rivai dot ai
@ 2023-11-16  7:31 ` rguenth at gcc dot gnu.org
  2023-11-16  7:54 ` [Bug middle-end/112552] " rdapp at gcc dot gnu.org
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-11-16  7:31 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|middle-end                  |target
             Target|                            |riscv
   Target Milestone|---                         |14.0

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

* [Bug middle-end/112552] [14 Regression] ICE: in expand_insn, at optabs.cc:8305
  2023-11-15 18:15 [Bug target/112552] New: [14 Regression] ICE: in require, at machmode.h:313 patrick at rivosinc dot com
                   ` (6 preceding siblings ...)
  2023-11-16  7:31 ` [Bug target/112552] " rguenth at gcc dot gnu.org
@ 2023-11-16  7:54 ` rdapp at gcc dot gnu.org
  2023-11-17 20:35 ` cvs-commit at gcc dot gnu.org
  2023-11-20 18:52 ` patrick at rivosinc dot com
  9 siblings, 0 replies; 11+ messages in thread
From: rdapp at gcc dot gnu.org @ 2023-11-16  7:54 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from Robin Dapp <rdapp at gcc dot gnu.org> ---
Ah, it's even easier to trigger then.  I already have a somewhat working
solution by going with Richi's suggestion and adding the handling for COND_OPs
in vect patterns.  Still needs a bit more polishing and testing before I post
it.

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

* [Bug middle-end/112552] [14 Regression] ICE: in expand_insn, at optabs.cc:8305
  2023-11-15 18:15 [Bug target/112552] New: [14 Regression] ICE: in require, at machmode.h:313 patrick at rivosinc dot com
                   ` (7 preceding siblings ...)
  2023-11-16  7:54 ` [Bug middle-end/112552] " rdapp at gcc dot gnu.org
@ 2023-11-17 20:35 ` cvs-commit at gcc dot gnu.org
  2023-11-20 18:52 ` patrick at rivosinc dot com
  9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-11-17 20:35 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Robin Dapp <rdapp@gcc.gnu.org>:

https://gcc.gnu.org/g:231bb992592a9e1bd7ce6583131acb1874c8e34e

commit r14-5564-g231bb992592a9e1bd7ce6583131acb1874c8e34e
Author: Robin Dapp <rdapp@ventanamicro.com>
Date:   Thu Nov 16 20:42:10 2023 +0100

    vect: Pass truth type to vect_get_vec_defs.

    For conditional operations the mask is loop invariant and cannot be
    stored explicitly.  By default, for reductions, we deduce the vectype
    from the statement or the loop but this does not work for conditional
    operations.  Therefore this patch passes the truth type of the reduction
    input vectype for the mask operand instead.  This will override the
    other choices and make sure we have the proper mask vectype.

    gcc/ChangeLog:

            PR middle-end/112406
            PR middle-end/112552

            * tree-vect-loop.cc (vect_transform_reduction): Pass truth
            vectype for mask operand.

    gcc/testsuite/ChangeLog:

            * gcc.target/aarch64/pr112406.c: New test.
            * gcc.target/riscv/rvv/autovec/pr112552.c: New test.

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

* [Bug middle-end/112552] [14 Regression] ICE: in expand_insn, at optabs.cc:8305
  2023-11-15 18:15 [Bug target/112552] New: [14 Regression] ICE: in require, at machmode.h:313 patrick at rivosinc dot com
                   ` (8 preceding siblings ...)
  2023-11-17 20:35 ` cvs-commit at gcc dot gnu.org
@ 2023-11-20 18:52 ` patrick at rivosinc dot com
  9 siblings, 0 replies; 11+ messages in thread
From: patrick at rivosinc dot com @ 2023-11-20 18:52 UTC (permalink / raw)
  To: gcc-bugs

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

Patrick O'Neill <patrick at rivosinc dot com> changed:

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

--- Comment #9 from Patrick O'Neill <patrick at rivosinc dot com> ---
Fixed.

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

end of thread, other threads:[~2023-11-20 18:52 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-15 18:15 [Bug target/112552] New: [14 Regression] ICE: in require, at machmode.h:313 patrick at rivosinc dot com
2023-11-16  1:18 ` [Bug target/112552] " juzhe.zhong at rivai dot ai
2023-11-16  1:27 ` patrick at rivosinc dot com
2023-11-16  1:33 ` juzhe.zhong at rivai dot ai
2023-11-16  1:44 ` [Bug middle-end/112552] [14 Regression] ICE: in expand_insn, at optabs.cc:8305 juzhe.zhong at rivai dot ai
2023-11-16  5:34 ` pinskia at gcc dot gnu.org
2023-11-16  6:21 ` juzhe.zhong at rivai dot ai
2023-11-16  7:31 ` [Bug target/112552] " rguenth at gcc dot gnu.org
2023-11-16  7:54 ` [Bug middle-end/112552] " rdapp at gcc dot gnu.org
2023-11-17 20:35 ` cvs-commit at gcc dot gnu.org
2023-11-20 18:52 ` patrick at rivosinc dot com

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).