diff options
Diffstat (limited to 'gcc/config/pa/pa.c')
-rw-r--r-- | gcc/config/pa/pa.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/gcc/config/pa/pa.c b/gcc/config/pa/pa.c index ed64d5de2fe..8e8db865e2b 100644 --- a/gcc/config/pa/pa.c +++ b/gcc/config/pa/pa.c @@ -2213,9 +2213,9 @@ compute_zdepwi_operands (unsigned HOST_WIDE_INT imm, unsigned *op) else { /* 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; } @@ -2234,10 +2234,12 @@ compute_zdepwi_operands (unsigned HOST_WIDE_INT imm, unsigned *op) void 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. */ - for (lsb = 0; lsb < HOST_BITS_PER_WIDE_INT; lsb++) + for (lsb = 0; lsb < maxlen; lsb++) { if ((imm & 1) != 0) break; @@ -2246,17 +2248,20 @@ compute_zdepdi_operands (unsigned HOST_WIDE_INT imm, unsigned *op) /* Choose variants based on *sign* of the 5-bit field. */ if ((imm & 0x10) == 0) - len = ((lsb <= HOST_BITS_PER_WIDE_INT - 4) - ? 4 : HOST_BITS_PER_WIDE_INT - lsb); + len = (lsb <= maxlen - 4) ? 4 : maxlen - lsb; else { /* 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) 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. */ imm = (imm & 0xf) - 0x10; } |