public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "redi at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug rtl-optimization/95493] [10 Regression] test for vector members apparently reordered with assignment to vector members since r10-7523-gb90061c6ec090c6b
Date: Tue, 16 Jun 2020 12:58:26 +0000	[thread overview]
Message-ID: <bug-95493-4-j51o9R96Il@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-95493-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #8 from Jonathan Wakely <redi at gcc dot gnu.org> ---
This also fixes a regression introduced by:

    alias.c (ao_ref_from_mem): Move stack-slot sharing rewrite ...

    2019-05-22  Richard Biener  <rguenther@suse.de>

            * alias.c (ao_ref_from_mem): Move stack-slot sharing
            rewrite ...
            * emit-rtl.c (set_mem_attributes_minus_bitpos): ... here.

    From-SVN: r271510

See https://gcc.gnu.org/pipermail/gcc-help/2020-June/139060.html which has the
following testcase (modified by me to abort instead of just print things out):

#include <array>
#include <iostream>

struct Point
{
    std::array<int, 3> array;

    Point(int x, int y, int z) : array{x, y, z} {}

    Point(const Point & other) : array{other.array} {} // OK if commented
    //Point(const Point &) = default; // OK

    //Point(Point && other) = default; // OK

    int  operator[] (std::size_t i) const { return array[i]; }
    int& operator[] (std::size_t i)       { return array[i]; }
};

//using Point = std::array<int, 3>; // OK

struct Cell
{
    Point point;
    Cell(Point const& pt) : point(pt) {}
    int   operator[] (std::size_t i) const { return point[i]; }
    int&  operator[] (std::size_t i)       { return point[i]; }
};

//using Cell = Point; // OK

std::ostream & operator<< (std::ostream & out, Cell const& object)
//std::ostream & operator<< (std::ostream & out, Cell object) // Fails with f2
too
{
    for ( std::size_t i = 0; i < 3; ++i )
        out << object[ i ] << " ";
    return out;
}


struct DirIterator
{
    std::size_t dir;
    Cell cell;

    DirIterator(Cell c)
        : dir(0), cell(c)
    {
        find(); // OK if commented
    }

    void find()
    {
        //while (dir < 3) // Fails with f2 too
        while (dir < 3 && (cell[dir] % 2) == 0)
            ++dir;
    }
};

Cell uIncident(Cell c, std::size_t k)
//Cell uIncident(Cell& c, std::size_t k) // OK
{
    --c[k];
    return c;
}

Cell uSpel(Point p)
{
    for (std::size_t i = 0; i < 3; ++i)
        p[i] += p[i] + 1;
    return Cell(p);
}


int main () {
    Cell c = uSpel(Point{0, 0, 0}); // Fails
    //Cell c( Point(1, 1, 1) ); // OK

    auto q = DirIterator( c );

    Cell f1 = uIncident( c, q.dir ); // Fails
    //Cell f1 = uIncident( c, 0 ); // OK

    Cell f2 = f1; // f2 is the right cell that f1 should be

    std::cout << "q.dir = " << q.dir << " ; f1 = " << f1 << " ; f2 = " << f2 <<
std::endl;
    //std::cout << "q.dir = " << q.dir << " ; f1 = " << f1[0] << " " << f1[1]
<< " " << f1[2] << " ; f2 = " << f2[0] << " " << f2[1] << " " << f2[2] <<
std::endl; // OK

    for (int i = 0; i < 3; ++i)
      if (f1[i] != f2[i])
        __builtin_abort();

    return 0;
}

  parent reply	other threads:[~2020-06-16 12:58 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-03  7:49 [Bug tree-optimization/95493] New: [10 Regression] test for vector members apparently reordered with assignment to vector members kretz at kde dot org
2020-06-03  8:15 ` [Bug tree-optimization/95493] [10/11 Regression] test for vector members apparently reordered with assignment to vector members since r10-7523-gb90061c6ec090c6b marxin at gcc dot gnu.org
2020-06-03  8:20 ` [Bug middle-end/95493] " pinskia at gcc dot gnu.org
2020-06-03  9:51 ` [Bug rtl-optimization/95493] " rguenth at gcc dot gnu.org
2020-06-03 10:00 ` rguenth at gcc dot gnu.org
2020-06-03 11:15 ` rguenth at gcc dot gnu.org
2020-06-05  6:35 ` cvs-commit at gcc dot gnu.org
2020-06-05  6:36 ` [Bug rtl-optimization/95493] [10 " rguenth at gcc dot gnu.org
2020-06-16 11:57 ` rguenth at gcc dot gnu.org
2020-06-16 12:58 ` redi at gcc dot gnu.org [this message]
2020-06-16 22:15 ` cvs-commit at gcc dot gnu.org
2020-06-19 12:08 ` kretz at kde dot org
2020-06-19 12:29 ` rguenth at gcc dot gnu.org
2020-06-23 13:31 ` cvs-commit at gcc dot gnu.org
2020-06-23 13:31 ` rguenth at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-95493-4-j51o9R96Il@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).