Skip to content

Commit 6fdab49

Browse files
committed
Fix float vector comparison
1 parent f228109 commit 6fdab49

File tree

4 files changed

+21
-8
lines changed

4 files changed

+21
-8
lines changed

gcc/jit/jit-playback.cc

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1310,7 +1310,7 @@ playback::rvalue *
13101310
playback::context::
13111311
new_comparison (location *loc,
13121312
enum gcc_jit_comparison op,
1313-
rvalue *a, rvalue *b)
1313+
rvalue *a, rvalue *b, type *vec_result_type)
13141314
{
13151315
// FIXME: type-checking, or coercion?
13161316
enum tree_code inner_op;
@@ -1354,11 +1354,12 @@ new_comparison (location *loc,
13541354
if (VECTOR_TYPE_P (a_type))
13551355
{
13561356
// TODO: document where this comes from and what it is doing.
1357-
tree zero_vec = build_zero_cst (a_type);
1358-
tree minus_one_vec = build_minus_one_cst (a_type);
1357+
tree t_vec_result_type = vec_result_type->as_tree ();
1358+
tree zero_vec = build_zero_cst (t_vec_result_type);
1359+
tree minus_one_vec = build_minus_one_cst (t_vec_result_type);
13591360
tree cmp_type = truth_type_for (a_type);
13601361
tree cmp = build2 (inner_op, cmp_type, node_a, node_b);
1361-
inner_expr = build3 (VEC_COND_EXPR, a_type, cmp, minus_one_vec, zero_vec);
1362+
inner_expr = build3 (VEC_COND_EXPR, t_vec_result_type, cmp, minus_one_vec, zero_vec);
13621363
}
13631364
else
13641365
{

gcc/jit/jit-playback.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ class context : public log_user
177177
rvalue *
178178
new_comparison (location *loc,
179179
enum gcc_jit_comparison op,
180-
rvalue *a, rvalue *b);
180+
rvalue *a, rvalue *b, type *vec_result_type);
181181

182182
rvalue *
183183
new_call (location *loc,

gcc/jit/jit-recording.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6066,7 +6066,8 @@ recording::comparison::replay_into (replayer *r)
60666066
set_playback_obj (r->new_comparison (playback_location (r, m_loc),
60676067
m_op,
60686068
m_a->playback_rvalue (),
6069-
m_b->playback_rvalue ()));
6069+
m_b->playback_rvalue (),
6070+
m_type->playback_type ()));
60706071
}
60716072

60726073
/* Implementation of pure virtual hook recording::rvalue::visit_children

gcc/jit/jit-recording.h

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1847,9 +1847,20 @@ class comparison : public rvalue
18471847
m_b (b)
18481848
{
18491849
type *a_type = a->get_type ();
1850-
if (a_type->dyn_cast_vector_type () != NULL)
1850+
vector_type *vec_type = a_type->dyn_cast_vector_type ();
1851+
if (vec_type != NULL)
18511852
{
1852-
m_type = a_type;
1853+
type *element_type = vec_type->get_element_type ();
1854+
type *inner_type;
1855+
if (element_type == ctxt->get_type (GCC_JIT_TYPE_FLOAT))
1856+
/* TODO: choose correct int type by size instead. */
1857+
inner_type = ctxt->get_type (GCC_JIT_TYPE_INT);
1858+
else if (element_type == ctxt->get_type (GCC_JIT_TYPE_DOUBLE))
1859+
inner_type = ctxt->get_type (GCC_JIT_TYPE_LONG);
1860+
else
1861+
inner_type = element_type;
1862+
m_type = new vector_type (inner_type, vec_type->get_num_units ());
1863+
ctxt->record (m_type);
18531864
}
18541865
}
18551866

0 commit comments

Comments
 (0)