Patchwork [C++] Missing save_expr in vector-scalar ops

login
register
mail settings
Submitter Marc Glisse
Date May 6, 2013, 11:46 a.m.
Message ID <alpine.DEB.2.02.1305061158180.21261@stedding.saclay.inria.fr>
Download mbox | patch
Permalink /patch/241622/
State New
Headers show

Comments

Marc Glisse - May 6, 2013, 11:46 a.m.
Hello,

this patch is extracted from
http://gcc.gnu.org/ml/gcc-patches/2013-04/msg00783.html

When I copied this code from the C front-end and removed c_fully_fold, I 
apparently also removed the save_expr, so I am putting it back in. I added 
it after convert while the C front-end has it before convert, I can put it 
before if you prefer.

Bootstrap+testsuite on x86_64-linux-gnu.
(I believe it should also be backported to 4.8)

2013-05-06  Marc Glisse  <marc.glisse@inria.fr>

gcc/cp/
 	* typeck.c (cp_build_binary_op): Call save_expr before
 	build_vector_from_val.

gcc/testsuite/
 	* c-c++-common/vector-scalar-2.c: New testcase.
Jason Merrill - May 6, 2013, 4:27 p.m.
On 05/06/2013 07:46 AM, Marc Glisse wrote:
> I added it after convert while the C front-end has it before convert, I
> can put it before if you prefer.

Let's be consistent.

OK for trunk and 4.8.

Jason

Patch

Index: gcc/testsuite/c-c++-common/vector-scalar-2.c

===================================================================
--- gcc/testsuite/c-c++-common/vector-scalar-2.c	(revision 0)

+++ gcc/testsuite/c-c++-common/vector-scalar-2.c	(revision 0)

@@ -0,0 +1,14 @@ 

+/* { dg-do compile } */

+/* { dg-options "-fdump-tree-gimple" } */

+

+typedef int veci __attribute__ ((vector_size (4 * sizeof (int))));

+

+int c;

+

+void f (veci *a)

+{

+  *a = *a + ++c;

+}

+

+/* { dg-final { scan-tree-dump-times " \\\+ 1" 1 "gimple" } } */

+/* { dg-final { cleanup-tree-dump "gimple" } } */


Property changes on: gcc/testsuite/c-c++-common/vector-scalar-2.c
___________________________________________________________________
Added: svn:keywords
   + Author Date Id Revision URL
Added: svn:eol-style
   + native

Index: gcc/cp/typeck.c

===================================================================
--- gcc/cp/typeck.c	(revision 198624)

+++ gcc/cp/typeck.c	(working copy)

@@ -3966,29 +3966,31 @@  cp_build_binary_op (location_t location,

       enum stv_conv convert_flag = scalar_to_vector (location, code, op0, op1,
 						     complain & tf_error);
 
       switch (convert_flag)
         {
           case stv_error:
             return error_mark_node;
           case stv_firstarg:
             {
               op0 = convert (TREE_TYPE (type1), op0);
+	      op0 = save_expr (op0);

               op0 = build_vector_from_val (type1, op0);
               type0 = TREE_TYPE (op0);
               code0 = TREE_CODE (type0);
               converted = 1;
               break;
             }
           case stv_secondarg:
             {
               op1 = convert (TREE_TYPE (type0), op1);
+	      op1 = save_expr (op1);

               op1 = build_vector_from_val (type0, op1);
               type1 = TREE_TYPE (op1);
               code1 = TREE_CODE (type1);
               converted = 1;
               break;
             }
           default:
             break;
         }
     }