<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Looks good.</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Reviewed-by: Jose Fonseca <jfonseca@vmware.com></div>
<div>
<div id="appendonsend"></div>
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<br>
</div>
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> sroland@vmware.com <sroland@vmware.com><br>
<b>Sent:</b> Thursday, October 17, 2019 03:20<br>
<b>To:</b> Jose Fonseca <jfonseca@vmware.com>; airlied@freedesktop.org <airlied@freedesktop.org>; mesa-dev@lists.freedesktop.org <mesa-dev@lists.freedesktop.org><br>
<b>Cc:</b> Roland Scheidegger <sroland@vmware.com>; mesa-stable@lists.freedesktop.org <mesa-stable@lists.freedesktop.org><br>
<b>Subject:</b> [PATCH] gallivm: Fix saturated signed psub/padd intrinsics on llvm 8</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt">
<div class="PlainText">From: Roland Scheidegger <sroland@vmware.com><br>
<br>
LLVM 8 did remove both the signed and unsigned sse2/avx intrinsics in<br>
the end, and provide arch-independent llvm intrinsics instead.<br>
Fixes a crash when using snorm framebuffers (tested with piglit<br>
arb_color_buffer_float-render GL_RGBA8_SNORM -auto).<br>
<br>
CC: <mesa-stable@lists.freedesktop.org><br>
---<br>
src/gallium/auxiliary/gallivm/lp_bld_arit.c | 28 ++++++++-------------<br>
1 file changed, 10 insertions(+), 18 deletions(-)<br>
<br>
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_arit.c b/src/gallium/auxiliary/gallivm/lp_bld_arit.c<br>
index 6b7ce9aacf9..53ee00e6767 100644<br>
--- a/src/gallium/auxiliary/gallivm/lp_bld_arit.c<br>
+++ b/src/gallium/auxiliary/gallivm/lp_bld_arit.c<br>
@@ -465,7 +465,7 @@ lp_build_add(struct lp_build_context *bld,<br>
return bld->one;<br>
<br>
if (!type.floating && !type.fixed) {<br>
- if (LLVM_VERSION_MAJOR >= 9) {<br>
+ if (LLVM_VERSION_MAJOR >= 8) {<br>
char intrin[32];<br>
intrinsic = type.sign ? "llvm.sadd.sat" : "llvm.uadd.sat";<br>
lp_format_intrinsic(intrin, sizeof intrin, intrinsic, bld->vec_type);<br>
@@ -474,11 +474,9 @@ lp_build_add(struct lp_build_context *bld,<br>
if (type.width * type.length == 128) {<br>
if (util_cpu_caps.has_sse2) {<br>
if (type.width == 8)<br>
- intrinsic = type.sign ? "llvm.x86.sse2.padds.b" :<br>
- LLVM_VERSION_MAJOR < 8 ? "llvm.x86.sse2.paddus.b" : NULL;<br>
+ intrinsic = type.sign ? "llvm.x86.sse2.padds.b" : "llvm.x86.sse2.paddus.b";<br>
if (type.width == 16)<br>
- intrinsic = type.sign ? "llvm.x86.sse2.padds.w" :<br>
- LLVM_VERSION_MAJOR < 8 ? "llvm.x86.sse2.paddus.w" : NULL;<br>
+ intrinsic = type.sign ? "llvm.x86.sse2.padds.w" : "llvm.x86.sse2.paddus.w";<br>
} else if (util_cpu_caps.has_altivec) {<br>
if (type.width == 8)<br>
intrinsic = type.sign ? "llvm.ppc.altivec.vaddsbs" : "llvm.ppc.altivec.vaddubs";<br>
@@ -489,11 +487,9 @@ lp_build_add(struct lp_build_context *bld,<br>
if (type.width * type.length == 256) {<br>
if (util_cpu_caps.has_avx2) {<br>
if (type.width == 8)<br>
- intrinsic = type.sign ? "llvm.x86.avx2.padds.b" :<br>
- LLVM_VERSION_MAJOR < 8 ? "llvm.x86.avx2.paddus.b" : NULL;<br>
+ intrinsic = type.sign ? "llvm.x86.avx2.padds.b" : "llvm.x86.avx2.paddus.b";<br>
if (type.width == 16)<br>
- intrinsic = type.sign ? "llvm.x86.avx2.padds.w" :<br>
- LLVM_VERSION_MAJOR < 8 ? "llvm.x86.avx2.paddus.w" : NULL;<br>
+ intrinsic = type.sign ? "llvm.x86.avx2.padds.w" : "llvm.x86.avx2.paddus.w";<br>
}<br>
}<br>
}<br>
@@ -793,7 +789,7 @@ lp_build_sub(struct lp_build_context *bld,<br>
return bld->zero;<br>
<br>
if (!type.floating && !type.fixed) {<br>
- if (LLVM_VERSION_MAJOR >= 9) {<br>
+ if (LLVM_VERSION_MAJOR >= 8) {<br>
char intrin[32];<br>
intrinsic = type.sign ? "llvm.ssub.sat" : "llvm.usub.sat";<br>
lp_format_intrinsic(intrin, sizeof intrin, intrinsic, bld->vec_type);<br>
@@ -802,11 +798,9 @@ lp_build_sub(struct lp_build_context *bld,<br>
if (type.width * type.length == 128) {<br>
if (util_cpu_caps.has_sse2) {<br>
if (type.width == 8)<br>
- intrinsic = type.sign ? "llvm.x86.sse2.psubs.b" :<br>
- LLVM_VERSION_MAJOR < 8 ? "llvm.x86.sse2.psubus.b" : NULL;<br>
+ intrinsic = type.sign ? "llvm.x86.sse2.psubs.b" : "llvm.x86.sse2.psubus.b";<br>
if (type.width == 16)<br>
- intrinsic = type.sign ? "llvm.x86.sse2.psubs.w" :<br>
- LLVM_VERSION_MAJOR < 8 ? "llvm.x86.sse2.psubus.w" : NULL;<br>
+ intrinsic = type.sign ? "llvm.x86.sse2.psubs.w" : "llvm.x86.sse2.psubus.w";<br>
} else if (util_cpu_caps.has_altivec) {<br>
if (type.width == 8)<br>
intrinsic = type.sign ? "llvm.ppc.altivec.vsubsbs" : "llvm.ppc.altivec.vsububs";<br>
@@ -817,11 +811,9 @@ lp_build_sub(struct lp_build_context *bld,<br>
if (type.width * type.length == 256) {<br>
if (util_cpu_caps.has_avx2) {<br>
if (type.width == 8)<br>
- intrinsic = type.sign ? "llvm.x86.avx2.psubs.b" :<br>
- LLVM_VERSION_MAJOR < 8 ? "llvm.x86.avx2.psubus.b" : NULL;<br>
+ intrinsic = type.sign ? "llvm.x86.avx2.psubs.b" : "llvm.x86.avx2.psubus.b";<br>
if (type.width == 16)<br>
- intrinsic = type.sign ? "llvm.x86.avx2.psubs.w" :<br>
- LLVM_VERSION_MAJOR < 8 ? "llvm.x86.avx2.psubus.w" : NULL;<br>
+ intrinsic = type.sign ? "llvm.x86.avx2.psubs.w" : "llvm.x86.avx2.psubus.w";<br>
}<br>
}<br>
}<br>
-- <br>
2.17.1<br>
<br>
</div>
</span></font></div>
</div>
</body>
</html>