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 libstdc++/99117] [9/10/11 Regression] cannot accumulate std::valarray
Date: Tue, 16 Feb 2021 11:47:43 +0000	[thread overview]
Message-ID: <bug-99117-4-OhawN8B6mR@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-99117-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #7 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Jakub Jelinek from comment #5)
> int* p = sum._M_data;
> int* e1 = sum._M_data;
> 
> If p and e1 aren't __restrict__ too, shouldn't that be fine?

p (called __p below) doesn't use __restrict__:

  template<typename _Tp, class _Dom>
    void
    __valarray_copy(const _Expr<_Dom, _Tp>& __e, size_t __n, _Array<_Tp> __a)
    {
      _Tp* __p (__a._M_data);
      for (size_t __i = 0; __i < __n; ++__i, ++__p)
        *__p = __e[__i];
    }

Here __e is the expression template which has two const valarray<int>& members,
so maybe more accurately it's:

struct valarray {
  int* __restrict__ _M_data;
  size_t _M_size;
};
valarray sum{ new int[2]{1,1}, 2 };
valarray rhs{ new int[2]{2,2}, 2 };
int* p = sum._M_data;
const valarray& e1 = sum;
const valarray& e2 = rhs;
for (size_t i = 0; i < sum._M_size; ++i, ++p)
  *p = e1._M_data[i] + e2._M_data[i];

So e1._M_data is marked with __restrict__.

  parent reply	other threads:[~2021-02-16 11:47 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-16  5:26 [Bug c++/99117] New: " yasui at icepp dot s.u-tokyo.ac.jp
2021-02-16  7:43 ` [Bug middle-end/99117] [9/10/11 Regression] " rguenth at gcc dot gnu.org
2021-02-16  7:59 ` [Bug libstdc++/99117] " rguenth at gcc dot gnu.org
2021-02-16 10:41 ` redi at gcc dot gnu.org
2021-02-16 11:01 ` redi at gcc dot gnu.org
2021-02-16 11:25 ` jakub at gcc dot gnu.org
2021-02-16 11:40 ` rguenther at suse dot de
2021-02-16 11:47 ` redi at gcc dot gnu.org [this message]
2021-02-16 11:54 ` rguenther at suse dot de
2021-02-16 14:07 ` redi at gcc dot gnu.org
2021-02-23  9:28 ` rguenth at gcc dot gnu.org
2021-02-23 10:35 ` redi at gcc dot gnu.org
2021-02-23 11:43 ` rguenther at suse dot de
2021-02-23 13:26 ` rguenth at gcc dot gnu.org
2021-02-23 13:30 ` jakub at gcc dot gnu.org
2021-02-23 13:56 ` jakub at gcc dot gnu.org
2021-02-23 14:17 ` jakub at gcc dot gnu.org
2021-02-23 14:20 ` jakub at gcc dot gnu.org
2021-06-01  8:19 ` [Bug libstdc++/99117] [9/10/11/12 " rguenth at gcc dot gnu.org
2022-05-27  9:44 ` [Bug libstdc++/99117] [10/11/12/13 " rguenth at gcc dot gnu.org
2022-06-28 10:43 ` jakub at gcc dot gnu.org
2023-07-07 10:39 ` [Bug libstdc++/99117] [11/12/13/14 " rguenth at gcc dot gnu.org
2024-02-08 21:34 ` redi at gcc dot gnu.org
2024-02-15 11:44 ` cvs-commit at gcc dot gnu.org
2024-02-16 15:12 ` [Bug libstdc++/99117] [11/12/13 " cvs-commit 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-99117-4-OhawN8B6mR@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).