]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
amdgcn: Various fixes for SIMD math library
authorKwok Cheung Yeung <kcy@codesourcery.com>
Mon, 7 Nov 2022 12:28:23 +0000 (12:28 +0000)
committerKwok Cheung Yeung <kcy@codesourcery.com>
Mon, 7 Nov 2022 13:16:12 +0000 (13:16 +0000)
Fix an error if VECTOR_RETURN is used on a constant.
Simplify the implementation of ilogb by removing VECTOR_IFs with a trivial
body.

2022-11-07  Kwok Cheung Yeung  <kcy@codesourcery.com>

libgcc/
* config/gcn/simd-math/amdgcnmach.h (VECTOR_RETURN): Store value of
return value in a local variable first.
* config/gcn/simd-math/v64df_ilogb.c (ilogb): Simplify.

libgcc/ChangeLog.omp
libgcc/config/gcn/simd-math/amdgcnmach.h
libgcc/config/gcn/simd-math/v64df_ilogb.c

index af9abdb220e4a0866c95aa5b48bda069d728f5ed..f41bbbb339a5da373136012eb940394b1504f95a 100644 (file)
@@ -1,3 +1,9 @@
+2022-11-07  Kwok Cheung Yeung  <kcy@codesourcery.com>
+
+       * config/gcn/simd-math/amdgcnmach.h (VECTOR_RETURN): Store value of
+       return value in a local variable first.
+       * config/gcn/simd-math/v64df_ilogb.c (ilogb): Simplify.
+
 2022-11-07  Kwok Cheung Yeung  <kcy@codesourcery.com>
 
        * config/gcn/simd-math/v64df_rint.c (rint): Simplified.  Fixed bug in
index f821f7b2c7707d0b436ff980e1dadde7618c5030..4436a9508250f3fc3864eede8757d61c583d9500 100644 (file)
@@ -177,7 +177,8 @@ do { \
 do { \
   _Static_assert (__builtin_types_compatible_p (typeof (retval), typeof (__ret))); \
   __auto_type __cond = __builtin_convertvector ((cond), typeof (__mask)); \
-  VECTOR_COND_MOVE (__ret, (retval), __cond); \
+  __auto_type __retval = (retval); \
+  VECTOR_COND_MOVE (__ret, __retval, __cond); \
   __mask &= ~__cond; \
 } while (0)
 
index aa71b845dc110865668fd39163a58ea54d7a5336..ea51bf10523528233d3924689e5176eed7fe5b30 100644 (file)
 DEF_VD_MATH_PRED (v64si, ilogb, v64df x)
 {
   FUNCTION_INIT(v64si);
-
   v64si hx, lx, ix;
   EXTRACT_WORDS (hx, lx, x);
   hx &= 0x7fffffff;
   VECTOR_IF (hx < 0x00100000, cond)
-    VECTOR_IF2 ((hx | lx) == 0, cond2, cond)
-    VECTOR_RETURN (VECTOR_INIT (-__INT_MAX__), cond2);  // FP_ILOGB0
-    VECTOR_ELSE (cond2)
-      VECTOR_IF2 (hx == 0, cond3, cond2)
-       ix = VECTOR_INIT (-1043);
-       for (v64si i = lx;
-            !ALL_ZEROES_P (cond3 & (i > 0));
-            i <<= 1)
-         VECTOR_COND_MOVE (ix, ix - 1, cond3 & (i > 0));
-      VECTOR_ELSE2 (cond3, cond2)
-       ix = VECTOR_INIT (-1022);
-       for (v64si i = (hx << 11);
-            !ALL_ZEROES_P (cond3 & (i > 0));
-            i <<= 1)
-         VECTOR_COND_MOVE (ix, ix - 1, cond3 & (i > 0));
-      VECTOR_ENDIF
+    VECTOR_RETURN (VECTOR_INIT (-__INT_MAX__), cond & ((hx | lx) == 0));  // FP_ILOGB0
+    VECTOR_IF2 (hx == 0, cond2, cond)
+      ix = VECTOR_INIT (-1043);
+      for (v64si i = lx;
+            !ALL_ZEROES_P (cond2 & (i > 0));
+            i <<= 1)
+        VECTOR_COND_MOVE (ix, ix - 1, cond2 & (i > 0));
+    VECTOR_ELSE2 (cond2, cond)
+      ix = VECTOR_INIT (-1022);
+      for (v64si i = (hx << 11);
+            !ALL_ZEROES_P (cond2 & (i > 0));
+            i <<= 1)
+        VECTOR_COND_MOVE (ix, ix - 1, cond2 & (i > 0));
     VECTOR_ENDIF
     VECTOR_RETURN (ix, cond);
   VECTOR_ENDIF
-  VECTOR_IF (hx < 0x7ff00000, cond)
-    VECTOR_RETURN ((hx >> 20) - 1023, cond);
-  VECTOR_ENDIF
+  VECTOR_RETURN ((hx >> 20) - 1023, hx < 0x7ff00000);
   VECTOR_RETURN (VECTOR_INIT (__INT_MAX__), NO_COND);
 
   FUNCTION_RETURN;