Vc icon indicating copy to clipboard operation
Vc copied to clipboard

Bug: Wrong Mask initialization under SSE + Vc Master + -ffast-math

Open sawenzel opened this issue 8 years ago • 1 comments

Vc-revision: 080116dec206dca965f01a9b19e6885e0f9a0cac OS: CentOS7 Compiler: g++ (GCC) 4.8.5 20150623 (Red Hat 4.8.5-4) Flags: see attachment ( combination of sse + -ffast-math ) CPU: does not matter (reproduced on different architectures)

Observation

There is a problem in mask initializations under SSE with latest master in combination with fast math compiler flag.

This problem goes away if either a) compile for AVX b) remove fast-math c) go to release tag 1.2.0

(see attached source code and compilation script for details) package.zip

Testcase

#include <Vc/Vc>
using Vec = Vc::double_v;
int main() {
  Vec a,b;
  for (size_t i=0;i<Vec::Size;++i) {
      a[i] = (i % 2) == 0 ? 1 : 4;
      b[i] = 4;
  }
  auto m = a < b;
  std::cerr << m << "\n";
}

Actual Results

m[00]

Expected Results

m[10]

sawenzel avatar Jul 07 '16 10:07 sawenzel

Thanks Sandro, I'll see what I can find out. The likely relevant change after the 1.2 release is the change in the subscript operator return type. Instead of returing a type-punned lvalue reference to EntryType, it returns a "smart reference" proxy type to avoid the type punning. So, in theory, the master version should be correct while 1.2 relies on a compiler extension (otherwise 1.2 would invoke undefined behavior on subscript assignment) which lead to multiple GCC bug reports already (and major new issues starting with GCC 6).

mattkretz avatar Jul 14 '16 09:07 mattkretz