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: unassignedclangb...@nondot.org
          Reporter: llvm-...@redking.me.uk
                CC: greg.bedw...@sony.com, llvm-bugs@lists.llvm.org,
                    neeil...@live.com, richard-l...@metafoo.co.uk,
                    warren_ris...@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.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to