diff mbox

[11/11] Fix get_mode_bounds

Message ID 4E0E06EC.3050709@codesourcery.com
State New
Headers show

Commit Message

Bernd Schmidt July 1, 2011, 5:42 p.m. UTC
get_mode_bounds should also use GET_MODE_PRECISION, but this exposes a
problem on ia64 - BImode needs to be handled specially here to work
around another preexisting special case in gen_int_mode.


Bernd
* stor-layout.c (get_mode_bounds): Use GET_MODE_PRECISION.  Special
	case BImode.

Comments

Richard Henderson July 6, 2011, 6:37 p.m. UTC | #1
On 07/01/2011 10:42 AM, Bernd Schmidt wrote:
> get_mode_bounds should also use GET_MODE_PRECISION, but this exposes a
> problem on ia64 - BImode needs to be handled specially here to work
> around another preexisting special case in gen_int_mode.

Would it be better to remove the trunc_int_for_mode special case?
It appears that I added that for ia64 and it's unchanged since...


r~
Bernd Schmidt July 6, 2011, 11:04 p.m. UTC | #2
On 07/06/11 20:37, Richard Henderson wrote:
> On 07/01/2011 10:42 AM, Bernd Schmidt wrote:
>> get_mode_bounds should also use GET_MODE_PRECISION, but this exposes a
>> problem on ia64 - BImode needs to be handled specially here to work
>> around another preexisting special case in gen_int_mode.
> 
> Would it be better to remove the trunc_int_for_mode special case?
> It appears that I added that for ia64 and it's unchanged since...

That might require target specific changes if there are assumptions that
a BImode value is either 0 or 1, not 0 or -1. For now I'd prefer to
minimize the impact.


Bernd
Richard Henderson July 6, 2011, 11:36 p.m. UTC | #3
On 07/06/2011 04:04 PM, Bernd Schmidt wrote:
> That might require target specific changes if there are assumptions that
> a BImode value is either 0 or 1, not 0 or -1. For now I'd prefer to
> minimize the impact.

Systems that set STORE_FLAG_VALUE to -1:
	m68k
	spu

Systems that use BImode:
	bfin
	ia64
	mep
	sh
	rs6000
	stormy16

There's no overlap.

That said, I'm willing to approve the patch as-is.  Certainly testing
the signed-ness of the tree type seems preferable to just the mode,
which can't tell signedness.


r~
Bernd Schmidt July 11, 2011, 10:10 a.m. UTC | #4
On 07/06/11 20:37, Richard Henderson wrote:
> On 07/01/2011 10:42 AM, Bernd Schmidt wrote:
>> get_mode_bounds should also use GET_MODE_PRECISION, but this exposes a
>> problem on ia64 - BImode needs to be handled specially here to work
>> around another preexisting special case in gen_int_mode.
> 
> Would it be better to remove the trunc_int_for_mode special case?
> It appears that I added that for ia64 and it's unchanged since...

I tried that on ia64. It didn't bootstrap with the special case removed
(configure-stage1-target-libgomp failure), and progressed further
without the change.

(It still failed with
/usr/bin/ld: /opt/cfarm/gmp-4.2.4/lib/libgmp.a(errno.o): @gprel
relocation against dynamic symbol __gmp_errno
/usr/bin/ld: /opt/cfarm/gmp-4.2.4/lib/libgmp.a(errno.o): @gprel
relocation against dynamic symbol __gmp_errno
/usr/bin/ld: /opt/cfarm/gmp-4.2.4/lib/libgmp.a(errno.o): @gprel
relocation against dynamic symbol __gmp_errno
/usr/bin/ld: final link failed: Nonrepresentable section on output
)

> That said, I'm willing to approve the patch as-is.

I'll commit it then.


Bernd
diff mbox

Patch

Index: gcc/stor-layout.c
===================================================================
--- gcc/stor-layout.c.orig
+++ gcc/stor-layout.c
@@ -2439,11 +2439,26 @@  get_mode_bounds (enum machine_mode mode,
 		 enum machine_mode target_mode,
 		 rtx *mmin, rtx *mmax)
 {
-  unsigned size = GET_MODE_BITSIZE (mode);
+  unsigned size = GET_MODE_PRECISION (mode);
   unsigned HOST_WIDE_INT min_val, max_val;
 
   gcc_assert (size <= HOST_BITS_PER_WIDE_INT);
 
+  /* gen_int_mode performs an unwanted canonicalization for BImode.  */
+  if (mode == BImode)
+    {
+      if (sign)
+	{
+	  *mmin = constm1_rtx;
+	  *mmax = const0_rtx;
+	}
+      else
+	{
+	  *mmin = const0_rtx;
+	  *mmax = const1_rtx;
+	}
+      return;
+    }
   if (sign)
     {
       min_val = -((unsigned HOST_WIDE_INT) 1 << (size - 1));