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

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