Bug 290006 - memcheck doesn't mark %xmm as initialized after "pcmpeqw %xmm %xmm"
Summary: memcheck doesn't mark %xmm as initialized after "pcmpeqw %xmm %xmm"
Status: RESOLVED FIXED
Alias: None
Product: valgrind
Classification: Developer tools
Component: memcheck (other bugs)
Version First Reported In: unspecified
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: ---
Assignee: Julian Seward
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-12-28 11:45 UTC by Alexey Samsonov
Modified: 2020-02-03 00:55 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed/Implemented In:
Sentry Crash Report:


Attachments
Valgrind VEX - a couple of IR optimizations (806 bytes, patch)
2012-01-13 14:32 UTC, Alexey Samsonov
Details

Note You need to log in before you can comment on or make changes to this bug.
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.