public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/111285] New: vector ABSU is lowered incorrectly
@ 2023-09-04 17:35 pinskia at gcc dot gnu.org
  2023-09-12 11:06 ` [Bug tree-optimization/111285] " rguenth at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-09-04 17:35 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 111285
           Summary: vector ABSU is lowered incorrectly
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: pinskia at gcc dot gnu.org
            Blocks: 110009
  Target Milestone: ---

Take:
```
#define vector __attribute__((vector_size(1*sizeof(int))))
void unsigned_f1 (vector int *vp,  vector unsigned *x)
{
  vector int v = *vp;
  vector unsigned int d_6;
  vector int b_5;
  vector unsigned int v1_2;
  vector unsigned int _7;
  vector int _9;

  b_5 = v>>(sizeof(int)*8 - 1);
  _9 = b_5 | 1;
  d_6 = (vector unsigned int) _9;
  v1_2 = (vector unsigned int) v;
  _7 = v1_2 * d_6;
  *x = _7;
}


```
and this match.pd pattern:
```
/* x * ((x>>N)|1) -> abs(x) */
(simplify
 (mult:c @0 (nop_convert? (bit_ior:c (rshift @1 INTEGER_CST@2) integer_onep)))
 (if (!TYPE_UNSIGNED (TREE_TYPE (@1))
      && wi::to_wide (@2) == element_precision (type) - 1
      && bitwise_equal_p (@0, @1))
  (if (TYPE_UNSIGNED (type))
   (absu @1)
   (abs @1))))
```
With this we get right before vector lowering:
```
  v_3 = *vp_2(D);
  _7_4 = ABSU_EXPR <v_3>;
  # .MEM_6 = VDEF <.MEM_1(D)>
  *x_5(D) = _7_4;
```
Which is correct.
But then lowering comes along and gives:
```
  v_3 = *vp_2(D);
  _7 = VIEW_CONVERT_EXPR<unsigned intD.9>(v_3);
  _7_4 = {_7};
  # .MEM_6 = VDEF <.MEM_1(D)>
  *x_5(D) = _7_4;

```

This is because we used the lhs type rather than the rhs type ...


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110009
[Bug 110009] Another missing ABS detection

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

* [Bug tree-optimization/111285] vector ABSU is lowered incorrectly
  2023-09-04 17:35 [Bug tree-optimization/111285] New: vector ABSU is lowered incorrectly pinskia at gcc dot gnu.org
@ 2023-09-12 11:06 ` rguenth at gcc dot gnu.org
  2023-09-12 16:33 ` pinskia at gcc dot gnu.org
  2023-09-25  0:04 ` pinskia at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-09-12 11:06 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
are you going to fix it?

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

* [Bug tree-optimization/111285] vector ABSU is lowered incorrectly
  2023-09-04 17:35 [Bug tree-optimization/111285] New: vector ABSU is lowered incorrectly pinskia at gcc dot gnu.org
  2023-09-12 11:06 ` [Bug tree-optimization/111285] " rguenth at gcc dot gnu.org
@ 2023-09-12 16:33 ` pinskia at gcc dot gnu.org
  2023-09-25  0:04 ` pinskia at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-09-12 16:33 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|unassigned at gcc dot gnu.org      |pinskia at gcc dot gnu.org
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2023-09-12
     Ever confirmed|0                           |1

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Richard Biener from comment #1)
> are you going to fix it?

Yes I am going to fix this but maybe the week after next. I filed it so I would
not lose track of what needs to be done.

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

* [Bug tree-optimization/111285] vector ABSU is lowered incorrectly
  2023-09-04 17:35 [Bug tree-optimization/111285] New: vector ABSU is lowered incorrectly pinskia at gcc dot gnu.org
  2023-09-12 11:06 ` [Bug tree-optimization/111285] " rguenth at gcc dot gnu.org
  2023-09-12 16:33 ` pinskia at gcc dot gnu.org
@ 2023-09-25  0:04 ` pinskia at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-09-25  0:04 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Created attachment 55985
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=55985&action=edit
Patch which fixes the issue

I am not sure this is the best patch but we don't pass down 2 inner types into
do_unop (or a different version of this).

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

end of thread, other threads:[~2023-09-25  0:04 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-04 17:35 [Bug tree-optimization/111285] New: vector ABSU is lowered incorrectly pinskia at gcc dot gnu.org
2023-09-12 11:06 ` [Bug tree-optimization/111285] " rguenth at gcc dot gnu.org
2023-09-12 16:33 ` pinskia at gcc dot gnu.org
2023-09-25  0:04 ` pinskia 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).