Author: rksimon
Date: Thu Jun  1 15:13:34 2017
New Revision: 304465

URL: http://llvm.org/viewvc/llvm-project?rev=304465&view=rev
Log:
Don't assume that a store source is a vector type just because the destination 
is (PR26099)

Added:
    cfe/trunk/test/CodeGen/pr26099.c
Modified:
    cfe/trunk/lib/CodeGen/CGExpr.cpp

Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=304465&r1=304464&r2=304465&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Thu Jun  1 15:13:34 2017
@@ -1487,9 +1487,9 @@ void CodeGenFunction::EmitStoreOfScalar(
     // 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),

Added: cfe/trunk/test/CodeGen/pr26099.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/pr26099.c?rev=304465&view=auto
==============================================================================
--- cfe/trunk/test/CodeGen/pr26099.c (added)
+++ cfe/trunk/test/CodeGen/pr26099.c Thu Jun  1 15:13:34 2017
@@ -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


_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to