On Fri, Apr 01, 2016 at 06:14:00PM +0200, Marek Polacek wrote: > On Fri, Apr 01, 2016 at 06:02:24PM +0200, Jakub Jelinek wrote: > > On Fri, Apr 01, 2016 at 09:54:39AM -0600, Jeff Law wrote: > > > >--- gcc/c/c-fold.c > > > >+++ gcc/c/c-fold.c > > > >@@ -528,6 +528,23 @@ c_fully_fold_internal (tree expr, bool in_init, > > > >bool *maybe_const_operands, > > > > *maybe_const_itself &= op2_const_self; > > > > goto out; > > > > > > > >+ case VEC_COND_EXPR: > > > >+ orig_op0 = op0 = TREE_OPERAND (expr, 0); > > > >+ op1 = TREE_OPERAND (expr, 1); > > > >+ op2 = TREE_OPERAND (expr, 2); > > > >+ op0 = c_fully_fold_internal (op0, in_init, maybe_const_operands, > > > >+ maybe_const_itself, for_int_const); > > > >+ STRIP_TYPE_NOPS (op0); > > > >+ > > > >+ /* OP1 will be a vector of -1 and OP2 a vector if 0, as created in > > > >+ build_vec_cmp -- no need to fold them. */ > > > Is this worth verifying with a gcc_assert? Your call. > > > > > > OK with or without the gcc_assert that op1/op2 are constants. > > I'm going to add the asserts. I should've add them in the first place. > > > I think either we should have an gcc_checking_assert, or can't > > we just handle VEC_COND_EXPR like COND_EXPR, with no extra code? > > It works (I seem to remember testing that variant), but the COND_EXPR case > code does a lot of stuff that doesn't seem to make sense for vectors, like > checking for truthvalue_false_node, folding op1/op2, playing games with > maybe_const_* stuff... So I decided to add a new case.
Those comparisons with truthvalue_*_node would fail and DTRT. Or just c_fully_fold_internal all the arguments, be ready for any future further uses of VEC_COND_EXPR early? Jakub