fork(3) download
  1. #include <emmintrin.h>
  2. #include <cassert>
  3.  
  4. bool less(const __m128i& a, const __m128i& b) {
  5. __m128i t = _mm_cmplt_epi32(a,b);
  6. __m128i u = _mm_cmpgt_epi32(a,b);
  7. __m128i z = _mm_or_si128(t,_mm_shuffle_epi32(t,177));
  8. z = _mm_andnot_si128(_mm_shuffle_epi32(u,245),z);
  9. return z.m128i_u64[0] == 0xffffffffull;
  10. }
  11.  
  12. int main() {
  13. __m128i vals[] = {
  14. _mm_set_epi32(0,0,0,0),
  15. _mm_set_epi32(0,0,0,1),
  16. _mm_set_epi32(0,0,0,0xffffffff),
  17. _mm_set_epi32(0,0,1,0),
  18. _mm_set_epi32(0,0,1,0xffffffff),
  19. _mm_set_epi32(0,0,2,0)
  20. };
  21.  
  22.  
  23. for (int i = 0; i < 6; ++i) {
  24. for (int j = 0; j < 6; ++j) {
  25. bool result = less(vals[i], vals[j]);
  26. bool expected = i < j;
  27. assert(result == expected);
  28. }
  29. }
  30. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
In file included from prog.cpp:1:
/usr/lib/gcc/i686-pc-linux-gnu/4.3.4/include/emmintrin.h:34:3: error: #error "SSE2 instruction set not enabled"
prog.cpp:4: error: expected ‘,’ or ‘...’ before ‘&’ token
prog.cpp:4: error: ISO C++ forbids declaration of ‘__m128i’ with no type
prog.cpp: In function ‘bool less(int)’:
prog.cpp:5: error: expected `;' before ‘t’
prog.cpp:5: warning: statement has no effect
prog.cpp:6: error: expected `;' before ‘u’
prog.cpp:6: warning: statement has no effect
prog.cpp:7: error: expected `;' before ‘z’
prog.cpp:7: warning: statement has no effect
prog.cpp:8: error: ‘z’ was not declared in this scope
prog.cpp:8: error: ‘u’ was not declared in this scope
prog.cpp:8: error: ‘_mm_shuffle_epi32’ was not declared in this scope
prog.cpp:8: error: ‘_mm_andnot_si128’ was not declared in this scope
prog.cpp: In function ‘int main()’:
prog.cpp:13: error: ‘__m128i’ was not declared in this scope
prog.cpp:13: error: expected `;' before ‘vals’
prog.cpp:25: error: ‘vals’ was not declared in this scope
stdout
Standard output is empty