Commit b7e4260
[clang] Restrict the use of scalar types in vector builtins (llvm#119423)
This commit restricts the use of scalar types in vector math builtins,
particularly the `__builtin_elementwise_*` builtins.
Previously, small scalar integer types would be promoted to `int`, as
per the usual conversions. This would silently do the wrong thing for
certain operations, such as `add_sat`, `popcount`, `bitreverse`, and
others. Similarly, since unsigned integer types were promoted to `int`,
something like `add_sat(unsigned char, unsigned char)` would perform a
*signed* operation.
With this patch, promotable scalar integer types are not promoted to
int, and are kept intact. If any of the types differ in the binary and
ternary builtins, an error is issued. Similarly an error is issued if
builtins are supplied integer types of different signs. Mixing enums of
different types in binary/ternary builtins now consistently raises an
error in all language modes.
This brings the behaviour surrounding scalar types more in line with
that of vector types. No change is made to vector types, which are both
not promoted and whose element types must match.
Fixes llvm#84047.
RFC:
https://discourse.llvm.org/t/rfc-change-behaviour-of-elementwise-builtins-on-scalar-integer-types/837251 parent b0d6e64 commit b7e4260
File tree
10 files changed
+322
-141
lines changed- clang
- docs
- include/clang/Sema
- lib/Sema
- test
- CodeGenHLSL/builtins
- CodeGen
- SemaHLSL/BuiltIns
- Sema
10 files changed
+322
-141
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
647 | 647 | | |
648 | 648 | | |
649 | 649 | | |
650 | | - | |
651 | | - | |
652 | | - | |
653 | | - | |
654 | | - | |
655 | | - | |
656 | | - | |
657 | | - | |
658 | | - | |
659 | | - | |
660 | | - | |
661 | | - | |
662 | | - | |
663 | | - | |
664 | | - | |
665 | | - | |
666 | | - | |
667 | | - | |
668 | | - | |
669 | | - | |
670 | | - | |
671 | | - | |
672 | | - | |
673 | | - | |
674 | | - | |
675 | | - | |
676 | | - | |
677 | | - | |
678 | | - | |
679 | | - | |
680 | | - | |
681 | | - | |
682 | | - | |
683 | | - | |
684 | | - | |
685 | | - | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
686 | 679 | | |
687 | 680 | | |
688 | 681 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2551 | 2551 | | |
2552 | 2552 | | |
2553 | 2553 | | |
2554 | | - | |
| 2554 | + | |
| 2555 | + | |
| 2556 | + | |
2555 | 2557 | | |
2556 | 2558 | | |
2557 | 2559 | | |
| |||
2762 | 2764 | | |
2763 | 2765 | | |
2764 | 2766 | | |
2765 | | - | |
2766 | | - | |
| 2767 | + | |
| 2768 | + | |
| 2769 | + | |
2767 | 2770 | | |
2768 | 2771 | | |
2769 | 2772 | | |
| |||
7751 | 7754 | | |
7752 | 7755 | | |
7753 | 7756 | | |
7754 | | - | |
7755 | | - | |
| 7757 | + | |
| 7758 | + | |
| 7759 | + | |
7756 | 7760 | | |
7757 | 7761 | | |
| 7762 | + | |
| 7763 | + | |
| 7764 | + | |
| 7765 | + | |
7758 | 7766 | | |
7759 | 7767 | | |
7760 | 7768 | | |
| |||
7829 | 7837 | | |
7830 | 7838 | | |
7831 | 7839 | | |
| 7840 | + | |
| 7841 | + | |
| 7842 | + | |
| 7843 | + | |
| 7844 | + | |
7832 | 7845 | | |
7833 | 7846 | | |
7834 | 7847 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2711 | 2711 | | |
2712 | 2712 | | |
2713 | 2713 | | |
2714 | | - | |
| 2714 | + | |
2715 | 2715 | | |
2716 | 2716 | | |
2717 | 2717 | | |
| |||
2727 | 2727 | | |
2728 | 2728 | | |
2729 | 2729 | | |
2730 | | - | |
| 2730 | + | |
2731 | 2731 | | |
2732 | 2732 | | |
2733 | 2733 | | |
| |||
2747 | 2747 | | |
2748 | 2748 | | |
2749 | 2749 | | |
2750 | | - | |
| 2750 | + | |
2751 | 2751 | | |
2752 | 2752 | | |
2753 | 2753 | | |
| |||
14899 | 14899 | | |
14900 | 14900 | | |
14901 | 14901 | | |
| 14902 | + | |
| 14903 | + | |
| 14904 | + | |
| 14905 | + | |
| 14906 | + | |
| 14907 | + | |
| 14908 | + | |
| 14909 | + | |
| 14910 | + | |
| 14911 | + | |
| 14912 | + | |
| 14913 | + | |
14902 | 14914 | | |
14903 | 14915 | | |
14904 | 14916 | | |
14905 | 14917 | | |
14906 | | - | |
| 14918 | + | |
14907 | 14919 | | |
14908 | 14920 | | |
14909 | 14921 | | |
| |||
14917 | 14929 | | |
14918 | 14930 | | |
14919 | 14931 | | |
14920 | | - | |
14921 | | - | |
14922 | | - | |
14923 | | - | |
14924 | | - | |
14925 | | - | |
| 14932 | + | |
| 14933 | + | |
| 14934 | + | |
| 14935 | + | |
| 14936 | + | |
| 14937 | + | |
14926 | 14938 | | |
14927 | 14939 | | |
14928 | 14940 | | |
14929 | | - | |
14930 | | - | |
| 14941 | + | |
| 14942 | + | |
14931 | 14943 | | |
14932 | 14944 | | |
14933 | | - | |
| 14945 | + | |
14934 | 14946 | | |
14935 | 14947 | | |
14936 | | - | |
| 14948 | + | |
14937 | 14949 | | |
14938 | 14950 | | |
14939 | 14951 | | |
14940 | 14952 | | |
14941 | | - | |
| 14953 | + | |
| 14954 | + | |
| 14955 | + | |
| 14956 | + | |
| 14957 | + | |
| 14958 | + | |
| 14959 | + | |
| 14960 | + | |
| 14961 | + | |
| 14962 | + | |
| 14963 | + | |
| 14964 | + | |
| 14965 | + | |
| 14966 | + | |
| 14967 | + | |
14942 | 14968 | | |
14943 | | - | |
| 14969 | + | |
14944 | 14970 | | |
14945 | | - | |
14946 | | - | |
14947 | | - | |
14948 | | - | |
14949 | | - | |
14950 | | - | |
14951 | | - | |
| 14971 | + | |
| 14972 | + | |
| 14973 | + | |
14952 | 14974 | | |
14953 | | - | |
14954 | | - | |
| 14975 | + | |
| 14976 | + | |
| 14977 | + | |
| 14978 | + | |
| 14979 | + | |
| 14980 | + | |
| 14981 | + | |
| 14982 | + | |
14955 | 14983 | | |
14956 | | - | |
14957 | | - | |
14958 | | - | |
14959 | | - | |
| 14984 | + | |
| 14985 | + | |
| 14986 | + | |
14960 | 14987 | | |
14961 | | - | |
14962 | | - | |
| 14988 | + | |
| 14989 | + | |
| 14990 | + | |
| 14991 | + | |
14963 | 14992 | | |
14964 | | - | |
14965 | | - | |
14966 | | - | |
| 14993 | + | |
| 14994 | + | |
| 14995 | + | |
| 14996 | + | |
| 14997 | + | |
| 14998 | + | |
| 14999 | + | |
| 15000 | + | |
| 15001 | + | |
| 15002 | + | |
| 15003 | + | |
14967 | 15004 | | |
14968 | 15005 | | |
14969 | 15006 | | |
14970 | 15007 | | |
14971 | 15008 | | |
14972 | 15009 | | |
14973 | 15010 | | |
| 15011 | + | |
| 15012 | + | |
| 15013 | + | |
| 15014 | + | |
| 15015 | + | |
| 15016 | + | |
| 15017 | + | |
14974 | 15018 | | |
14975 | 15019 | | |
14976 | | - | |
| 15020 | + | |
| 15021 | + | |
14977 | 15022 | | |
14978 | 15023 | | |
14979 | 15024 | | |
| |||
15010 | 15055 | | |
15011 | 15056 | | |
15012 | 15057 | | |
15013 | | - | |
| 15058 | + | |
15014 | 15059 | | |
15015 | 15060 | | |
15016 | 15061 | | |
| |||
0 commit comments