On Fri, Sep 6, 2019 at 5:45 PM Ilya Leoshkevich <i...@linux.ibm.com> wrote: > > > Am 06.09.2019 um 13:07 schrieb Richard Biener <richard.guent...@gmail.com>: > > > > On Thu, Sep 5, 2019 at 1:10 PM Ilya Leoshkevich <i...@linux.ibm.com> wrote: > >> > >> Right now gimplifier does not allow VEC_COND_EXPR's condition to trap > >> and introduces a temporary if this could happen, for example, generating > >> > >> _5 = _4 > { 2.0e+0, 2.0e+0, 2.0e+0, 2.0e+0 }; > >> _6 = VEC_COND_EXPR <_5, { -1, -1, -1, -1 }, { 0, 0, 0, 0 }>; > >> > >> from GENERIC > >> > >> VEC_COND_EXPR < (*b > { 2.0e+0, 2.0e+0, 2.0e+0, 2.0e+0 }) , > >> { -1, -1, -1, -1 } , > >> { 0, 0, 0, 0 } > > >> > >> This is not necessary and makes the resulting GIMPLE harder to analyze. > >> In particular, one of the next patches in series needs to get to > >> VEC_COND_EXPR's comparison code, which is not possible when a temporary > >> is introduced. > >> > >> This patch takes special care to avoid introducing trapping comparisons > >> in GIMPLE_COND. They are not allowed, because they would require 3 > >> outgoing edges (then, else and EH), which is awkward to say the least. > >> Therefore, computations of such conditions should live in their own basic > >> blocks. > > > > Comments inline (thanks for the work btw) > > > >> #endif /* GCC_GIMPLE_EXPR_H */ > >> diff --git a/gcc/gimple.c b/gcc/gimple.c > >> index 633ef512a19..fd14fbec15e 100644 > >> --- a/gcc/gimple.c > >> +++ b/gcc/gimple.c > >> @@ -2144,6 +2144,8 @@ gimple_could_trap_p_1 (gimple *s, bool include_mem, > >> bool include_stores) > >> op = gimple_assign_rhs_code (s); > >> if (get_gimple_rhs_class (op) == GIMPLE_BINARY_RHS) > >> div = gimple_assign_rhs2 (s); > >> + else if (op == COND_EXPR || op == VEC_COND_EXPR) > >> + op = TREE_CODE (gimple_assign_rhs1 (s)); > > > > I think this is not correct since we can have > > > > int i = fp > 1. ? intval1 : intval2 > > > > and thus FLOAT_TYPE_P (t) is wrong. You need to do > > > > t = TREE_TYPE (op); > > > > as well I think. > > Doesn't this mean there is a problem with the existing logic too? If `s` > is > > int i = fp > 1.; > > then > > t = gimple_expr_type (s); > > would give us BOOLEAN_TYPE instead of REAL_TYPE.
Yeah, that looks broken as well. > > Also, the new logic will probably be a bit more complicated, since I > will first have to do: > > tree cond = gimple_assign_rhs1 (s); > > then see if `cond` is not e.g. an SSA_NAME, but rather a tcc_comparison, > and only then > > t = TREE_TYPE (TREE_OPERAND (cond, 0)) > > So I'd rather send a new version before merging this :-) Fine with me ;) Richard.