The attached program runs fine on my Intel Core i7-3930K, but when I run it through memcheck, I get a complaint about an illegal instruction. This happens on this line: v4df zmask = _mm256_cmp_pd(xarg, zero, _CMP_EQ_OS); The interesting detail is that this is not the first instance of _mm256_cmp_pd(), but the second... Reproducible: Always Steps to Reproduce: 1. compile with "g++ -mavx bug.cpp" 2. run with "valgrind a.out" (obviously on AVX capable hardware) Actual Results: ==24621== Memcheck, a memory error detector ==24621== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al. ==24621== Using Valgrind-3.10.0 and LibVEX; rerun with -h for copyright info ==24621== Command: a.out ==24621== vex amd64->IR: unhandled instruction bytes: 0xC5 0xFD 0xC2 0xC1 0x10 0xC5 0xFD 0x29 vex amd64->IR: REX=0 REX.W=0 REX.R=0 REX.X=0 REX.B=0 vex amd64->IR: VEX=1 VEX.L=1 VEX.nVVVV=0x0 ESC=0F vex amd64->IR: PFX.66=1 PFX.F2=0 PFX.F3=0 ==24621== valgrind: Unrecognised instruction at address 0x401256. ==24621== at 0x401256: v1logd(double __vector(4)) (bug.cpp:107) ==24621== by 0x4005F6: main (bug.cpp:121) ... etc ... Expected Results: A run with no complaints. OS : openSUSE 13.2 64-bit g++ : g++ (SUSE Linux) 4.8.3 20140627 [gcc-4_8-branch revision 212064]
Created attachment 92163 [details] test case
Further testing shows that the failure depends on the value of the compare predicate. The following predicates fail: _CMP_FALSE_OQ _CMP_TRUE_UQ _CMP_EQ_OS _CMP_UNORD_S _CMP_NEQ_US _CMP_NLT_UQ _CMP_ORD_S _CMP_EQ_US _CMP_NGE_UQ _CMP_NGT_UQ _CMP_FALSE_OS _CMP_NEQ_OS _CMP_GE_OQ _CMP_TRUE_US The rest works fine. This explains why only the second instance of _mm256_cmp_pd() failed.
Based on this I created a simplified test case bug2.cpp Steps to Reproduce: 1. compile with "g++ -mavx bug.cpp" 2. run with "valgrind a.out <n>" where <n> is the numeric value of the compare predicate (between 0 and 31).
Created attachment 92589 [details] simplified test case
Fixed, vex r3170. *** This bug has been marked as a duplicate of bug 342571 ***