[llvm-bugs] [Bug 37795] New: Clang now emitting an error for valid arguments to _mm_slli_si128/_mm_srli_si128

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Jun 13 14:33:38 PDT 2018


https://bugs.llvm.org/show_bug.cgi?id=37795

            Bug ID: 37795
           Summary: Clang now emitting an error for valid arguments to
                    _mm_slli_si128/_mm_srli_si128
           Product: new-bugs
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: douglas_yung at playstation.sony.com
                CC: llvm-bugs at lists.llvm.org

Change r334208 changed the implementation of the _mm_slli_si128 and
_mm_srli_si128 intrinsics such that now valid values are causing the compiler
to emit an error. Consider the following code:

/* test.cpp */

#include <x86intrin.h>

void foo(__v2di InVec) {
  _mm_slli_si128(InVec, 128);
  _mm_srli_si128(InVec, 128);
}

If compiled with an upstream compiler built from r334207 or earlier, it would
compile with no errors.

However, after upstream change r334208 changed the implementation of these
intrinsics, the compiler gives the following error:

C:\sandbox\r334208>C:\src\upstream\334208-PS4-Release\Release\bin\clang.exe -S
test.cpp
test.cpp:4:3: error: argument should be a value from 0 to 1023
  _mm_slli_si128(InVec, 128);
  ^~~~~~~~~~~~~~~~~~~~~~~~~~
C:\src\upstream\334208-PS4-Release\Release\lib\clang\7.0.0\include\emmintrin.h:2797:12:
note:
expanded from macro '_mm_slli_si128'
  (__m128i)__builtin_ia32_pslldqi128((__v2di)(__m128i)(a), (int)(imm) * 8)
           ^                                               ~~~~~~~~~~~~~~
test.cpp:5:3: error: argument should be a value from 0 to 1023
  _mm_srli_si128(InVec, 128);
  ^~~~~~~~~~~~~~~~~~~~~~~~~~
C:\src\upstream\334208-PS4-Release\Release\lib\clang\7.0.0\include\emmintrin.h:3014:12:
note:
expanded from macro '_mm_srli_si128'
  (__m128i)__builtin_ia32_psrldqi128((__v2di)(__m128i)(a), (int)(imm) * 8)
           ^                                               ~~~~~~~~~~~~~~
2 errors generated.

The problem here is that the compiler error message states that the second
argument should be a value from 0-1023, but because of the implementation in
emmintrin.h ((int)(imm) * 8), the actual allowed values are really much
smaller, only 0-127. As you can see, the specified value of 128 is within the
range, but still causes the compiler to emit an error due to the implementation
of the intrinsic.

There are possibly two problems here. The first is that the compiler should
emit the correct valid ranges for values. The second is that because we are now
only limited to 0-127 instead of 0-1023, we might have lost some functionality
due to the new implementation.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20180613/6217bcf7/attachment-0001.html>


More information about the llvm-bugs mailing list