public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/113326] New: Optimize vector shift with constant delta on shifting-count operand
@ 2024-01-11  7:13 fxue at os dot amperecomputing.com
  2024-01-11  7:30 ` [Bug target/113326] " pinskia at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: fxue at os dot amperecomputing.com @ 2024-01-11  7:13 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113326

            Bug ID: 113326
           Summary: Optimize vector shift with constant delta on
                    shifting-count operand
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: fxue at os dot amperecomputing.com
  Target Milestone: ---

For shift by induction variable, loop vectorization could generate a series of
vector shifts, whose shifting-count operands are advanced by constant delta. We
could use result of the first vector shift as base, and transform others to be
vector shift on the result by scalar delta, which would eliminate non-uniform
shift vector count constant, and thereby save a load on most architectures.

 int test(int array[16]);

 int foo(int value)
 {
   int array[16];

   for (int i = 0; i < 16; i++)
      array[i] = value >> i;

   return test(array);
 }

 // Current
 vect_value = { value, value, value, value };
 vect_shift_0 = vect_value >> { 0, 1, 2, 3 };
 vect_shift_1 = vect_value >> { 4, 5, 6, 7 };
 vect_shift_2 = vect_value >> { 8, 9, 10, 11 };
 vect_shift_3 = vect_value >> { 12, 13, 14, 15 };

 // To be optimized to
 vect_value = { value, value, value, value };
 vect_shift_0 = vect_value >> { 0, 1, 2, 3 };
 vect_shift_1 = vect_shift_0 >> { 4, 4, 4, 4 };
 vect_shift_2 = vect_shift_0 >> { 8, 8, 8, 8 };
 vect_shift_3 = vect_shift_0 >> { 12, 12, 12, 12 };

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2024-01-11  9:58 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-11  7:13 [Bug tree-optimization/113326] New: Optimize vector shift with constant delta on shifting-count operand fxue at os dot amperecomputing.com
2024-01-11  7:30 ` [Bug target/113326] " pinskia at gcc dot gnu.org
2024-01-11  7:44 ` pinskia at gcc dot gnu.org
2024-01-11  7:52 ` fxue at os dot amperecomputing.com
2024-01-11  7:56 ` pinskia at gcc dot gnu.org
2024-01-11  8:10 ` pinskia at gcc dot gnu.org
2024-01-11  9:13 ` rguenth at gcc dot gnu.org
2024-01-11  9:58 ` fxue at os dot amperecomputing.com

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).