public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* How to ignore the vector's duplication
@ 2020-07-20  2:12 夏 晋
  0 siblings, 0 replies; only message in thread
From: 夏 晋 @ 2020-07-20  2:12 UTC (permalink / raw)
  To: gcc

Hi everyone,
  As we know, before we add a vector and a scalar, the first thing to do is to duplicate the scalar varable. For example (the vector has a length of 16):
  for (int i = 0; i < 16; i ++) c[i] = a[i] + b;
  will goes to:
  vld v0,a0
  vdup v1,a1
  vadd v0,v0,v1
  vfst v0,a2
  And now we can deal with the addtion of a vector and a scalar directly by "vadds", so the assembler above could be optimized like:
  vld v0,a0
  vadds v0,v0,a1
  vfst v0,a2
  we can achieve this goal by peephole for the loop size 16, but if we enlarge the loop size to 32, the peephole will be missed like:
  vld v0,a0
  vdup v1,a1
  vadd v0,v0,v1
  addi a3,a0,32
  addi a4,a2,32
  vfst v0,a2
  vld v2,a3
  vadd v0,v2,v1
  vfst v0,a4
  Is there any way to let GCC ignore the vector's duplication no matter the size of loop, for using the "vadds" only?

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-07-20  2:12 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-20  2:12 How to ignore the vector's duplication 夏 晋

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).