public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/106476] New: ICE generating FOLD_EXTRACT_LAST
@ 2022-07-29 13:08 ams at gcc dot gnu.org
  2022-08-01  9:04 ` [Bug tree-optimization/106476] " rguenth at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: ams at gcc dot gnu.org @ 2022-07-29 13:08 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 106476
           Summary: ICE generating FOLD_EXTRACT_LAST
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: major
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ams at gcc dot gnu.org
                CC: rguenther at suse dot de
  Target Milestone: ---
            Target: amdgcn-amdhsa

Commit 8f4d9c1deda "amdgcn: 64-bit not" exposed an ICE in tree-vect_stmts.cc
when compiling gcc.dg/torture/pr67470.c at -O2 for amdgcn. The newly
implemented op is not the problem, but it allows this optimization (and many
others) to proceed, and the error is no longer hidden.

amdgcn has masked vectors and fold_extract_last, which leads to a code path
through tree-vect-stmts.cc that has

   vec_then_clause = vec_oprnds2[i];
   if (reduction_type != EXTRACT_LAST_REDUCTION)
     vec_else_clause = vec_oprnds3[i];

and then

   /* Instead of doing ~x ? y : z do x ? z : y.  */
   vec_compare = new_temp;
   std::swap (vec_then_clause, vec_else_clause);

and finally

   new_stmt = gimple_build_call_internal
       (IFN_FOLD_EXTRACT_LAST, 3, else_clause, vec_compare,
        vec_then_clause);

in which vec_then_clause remains set to NULL_TREE.

The dump shows

   e_lsm.16_32 = .FOLD_EXTRACT_LAST (e_lsm.16_8, _70, );

(note the last field is missing.)

I can fix the ICE if I add "else vec_else_clause = integer_zero_node", but I'm
not sure that is the correct logical solution.

(CC Richi who touched this code last)

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

* [Bug tree-optimization/106476] ICE generating FOLD_EXTRACT_LAST
  2022-07-29 13:08 [Bug tree-optimization/106476] New: ICE generating FOLD_EXTRACT_LAST ams at gcc dot gnu.org
@ 2022-08-01  9:04 ` rguenth at gcc dot gnu.org
  2022-09-15 12:08 ` rsandifo at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-08-01  9:04 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Version|unknown                     |13.0
                 CC|rguenther at suse dot de           |rguenth at gcc dot gnu.org,
                   |                            |rsandifo at gcc dot gnu.org
           Keywords|                            |ice-on-valid-code

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
I think EXTRACT_LAST_REDUCTION cannot simply do

   /* Instead of doing ~x ? y : z do x ? z : y.  */
   vec_compare = new_temp;
   std::swap (vec_then_clause, vec_else_clause);

So either the fix could be to not support bitop2 == BIT_NOT_EXPR for
EXTRACT_LAST_REDUCTION or we have to perform the BIT_NOT_EXPR as
vector operation.

Richard?

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

* [Bug tree-optimization/106476] ICE generating FOLD_EXTRACT_LAST
  2022-07-29 13:08 [Bug tree-optimization/106476] New: ICE generating FOLD_EXTRACT_LAST ams at gcc dot gnu.org
  2022-08-01  9:04 ` [Bug tree-optimization/106476] " rguenth at gcc dot gnu.org
@ 2022-09-15 12:08 ` rsandifo at gcc dot gnu.org
  2023-01-10 10:47 ` rguenth at gcc dot gnu.org
  2023-01-10 12:09 ` rguenth at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: rsandifo at gcc dot gnu.org @ 2022-09-15 12:08 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from rsandifo at gcc dot gnu.org <rsandifo at gcc dot gnu.org> ---
(In reply to Richard Biener from comment #1)
> I think EXTRACT_LAST_REDUCTION cannot simply do
> 
>    /* Instead of doing ~x ? y : z do x ? z : y.  */
>    vec_compare = new_temp;
>    std::swap (vec_then_clause, vec_else_clause);
> 
> So either the fix could be to not support bitop2 == BIT_NOT_EXPR for
> EXTRACT_LAST_REDUCTION or we have to perform the BIT_NOT_EXPR as
> vector operation.
> 
> Richard?
Agreed.  This case seems to be specific to EQ_EXPR on booleans,
and I'm not sure why we can't just emit an EQ_EXPR for that case.
Anything else would lead to redundant ops for EXTRACT_LAST_REDUCTION.

There again, having (predicate, predicate → predicate) comparisons for
EQ_EXPR might be a weird special case, and might be similar to having
things like NAND and NOR (which we deliberately don't have).  So maybe
emitting the separate NOT_EXPR is better after all.

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

* [Bug tree-optimization/106476] ICE generating FOLD_EXTRACT_LAST
  2022-07-29 13:08 [Bug tree-optimization/106476] New: ICE generating FOLD_EXTRACT_LAST ams at gcc dot gnu.org
  2022-08-01  9:04 ` [Bug tree-optimization/106476] " rguenth at gcc dot gnu.org
  2022-09-15 12:08 ` rsandifo at gcc dot gnu.org
@ 2023-01-10 10:47 ` rguenth at gcc dot gnu.org
  2023-01-10 12:09 ` rguenth at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-01-10 10:47 UTC (permalink / raw)
  To: gcc-bugs

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

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
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2023-01-10
             Status|UNCONFIRMED                 |ASSIGNED

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
I've posted a patch.

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

* [Bug tree-optimization/106476] ICE generating FOLD_EXTRACT_LAST
  2022-07-29 13:08 [Bug tree-optimization/106476] New: ICE generating FOLD_EXTRACT_LAST ams at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2023-01-10 10:47 ` rguenth at gcc dot gnu.org
@ 2023-01-10 12:09 ` rguenth at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-01-10 12:09 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to work|                            |13.0
         Resolution|---                         |FIXED
             Status|ASSIGNED                    |RESOLVED

--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> ---
Fixed by r13-5089-g554bb9b61e2b76d4ace16a3f766b98ea887b17f4 on trunk.

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

end of thread, other threads:[~2023-01-10 12:09 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-29 13:08 [Bug tree-optimization/106476] New: ICE generating FOLD_EXTRACT_LAST ams at gcc dot gnu.org
2022-08-01  9:04 ` [Bug tree-optimization/106476] " rguenth at gcc dot gnu.org
2022-09-15 12:08 ` rsandifo at gcc dot gnu.org
2023-01-10 10:47 ` rguenth at gcc dot gnu.org
2023-01-10 12:09 ` 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).