[llvm-bugs] [Bug 43045] New: Binary operators should consistently warn/error with mismatching vector types
via llvm-bugs
llvm-bugs at lists.llvm.org
Mon Aug 19 06:21:22 PDT 2019
https://bugs.llvm.org/show_bug.cgi?id=43045
Bug ID: 43045
Summary: Binary operators should consistently warn/error with
mismatching vector types
Product: clang
Version: unspecified
Hardware: PC
OS: Windows NT
Status: NEW
Severity: enhancement
Priority: P
Component: Frontend
Assignee: unassignedclangbugs at nondot.org
Reporter: llvm-dev at redking.me.uk
CC: greg.bedwell at sony.com, llvm-bugs at lists.llvm.org,
neeilans at live.com, richard-llvm at metafoo.co.uk,
warren_ristow at playstation.sony.com
https://godbolt.org/z/T4BOcu
#include <x86intrin.h>
__v16qi add(__v4si x, __v4sf y) {
return x + y;
}
__v16qi mul(__v4si x, __v8hi y) {
return x * y;
}
We can have different source/destination types for vectors and at first glance
have no idea what code will be generated, and get nothing to indicate what's
going on (even with -Weverything enabled).
They are silently bitcasting to/from the first source type:
define <16 x i8> @add(<4 x i32> %0, <4 x float> %1) {
%3 = bitcast <4 x float> %1 to <4 x i32>
%4 = add <4 x i32> %3, %0
%5 = bitcast <4 x i32> %4 to <16 x i8>
ret <16 x i8> %5
}
We should at least get a warning that this is happening for both the implicit
bitcasting of the second source and to the destination types, this should work
in parallel to the -flax-vector-conversions switch.
Interestingly, the shift operators are a lot stricter and will error out on
type mismatches with different vector element count/size:
__v16qi shl(__v4si x, __v4sf y) {
return x << y;
}
__v16qi shl(__v4si x, __v4di y) {
return x << y;
}
--
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/20190819/c5fe5069/attachment.html>
More information about the llvm-bugs
mailing list