Bug 44403 - vectorization does not maintain 'restrict' qualifier
Summary: vectorization does not maintain 'restrict' qualifier
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 4.6.0
: P3 normal
Target Milestone: 4.6.0
Assignee: Richard Biener
URL:
Keywords: missed-optimization
Depends on:
Blocks:
 
Reported: 2010-06-03 15:48 UTC by Roy Rosen
Modified: 2010-06-03 21:12 UTC (History)
3 users (show)

See Also:
Host: linux
Target: i386
Build: elf
Known to work:
Known to fail:
Last reconfirmed: 2010-06-03 16:03:01


Attachments
preprocessed file (137 bytes, text/plain)
2010-06-03 15:49 UTC, Roy Rosen
Details
patch (700 bytes, patch)
2010-06-03 19:39 UTC, Richard Biener
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Roy Rosen 2010-06-03 15:48:28 UTC
For the following function:

void xxx(short* __restrict__ a, short* __restrict__ b)
{
   int i;
   for (i = 0; i < 8; i++)
   {
       a[i] = b[i];
   }
}

the following is generated in the .optimized file:

xxx (short int * restrict a, short int * restrict b)
{
  vector(2) short int * vect_p.27;
  vector(2) short int vect_var_.26;
  vector(2) short int * vect_p.22;
  int andmask.21;
  int orptrs1.20;
  int addr2int1.19;
  vector(2) short int * vect_p.18;
  int addr2int0.15;
  vector(2) short int * vect_p.14;
  short int D.1998;
  short int * restrict D.1997;
  short int * restrict D.1996;

<bb 2>:
  vect_p.14_18 = (vector(2) short int *) b_9(D);
  addr2int0.15_23 = (int) vect_p.14_18;
  vect_p.18_24 = (vector(2) short int *) a_5(D);
  addr2int1.19_25 = (int) vect_p.18_24;
  orptrs1.20_26 = addr2int0.15_23 | addr2int1.19_25;
  andmask.21_27 = orptrs1.20_26 & 3;
  if (andmask.21_27 == 0)
    goto <bb 3>;
  else
    goto <bb 4>;

<bb 3>:
  vect_var_.26_6 = *vect_p.14_18;
  *vect_p.18_24 = vect_var_.26_6;
  vect_p.22_11 = vect_p.14_18 + 4;
  vect_p.27_12 = vect_p.18_24 + 4;
  vect_var_.26_56 = *vect_p.22_11;
  *vect_p.27_12 = vect_var_.26_56;
  vect_p.22_58 = vect_p.22_11 + 4;
  vect_p.27_59 = vect_p.27_12 + 4;
  vect_var_.26_65 = *vect_p.22_58;
  *vect_p.27_59 = vect_var_.26_65;
  vect_p.22_67 = vect_p.22_58 + 4;
  vect_p.27_68 = vect_p.27_59 + 4;
  vect_var_.26_44 = *vect_p.22_67;
  *vect_p.27_68 = vect_var_.26_44;
  goto <bb 5>;

<bb 4>:
  D.1998_77 = *b_9(D);
  *a_5(D) = D.1998_77;
  D.1996_86 = a_5(D) + 2;
  D.1997_87 = b_9(D) + 2;
  D.1998_88 = *D.1997_87;
  *D.1996_86 = D.1998_88;
  D.1996_97 = a_5(D) + 4;
  D.1997_98 = b_9(D) + 4;
  D.1998_99 = *D.1997_98;
  *D.1996_97 = D.1998_99;
  D.1996_108 = a_5(D) + 6;
  D.1997_109 = b_9(D) + 6;
  D.1998_110 = *D.1997_109;
  *D.1996_108 = D.1998_110;
  D.1996_119 = a_5(D) + 8;
  D.1997_120 = b_9(D) + 8;
  D.1998_121 = *D.1997_120;
  *D.1996_119 = D.1998_121;
  D.1996_130 = a_5(D) + 10;
  D.1997_131 = b_9(D) + 10;
  D.1998_132 = *D.1997_131;
  *D.1996_130 = D.1998_132;
  D.1996_141 = a_5(D) + 12;
  D.1997_142 = b_9(D) + 12;
  D.1998_143 = *D.1997_142;
  *D.1996_141 = D.1998_143;
  D.1996_34 = a_5(D) + 14;
  D.1997_35 = b_9(D) + 14;
  D.1998_36 = *D.1997_35;
  *D.1996_34 = D.1998_36;

<bb 5>:
  return;

} 

You may notice that the vect variables don't have the restrict qualifier.

