Commit c33d51b
authored
Rollup merge of #147355 - sayantn:masked-loads, r=RalfJung,bjorn3
Add alignment parameter to `simd_masked_{load,store}`
This PR adds an alignment parameter in `simd_masked_load` and `simd_masked_store`, in the form of a const-generic enum `core::intrinsics::simd::SimdAlign`. This represents the alignment of the `ptr` argument in these intrinsics as follows
- `SimdAlign::Unaligned` - `ptr` is unaligned/1-byte aligned
- `SimdAlign::Element` - `ptr` is aligned to the element type of the SIMD vector (default behavior in the old signature)
- `SimdAlign::Vector` - `ptr` is aligned to the SIMD vector type
The main motive for this is stdarch - most vector loads are either fully aligned (to the vector size) or unaligned (byte-aligned), so the previous signature doesn't cut it.
Now, stdarch will mostly use `SimdAlign::Unaligned` and `SimdAlign::Vector`, whereas portable-simd will use `SimdAlign::Element`.
- [x] `cg_llvm`
- [x] `cg_clif`
- [x] `miri`/`const_eval`
## Alternatives
Using a const-generic/"const" `u32` parameter as alignment (and we error during codegen if this argument is not a power of two). This, although more flexible than this, has a few drawbacks
- If we use an const-generic argument, then portable-simd somehow needs to pass `align_of::<T>()` as the alignment, which isn't possible without GCE
- "const" function parameters are just an ugly hack, and a pain to deal with in non-LLVM backends
We can remedy the problem with the const-generic `u32` parameter by adding a special rule for the element alignment case (e.g. `0` can mean "use the alignment of the element type), but I feel like this is not as expressive as the enum approach, although I am open to suggestions
cc `@workingjubilee` `@RalfJung` `@BoxyUwU`File tree
27 files changed
+677
-115
lines changed- compiler
- rustc_codegen_cranelift/src/intrinsics
- rustc_codegen_llvm/src
- rustc_const_eval/src/interpret/intrinsics
- rustc_hir_analysis/src/check
- rustc_middle/src/ty
- consts
- library
- core/src/intrinsics
- portable-simd/crates/core_simd/src
- src/tools/miri/tests
- fail/intrinsics
- pass/intrinsics
- tests
- assembly-llvm
- auxiliary
- codegen-llvm/simd-intrinsic
- ui/simd
27 files changed
+677
-115
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
| |||
960 | 961 | | |
961 | 962 | | |
962 | 963 | | |
| 964 | + | |
| 965 | + | |
| 966 | + | |
| 967 | + | |
| 968 | + | |
| 969 | + | |
| 970 | + | |
| 971 | + | |
| 972 | + | |
963 | 973 | | |
964 | 974 | | |
965 | 975 | | |
| |||
972 | 982 | | |
973 | 983 | | |
974 | 984 | | |
975 | | - | |
| 985 | + | |
976 | 986 | | |
977 | 987 | | |
978 | 988 | | |
| |||
996 | 1006 | | |
997 | 1007 | | |
998 | 1008 | | |
| 1009 | + | |
| 1010 | + | |
| 1011 | + | |
| 1012 | + | |
| 1013 | + | |
| 1014 | + | |
| 1015 | + | |
| 1016 | + | |
| 1017 | + | |
999 | 1018 | | |
1000 | 1019 | | |
1001 | 1020 | | |
| |||
1011 | 1030 | | |
1012 | 1031 | | |
1013 | 1032 | | |
1014 | | - | |
| 1033 | + | |
1015 | 1034 | | |
1016 | 1035 | | |
1017 | 1036 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
| 16 | + | |
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| |||
1840 | 1840 | | |
1841 | 1841 | | |
1842 | 1842 | | |
| 1843 | + | |
| 1844 | + | |
| 1845 | + | |
| 1846 | + | |
| 1847 | + | |
| 1848 | + | |
| 1849 | + | |
| 1850 | + | |
| 1851 | + | |
| 1852 | + | |
| 1853 | + | |
| 1854 | + | |
| 1855 | + | |
1843 | 1856 | | |
1844 | | - | |
| 1857 | + | |
1845 | 1858 | | |
1846 | 1859 | | |
1847 | 1860 | | |
1848 | 1861 | | |
1849 | 1862 | | |
1850 | 1863 | | |
1851 | 1864 | | |
| 1865 | + | |
| 1866 | + | |
| 1867 | + | |
| 1868 | + | |
1852 | 1869 | | |
1853 | 1870 | | |
1854 | 1871 | | |
| |||
1905 | 1922 | | |
1906 | 1923 | | |
1907 | 1924 | | |
1908 | | - | |
| 1925 | + | |
1909 | 1926 | | |
1910 | 1927 | | |
1911 | 1928 | | |
| |||
1932 | 1949 | | |
1933 | 1950 | | |
1934 | 1951 | | |
1935 | | - | |
| 1952 | + | |
1936 | 1953 | | |
1937 | 1954 | | |
1938 | 1955 | | |
1939 | 1956 | | |
1940 | 1957 | | |
1941 | 1958 | | |
1942 | 1959 | | |
| 1960 | + | |
| 1961 | + | |
| 1962 | + | |
| 1963 | + | |
1943 | 1964 | | |
1944 | 1965 | | |
1945 | 1966 | | |
| |||
1990 | 2011 | | |
1991 | 2012 | | |
1992 | 2013 | | |
1993 | | - | |
| 2014 | + | |
1994 | 2015 | | |
1995 | 2016 | | |
1996 | 2017 | | |
| |||
Lines changed: 50 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
6 | | - | |
| 5 | + | |
| 6 | + | |
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
| 13 | + | |
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| |||
644 | 644 | | |
645 | 645 | | |
646 | 646 | | |
| 647 | + | |
| 648 | + | |
647 | 649 | | |
648 | 650 | | |
649 | 651 | | |
| |||
652 | 654 | | |
653 | 655 | | |
654 | 656 | | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
655 | 665 | | |
656 | 666 | | |
657 | 667 | | |
| |||
660 | 670 | | |
661 | 671 | | |
662 | 672 | | |
663 | | - | |
| 673 | + | |
| 674 | + | |
664 | 675 | | |
665 | 676 | | |
666 | 677 | | |
| |||
675 | 686 | | |
676 | 687 | | |
677 | 688 | | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
678 | 697 | | |
679 | 698 | | |
680 | 699 | | |
681 | 700 | | |
682 | 701 | | |
683 | 702 | | |
684 | 703 | | |
685 | | - | |
| 704 | + | |
| 705 | + | |
686 | 706 | | |
687 | 707 | | |
688 | 708 | | |
| |||
753 | 773 | | |
754 | 774 | | |
755 | 775 | | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
756 | 800 | | |
757 | 801 | | |
758 | 802 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
695 | 695 | | |
696 | 696 | | |
697 | 697 | | |
698 | | - | |
699 | | - | |
| 698 | + | |
| 699 | + | |
700 | 700 | | |
701 | 701 | | |
702 | 702 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
42 | 51 | | |
43 | 52 | | |
44 | 53 | | |
| |||
350 | 359 | | |
351 | 360 | | |
352 | 361 | | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
353 | 377 | | |
354 | 378 | | |
355 | 379 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
74 | 74 | | |
75 | 75 | | |
76 | 76 | | |
77 | | - | |
| 77 | + | |
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
| 6 | + | |
5 | 7 | | |
6 | 8 | | |
7 | 9 | | |
| |||
377 | 379 | | |
378 | 380 | | |
379 | 381 | | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
380 | 395 | | |
381 | 396 | | |
382 | 397 | | |
| |||
392 | 407 | | |
393 | 408 | | |
394 | 409 | | |
395 | | - | |
396 | | - | |
| 410 | + | |
397 | 411 | | |
398 | 412 | | |
399 | 413 | | |
400 | 414 | | |
401 | | - | |
| 415 | + | |
402 | 416 | | |
403 | 417 | | |
404 | 418 | | |
| |||
414 | 428 | | |
415 | 429 | | |
416 | 430 | | |
417 | | - | |
418 | | - | |
| 431 | + | |
419 | 432 | | |
420 | 433 | | |
421 | 434 | | |
422 | 435 | | |
423 | | - | |
| 436 | + | |
424 | 437 | | |
425 | 438 | | |
426 | 439 | | |
| |||
0 commit comments