summaryrefslogtreecommitdiff
path: root/lib/mesa/src/gallium/auxiliary
diff options
context:
space:
mode:
authorJonathan Gray <jsg@cvs.openbsd.org>2021-03-11 08:21:04 +0000
committerJonathan Gray <jsg@cvs.openbsd.org>2021-03-11 08:21:04 +0000
commite4ca19e92c3ff7df678446a3537af278c034e6bc (patch)
treed023c8970f7446cdd99f4b623191579c20f646f4 /lib/mesa/src/gallium/auxiliary
parenta555e39846a398cfab864e0c5446a76e5b74dc58 (diff)
gallivm: fix half to float conversions with llvm 11
From Roland Scheidegger 51a82ec3e437d1d2dc4c688578640d25b3e7f0a2 in mainline Mesa
Diffstat (limited to 'lib/mesa/src/gallium/auxiliary')
-rw-r--r--lib/mesa/src/gallium/auxiliary/gallivm/lp_bld_conv.c34
1 files changed, 24 insertions, 10 deletions
diff --git a/lib/mesa/src/gallium/auxiliary/gallivm/lp_bld_conv.c b/lib/mesa/src/gallium/auxiliary/gallivm/lp_bld_conv.c
index c688965a7..556babdd2 100644
--- a/lib/mesa/src/gallium/auxiliary/gallivm/lp_bld_conv.c
+++ b/lib/mesa/src/gallium/auxiliary/gallivm/lp_bld_conv.c
@@ -103,19 +103,33 @@ lp_build_half_to_float(struct gallivm_state *gallivm,
if (util_cpu_caps.has_f16c &&
(src_length == 4 || src_length == 8)) {
- const char *intrinsic = NULL;
- if (src_length == 4) {
- src = lp_build_pad_vector(gallivm, src, 8);
- intrinsic = "llvm.x86.vcvtph2ps.128";
- }
- else {
- intrinsic = "llvm.x86.vcvtph2ps.256";
+ if (LLVM_VERSION_MAJOR < 11) {
+ const char *intrinsic = NULL;
+ if (src_length == 4) {
+ src = lp_build_pad_vector(gallivm, src, 8);
+ intrinsic = "llvm.x86.vcvtph2ps.128";
+ }
+ else {
+ intrinsic = "llvm.x86.vcvtph2ps.256";
+ }
+ return lp_build_intrinsic_unary(builder, intrinsic,
+ lp_build_vec_type(gallivm, f32_type), src);
+ } else {
+ /*
+ * XXX: could probably use on other archs as well.
+ * But if the cpu doesn't support it natively it looks like the backends still
+ * can't lower it and will try to call out to external libraries, which will crash.
+ */
+ /*
+ * XXX: lp_build_vec_type() would use int16 vector. Probably need to revisit
+ * this at some point.
+ */
+ src = LLVMBuildBitCast(builder, src,
+ LLVMVectorType(LLVMHalfTypeInContext(gallivm->context), src_length), "");
+ return LLVMBuildFPExt(builder, src, lp_build_vec_type(gallivm, f32_type), "");
}
- return lp_build_intrinsic_unary(builder, intrinsic,
- lp_build_vec_type(gallivm, f32_type), src);
}
- /* Convert int16 vector to int32 vector by zero ext (might generate bad code) */
h = LLVMBuildZExt(builder, src, int_vec_type, "");
return lp_build_smallfloat_to_float(gallivm, f32_type, h, 10, 5, 0, true);
}