[Bug tree-optimization/115426] ICE: in execute_todo, at passes.cc:2138

2024-09-18 Thread rguenth at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115426

Richard Biener  changed:

   What|Removed |Added

   Target Milestone|--- |14.3
 Status|ASSIGNED|RESOLVED
 Resolution|--- |FIXED
  Known to fail||14.2.0
  Known to work||14.2.1

--- Comment #7 from Richard Biener  ---
Fixed for GCC 14, not backporting further (the testcase looks artificially
generated, not from real-world code).

[Bug tree-optimization/115426] ICE: in execute_todo, at passes.cc:2138

2024-09-18 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115426

--- Comment #6 from GCC Commits  ---
The releases/gcc-14 branch has been updated by Richard Biener
:

https://gcc.gnu.org/g:5b264a4b95b8f27c3c73892892d5c2030d3c8ea7

commit r14-10685-g5b264a4b95b8f27c3c73892892d5c2030d3c8ea7
Author: Richard Biener 
Date:   Tue Jun 11 13:11:08 2024 +0200

middle-end/115426 - wrong gimplification of "rm" asm output operand

When the operand is gimplified to an extract of a register or a
register we have to disallow memory as we otherwise fail to
gimplify it properly.  Instead of

  __asm__("" : "=rm" __imag );

we want

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

otherwise SSA rewrite will fail and generate wrong code with 'r'
left bare in the asm output.

PR middle-end/115426
* gimplify.cc (gimplify_asm_expr): Handle "rm" output
constraint gimplified to a register (operation).

* gcc.dg/pr115426.c: New testcase.

(cherry picked from commit a4bbdec2be1c9f8fb49276b8a54ee86024ceac17)

[Bug tree-optimization/115426] ICE: in execute_todo, at passes.cc:2138

2024-07-04 Thread rguenth at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115426

Richard Biener  changed:

   What|Removed |Added

  Known to work||15.0
   Keywords|ice-on-invalid-code |ice-on-valid-code

--- Comment #5 from Richard Biener  ---
Fixed on trunk sofar (I think the final testcases are valid).

[Bug tree-optimization/115426] ICE: in execute_todo, at passes.cc:2138

2024-07-03 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115426

--- Comment #4 from GCC Commits  ---
The master branch has been updated by Richard Biener :

https://gcc.gnu.org/g:a4bbdec2be1c9f8fb49276b8a54ee86024ceac17

commit r15-1837-ga4bbdec2be1c9f8fb49276b8a54ee86024ceac17
Author: Richard Biener 
Date:   Tue Jun 11 13:11:08 2024 +0200

middle-end/115426 - wrong gimplification of "rm" asm output operand

When the operand is gimplified to an extract of a register or a
register we have to disallow memory as we otherwise fail to
gimplify it properly.  Instead of

  __asm__("" : "=rm" __imag );

we want

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

otherwise SSA rewrite will fail and generate wrong code with 'r'
left bare in the asm output.

PR middle-end/115426
* gimplify.cc (gimplify_asm_expr): Handle "rm" output
constraint gimplified to a register (operation).

* gcc.dg/pr115426.c: New testcase.

[Bug tree-optimization/115426] ICE: in execute_todo, at passes.cc:2138

2024-06-11 Thread rguenth at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115426

--- Comment #3 from Richard Biener  ---
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 = 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 = COMPLEX_EXPR <_1, D.2772>;
  D.2773 = r;

[Bug tree-optimization/115426] ICE: in execute_todo, at passes.cc:2138

2024-06-11 Thread rguenth at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115426

Richard Biener  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  ---
Mine (into-SSA is broken it seems)

[Bug tree-optimization/115426] ICE: in execute_todo, at passes.cc:2138

2024-06-10 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115426

Andrew Pinski  changed:

   What|Removed |Added

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

--- Comment #1 from Andrew Pinski  ---
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.