Vector widening code gen error
| Bugzilla Link | 22774 |
| Resolution | FIXED |
| Resolved on | Mar 04, 2015 07:56 |
| Version | trunk |
| OS | Windows NT |
| CC | @adibiagio |
Extended Description
@id9883 = global <4 x i64> <i64 -1, i64 -1, i64 -1, i64 -1>, align 32 @id9881 = global <2 x i64> zeroinitializer, align 16
define i32 @_Z3foov() #0 { entry: %0 = load <4 x i64>, <4 x i64>* @id9883, align 32 %vecext = extractelement <4 x i64> %0, i32 0 %vecinit = insertelement <2 x i64> undef, i64 %vecext, i32 0 %vecinit1 = insertelement <2 x i64> %vecinit, i64 0, i32 1 store <2 x i64> %vecinit1, <2 x i64>* @id9881, align 16 ret i32 0 }
; llc -march=x86-64 -mattr=avx ; ; does not zero out the upper bits of the result despite ; %vecinit1 = insertelement <2 x i64> %vecinit, i64 0, i32 1 ; ; generating the following code: ; ; vmovaps id9883(%rip), %ymm0 ; vextractf128 $1, %ymm0, %xmm1 ; vpblendw $240, %xmm1, %xmm0, %xmm0 # xmm0 = xmm0[0,1,2,3],xmm1[4,5,6,7] ; vmovdqa %xmm0, id9881(%rip) ; ; Seems to have started with r224429. ; ; The test case is a simplification from a use of the builtin ; _mm_cvtsi64_si128.
Hi Wolfgang,
Just for your info: Michael fixed this bug at revision 231219. http://llvm.org/viewvc/llvm-project?view=revision&revision=231219
Fix up for review in http://reviews.llvm.org/D8040
// runnable c++ test case. Upper 64 bits should be 0. Compile with clang -O2 -target x86_64-unkown-linux-gnu -march=btver2
// runnable c++ test case. Upper 64 bits should be 0. extern "C" int printf(const char *, ...); extern "C" int sprintf(char *, const char *, ...);
typedef long long __m128i attribute((vector_size(16))); typedef long long __m256i attribute((vector_size(32)));
attribute((noinline)) static void init(unsigned char pred, volatile void *data, unsigned size) { unsigned char *bytes = (unsigned char *)data; for (unsigned i = 0; i != size; ++i) { bytes[i] = pred + i; } }
attribute((noinline)) static void print(const char *msg, volatile void *data, unsigned size) { unsigned char *bytes = (unsigned char *)data; char tmp[256]; for (unsigned i = 0; i != size; ++i) { sprintf(tmp + i * 2, "%02x", bytes[size - 1 - i]); }
printf("%s:%s\n", msg, tmp); }
int main() { volatile __m256i id9883;
init(43, &id9883, sizeof(id9883));
long long id9882 = id9883[0]; __m128i id9881 = (__m128i){ id9882, 0 };
print("id9881", &id9881, sizeof(id9881)); }