Patchwork [C++] Don't build NE_EXPR manually

login
register
mail settings
Submitter Marc Glisse
Date May 16, 2013, 3:07 p.m.
Message ID <alpine.DEB.2.02.1305161654380.19706@stedding.saclay.inria.fr>
Download mbox | patch
Permalink /patch/244350/
State New
Headers show

Comments

Marc Glisse - May 16, 2013, 3:07 p.m.
Hello,

this is a minor patch, instead of manually building a NE_EXPR, it seems 
better to call the front-end function whose job it is. Incidentally, it 
means one expression is folded a little bit more, so I am re-enabling a 
test that I commented out this morning.

Bootstrap+testsuite on x86_64-linux-gnu.

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

gcc/cp/
 	* call.c (build_conditional_expr_1): Use cp_build_binary_op
 	instead of directly calling fold_build2.

gcc/testsuite/
 	* g++.dg/ext/vector22.C: Uncomment working test.
Jason Merrill - May 16, 2013, 8:02 p.m.
OK.

Jason

Patch

Index: cp/call.c

===================================================================
--- cp/call.c	(revision 198970)

+++ cp/call.c	(working copy)

@@ -4448,22 +4448,22 @@  build_conditional_expr_1 (tree arg1, tre

 	  || TYPE_SIZE (arg1_type) != TYPE_SIZE (arg2_type))
 	{
 	  if (complain & tf_error)
 	    error ("incompatible vector types in conditional expression: "
 		   "%qT, %qT and %qT", TREE_TYPE (arg1), TREE_TYPE (orig_arg2),
 		   TREE_TYPE (orig_arg3));
 	  return error_mark_node;
 	}
 
       if (!COMPARISON_CLASS_P (arg1))
-	arg1 = fold_build2 (NE_EXPR, signed_type_for (arg1_type), arg1,

-		       build_zero_cst (arg1_type));

+	arg1 = cp_build_binary_op (input_location, NE_EXPR, arg1,

+				   build_zero_cst (arg1_type), complain);

       return fold_build3 (VEC_COND_EXPR, arg2_type, arg1, arg2, arg3);
     }
 
   /* [expr.cond]
 
      The first expression is implicitly converted to bool (clause
      _conv_).  */
   arg1 = perform_implicit_conversion_flags (boolean_type_node, arg1, complain,
 					    LOOKUP_NORMAL);
   if (error_operand_p (arg1))
Index: testsuite/g++.dg/ext/vector22.C

===================================================================
--- testsuite/g++.dg/ext/vector22.C	(revision 198970)

+++ testsuite/g++.dg/ext/vector22.C	(working copy)

@@ -4,19 +4,19 @@ 

 typedef unsigned vec __attribute__((vector_size(4*sizeof(int))));
 
 /* Disabled after PR57286
 void f(vec*a,vec*b){
   *a=(*a)?-1:(*b<10);
   *b=(*b)?(*a<10):0;
 }
 */
 void g(vec*a,vec*b){
   *a=(*a)?(*a<*a):-1;
-// *b=(*b)?-1:(*b<*b);

+  *b=(*b)?-1:(*b<*b);

 }
 void h(vec*a){
   *a=(~*a==5);
 }
 
 /* { dg-final { scan-tree-dump-not "~" "gimple" } } */
 /* { dg-final { scan-tree-dump-not "VEC_COND_EXPR" "gimple" } } */
 /* { dg-final { cleanup-tree-dump "gimple" } } */