From a498c55660d613cb7a29c727b73ffcdb8079c470 Mon Sep 17 00:00:00 2001 From: Antoni Boucher Date: Thu, 26 Oct 2023 19:17:55 -0400 Subject: [PATCH] Make is_int return false on vector types --- gcc/jit/jit-recording.h | 13 +++++++++++-- gcc/jit/libgccjit.cc | 4 ++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/gcc/jit/jit-recording.h b/gcc/jit/jit-recording.h index 74c9f62184ad6..eae9df8ce30f5 100644 --- a/gcc/jit/jit-recording.h +++ b/gcc/jit/jit-recording.h @@ -613,6 +613,7 @@ class type : public memento virtual bool is_int () const = 0; virtual bool is_float () const = 0; virtual bool is_bool () const = 0; + virtual bool is_numeric_vector () const { return false; } virtual type *is_pointer () = 0; virtual type *is_volatile () { return NULL; } virtual type *is_restrict () { return NULL; } @@ -757,10 +758,10 @@ class decorated_type : public type size_t get_size () final override { return m_other_type->get_size (); }; - // FIXME: this is wrong. A vector is not an int. - bool is_int () const final override { return m_other_type->is_int (); } + bool is_int () const override { return m_other_type->is_int (); } bool is_float () const final override { return m_other_type->is_float (); } bool is_bool () const final override { return m_other_type->is_bool (); } + bool is_numeric_vector () const override { return m_other_type->is_numeric_vector (); } type *is_pointer () final override { return m_other_type->is_pointer (); } type *is_array () final override { return m_other_type->is_array (); } struct_ *is_struct () final override { return m_other_type->is_struct (); } @@ -926,6 +927,14 @@ class vector_type : public decorated_type return result; } + bool is_int () const final override { + return false; + } + + bool is_numeric_vector () const final override { + return true; + } + size_t get_num_units () const { return m_num_units; } vector_type *dyn_cast_vector_type () final override { return this; } diff --git a/gcc/jit/libgccjit.cc b/gcc/jit/libgccjit.cc index 577dc0701fcbd..908d70a594326 100644 --- a/gcc/jit/libgccjit.cc +++ b/gcc/jit/libgccjit.cc @@ -2196,7 +2196,7 @@ gcc_jit_context_new_unary_op (gcc_jit_context *ctxt, op); RETURN_NULL_IF_FAIL (result_type, ctxt, loc, "NULL result_type"); RETURN_NULL_IF_FAIL_PRINTF3 ( - result_type->is_numeric (), ctxt, loc, + result_type->is_numeric () || result_type->is_numeric_vector (), ctxt, loc, "gcc_jit_unary_op %s with operand %s " "has non-numeric result_type: %s", gcc::jit::unary_op_reproducer_strings[op], @@ -2253,7 +2253,7 @@ gcc_jit_context_new_binary_op (gcc_jit_context *ctxt, b->get_debug_string (), b->get_type ()->get_debug_string ()); RETURN_NULL_IF_FAIL_PRINTF4 ( - result_type->is_numeric (), ctxt, loc, + result_type->is_numeric () || result_type->is_numeric_vector (), ctxt, loc, "gcc_jit_binary_op %s with operands a: %s b: %s " "has non-numeric result_type: %s", gcc::jit::binary_op_reproducer_strings[op],