[llvm-bugs] [Bug 51988] New: AVX-512F intrinsics do not respect masking: _mm512_mask_mul_pd (-ftrapping-math)
via llvm-bugs
llvm-bugs at lists.llvm.org
Mon Sep 27 13:31:57 PDT 2021
https://bugs.llvm.org/show_bug.cgi?id=51988
Bug ID: 51988
Summary: AVX-512F intrinsics do not respect masking:
_mm512_mask_mul_pd (-ftrapping-math)
Product: clang
Version: trunk
Hardware: PC
OS: All
Status: NEW
Severity: enhancement
Priority: P
Component: -New Bugs
Assignee: unassignedclangbugs at nondot.org
Reporter: florian_hahn at apple.com
CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org,
neeilans at live.com, richard-llvm at metafoo.co.uk
AVX-512F has intrinsics that are suppose to mask off lanes for an operation.
The masking is required to avoid out-of-bounds as well as other failures like
divide-by-zero or invalid FP exceptions.
Clang generates invalid code for these masked intrinsics. It generates an
unmasked multiply followed by a select in IR (also see
https://godbolt.org/z/dsdG6vnM7):
#include <immintrin.h>
__m512d test(__mmask8 mask, __m512d a, __m512d b, __m512d c){
return _mm512_mask_mul_pd(a, mask, b, c);
}
generates the IR below with `clang -emit-llvm -g0 -O3 -ftrapping-math -mavx2
-mavx512f`
define dso_local <8 x double> @test(i8 zeroext %0, <8 x double> %1, <8 x
double> %2, <8 x double> %3) local_unnamed_addr #0 {
%5 = tail call <8 x double> @llvm.experimental.constrained.fmul.v8f64(<8 x
double> %2, <8 x double> %3, metadata !"round.tonearest", metadata
!"fpexcept.strict") #2
%6 = bitcast i8 %0 to <8 x i1>
%7 = select <8 x i1> %6, <8 x double> %5, <8 x double> %1
ret <8 x double> %7
}
declare <8 x double> @llvm.experimental.constrained.fmul.v8f64(<8 x double>, <8
x double>, metadata, metadata) #1
define dso_local <8 x double> @test(i8 zeroext %0, <8 x double> %1, <8 x
double> %2, <8 x double> %3) local_unnamed_addr #0 {
%5 = tail call <8 x double> @llvm.experimental.constrained.fmul.v8f64(<8 x
double> %2, <8 x double> %3, metadata !"round.tonearest", metadata
!"fpexcept.strict") #2
%6 = bitcast i8 %0 to <8 x i1>
%7 = select <8 x i1> %6, <8 x double> %5, <8 x double> %1
ret <8 x double> %7
}
declare <8 x double> @llvm.experimental.constrained.fmul.v8f64(<8 x double>, <8
x double>, metadata, metadata) #1
attributes #0 = { mustprogress nofree nosync nounwind strictfp uwtable
willreturn "frame-pointer"="none" "min-legal-vector-width"="512"
"stack-protector-buffer-size"="8" "strictfp" "target-cpu"="x86-64"
"target-features"="+avx,+avx2,+avx512f,+crc32,+cx8,+f16c,+fma,+fxsr,+mmx,+popcnt,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+x87,+xsave"
"tune-cpu"="generic" }
attributes #1 = { inaccessiblememonly mustprogress nofree nosync nounwind
willreturn }
attributes #2 = { nounwind strictfp }
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210927/cf77d2b9/attachment.html>
More information about the llvm-bugs
mailing list