public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "vincenzo.innocente at cern dot ch" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/53094] constexpr vector subscripting
Date: Mon, 03 Dec 2012 21:58:00 -0000	[thread overview]
Message-ID: <bug-53094-4-f2RMk4m3s4@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-53094-4@http.gcc.gnu.org/bugzilla/>


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53094

--- Comment #11 from vincenzo Innocente <vincenzo.innocente at cern dot ch> 2012-12-03 21:58:05 UTC ---
thanks Marc,
adding your proposed change above Jason's one make my full test works (but when
subscripting is involved..)
this is my current svn diff
Hope that c++ maintainers came make, out of all this, an optimal patch for the
trunk. 
I'm not expert enough on the details to judge what best (besides that I did not
run regression!)

Index: gcc/cp/tree.c
===================================================================
--- gcc/cp/tree.c    (revision 194084)
+++ gcc/cp/tree.c    (working copy)
@@ -2468,7 +2468,8 @@
     case COMPLEX_CST:
       return cp_tree_equal (TREE_REALPART (t1), TREE_REALPART (t2))
     && cp_tree_equal (TREE_IMAGPART (t1), TREE_IMAGPART (t2));
-
+    case VECTOR_CST:
+          return operand_equal_p (t1, t2, OEP_ONLY_CONST);    
     case CONSTRUCTOR:
       /* We need to do this when determining whether or not two
      non-type pointer to member function template arguments
Index: gcc/cp/semantics.c
===================================================================
--- gcc/cp/semantics.c    (revision 194084)
+++ gcc/cp/semantics.c    (working copy)
@@ -6451,6 +6451,14 @@
   /* Avoid wrapping an aggregate value in a NOP_EXPR.  */
   if (TREE_CODE (temp) == CONSTRUCTOR)
     return build_constructor (type, CONSTRUCTOR_ELTS (temp));
+  if (TREE_CODE (temp) == VECTOR_CST)
+    {
+      int i, count = TYPE_VECTOR_SUBPARTS (type);
+      tree *vec = XALLOCAVEC (tree, count);
+      for (i = 0; i < count; i++)
+    vec[i] = cp_fold_convert (TREE_TYPE (type), VECTOR_CST_ELT (temp, i));
+      return build_vector (type, vec);
+    }
   gcc_assert (SCALAR_TYPE_P (type));
   return cp_fold_convert (type, temp);
 }
@@ -7134,7 +7142,10 @@
       vec_free (n);
       return t;
     }
+
   t = build_constructor (TREE_TYPE (t), n);
+  if (TREE_CODE (TREE_TYPE (t)) == VECTOR_TYPE)
+    t = fold (t);
   TREE_CONSTANT (t) = true;
   return t;
 }


  parent reply	other threads:[~2012-12-03 21:58 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-23 20:14 [Bug c++/53094] New: vector literal marc.glisse at normalesup dot org
2012-11-26 23:18 ` [Bug c++/53094] " glisse at gcc dot gnu.org
2012-11-28 17:26 ` glisse at gcc dot gnu.org
2012-11-28 21:11 ` glisse at gcc dot gnu.org
2012-11-28 21:53 ` glisse at gcc dot gnu.org
2012-11-29 15:40 ` glisse at gcc dot gnu.org
2012-11-29 15:45 ` [Bug c++/53094] constexpr vector subscripting glisse at gcc dot gnu.org
2012-12-03 14:30 ` vincenzo.innocente at cern dot ch
2012-12-03 14:54 ` glisse at gcc dot gnu.org
2012-12-03 19:15 ` vincenzo.innocente at cern dot ch
2012-12-03 19:53 ` glisse at gcc dot gnu.org
2012-12-03 21:58 ` vincenzo.innocente at cern dot ch [this message]
2012-12-03 22:05 ` vincenzo.innocente at cern dot ch
2012-12-03 22:31 ` glisse at gcc dot gnu.org
2012-12-11 20:20 ` glisse at gcc dot gnu.org
2013-07-09 16:02 ` glisse at gcc dot gnu.org
2013-07-09 16:10 ` glisse 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-53094-4-f2RMk4m3s4@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).