Index: lib/Sema/SemaExpr.cpp =================================================================== --- lib/Sema/SemaExpr.cpp +++ lib/Sema/SemaExpr.cpp @@ -7932,11 +7932,12 @@ // If we're allowing lax vector conversions, only the total (data) size // needs to be the same. // FIXME: Should we really be allowing this? - // FIXME: We really just pick the LHS type arbitrarily? - if (isLaxVectorConversion(RHSType, LHSType)) { - QualType resultType = LHSType; - RHS = ImpCastExprToType(RHS.get(), resultType, CK_BitCast); - return resultType; + QualType VecType = LHSVecType ? LHSType : RHSType; + QualType ScalarType = LHSVecType ? RHSType : LHSType; + ExprResult *ScalarExpr = LHSVecType ? &RHS : &LHS; + if (isLaxVectorConversion(ScalarType, VecType)) { + *ScalarExpr = ImpCastExprToType(ScalarExpr->get(), VecType, CK_BitCast); + return VecType; } // Okay, the expression is invalid. Index: test/CodeGen/vector.c =================================================================== --- test/CodeGen/vector.c +++ test/CodeGen/vector.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple i386-apple-darwin9 -O1 -target-cpu pentium4 -target-feature +sse4.1 -debug-info-kind=limited -emit-llvm %s -o - | FileCheck %s +// RUN: %clang_cc1 -triple i386-apple-darwin9 -O1 -target-cpu core2 -debug-info-kind=limited -emit-llvm %s -o - | FileCheck %s typedef short __v4hi __attribute__ ((__vector_size__ (8))); void test1() { @@ -62,3 +62,23 @@ extern __typeof(_mm_extract_epi16(_mm_setzero_si128(), 3)) check_result_int; extern __typeof(_mm_extract_epi32(_mm_setzero_si128(), 3)) check_result_int; } + +// Test some logic around our lax vector comparison rules with integers. + +typedef int vec_int1 __attribute__((vector_size(4))); +vec_int1 lax_vector_compare1(int x, vec_int1 y) { + y = x == y; + return y; +} + +// CHECK: define i32 @lax_vector_compare1(i32 {{.*}}, i32 {{.*}}) +// CHECK: icmp eq <1 x i32> + +typedef int vec_int2 __attribute__((vector_size(8))); +vec_int2 lax_vector_compare2(long long x, vec_int2 y) { + y = x == y; + return y; +} + +// CHECK: define void @lax_vector_compare2(<2 x i32>* {{.*sret.*}}, i64 {{.*}}, i64 {{.*}}) +// CHECK: icmp eq <2 x i32>