Hello!

Attached patch removes "left shift count >= width of type" warnings in
soft-fp code. The patch implements the same approach - checking of
rsize against _FP_W_TYPE_SIZE - as is implemented in corresponding
FP_FRAC_DISASSEMBLE_{2,4} macros a couple of lines below.

This patch removes all remaining soft-fp warnings from the build.

2013-11-25  Uros Bizjak  <ubiz...@gmail.com>

    * soft-fp/op-2.h (_FP_FRAC_ASSEMBLE_2): Check rsize against
    _FP_W_TYPE_SIZE to avoid "left shift count >= width of type" warning.
    * soft-fp/op-4.h (_FP_FRAC_ASSEMBLE_4): Ditto.

Bootstrapped and regression tested on x86_64-pc-linux-gnu {,-m32}.

OK for mainline?

Uros.
Index: soft-fp/op-2.h
===================================================================
--- soft-fp/op-2.h      (revision 205357)
+++ soft-fp/op-2.h      (working copy)
@@ -627,13 +627,13 @@
  * No shifting or overflow handled here.
  */
 
-#define _FP_FRAC_ASSEMBLE_2(r, X, rsize)       \
-  (void) ((rsize <= _FP_W_TYPE_SIZE)           \
-         ? ({ r = X##_f0; })                   \
-         : ({                                  \
-             r = X##_f1;                       \
-             r <<= _FP_W_TYPE_SIZE;            \
-             r += X##_f0;                      \
+#define _FP_FRAC_ASSEMBLE_2(r, X, rsize)                               \
+  (void) ((rsize <= _FP_W_TYPE_SIZE)                                   \
+         ? ({ r = X##_f0; })                                           \
+         : ({                                                          \
+             r = X##_f1;                                               \
+             r = (rsize <= _FP_W_TYPE_SIZE ? 0 : r << _FP_W_TYPE_SIZE); \
+             r += X##_f0;                                              \
            }))
 
 #define _FP_FRAC_DISASSEMBLE_2(X, r, rsize)                            \
Index: soft-fp/op-4.h
===================================================================
--- soft-fp/op-4.h      (revision 205357)
+++ soft-fp/op-4.h      (working copy)
@@ -709,7 +709,7 @@
       else if (rsize <= 2*_FP_W_TYPE_SIZE)                             \
        {                                                               \
          r = X##_f[1];                                                 \
-         r <<= _FP_W_TYPE_SIZE;                                        \
+         r = (rsize <= _FP_W_TYPE_SIZE ? 0 : r << _FP_W_TYPE_SIZE);    \
          r += X##_f[0];                                                \
        }                                                               \
       else                                                             \
@@ -717,11 +717,11 @@
          /* I'm feeling lazy so we deal with int == 3words (implausible)*/ \
          /* and int == 4words as a single case.                         */ \
          r = X##_f[3];                                                 \
-         r <<= _FP_W_TYPE_SIZE;                                        \
+         r = (rsize <= _FP_W_TYPE_SIZE ? 0 : r << _FP_W_TYPE_SIZE);    \
          r += X##_f[2];                                                \
-         r <<= _FP_W_TYPE_SIZE;                                        \
+         r = (rsize <= _FP_W_TYPE_SIZE ? 0 : r << _FP_W_TYPE_SIZE);    \
          r += X##_f[1];                                                \
-         r <<= _FP_W_TYPE_SIZE;                                        \
+         r = (rsize <= _FP_W_TYPE_SIZE ? 0 : r << _FP_W_TYPE_SIZE);    \
          r += X##_f[0];                                                \
        }                                                               \
     }                                                                  \

Reply via email to