On 12/6/24 13:56, Thomas Schwinge wrote:
Hi Andrew!

On 2024-12-05T15:14:45+0100, I wrote:
On 2020-01-31T11:20:14+0000, Andrew Stubbs <a...@codesourcery.com> wrote:
This is one of those things I don't know why we didn't notice sooner.

..., and here's another thing I don't know why we didn't notice sooner.
;-P (Category: "don't we all love C++?!")

[...]
I also needed a convenient way to create 0.0 vector constants without
uglifying the machine description code, so extending gcn_vec_constant
seemed like a useful place to do it.

--- a/gcc/config/gcn/gcn.c
+++ b/gcc/config/gcn/gcn.c
@@ -992,9 +992,19 @@ gcn_vec_constant (machine_mode mode, int a)
      return CONST2_RTX (mode);*/
int units = GET_MODE_NUNITS (mode);
-  rtx tem = gen_int_mode (a, GET_MODE_INNER (mode));
-  rtvec v = rtvec_alloc (units);
+  machine_mode innermode = GET_MODE_INNER (mode);
+
+  rtx tem;
+  if (FLOAT_MODE_P (innermode))
+    {
+      REAL_VALUE_TYPE rv;
+      real_from_integer (&rv, NULL, a, SIGNED);
+      tem = const_double_from_real_value (rv, innermode);
+    }
+  else
+    tem = gen_int_mode (a, innermode);
+ rtvec v = rtvec_alloc (units);
    for (int i = 0; i < units; ++i)
      RTVEC_ELT (v, i) = tem;

That's apparently not the proper way to use 'real_from_integer'.  Its
second argument is a 'format_helper', which is a class defined in
'gcc/real.h', which has a templated constructor that is meant to receive
a mode, so instead of 'NULL', this should pass in 'VOIDmode' (correct?).
Anyway: until recently, this appeared to work (fine?) -- but broke with
Andrew Pinski's recent commit b3f1b9e2aa079f8ec73e3cb48143a16645c49566
"build: Remove INCLUDE_MEMORY [PR117737]":

     [...]
     In file included from ../../source-gcc/gcc/coretypes.h:507:0,
                      from ../../source-gcc/gcc/config/gcn/gcn.cc:24:
     ../../source-gcc/gcc/real.h: In instantiation of 
‘format_helper::format_helper(const T&) [with T = std::nullptr_t]’:
     ../../source-gcc/gcc/config/gcn/gcn.cc:1178:46:   required from here
     ../../source-gcc/gcc/real.h:233:17: error: no match for ‘operator==’ 
(operand types are ‘std::nullptr_t’ and ‘machine_mode’)
        : m_format (m == VOIDmode ? 0 : REAL_MODE_FORMAT (m))
                      ^
     [...]

Andrew P.'s commit doesn't touch 'gcc/config/gcn/gcn.cc'; the only part
relevant here -- per my understanding -- should be:

     --- gcc/system.h
     +++ gcc/system.h
     @@ -224,0 +225 @@ extern int fprintf_unlocked (FILE *, const char *, ...);
     +# include <memory>
     @@ -761,7 +761,0 @@ private:
     -/* Some of the headers included by <memory> can use "abort" within a
     -   namespace, e.g. "_VSTD::abort();", which fails after we use the
     -   preprocessor to redefine "abort" as "fancy_abort" below.  */
     -
     -#ifdef INCLUDE_MEMORY
     -# include <memory>
     -#endif

In other words, (unconditional) '#include <memory>' appears to preclude
ability to convert 'NULL' into a mode?  (Or, I'm off-track, of course...)

Either way: OK to push the attached "GCN: Fix 'real_from_integer' usage"
after testing completes?

No issues found in testing.

I don't understand how that change broke anything, but if NULL was supposed to mean VOIDmode (which was probably defined to zero??) and it fixes the observed problem, then I think the patch is fine.

Andrew



Grüße
  Thomas



Reply via email to