This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [PATCH, ppc] Allow IMM8 operands to accept both signed and unsigned values
- From: Alan Modra <amodra at gmail dot com>
- To: Jan Beulich <JBeulich at suse dot com>
- Cc: Peter Bergner <bergner at vnet dot ibm dot com>, "binutils at sourceware dot org" <binutils at sourceware dot org>
- Date: Wed, 18 May 2016 12:07:25 +0930
- Subject: Re: [PATCH, ppc] Allow IMM8 operands to accept both signed and unsigned values
- Authentication-results: sourceware.org; auth=none
- References: <1463173058 dot 4256 dot 45 dot camel at vnet dot ibm dot com> <573AEB5B02000078000EBFB6 at prv-mh dot provo dot novell dot com>
On Tue, May 17, 2016 at 01:58:51AM -0600, Jan Beulich wrote:
> >>> On 13.05.16 at 22:57, <bergner@vnet.ibm.com> wrote:
> > --- a/gas/testsuite/gas/ppc/power9.s
> > +++ b/gas/testsuite/gas/ppc/power9.s
> > @@ -131,7 +131,9 @@ power9:
> > xxextractuw 4,5,0x0
> > xxextractuw 40,50,0xf
> > xxspltib 4,0x0
> > + xxspltib 4,-256
>
> Why would (and should) this now get accepted? It's out of range
> even for signed 8-bit (and as we can see disassembles to 0).
I think it probably shouldn't be allowed. PPC_OPERAND_SIGNOPT was
changed to accept a wider range in
https://sourceware.org/ml/binutils/2007-04/msg00252.html
I didn't comment on why I made that change nor can I remember a good
reason, so it likely was accidental.
Peter, do you agree with the following?
* config/tc-ppc.c (ppc_insert_operand): Trim PPC_OPERAND_SIGNOPT
allowed negative range.
* testsuite/gas/ppc/power9.s: Test xxspltib of -128, not -256.
* testsuite/gas/ppc/power9.d: Update.
diff --git a/gas/config/tc-ppc.c b/gas/config/tc-ppc.c
index c3909c4..01b5c5a 100644
--- a/gas/config/tc-ppc.c
+++ b/gas/config/tc-ppc.c
@@ -1787,17 +1787,15 @@ ppc_insert_operand (unsigned long insn,
if ((operand->flags & PPC_OPERAND_SIGNOPT) != 0)
{
- /* Extend the allowed range for addis to [-65536, 65535].
- Similarly for some VLE high part insns. For 64-bit it
- would be good to disable this for signed fields since the
+ /* Extend the allowed range for addis to [-32768, 65535].
+ Similarly for cmpli and some VLE high part insns. For 64-bit
+ it would be good to disable this for signed fields since the
value is sign extended into the high 32 bits of the register.
If the value is, say, an address, then we might care about
the high bits. However, gcc as of 2014-06 uses unsigned
values when loading the high part of 64-bit constants using
- lis.
- Use the same extended range for cmpli, to allow at least
- [-32768, 65535]. */
- min = ~max & -right;
+ lis. */
+ min = ~(max >> 1) & -right;
}
else if ((operand->flags & PPC_OPERAND_SIGNED) != 0)
{
diff --git a/gas/testsuite/gas/ppc/power9.d b/gas/testsuite/gas/ppc/power9.d
index d84e635..a1d4681 100644
--- a/gas/testsuite/gas/ppc/power9.d
+++ b/gas/testsuite/gas/ppc/power9.d
@@ -140,7 +140,7 @@ Disassembly of section \.text:
.*: (f0 80 2a 94|94 2a 80 f0) xxextractuw vs4,vs5,0
.*: (f1 0f 92 97|97 92 0f f1) xxextractuw vs40,vs50,15
.*: (f0 80 02 d0|d0 02 80 f0) xxspltib vs4,0
-.*: (f0 80 02 d0|d0 02 80 f0) xxspltib vs4,0
+.*: (f0 84 02 d0|d0 02 84 f0) xxspltib vs4,128
.*: (f1 27 fa d1|d1 fa 27 f1) xxspltib vs41,255
.*: (f1 27 fa d1|d1 fa 27 f1) xxspltib vs41,255
.*: (f0 a0 32 d4|d4 32 a0 f0) xxinsertw vs5,vs6,0
diff --git a/gas/testsuite/gas/ppc/power9.s b/gas/testsuite/gas/ppc/power9.s
index 9cf306c..34576b7 100644
--- a/gas/testsuite/gas/ppc/power9.s
+++ b/gas/testsuite/gas/ppc/power9.s
@@ -131,7 +131,7 @@ power9:
xxextractuw 4,5,0x0
xxextractuw 40,50,0xf
xxspltib 4,0x0
- xxspltib 4,-256
+ xxspltib 4,-128
xxspltib 41,255
xxspltib 41,-1
xxinsertw 5,6,0
--
Alan Modra
Australia Development Lab, IBM