diff --git a/gcc/jit/jit-playback.cc b/gcc/jit/jit-playback.cc index 2ea6ed9ee46a2..0da3b42257e22 100644 --- a/gcc/jit/jit-playback.cc +++ b/gcc/jit/jit-playback.cc @@ -1288,7 +1288,7 @@ playback::rvalue * playback::context:: new_comparison (location *loc, enum gcc_jit_comparison op, - rvalue *a, rvalue *b) + rvalue *a, rvalue *b, type *vec_result_type) { // FIXME: type-checking, or coercion? enum tree_code inner_op; @@ -1332,11 +1332,12 @@ new_comparison (location *loc, if (VECTOR_TYPE_P (a_type)) { // TODO: document where this comes from and what it is doing. - tree zero_vec = build_zero_cst (a_type); - tree minus_one_vec = build_minus_one_cst (a_type); + tree t_vec_result_type = vec_result_type->as_tree (); + tree zero_vec = build_zero_cst (t_vec_result_type); + tree minus_one_vec = build_minus_one_cst (t_vec_result_type); tree cmp_type = truth_type_for (a_type); tree cmp = build2 (inner_op, cmp_type, node_a, node_b); - inner_expr = build3 (VEC_COND_EXPR, a_type, cmp, minus_one_vec, zero_vec); + inner_expr = build3 (VEC_COND_EXPR, t_vec_result_type, cmp, minus_one_vec, zero_vec); } else { diff --git a/gcc/jit/jit-playback.h b/gcc/jit/jit-playback.h index ed9f590bedc75..0d285637cdf36 100644 --- a/gcc/jit/jit-playback.h +++ b/gcc/jit/jit-playback.h @@ -176,7 +176,7 @@ class context : public log_user rvalue * new_comparison (location *loc, enum gcc_jit_comparison op, - rvalue *a, rvalue *b); + rvalue *a, rvalue *b, type *vec_result_type); rvalue * new_call (location *loc, diff --git a/gcc/jit/jit-recording.cc b/gcc/jit/jit-recording.cc index 8e93736cda47c..efed7c4319679 100644 --- a/gcc/jit/jit-recording.cc +++ b/gcc/jit/jit-recording.cc @@ -6061,7 +6061,8 @@ recording::comparison::replay_into (replayer *r) set_playback_obj (r->new_comparison (playback_location (r, m_loc), m_op, m_a->playback_rvalue (), - m_b->playback_rvalue ())); + m_b->playback_rvalue (), + m_type->playback_type ())); } /* Implementation of pure virtual hook recording::rvalue::visit_children diff --git a/gcc/jit/jit-recording.h b/gcc/jit/jit-recording.h index d9caa4fbf6f07..bd29a9eedd22d 100644 --- a/gcc/jit/jit-recording.h +++ b/gcc/jit/jit-recording.h @@ -1836,9 +1836,20 @@ class comparison : public rvalue m_b (b) { type *a_type = a->get_type (); - if (a_type->dyn_cast_vector_type () != NULL) + vector_type *vec_type = a_type->dyn_cast_vector_type (); + if (vec_type != NULL) { - m_type = a_type; + type *element_type = vec_type->get_element_type (); + type *inner_type; + if (element_type == ctxt->get_type (GCC_JIT_TYPE_FLOAT)) + /* TODO: choose correct int type by size instead. */ + inner_type = ctxt->get_type (GCC_JIT_TYPE_INT); + else if (element_type == ctxt->get_type (GCC_JIT_TYPE_DOUBLE)) + inner_type = ctxt->get_type (GCC_JIT_TYPE_LONG); + else + inner_type = element_type; + m_type = new vector_type (inner_type, vec_type->get_num_units ()); + ctxt->record (m_type); } }