Fwd: [PATCH, libgcc]: Avoid "left shift count >= width of type" warnings in soft-fp code

Uros Bizjak ubizjak@gmail.com
Tue Nov 26 19:32:00 GMT 2013


On Tue, Nov 26, 2013 at 12:31 AM, Joseph S. Myers
<joseph@codesourcery.com> wrote:
> I don't see why the op-2.h change should be needed - the code with the
> problem shift is already inside the "else" part of a ((rsize <=
> _FP_W_TYPE_SIZE) ? : ...) conditional, and the reason ?: is used here
> instead of if/else is exactly to avoid such warnings; putting in a second
> nested such conditional with the same condition shouldn't make any
> difference.

You are right. I have added op-2.h mechanically, following op-4.h change.

Attached patch also compiles gcc soft-fp without problems for x86_64
64bit and 32bit multilibs, so the build exercises op-4.h as well as
op-2.h headers.

Re-tested on x86_64 multilib gcc bootstrap and regression test.

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

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

Uros.
-------------- next part --------------
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];						\
 	}								\
     }									\


More information about the Libc-alpha mailing list