_mm_alignr_epi8 sets immediate wrong in llvm-gcc, clang
| Bugzilla Link | 5739 |
| Resolution | FIXED |
| Resolved on | Dec 09, 2009 17:32 |
| Version | 2.6 |
| OS | Linux |
| Reporter | LLVM Bugzilla Contributor |
| CC | @asl,@lattner,@echristo |
Extended Description
The SSE3 function _mm_alignr_epi8, which lowers to palignr, is given the wrong immediate by both llvm-gcc and clang.
Version numbers:
llvm-gcc: llvm-gcc (GCC) 4.2.1 (Based on Apple Inc. build 5649) (LLVM build)
clang: clang version 1.1 (trunk 85640) Target: x86_64-unknown-linux-gnu Thread model: posix
LLVM: Low Level Virtual Machine (http://llvm.org/): llvm version 2.7svn DEBUG build with assertions. Built Oct 30 2009 (18:06:39). Host: x86_64-unknown-linux-gnu
gcc: gcc (Ubuntu 4.4.1-4ubuntu8) 4.4.1
Linux distro: Ubuntu 8.10 "Karmic" Linux peppercorn 2.6.31-16-generic #52-Ubuntu SMP Thu Dec 3 22:07:16 UTC 2009 x86_64 GNU/Linux
Test case: //////////////////////////////////////////// #include <tmmintrin.h>
int main(int argc, char **argv) { __m128i x = _mm_setzero_si128(), y = _mm_alignr_epi8(x, x, 1);
return 0; } ////////////////////////////////////////////
$ llvm-gcc -S -mssse3 test.c -o - | grep palignr palignr $8, %xmm1, %xmm1
$ clang -S -mssse3 test.c -o - | grep palignr palignr $0, %xmm1, %xmm1
$ gcc -S -mssse3 test.c -o - | grep palignr palignr $1, %xmm1, %xmm0
gcc is correct, but clang and llvm-gcc give different wrong results. From other testing, it appears that llvm-gcc always sets the immediate too high by a factor of 8. Clang sometimes sets it to 0 and sometimes sets it to 1.
The code in the test case is obviously dead, but the optimizer is off here and the bug occurs in real code as well.
Fixed in llvm-gcc, just verified that clang still has a problem. Just wanted to verify.
Current codegen llvm-gcc:
palignr $1, %xmm1, %xmm1
Current codegen clang:
palignr $0, %xmm1, %xmm1
I'll file a bug against clang.
Thanks Eric, hasn't this already been fixed?
I'll take it.