public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/115426] New: ICE in execute_todo, at passes.cc:2138
@ 2024-06-11  3:40 iamanonymous.cs at gmail dot com
  2024-06-11  4:05 ` [Bug tree-optimization/115426] ICE: " pinskia at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: iamanonymous.cs at gmail dot com @ 2024-06-11  3:40 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 115426
           Summary: ICE in execute_todo, at passes.cc:2138
           Product: gcc
           Version: 15.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: iamanonymous.cs at gmail dot com
  Target Milestone: ---
            Target: x86_64

*******************************************************************************
The compiler produces an internal error when compiling the provided code with
the specified options. 
The issue occurs during the GIMPLE pass (walloca), causing an internal compiler
error in the execute_todo function at passes.cc:2138.
*******************************************************************************
OS and Platform:
# uname -a
Linux ubuntu 4.15.0-213-generic #224-Ubuntu SMP Mon Jun 19 13:30:12 UTC 2023
x86_64 x86_64 x86_64 GNU/Linux
*******************************************************************************
# gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/root/gdbtest/gcc/gcc-15/libexec/gcc/x86_64-pc-linux-gnu/15.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /root/gdbtest/gcc/obj/../gcc/configure
--prefix=/root/gdbtest/gcc/gcc-15 --enable-languages=c,c++,fortran,go
--disable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 15.0.0 20240509 (experimental) (GCC) 
*******************************************************************************
Program:
# cat fam-asm.c

 #include <stdio.h>
 #include <complex.h> 

 _Complex float fcs(_Complex float x) {
  float ixy;
  float diff, sum;
  _Complex float r;
  __asm__("fmul %s[ixy], %s[xr], %s[yr]\n"
          "\tfsub %s[diff], %s[xr], %s[yr]\n"
          "\tfadd %s[sum],  %s[xr], %s[yr]\n"
          "\tfmul %s[rr],  %s[diff], %s[sum]\n"
          "\tfadd %s[ri],  %s[ixy], %s[ixy]\n"
          : [ixy] "=&w" (ixy), [diff] "=&w" (diff), [sum] "=w" (sum), [rr] "=w"
(__real__ r), [ri] "=w" (__imag__ r)
          : [xr] "w" (__real__ x), [yr] "w"( __imag__ x)
          : );
  return r;
 }

 int main(int argc, char *argv[])
 {
  _Complex float i = 0.0f + I * 1.0f;
  _Complex float i2 = fcs(i);
  printf("%f+i%f\n", __real__ i2, __imag__ i2);
 }


*******************************************************************************
Command Lines:
# gcc fam-asm.c -Wall -Wextra  -o fam-asm.out
fam-asm.c: In function ‘main’:
fam-asm.c:19:15: warning: unused parameter ‘argc’ [-Wunused-parameter]
   19 |  int main(int argc, char *argv[])
      |           ~~~~^~~~
fam-asm.c:19:27: warning: unused parameter ‘argv’ [-Wunused-parameter]
   19 |  int main(int argc, char *argv[])
      |                     ~~~~~~^~~~~~
during GIMPLE pass: walloca
fam-asm.c: In function ‘fcs’:
fam-asm.c:24:2: internal compiler error: in execute_todo, at passes.cc:2138
   24 |  }
      |  ^
0x839f1b execute_todo
        /root/gdbtest/gcc/obj/../gcc/gcc/passes.cc:2138
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.

*******************************************************************************

Also ICE on trunk, compiler explorer:https://godbolt.org/z/soaoeW5z7

*******************************************************************************

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

* [Bug tree-optimization/115426] ICE: in execute_todo, at passes.cc:2138
  2024-06-11  3:40 [Bug c/115426] New: ICE in execute_todo, at passes.cc:2138 iamanonymous.cs at gmail dot com
@ 2024-06-11  4:05 ` pinskia at gcc dot gnu.org
  2024-06-11  9:51 ` rguenth at gcc dot gnu.org
  2024-06-11 11:07 ` rguenth at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-06-11  4:05 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2024-06-11
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Reduced testcase that ICEs on all targets:
```
 _Complex float fcs() {
  _Complex float r;
  __asm__(""  : "=X" (__imag__ r)  );
  return r;
 } 
```

Looks like this has been ICEing for a while with checking enabled.

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

* [Bug tree-optimization/115426] ICE: in execute_todo, at passes.cc:2138
  2024-06-11  3:40 [Bug c/115426] New: ICE in execute_todo, at passes.cc:2138 iamanonymous.cs at gmail dot com
  2024-06-11  4:05 ` [Bug tree-optimization/115426] ICE: " pinskia at gcc dot gnu.org
@ 2024-06-11  9:51 ` rguenth at gcc dot gnu.org
  2024-06-11 11:07 ` rguenth at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: rguenth at gcc dot gnu.org @ 2024-06-11  9:51 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|unassigned at gcc dot gnu.org      |rguenth at gcc dot gnu.org
             Status|NEW                         |ASSIGNED

--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
Mine (into-SSA is broken it seems)

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

* [Bug tree-optimization/115426] ICE: in execute_todo, at passes.cc:2138
  2024-06-11  3:40 [Bug c/115426] New: ICE in execute_todo, at passes.cc:2138 iamanonymous.cs at gmail dot com
  2024-06-11  4:05 ` [Bug tree-optimization/115426] ICE: " pinskia at gcc dot gnu.org
  2024-06-11  9:51 ` rguenth at gcc dot gnu.org
@ 2024-06-11 11:07 ` rguenth at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: rguenth at gcc dot gnu.org @ 2024-06-11 11:07 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
I think this is a gimplification failure.  'r' is neither TREE_ADDRESSABLE
nor DECL_NOT_GIMPLE_REG and the =X constraint results in both allow_reg
and allow_mem but we gimplify it as is_gimple_lvalue which should,
as the base is a gimple register, emit a component extract to pre_p and
a complex build to post_p.

gimplify_compound_lval correctly sees this and forces a register argument
to the __imag operation but I'm not sure that's enough for lvalues.
IIRC a simple

 __imag x = 1;

also doesn't have DECL_NOT_GIMPLE_REG on 'x', and gimplify_compound_lval
behaves the same.  Still we eventually gimplify to

  _1 = REALPART_EXPR <x>;
  x = COMPLEX_EXPR <_1, 1.0e+0>;
  D.2772 = x;

which is done via gimplify_modify_expr_complex_part.  That suggests
it's gimplify_asm_expr that would need to do this very same thing as we
seem to rely on this for correctness.

With "=r" we correctly gimplify to

  __asm__("" : "=r" D.2772);
  _1 = REALPART_EXPR <r>;
  r = COMPLEX_EXPR <_1, D.2772>;
  D.2773 = r;

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

end of thread, other threads:[~2024-06-11 11:07 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-06-11  3:40 [Bug c/115426] New: ICE in execute_todo, at passes.cc:2138 iamanonymous.cs at gmail dot com
2024-06-11  4:05 ` [Bug tree-optimization/115426] ICE: " pinskia at gcc dot gnu.org
2024-06-11  9:51 ` rguenth at gcc dot gnu.org
2024-06-11 11:07 ` rguenth 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).