Index: lib/AST/ASTContext.cpp =================================================================== --- lib/AST/ASTContext.cpp +++ lib/AST/ASTContext.cpp @@ -7618,7 +7618,7 @@ Qualifiers RQuals = RHSCan.getLocalQualifiers(); if (LQuals != RQuals) { if (getLangOpts().OpenCL) { - if (LHS.getUnqualifiedType() != RHS.getUnqualifiedType() || + if (LHSCan.getUnqualifiedType() != RHSCan.getUnqualifiedType() || LQuals.getCVRQualifiers() != RQuals.getCVRQualifiers()) return QualType(); if (LQuals.isAddressSpaceSupersetOf(RQuals)) Index: test/CodeGenOpenCL/address-spaces-conversions.cl =================================================================== --- test/CodeGenOpenCL/address-spaces-conversions.cl +++ test/CodeGenOpenCL/address-spaces-conversions.cl @@ -49,7 +49,7 @@ generic int *var_gen2; generic float *var_gen_f; generic void *var_gen_v; - + var_gen = var_gen ? var_gen : var_gen2; // operands of the same addr spaces and the same type // CHECK: icmp // CHECK-NOT: addrspacecast @@ -63,7 +63,16 @@ // CHECK: %{{.+}} = addrspacecast i32 addrspace(1)* %{{.+}} to i32 addrspace(4)* // CHECK: phi // CHECK: store - + + typedef int int_t; + global int_t *var_glob_typedef; + var_gen = var_gen ? var_gen : var_glob_typedef; // operands of overlapping addr spaces and equivalent types + // CHECK: icmp + // CHECK-NOT: bitcast + // CHECK: %{{.+}} = addrspacecast i32 addrspace(1)* %{{.+}} to i32 addrspace(4)* + // CHECK: phi + // CHECK: store + var_gen_v = var_gen ? var_gen : var_gen_f; // operands of the same addr space and different types // CHECK: icmp // CHECK: %{{.+}} = bitcast i32 addrspace(4)* %{{.+}} to i8 addrspace(4)*