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] |
Hello! This patch fixes the problem with vector shifts, where shift value is defined as a scalar value. This upsets vectoriser, which expects that vectors are shifted by a vector of values. The proposed solution is, that vectorizer looks into insn pattern that corresponds to vectorizer optab, and checks the mode of operand 2 (shift value in case of vectoriser shifts). If the mode of operand 2 is scalar mode, then simply use a scalar or loop invariant shift value as paramtere to the vector operation optab. The testcase: void test_1 (void) { static unsigned int bm[16]; int j; for (j = 0; j < 16; j++) bm[j] <<= 8; } void test_2 (int a) { static unsigned int bm[16]; int j; for (j = 0; j < 16; j++) bm[j] <<= a; } then compiles to: (vector shift by constant) test_1: pushl %ebp movl $bm.1591, %eax movl %esp, %ebp movl $bm.1591, %edx .p2align 4,,15 .L2: movdqa (%eax), %xmm0 addl $4, %edx pslld $8, %xmm0 movdqa %xmm0, (%eax) addl $16, %eax cmpl $bm.1591+16, %edx jne .L2 popl %ebp ret and (vector shift by parameter) test_2: pushl %ebp movl $bm.1602, %eax movl %esp, %ebp movl $bm.1602, %edx movd 8(%ebp), %xmm1 .p2align 4,,15 .L9: movdqa (%eax), %xmm0 addl $4, %edx pslld %xmm1, %xmm0 movdqa %xmm0, (%eax) addl $16, %eax cmpl $bm.1602+16, %edx jne .L9 popl %ebp ret 2005-09-07 Uros Bizjak <uros@kss-loka.si> PR middle-end/22480 * tree-vect-transform.c (vectorizable_operation): Fallback to scalar mode for tree operand 1, if operand 2 of vector insn pattern can not handle vector modes. * Makefile.in (tree-vect-transform.o): Depend on recog.h. testsuite/ChangeLog: 2005-09-07 Uros Bizjak <uros@kss-loka.si> PR middle-end/22480 * gcc.dg/vect/pr22480.c: New test. Patch was regtested for c anc c++ on i686-pc-linux-gnu. Uros.
Attachment:
pr22480.diff
Description: Binary data
Attachment:
pr22480.c
Description: Text document
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |