Commit ef8d9a0e by John David Anglin Committed by John David Anglin

pa.c (compute_zdepwi_operands): Limit deposit length to 32 - lsb.

	* pa.c (compute_zdepwi_operands): Limit deposit length to 32 - lsb.
	Cast "1" to unsigned HOST_WIDE_INT.
	(compute_zdepdi_operands): Limit maximum length to 64 bits.  Limit
	deposit length to the maximum length - lsb.  Extend length if
	HOST_BITS_PER_WIDE_INT is 32.

From-SVN: r149843
parent 7e4bc1f8
2009-07-20 John David Anglin <dave.anglin@nrc-cnrc.gc.ca>
* pa.c (compute_zdepwi_operands): Limit deposit length to 32 - lsb.
Cast "1" to unsigned HOST_WIDE_INT.
(compute_zdepdi_operands): Limit maximum length to 64 bits. Limit
deposit length to the maximum length - lsb. Extend length if
HOST_BITS_PER_WIDE_INT is 32.
2009-07-20 Olatunji Ruwase <tjruwase@google.com> 2009-07-20 Olatunji Ruwase <tjruwase@google.com>
* cgraph.h (constant_pool_htab): New function. * cgraph.h (constant_pool_htab): New function.
......
...@@ -2213,9 +2213,9 @@ compute_zdepwi_operands (unsigned HOST_WIDE_INT imm, unsigned *op) ...@@ -2213,9 +2213,9 @@ compute_zdepwi_operands (unsigned HOST_WIDE_INT imm, unsigned *op)
else else
{ {
/* Find the width of the bitstring in IMM. */ /* Find the width of the bitstring in IMM. */
for (len = 5; len < 32; len++) for (len = 5; len < 32 - lsb; len++)
{ {
if ((imm & (1 << len)) == 0) if ((imm & ((unsigned HOST_WIDE_INT) 1 << len)) == 0)
break; break;
} }
...@@ -2234,10 +2234,12 @@ compute_zdepwi_operands (unsigned HOST_WIDE_INT imm, unsigned *op) ...@@ -2234,10 +2234,12 @@ compute_zdepwi_operands (unsigned HOST_WIDE_INT imm, unsigned *op)
void void
compute_zdepdi_operands (unsigned HOST_WIDE_INT imm, unsigned *op) compute_zdepdi_operands (unsigned HOST_WIDE_INT imm, unsigned *op)
{ {
HOST_WIDE_INT lsb, len; int lsb, len, maxlen;
maxlen = MIN (HOST_BITS_PER_WIDE_INT, 64);
/* Find the least significant set bit in IMM. */ /* Find the least significant set bit in IMM. */
for (lsb = 0; lsb < HOST_BITS_PER_WIDE_INT; lsb++) for (lsb = 0; lsb < maxlen; lsb++)
{ {
if ((imm & 1) != 0) if ((imm & 1) != 0)
break; break;
...@@ -2246,17 +2248,20 @@ compute_zdepdi_operands (unsigned HOST_WIDE_INT imm, unsigned *op) ...@@ -2246,17 +2248,20 @@ compute_zdepdi_operands (unsigned HOST_WIDE_INT imm, unsigned *op)
/* Choose variants based on *sign* of the 5-bit field. */ /* Choose variants based on *sign* of the 5-bit field. */
if ((imm & 0x10) == 0) if ((imm & 0x10) == 0)
len = ((lsb <= HOST_BITS_PER_WIDE_INT - 4) len = (lsb <= maxlen - 4) ? 4 : maxlen - lsb;
? 4 : HOST_BITS_PER_WIDE_INT - lsb);
else else
{ {
/* Find the width of the bitstring in IMM. */ /* Find the width of the bitstring in IMM. */
for (len = 5; len < HOST_BITS_PER_WIDE_INT; len++) for (len = 5; len < maxlen - lsb; len++)
{ {
if ((imm & ((unsigned HOST_WIDE_INT) 1 << len)) == 0) if ((imm & ((unsigned HOST_WIDE_INT) 1 << len)) == 0)
break; break;
} }
/* Extend length if host is narrow and IMM is negative. */
if (HOST_BITS_PER_WIDE_INT == 32 && len == maxlen - lsb)
len += 32;
/* Sign extend IMM as a 5-bit value. */ /* Sign extend IMM as a 5-bit value. */
imm = (imm & 0xf) - 0x10; imm = (imm & 0xf) - 0x10;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment