This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug target/71106] MIPS: Unaligned load/store instructions are not used to access a variable with an aligned attribute
- From: "pinskia at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 04 Jul 2016 08:51:56 +0000
- Subject: [Bug target/71106] MIPS: Unaligned load/store instructions are not used to access a variable with an aligned attribute
- Auto-submitted: auto-generated
- References: <bug-71106-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71106
--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Doing a movmisalign for mips is actually very easy:
;; Unaligned load/store (movmisalign<mode>)
(define_expand "movmisalign<mode>"
[(set (match_operand:GPR 0 "nonimmediate_operand")
(match_operand:GPR 1 "move_operand"))]
""
{
if (MEM_P (operands[0]))
{
operands[1] = force_reg (<MODE>mode, operands[1]);
if (!mips_expand_ins_as_unaligned_store (operands[0],
operands[1],
GET_MODE_BITSIZE (<MODE>mode),
0))
gcc_unreachable ();
}
else if (MEM_P (operands[1]))
{
if (!mips_expand_ext_as_unaligned_load (operands[0],
operands[1],
GET_MODE_BITSIZE (<MODE>mode), 0,
0))
gcc_unreachable ();
}
else
gcc_unreachable ();
DONE;
})
---- CUT -----
I had this in Cavium's GCC for years now but I never got around to testing it
to the trunk.
There was one issue with it, the MEM did not always have an alignment set on
it.
Sprinkling some "set_mem_align (mem, align);" in expr.c fixes that issue.
--- CUT ---
The testcase which fails was:
extern int nc;
void f(void)
{
unsigned char resp[1024];
int c;
int bl = 0;
unsigned long long *dwords = (unsigned long long *)(resp + 5);
for (c=0; c<nc; c++)
{
ff(dwords[bl/64]);
bl++;
}
}
--- CUT ----