The _mm_prefetch() intrinsic causes profiles to be ignored

Problem : 
The _mm_prefetch() Intrinsic causes profiles to be ignored when you add it to profiled code with existing profiles.

_mm_prefetch((const char *)(latch), _MM_HINT_NTA );

The above statement is inserted into code to improve performance. This statement destroys profiles. This happens in Intel C++ compiler 10.1.

The follwoing example demonstrates the issue.

$ cat func.c

long func (long l) {
if ( l++ ) { return(l); } else { return(l++); }

#ifdef MMPF
_mm_prefetch((const char *)(&l), 0 );

if ( l++ ) { return(l); } else { return(l++); }


$ cat main.c

extern long func(long l);

long l=0;
int main () {
int i;
for (i=0;i<1000;i++) { l=func(i);}


$ icc -prof_gen func.c main.c
$ ls
a.out func.c main.c
$ ./a.out
$ ls
4b134bef_18815.dyn a.out func.c main.c
$icc -prof_use func.c main.c
/opt/spdtools/compiler/ia32e/cc-10.1.025/bin/profmerge: looking at dynamic file: ./4b134bef_18815.dyn

$ icc -prof_use -DMMPF func.c main.c
func.c(10): warning #167: argument of type "const char *" is incompatible with parameter of type "void *"
_mm_prefetch((const char *)(&l), 0 );

func.c(4): warning #11506: Profile information will be ignored for 'func':
func.c: warning #11503: Total routines 1, routines w/o profile info: 1

Environment : 
Intel C++ compiler 10.1

Resolution : 

This is resolved in Intel compiler 11.1.

In compiler 10.1, tThe profiles would have to be RECOLLECTED with a new -prof-gen binary just to insert one _mm_prefetch() intrinsic.

For more complete information about compiler optimizations, see our Optimization Notice.