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]

[RFC] [Patch]: Try and vectorize with shift for mult expr with power 2 integer constant.


Hi Richard,

For Aarch64 target, I was trying to  vectorize  the expression  "arr[i]=arr[i]*4;"   via vector shifts instructions since they don't have vector mults.

unsigned  long int __attribute__ ((aligned (64)))arr[100];
int i;
#if 1
void test_vector_shifts()
{
        for(i=0; i<=99;i++)
        arr[i]=arr[i]<<2;
}
#endif

void test_vectorshift_via_mul()
{
        for(i=0; i<=99;i++)
        arr[i]=arr[i]*4;

}

I found a similar PR and your comments https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65952#c6. 
Based on that and IRC discussion I had with you,  I added vector recog pattern that transforms mults to shifts.  The vectorizer is now able to generate vector shifts for the above test case.
PR case also gets vectorized https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65952#c10.

This is just an initial patch and tries to optimize integer type power 2 constants.  I wanted to get feedback on this .  I bootstrapped and reg tested on aarch64-none-linux-gnu .

Regards,
Venkat.

Attachment: vectorize_mults_shift.diff.txt
Description: vectorize_mults_shift.diff.txt


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