public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/101540] New: CONSTRUCTOR for vector(1) should just be VCE
@ 2021-07-20 22:01 pinskia at gcc dot gnu.org
  2021-07-21  7:00 ` [Bug tree-optimization/101540] " rguenth at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-07-20 22:01 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 101540
           Summary: CONSTRUCTOR for vector(1) should just be VCE
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: enhancement
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: pinskia at gcc dot gnu.org
  Target Milestone: ---

I noticed with the following source:
typedef unsigned char __attribute__((__vector_size__ (1))) W;
typedef unsigned char __attribute__((__vector_size__ (8))) V;
typedef unsigned short __attribute__((__vector_size__ (16))) U;

unsigned short us;

W
foo (unsigned char uc)
{
  V v = __builtin_convertvector ((U){ } >= us, V);
  return __builtin_shufflevector ((W){ }, v, 4) & uc;
}

int
main (void)
{
  W x = foo (5);
  if (x[0] != 5)
    __builtin_abort();
  return 0;
}
----- CUT ----
We produce
_6 = {uc_10(D)};
But this should be the same as
_6 = VIEW_CONVERT_EXPR<uc_10>

--- CUT ---
This is what we get in the IR:
  _6 = {uc_10(D)};
  _14 = BIT_FIELD_REF <_4, 8, 0>;
  _15 = VIEW_CONVERT_EXPR<unsigned char>(_6);
  _16 = _14 & _15;
  _17 = VIEW_CONVERT_EXPR<W>(_16);

We do change the BIT_FIELD_REF that was assigned to _15 to a VCE though.

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

* [Bug tree-optimization/101540] CONSTRUCTOR for vector(1) should just be VCE
  2021-07-20 22:01 [Bug tree-optimization/101540] New: CONSTRUCTOR for vector(1) should just be VCE pinskia at gcc dot gnu.org
@ 2021-07-21  7:00 ` rguenth at gcc dot gnu.org
  2021-11-28  8:55 ` pinskia at gcc dot gnu.org
  2021-11-28 17:57 ` pinskia at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-07-21  7:00 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2021-07-21
             Status|UNCONFIRMED                 |NEW

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
Confirmed.  forwprop has simplify_vector_constructor for example.

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

* [Bug tree-optimization/101540] CONSTRUCTOR for vector(1) should just be VCE
  2021-07-20 22:01 [Bug tree-optimization/101540] New: CONSTRUCTOR for vector(1) should just be VCE pinskia at gcc dot gnu.org
  2021-07-21  7:00 ` [Bug tree-optimization/101540] " rguenth at gcc dot gnu.org
@ 2021-11-28  8:55 ` pinskia at gcc dot gnu.org
  2021-11-28 17:57 ` pinskia at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-11-28  8:55 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
I think I have a patch.

Basically adding this to simplify_vector_constructor should work for most
cases.

  if (nelts == 1 && CONSTRUCTOR_NELTS (op) == 1)
    {
      tree op1 = CONSTRUCTOR_ELT (op, 0);
      if (useless_type_conversion_p (elem_type, TREE_TYPE (op1)))
        {
          op1 = build1 (VIEW_CONVERT_EXPR, type, op1);
          gimple_assign_set_rhs_from_tree (gsi, op1);
          update_stmt (gsi_stmt (*gsi));
          return true;
        }
    }

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

* [Bug tree-optimization/101540] CONSTRUCTOR for vector(1) should just be VCE
  2021-07-20 22:01 [Bug tree-optimization/101540] New: CONSTRUCTOR for vector(1) should just be VCE pinskia at gcc dot gnu.org
  2021-07-21  7:00 ` [Bug tree-optimization/101540] " rguenth at gcc dot gnu.org
  2021-11-28  8:55 ` pinskia at gcc dot gnu.org
@ 2021-11-28 17:57 ` pinskia at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-11-28 17:57 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                URL|                            |https://gcc.gnu.org/piperma
                   |                            |il/gcc-patches/2021-Novembe
                   |                            |r/585597.html
           Keywords|                            |patch

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Patch submitted:
https://gcc.gnu.org/pipermail/gcc-patches/2021-November/585597.html

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

end of thread, other threads:[~2021-11-28 17:57 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-20 22:01 [Bug tree-optimization/101540] New: CONSTRUCTOR for vector(1) should just be VCE pinskia at gcc dot gnu.org
2021-07-21  7:00 ` [Bug tree-optimization/101540] " rguenth at gcc dot gnu.org
2021-11-28  8:55 ` pinskia at gcc dot gnu.org
2021-11-28 17:57 ` 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).