[Mesa-stable] [PATCH] gallivm: don't use integer min/max sse intrinsics with llvm >= 3.9
Roland Scheidegger
sroland at vmware.com
Mon Jun 20 15:13:13 UTC 2016
Am 20.06.2016 um 11:21 schrieb Jose Fonseca:
> On 19/06/16 03:06, sroland at vmware.com wrote:
>> From: Roland Scheidegger <sroland at vmware.com>
>>
>> Apparently, these are deprecated. There's some AutoUpgrade feature which
>> is supposed to promote these to cmp/select, which apparently doesn't work
>> with jit code. It is possible it's not actually even meant to work (see
>> the bug filed against llvm which couldn't provide an answer neither)
>> but in any case this is meant to be only temporary unless the intrinsics
>> are really illegal. So, just use the fallback code (which should be
>> cmp/select,
>> we're actually doing cmp/sext/trunc/select, but in any case llvm 3.9
>> manages
>> to optimize this back to pmin/pmax in the end).
>>
>> This addresses https://llvm.org/bugs/show_bug.cgi?id=28176
>>
>> CC: <mesa-stable at lists.freedesktop.org>
>> ---
>> src/gallium/auxiliary/gallivm/lp_bld_arit.c | 6 ++++--
>> 1 file changed, 4 insertions(+), 2 deletions(-)
>>
>> diff --git a/src/gallium/auxiliary/gallivm/lp_bld_arit.c
>> b/src/gallium/auxiliary/gallivm/lp_bld_arit.c
>> index 114c766..c4e35a2 100644
>> --- a/src/gallium/auxiliary/gallivm/lp_bld_arit.c
>> +++ b/src/gallium/auxiliary/gallivm/lp_bld_arit.c
>> @@ -142,7 +142,8 @@ lp_build_min_simple(struct lp_build_context *bld,
>> intrinsic = "llvm.ppc.altivec.vminfp";
>> intr_size = 128;
>> }
>> - } else if (util_cpu_caps.has_sse2 && type.length >= 2) {
>> + } else if (HAVE_LLVM < 0x0309 &&
>> + util_cpu_caps.has_sse2 && type.length >= 2) {
>> intr_size = 128;
>> if ((type.width == 8 || type.width == 16) &&
>> (type.width * type.length <= 64) &&
>> @@ -345,7 +346,8 @@ lp_build_max_simple(struct lp_build_context *bld,
>> intrinsic = "llvm.ppc.altivec.vmaxfp";
>> intr_size = 128;
>> }
>> - } else if (util_cpu_caps.has_sse2 && type.length >= 2) {
>> + } else if (HAVE_LLVM < 0x0309 &&
>> + util_cpu_caps.has_sse2 && type.length >= 2) {
>> intr_size = 128;
>> if ((type.width == 8 || type.width == 16) &&
>> (type.width * type.length <= 64) &&
>>
>
> Thanks for looking into this.
>
> Reviewed-by: Jose Fonseca <jfonseca at vmware.com>
>
> There are other intrinsics in lp_build_min_simple , and from the sound
> of it it sounds they'll all go away.
>
Yes, this only won't use the sse integer ones. The altivec integer ones
are still used - as are the float ones (sse or altivec). For the latter
though it's a bit more complex due to NaN behavior. There's now a llvm
intrinsic for fmin/fmax (llvm.minimum/llvm.maximum) which returns the
non-NaN number if one is NaN - this corresponds to the altivec intrinsic
but not the sse one. In some cases llvm will not be able to generate the
most efficient code if the sse intrinsic is going away, albeit in most
cases it should work fine.
I suppose though the altivec ones could go away, they don't provide
anyhting over cmp/select (for ints) or the llvm minimum/maximum
intrinsics (for floats) but I don't really touch the altivec code unless
necessary (I don't know if cmp/select would be fused back to min/max for
ints).
Roland
More information about the mesa-stable
mailing list