Index: lib/CodeGen/CGStmt.cpp =================================================================== --- lib/CodeGen/CGStmt.cpp +++ lib/CodeGen/CGStmt.cpp @@ -2210,7 +2210,7 @@ llvm::IntegerType::get(getLLVMContext(), (unsigned)TmpSize)); Tmp = Builder.CreateTrunc(Tmp, TruncTy); } else if (TruncTy->isIntegerTy()) { - Tmp = Builder.CreateTrunc(Tmp, TruncTy); + Tmp = Builder.CreateZExtOrTrunc(Tmp, TruncTy); } else if (TruncTy->isVectorTy()) { Tmp = Builder.CreateBitCast(Tmp, TruncTy); } Index: test/CodeGen/pr34021.c =================================================================== --- test/CodeGen/pr34021.c +++ test/CodeGen/pr34021.c @@ -0,0 +1,10 @@ +// RUN: %clang_cc1 -fms-extensions %s -triple=i686-unknown-unknown -emit-llvm -o - +// RUN: %clang_cc1 -fms-extensions %s -triple=x86_64-unknown-unknown -emit-llvm -o - +// REQUIRES: asserts + +typedef int v4si __attribute__ ((vector_size (16))); +v4si rep() { + v4si res; + __asm {} + return res; +}