This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: [PATCH][GCC][mid-end] Allow larger copies when target supports unaligned access [Patch (1/2)]



> -----Original Message-----
> From: Richard Biener [mailto:rguenther@suse.de]
> Sent: Wednesday, November 15, 2017 08:24
> To: Tamar Christina <Tamar.Christina@arm.com>
> Cc: gcc-patches@gcc.gnu.org; nd <nd@arm.com>; law@redhat.com;
> ian@airs.com
> Subject: Re: [PATCH][GCC][mid-end] Allow larger copies when target
> supports unaligned access [Patch (1/2)]
> 
> On Tue, 14 Nov 2017, Tamar Christina wrote:
> 
> > Hi All,
> >
> > This patch allows larger bitsizes to be used as copy size when the
> > target does not have SLOW_UNALIGNED_ACCESS.
> >
> > fun3:
> > 	adrp	x2, .LANCHOR0
> > 	add	x2, x2, :lo12:.LANCHOR0
> > 	mov	x0, 0
> > 	sub	sp, sp, #16
> > 	ldrh	w1, [x2, 16]
> > 	ldrb	w2, [x2, 18]
> > 	add	sp, sp, 16
> > 	bfi	x0, x1, 0, 8
> > 	ubfx	x1, x1, 8, 8
> > 	bfi	x0, x1, 8, 8
> > 	bfi	x0, x2, 16, 8
> > 	ret
> >
> > is turned into
> >
> > fun3:
> > 	adrp	x0, .LANCHOR0
> > 	add	x0, x0, :lo12:.LANCHOR0
> > 	sub	sp, sp, #16
> > 	ldrh	w1, [x0, 16]
> > 	ldrb	w0, [x0, 18]
> > 	strh	w1, [sp, 8]
> > 	strb	w0, [sp, 10]
> > 	ldr	w0, [sp, 8]
> > 	add	sp, sp, 16
> > 	ret
> >
> > which avoids the bfi's for a simple 3 byte struct copy.
> >
> > Regression tested on aarch64-none-linux-gnu and x86_64-pc-linux-gnu and
> no regressions.
> >
> > This patch is just splitting off from the previous combined patch with
> > AArch64 and adding a testcase.
> >
> > I assume Jeff's ACK from
> > https://gcc.gnu.org/ml/gcc-patches/2017-08/msg01523.html is still valid as
> the code did not change.
> 
> Given your no_slow_unalign isn't mode specific can't you use the existing
> non_strict_align?

No because non_strict_align checks if the target supports unaligned access at all,

This no_slow_unalign corresponds instead to the target slow_unaligned_access
which checks that the access you want to make has a greater cost than doing an
aligned access. ARM for instance always return 1 (value of STRICT_ALIGNMENT)
for slow_unaligned_access while for non_strict_align it may return 0 or 1 based
on the options provided to the compiler.

The problem is I have no way to test STRICT_ALIGNMENT or slow_unaligned_access
So I had to hardcode some targets that I know it does work on.

Thanks,
Tamar
> 
> Otherwise the expr.c change looks ok.
> 
> Thanks,
> Richard.
> 
> > Thanks,
> > Tamar
> >
> >
> > gcc/
> > 2017-11-14  Tamar Christina  <tamar.christina@arm.com>
> >
> > 	* expr.c (copy_blkmode_to_reg): Fix bitsize for targets
> > 	with fast unaligned access.
> > 	* doc/sourcebuild.texi (no_slow_unalign): New.
> >
> > gcc/testsuite/
> > 2017-11-14  Tamar Christina  <tamar.christina@arm.com>
> >
> > 	* gcc.dg/struct-simple.c: New.
> > 	* lib/target-supports.exp
> > 	(check_effective_target_no_slow_unalign): New.
> >
> >
> 
> --
> Richard Biener <rguenther@suse.de>
> SUSE LINUX GmbH, GF: Felix Imendoerffer, Jane Smithard, Graham Norton,
> HRB 21284 (AG Nuernberg)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]