Skip to content

Commit c689be4

Browse files
committed
Fix float vector comparison
1 parent 2586690 commit c689be4

File tree

4 files changed

+21
-8
lines changed

4 files changed

+21
-8
lines changed

gcc/jit/jit-playback.cc

+5-4
Original file line numberDiff line numberDiff line change
@@ -1288,7 +1288,7 @@ playback::rvalue *
12881288
playback::context::
12891289
new_comparison (location *loc,
12901290
enum gcc_jit_comparison op,
1291-
rvalue *a, rvalue *b)
1291+
rvalue *a, rvalue *b, type *vec_result_type)
12921292
{
12931293
// FIXME: type-checking, or coercion?
12941294
enum tree_code inner_op;
@@ -1332,11 +1332,12 @@ new_comparison (location *loc,
13321332
if (VECTOR_TYPE_P (a_type))
13331333
{
13341334
// TODO: document where this comes from and what it is doing.
1335-
tree zero_vec = build_zero_cst (a_type);
1336-
tree minus_one_vec = build_minus_one_cst (a_type);
1335+
tree t_vec_result_type = vec_result_type->as_tree ();
1336+
tree zero_vec = build_zero_cst (t_vec_result_type);
1337+
tree minus_one_vec = build_minus_one_cst (t_vec_result_type);
13371338
tree cmp_type = truth_type_for (a_type);
13381339
tree cmp = build2 (inner_op, cmp_type, node_a, node_b);
1339-
inner_expr = build3 (VEC_COND_EXPR, a_type, cmp, minus_one_vec, zero_vec);
1340+
inner_expr = build3 (VEC_COND_EXPR, t_vec_result_type, cmp, minus_one_vec, zero_vec);
13401341
}
13411342
else
13421343
{

gcc/jit/jit-playback.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ class context : public log_user
176176
rvalue *
177177
new_comparison (location *loc,
178178
enum gcc_jit_comparison op,
179-
rvalue *a, rvalue *b);
179+
rvalue *a, rvalue *b, type *vec_result_type);
180180

181181
rvalue *
182182
new_call (location *loc,

gcc/jit/jit-recording.cc

+2-1
Original file line numberDiff line numberDiff line change
@@ -6061,7 +6061,8 @@ recording::comparison::replay_into (replayer *r)
60616061
set_playback_obj (r->new_comparison (playback_location (r, m_loc),
60626062
m_op,
60636063
m_a->playback_rvalue (),
6064-
m_b->playback_rvalue ()));
6064+
m_b->playback_rvalue (),
6065+
m_type->playback_type ()));
60656066
}
60666067

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

gcc/jit/jit-recording.h

+13-2
Original file line numberDiff line numberDiff line change
@@ -1836,9 +1836,20 @@ class comparison : public rvalue
18361836
m_b (b)
18371837
{
18381838
type *a_type = a->get_type ();
1839-
if (a_type->dyn_cast_vector_type () != NULL)
1839+
vector_type *vec_type = a_type->dyn_cast_vector_type ();
1840+
if (vec_type != NULL)
18401841
{
1841-
m_type = a_type;
1842+
type *element_type = vec_type->get_element_type ();
1843+
type *inner_type;
1844+
if (element_type == ctxt->get_type (GCC_JIT_TYPE_FLOAT))
1845+
/* TODO: choose correct int type by size instead. */
1846+
inner_type = ctxt->get_type (GCC_JIT_TYPE_INT);
1847+
else if (element_type == ctxt->get_type (GCC_JIT_TYPE_DOUBLE))
1848+
inner_type = ctxt->get_type (GCC_JIT_TYPE_LONG);
1849+
else
1850+
inner_type = element_type;
1851+
m_type = new vector_type (inner_type, vec_type->get_num_units ());
1852+
ctxt->record (m_type);
18421853
}
18431854
}
18441855

0 commit comments

Comments
 (0)