Bug 290006

Summary: memcheck doesn't mark %xmm as initialized after "pcmpeqw %xmm %xmm"
Product: [Developer tools] valgrind Reporter: Alexey Samsonov <samsonov>
Component: memcheckAssignee: Julian Seward <jseward>
Status: RESOLVED FIXED    
Severity: normal CC: glider, nh2, samsonov
Priority: NOR    
Version First Reported In: unspecified   
Target Milestone: ---   
Platform: Compiled Sources   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:
Attachments: Valgrind VEX - a couple of IR optimizations

Description Alexey Samsonov 2011-12-28 11:45:28 UTC
Version:           unspecified
OS:                Linux

When an uninitialized value is stored in SSE register %xmm, instruction
"pcmpeqw %xmm, %xmm" should mark it as initialized, but it doesn't. Same problem for "pcmpeqd", but "pcmpeqb" or "pxor" works.

Reproducible: Always

Steps to Reproduce:
$ cat test.cc
#include <stdio.h>
#include "include/valgrind/memcheck.h"
int main() {
  unsigned char data[32], vbits[32];
  asm("movdqu (%0), %%xmm0\n"
      "pcmpeqw %%xmm0, %%xmm0\n"
      "movdqu  %%xmm0, 16(%0)\n"
      ::"r"(data):"memory");
  VALGRIND_GET_VBITS(data, vbits, 32);
  for(int i=0; i<2; i++) {
    for(int j=0; j<16; j++)
      printf("%02x ", vbits[i*16+j]);
    printf("\n");
  }
  return 0;
}
$ (g++ test.cc && ./bin/valgrind ./a.out)

Actual Results:  
ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff 
ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff 

Expected Results:  
ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
Comment 1 Alexey Samsonov 2012-01-13 14:32:06 UTC
Created attachment 67783 [details]
Valgrind VEX - a couple of IR optimizations
Comment 2 Alexey Samsonov 2012-01-13 14:33:16 UTC
Attached patch seems to fix memcheck false positives for pcmpeqw and pcmpeqd instructions.
Comment 3 Julian Seward 2012-07-10 21:41:49 UTC
Committed, vex r2423.  Thanks.