diff options
author | Simon Pilgrim <llvm-dev@redking.me.uk> | 2017-06-01 20:13:34 +0000 |
---|---|---|
committer | Simon Pilgrim <llvm-dev@redking.me.uk> | 2017-06-01 20:13:34 +0000 |
commit | a5dbbc6eada042cc86628da235829b715cec543d (patch) | |
tree | d372bc96552afd91fc692d359fe6488cfc67febf | |
parent | c784e96eac1bbbde394ce51a560381d3edcdde7d (diff) | |
download | bcm5719-llvm-a5dbbc6eada042cc86628da235829b715cec543d.tar.gz bcm5719-llvm-a5dbbc6eada042cc86628da235829b715cec543d.zip |
Don't assume that a store source is a vector type just because the destination is (PR26099)
llvm-svn: 304465
-rw-r--r-- | clang/lib/CodeGen/CGExpr.cpp | 4 | ||||
-rw-r--r-- | clang/test/CodeGen/pr26099.c | 12 |
2 files changed, 14 insertions, 2 deletions
diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp index 84ce896506d..2aa04587921 100644 --- a/clang/lib/CodeGen/CGExpr.cpp +++ b/clang/lib/CodeGen/CGExpr.cpp @@ -1487,9 +1487,9 @@ void CodeGenFunction::EmitStoreOfScalar(llvm::Value *Value, Address Addr, // Handle vectors differently to get better performance. if (Ty->isVectorType()) { llvm::Type *SrcTy = Value->getType(); - auto *VecTy = cast<llvm::VectorType>(SrcTy); + auto *VecTy = dyn_cast<llvm::VectorType>(SrcTy); // Handle vec3 special. - if (VecTy->getNumElements() == 3) { + if (VecTy && VecTy->getNumElements() == 3) { // Our source is a vec3, do a shuffle vector to make it a vec4. llvm::Constant *Mask[] = {Builder.getInt32(0), Builder.getInt32(1), Builder.getInt32(2), diff --git a/clang/test/CodeGen/pr26099.c b/clang/test/CodeGen/pr26099.c new file mode 100644 index 00000000000..15b73b832e9 --- /dev/null +++ b/clang/test/CodeGen/pr26099.c @@ -0,0 +1,12 @@ +// RUN: %clang_cc1 -ffreestanding %s -triple=i686-apple-darwin -target-feature +mmx -emit-llvm -o - -Wall -Werror +// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +mmx -emit-llvm -o - -Wall -Werror +// REQUIRES: asserts + +#include <x86intrin.h> + +int __attribute__ ((__vector_size__ (8))) b; + +void bar(int a) +{ + b = __builtin_ia32_vec_init_v2si (0, a); +}
\ No newline at end of file |