<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - AVX-512F intrinsics do not respect masking: _mm512_mask_mul_pd (-ftrapping-math)"
href="https://bugs.llvm.org/show_bug.cgi?id=51988">51988</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>AVX-512F intrinsics do not respect masking: _mm512_mask_mul_pd (-ftrapping-math)
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>All
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>-New Bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>florian_hahn@apple.com
</td>
</tr>
<tr>
<th>CC</th>
<td>htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org, neeilans@live.com, richard-llvm@metafoo.co.uk
</td>
</tr></table>
<p>
<div>
<pre>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
<a href="https://godbolt.org/z/dsdG6vnM7">https://godbolt.org/z/dsdG6vnM7</a>):
#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 }</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>