This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug target/70162] [RX] const_int printing causes wrong code on 32 bit host
- From: "olegendo at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 11 Mar 2016 01:35:00 +0000
- Subject: [Bug target/70162] [RX] const_int printing causes wrong code on 32 bit host
- Auto-submitted: auto-generated
- References: <bug-70162-4 at http dot gcc dot gnu dot org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70162
--- Comment #2 from Oleg Endo <olegendo at gcc dot gnu.org> ---
(In reply to Oleg Endo from comment #1)
>
> I guess there are more cases like (*2) above, where constants are encoded in
> a larger format than necessary.
Looks like that indeed. For example:
void bleh (volatile unsigned char* p)
{
*p &= 0x80;
}
compiled on i686:
__Z4blehPVh:
mov.B [r1], r14
and #0xffffffffffffff80, r14
mov.B r14, [r1]
rts
0000003f <__Z4blehPVh>:
3f: cc 1e mov.b [r1], r14
41: 74 2e 80 ff ff ff and #-128, r14
47: c3 1e mov.b r14, [r1]
49: 02 rts
compiled on x86_64:
__Z4blehPVh:
mov.B [r1], r14
and #0xffffffffffffff80, r14
mov.B r14, [r1]
rts
0000003f <__Z4blehPVh>:
3f: cc 1e mov.b [r1], r14
41: 75 2e 80 and #-128, r14
44: c3 1e mov.b r14, [r1]
46: 02 rts
Instead of the two patches above, the following patch will avoid printing hex
numbers, which seems to fix most of the issues.
Index: gcc/config/rx/rx.c
===================================================================
--- gcc/config/rx/rx.c (revision 234073)
+++ gcc/config/rx/rx.c (working copy)
@@ -501,18 +501,24 @@
static void
rx_print_integer (FILE * file, HOST_WIDE_INT val)
{
+ if (!TARGET_AS100_SYNTAX)
+ {
+ fprintf (file, HOST_WIDE_INT_PRINT_DEC, val);
+ return;
+ }
+
if (IN_RANGE (val, -64, 64))
fprintf (file, HOST_WIDE_INT_PRINT_DEC, val);
else
- fprintf (file,
- TARGET_AS100_SYNTAX
- ? "0%" HOST_WIDE_INT_PRINT "xH" : HOST_WIDE_INT_PRINT_HEX,
- val);
+ fprintf (file,"0%" HOST_WIDE_INT_PRINT "xH", val);
}
static bool
rx_assemble_integer (rtx x, unsigned int size, int is_aligned)
{
+ if (!TARGET_AS100_SYNTAX)
+ return default_assemble_integer (x, size, is_aligned);
+
const char * op = integer_asm_op (size, is_aligned);
if (! CONST_INT_P (x))
With this patch applied I get almost the same result as on x86_64:
text data bss dec hex
253428 3174 22812 279414 44376