Using built-in specs.
COLLECT_GCC=./xgcc
Target: i386-elf-linux
Configured with: ../gcc-4.6-20100529/configure --target=i386-elf-linux --enable-languages=c
Thread model: posix
gcc version 4.6.0 20100529 (experimental) (GCC)
COLLECT_GCC_OPTIONS='-save-temps' '-v' '-O3' '-fno-ivopts' '-mtune=i386' '-march=i386'
 cc1 -E -quiet -v -iprefix /home/swproj/sw/users/eyalhar/i386-46/gcc/../lib/gcc/i386-elf-linux/4.6.0/ ./a.c -mtune=i386 -march=i386 -fno-ivopts -O3 -fpch-preprocess -o a.i
ignoring nonexistent directory "/home/swproj/sw/users/eyalhar/i386-46/gcc/../lib/gcc/i386-elf-linux/4.6.0/include"
ignoring nonexistent directory "/home/swproj/sw/users/eyalhar/i386-46/gcc/../lib/gcc/i386-elf-linux/4.6.0/include-fixed"
ignoring nonexistent directory "/home/swproj/sw/users/eyalhar/i386-46/gcc/../lib/gcc/i386-elf-linux/4.6.0/../../../../i386-elf-linux/sys-include"
ignoring nonexistent directory "/home/swproj/sw/users/eyalhar/i386-46/gcc/../lib/gcc/i386-elf-linux/4.6.0/../../../../i386-elf-linux/include"
ignoring nonexistent directory "/home/swproj/sw/users/eyalhar/i386-46/gcc/../lib/gcc/../../lib/gcc/i386-elf-linux/4.6.0/include"
ignoring nonexistent directory "/home/swproj/sw/users/eyalhar/i386-46/gcc/../lib/gcc/../../lib/gcc/i386-elf-linux/4.6.0/include-fixed"
ignoring nonexistent directory "/home/swproj/sw/users/eyalhar/i386-46/gcc/../lib/gcc/../../lib/gcc/i386-elf-linux/4.6.0/../../../../i386-elf-linux/sys-include"
ignoring nonexistent directory "/home/swproj/sw/users/eyalhar/i386-46/gcc/../lib/gcc/../../lib/gcc/i386-elf-linux/4.6.0/../../../../i386-elf-linux/include"
#include "..." search starts here:
#include <...> search starts here:
End of search list.
COLLECT_GCC_OPTIONS='-save-temps' '-v' '-O3' '-fno-ivopts' '-mtune=i386' '-march=i386'
 cc1 -fpreprocessed a.i -quiet -dumpbase a.c -mtune=i386 -march=i386 -auxbase a -O3 -version -fno-ivopts -o a.s
GNU C (GCC) version 4.6.0 20100529 (experimental) (i386-elf-linux)
        compiled by GNU C version 4.1.2 20080704 (Red Hat 4.1.2-44), GMP version 4.3.2, MPFR version 2.4.2, MPC version 0.8.1
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
GNU C (GCC) version 4.6.0 20100529 (experimental) (i386-elf-linux)
        compiled by GNU C version 4.1.2 20080704 (Red Hat 4.1.2-44), GMP version 4.3.2, MPFR version 2.4.2, MPC version 0.8.1
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
Compiler executable checksum: b29c4bb89017c75caf92d2ab060612f6
COLLECT_GCC_OPTIONS='-save-temps' '-v' '-O3' '-fno-ivopts' '-mtune=i386' '-march=i386'
 as -V -Qy --32 -o a.o a.s
GNU assembler version 2.17.50.0.6-9.el5 (x86_64-redhat-linux) using BFD version 2.17.50.0.6-9.el5 20061020
COMPILER_PATH=
LIBRARY_PATH=
COLLECT_GCC_OPTIONS='-save-temps' '-v' '-O3' '-fno-ivopts' '-mtune=i386' '-march=i386'
 ld -m elf_i386 -dynamic-linker /lib/ld-linux.so.2 crt1.o crti.o crtbegin.o a.o -lgcc -lgcc_eh -lc -lgcc -lgcc_eh crtend.o crtn.o
ld: crt1.o: No such file: No such file or directory
Comment 1 Roy Rosen 2010-06-03 15:49:45 UTC
Created attachment 20818 [details]
preprocessed file
Comment 2 Richard Biener 2010-06-03 16:03:01 UTC
Confirmed.
Comment 3 Richard Biener 2010-06-03 19:39:19 UTC
Created attachment 20821 [details]
patch

Mine.
Comment 4 Richard Biener 2010-06-03 21:12:54 UTC
Fixed.
Comment 5 Richard Biener 2010-06-03 21:12:58 UTC
Subject: Bug 44403

Author: rguenth
Date: Thu Jun  3 21:12:38 2010
New Revision: 160235

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=160235
Log:
2010-06-03  Richard Guenther  <rguenther@suse.de>

	PR tree-optimization/44403
	* tree-vect-data-refs.c (vect_create_addr_base_for_vector_ref):
	Preserve pointer qualifiers.
	(vect_create_data_ref_ptr): Likewise.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/tree-vect-data-refs.c