forked from OSchip/llvm-project
[OpenCL] Fix `mix` builtin overloads
`mix` is subtly different from `clamp`: in the overloads where the last argument is a scalar, the second argument should be a gentype for `mix`. As scalars can be implicitly converted to vectors, this cannot be caught in the Sema test. Hence adding a CodeGen test, where we can verify the types using the mangled name.
This commit is contained in:
parent
9c0069d836
commit
f0686569cc
|
@ -651,12 +651,18 @@ foreach name = ["step"] in {
|
|||
}
|
||||
|
||||
// --- 3 arguments ---
|
||||
foreach name = ["clamp", "mix"] in {
|
||||
foreach name = ["clamp"] in {
|
||||
def : Builtin<name, [FGenTypeN, FGenTypeN, FGenTypeN, FGenTypeN], Attr.Const>;
|
||||
def : Builtin<name, [GenTypeFloatVecNoScalar, GenTypeFloatVecNoScalar, Float, Float], Attr.Const>;
|
||||
def : Builtin<name, [GenTypeDoubleVecNoScalar, GenTypeDoubleVecNoScalar, Double, Double], Attr.Const>;
|
||||
def : Builtin<name, [GenTypeHalfVecNoScalar, GenTypeHalfVecNoScalar, Half, Half], Attr.Const>;
|
||||
}
|
||||
foreach name = ["mix"] in {
|
||||
def : Builtin<name, [FGenTypeN, FGenTypeN, FGenTypeN, FGenTypeN], Attr.Const>;
|
||||
def : Builtin<name, [GenTypeFloatVecNoScalar, GenTypeFloatVecNoScalar, GenTypeFloatVecNoScalar, Float], Attr.Const>;
|
||||
def : Builtin<name, [GenTypeDoubleVecNoScalar, GenTypeDoubleVecNoScalar, GenTypeDoubleVecNoScalar, Double], Attr.Const>;
|
||||
def : Builtin<name, [GenTypeHalfVecNoScalar, GenTypeHalfVecNoScalar, GenTypeHalfVecNoScalar, Half], Attr.Const>;
|
||||
}
|
||||
foreach name = ["smoothstep"] in {
|
||||
def : Builtin<name, [FGenTypeN, FGenTypeN, FGenTypeN, FGenTypeN], Attr.Const>;
|
||||
def : Builtin<name, [GenTypeFloatVecNoScalar, Float, Float, GenTypeFloatVecNoScalar], Attr.Const>;
|
||||
|
|
|
@ -1,5 +1,13 @@
|
|||
// RUN: %clang_cc1 -emit-llvm -o - -O0 -triple spir-unknown-unknown -cl-std=CL1.2 -fdeclare-opencl-builtins -finclude-default-header %s | FileCheck %s
|
||||
|
||||
// Test that mix is correctly defined.
|
||||
// CHECK-LABEL: @test_float
|
||||
// CHECK: call <4 x float> @_Z3mixDv4_fS_f
|
||||
// CHECK: ret
|
||||
void test_float(float4 x, float a) {
|
||||
float4 ret = mix(x, x, a);
|
||||
}
|
||||
|
||||
// Test that Attr.Const from OpenCLBuiltins.td is lowered to a readnone attribute.
|
||||
// CHECK-LABEL: @test_const_attr
|
||||
// CHECK: call i32 @_Z3maxii({{.*}}) [[ATTR_CONST:#[0-9]]]
|
||||
|
|
Loading…
Reference in New Issue