1. Apr 07, 2024
  2. Apr 06, 2024
    • Nikolas Klauser's avatar
      [libc++] Optimize ranges::minmax (#87335) · 935e6991
      Nikolas Klauser authored
      This allows Clang to vectorize the loop.
      ```
      ---------------------------------------------------------------------
      Benchmark                                         old             new
      ---------------------------------------------------------------------
      BM_std_minmax<char>/1                        0.659 ns         1.41 ns
      BM_std_minmax<char>/2                         1.08 ns         2.16 ns
      BM_std_minmax<char>/3                         2.16 ns         2.96 ns
      BM_std_minmax<char>/4                         2.82 ns         3.81 ns
      BM_std_minmax<char>/5                         3.43 ns         4.69 ns
      BM_std_minmax<char>/6                         4.08 ns         5.63 ns
      BM_std_minmax<char>/7                         4.75 ns         6.51 ns
      BM_std_minmax<char>/8                         5.42 ns         7.41 ns
      BM_std_minmax<char>/9                         6.05 ns         8.34 ns
      BM_std_minmax<char>/10                        6.68 ns         9.29 ns
      BM_std_minmax<char>/11                        7.47 ns         10.6 ns
      BM_std_minmax<char>/12                        7.95 ns         11.4 ns
      BM_std_minmax<char>/13                        8.64 ns         12.4 ns
      BM_std_minmax<char>/14                        9.35 ns         13.4 ns
      BM_std_minmax<char>/15                        10.1 ns         14.4 ns
      BM_std_minmax<char>/16                        10.6 ns         2.25 ns
      BM_std_minmax<char>/17                        11.3 ns         2.82 ns
      BM_std_minmax<char>/18                        11.8 ns         3.71 ns
      BM_std_minmax<char>/19                        12.6 ns         4.52 ns
      BM_std_minmax<char>/20                        13.2 ns         5.47 ns
      BM_std_minmax<char>/21                        14.1 ns         6.67 ns
      BM_std_minmax<char>/22                        14.5 ns         7.78 ns
      BM_std_minmax<char>/23                        15.1 ns         8.67 ns
      BM_std_minmax<char>/24                        15.7 ns         9.68 ns
      BM_std_minmax<char>/25                        16.4 ns         10.7 ns
      BM_std_minmax<char>/26                        17.1 ns         11.7 ns
      BM_std_minmax<char>/27                        17.8 ns         12.8 ns
      BM_std_minmax<char>/28                        18.4 ns         14.1 ns
      BM_std_minmax<char>/29                        19.0 ns         15.0 ns
      BM_std_minmax<char>/30                        19.6 ns         16.0 ns
      BM_std_minmax<char>/31                        20.2 ns         17.0 ns
      BM_std_minmax<char>/32                        20.8 ns         2.46 ns
      BM_std_minmax<char>/64                        41.5 ns         2.97 ns
      BM_std_minmax<char>/512                        340 ns         6.05 ns
      BM_std_minmax<char>/1024                       667 ns         8.83 ns
      BM_std_minmax<char>/4000                      2571 ns         28.6 ns
      BM_std_minmax<char>/4096                      2632 ns         25.8 ns
      BM_std_minmax<char>/5500                      3554 ns         51.1 ns
      BM_std_minmax<char>/64000                    41175 ns          480 ns
      BM_std_minmax<char>/65536                    42039 ns          490 ns
      BM_std_minmax<char>/70000                    44931 ns          528 ns
      BM_std_minmax<short>/1                       0.708 ns         1.20 ns
      BM_std_minmax<short>/2                        1.18 ns         1.78 ns
      BM_std_minmax<short>/3                        1.98 ns         2.42 ns
      BM_std_minmax<short>/4                        2.47 ns         3.05 ns
      BM_std_minmax<short>/5                        3.09 ns         3.72 ns
      BM_std_minmax<short>/6                        3.49 ns         4.37 ns
      BM_std_minmax<short>/7                        4.24 ns         5.03 ns
      BM_std_minmax<short>/8                        4.65 ns         2.12 ns
      BM_std_minmax<short>/9                        5.34 ns         2.51 ns
      BM_std_minmax<short>/10                       5.82 ns         3.18 ns
      BM_std_minmax<short>/11                       6.36 ns         3.97 ns
      BM_std_minmax<short>/12                       6.73 ns         4.68 ns
      BM_std_minmax<short>/13                       7.59 ns         5.49 ns
      BM_std_minmax<short>/14                       7.77 ns         6.45 ns
      BM_std_minmax<short>/15                       8.54 ns         7.55 ns
      BM_std_minmax<short>/16                       8.74 ns         2.38 ns
      BM_std_minmax<short>/17                       9.59 ns         2.76 ns
      BM_std_minmax<short>/18                       9.88 ns         3.37 ns
      BM_std_minmax<short>/19                       10.7 ns         4.17 ns
      BM_std_minmax<short>/20                       10.9 ns         4.88 ns
      BM_std_minmax<short>/21                       12.1 ns         5.70 ns
      BM_std_minmax<short>/22                       12.6 ns         6.64 ns
      BM_std_minmax<short>/23                       13.5 ns         7.72 ns
      BM_std_minmax<short>/24                       13.2 ns         2.87 ns
      BM_std_minmax<short>/25                       14.2 ns         3.10 ns
      BM_std_minmax<short>/26                       14.2 ns         3.59 ns
      BM_std_minmax<short>/27                       15.4 ns         4.35 ns
      BM_std_minmax<short>/28                       15.3 ns         5.10 ns
      BM_std_minmax<short>/29                       16.2 ns         5.87 ns
      BM_std_minmax<short>/30                       16.2 ns         6.88 ns
      BM_std_minmax<short>/31                       17.0 ns         7.78 ns
      BM_std_minmax<short>/32                       17.2 ns         3.45 ns
      BM_std_minmax<short>/64                       34.1 ns         3.35 ns
      BM_std_minmax<short>/512                       279 ns         8.37 ns
      BM_std_minmax<short>/1024                      549 ns         14.2 ns
      BM_std_minmax<short>/4000                     2111 ns         50.1 ns
      BM_std_minmax<short>/4096                     2167 ns         47.9 ns
      BM_std_minmax<short>/5500                     2895 ns         69.7 ns
      BM_std_minmax<short>/64000                   33454 ns          953 ns
      BM_std_minmax<short>/65536                   34474 ns          970 ns
      BM_std_minmax<short>/70000                   36691 ns         1037 ns
      BM_std_minmax<int>/1                         0.664 ns         1.17 ns
      BM_std_minmax<int>/2                          1.11 ns         1.69 ns
      BM_std_minmax<int>/3                          2.36 ns         2.29 ns
      BM_std_minmax<int>/4                          2.53 ns         2.91 ns
      BM_std_minmax<int>/5                          3.23 ns         3.56 ns
      BM_std_minmax<int>/6                          3.56 ns         4.23 ns
      BM_std_minmax<int>/7                          4.28 ns         4.91 ns
      BM_std_minmax<int>/8                          4.60 ns         5.60 ns
      BM_std_minmax<int>/9                          5.38 ns         6.31 ns
      BM_std_minmax<int>/10                         5.69 ns         7.03 ns
      BM_std_minmax<int>/11                         6.41 ns         7.70 ns
      BM_std_minmax<int>/12                         6.73 ns         8.39 ns
      BM_std_minmax<int>/13                         7.38 ns         9.07 ns
      BM_std_minmax<int>/14                         7.74 ns         9.79 ns
      BM_std_minmax<int>/15                         8.53 ns         10.5 ns
      BM_std_minmax<int>/16                         8.79 ns         11.2 ns
      BM_std_minmax<int>/17                         9.63 ns         12.0 ns
      BM_std_minmax<int>/18                         9.84 ns         12.7 ns
      BM_std_minmax<int>/19                         10.6 ns         13.5 ns
      BM_std_minmax<int>/20                         11.0 ns         14.3 ns
      BM_std_minmax<int>/21                         11.7 ns         15.0 ns
      BM_std_minmax<int>/22                         12.0 ns         15.7 ns
      BM_std_minmax<int>/23                         13.1 ns         16.5 ns
      BM_std_minmax<int>/24                         13.0 ns         17.3 ns
      BM_std_minmax<int>/25                         13.7 ns         17.9 ns
      BM_std_minmax<int>/26                         14.0 ns         18.6 ns
      BM_std_minmax<int>/27                         14.8 ns         19.4 ns
      BM_std_minmax<int>/28                         15.1 ns         20.3 ns
      BM_std_minmax<int>/29                         15.8 ns         20.9 ns
      BM_std_minmax<int>/30                         16.1 ns         21.7 ns
      BM_std_minmax<int>/31                         16.9 ns         22.5 ns
      BM_std_minmax<int>/32                         17.2 ns         3.40 ns
      BM_std_minmax<int>/64                         33.9 ns         4.04 ns
      BM_std_minmax<int>/512                         275 ns         14.6 ns
      BM_std_minmax<int>/1024                        541 ns         27.5 ns
      BM_std_minmax<int>/4000                       2093 ns         96.3 ns
      BM_std_minmax<int>/4096                       2146 ns         98.3 ns
      BM_std_minmax<int>/5500                       2866 ns          157 ns
      BM_std_minmax<int>/64000                     33619 ns         1954 ns
      BM_std_minmax<int>/65536                     34252 ns         2009 ns
      BM_std_minmax<int>/70000                     36618 ns         2125 ns
      BM_std_minmax<long long>/1                   0.709 ns         1.19 ns
      BM_std_minmax<long long>/2                    1.01 ns         1.65 ns
      BM_std_minmax<long long>/3                    2.14 ns         2.21 ns
      BM_std_minmax<long long>/4                    2.45 ns         2.83 ns
      BM_std_minmax<long long>/5                    3.09 ns         3.47 ns
      BM_std_minmax<long long>/6                    3.44 ns         4.11 ns
      BM_std_minmax<long long>/7                    4.16 ns         4.79 ns
      BM_std_minmax<long long>/8                    4.54 ns         5.47 ns
      BM_std_minmax<long long>/9                    5.37 ns         6.20 ns
      BM_std_minmax<long long>/10                   5.71 ns         6.93 ns
      BM_std_minmax<long long>/11                   6.00 ns         7.60 ns
      BM_std_minmax<long long>/12                   6.43 ns         8.27 ns
      BM_std_minmax<long long>/13                   7.01 ns         8.94 ns
      BM_std_minmax<long long>/14                   7.45 ns         9.65 ns
      BM_std_minmax<long long>/15                   8.16 ns         10.4 ns
      BM_std_minmax<long long>/16                   8.46 ns         5.22 ns
      BM_std_minmax<long long>/17                   9.16 ns         5.22 ns
      BM_std_minmax<long long>/18                   9.53 ns         5.52 ns
      BM_std_minmax<long long>/19                   10.2 ns         6.02 ns
      BM_std_minmax<long long>/20                   10.5 ns         6.89 ns
      BM_std_minmax<long long>/21                   11.3 ns         7.83 ns
      BM_std_minmax<long long>/22                   11.6 ns         8.59 ns
      BM_std_minmax<long long>/23                   12.3 ns         9.91 ns
      BM_std_minmax<long long>/24                   12.6 ns         10.1 ns
      BM_std_minmax<long long>/25                   13.2 ns         12.0 ns
      BM_std_minmax<long long>/26                   13.6 ns         13.5 ns
      BM_std_minmax<long long>/27                   14.2 ns         14.8 ns
      BM_std_minmax<long long>/28                   14.7 ns         15.9 ns
      BM_std_minmax<long long>/29                   15.3 ns         16.6 ns
      BM_std_minmax<long long>/30                   15.8 ns         17.3 ns
      BM_std_minmax<long long>/31                   16.3 ns         18.2 ns
      BM_std_minmax<long long>/32                   16.7 ns         7.18 ns
      BM_std_minmax<long long>/64                   33.1 ns         11.5 ns
      BM_std_minmax<long long>/512                   268 ns         71.0 ns
      BM_std_minmax<long long>/1024                  532 ns          138 ns
      BM_std_minmax<long long>/4000                 2056 ns          533 ns
      BM_std_minmax<long long>/4096                 2112 ns          539 ns
      BM_std_minmax<long long>/5500                 2823 ns          749 ns
      BM_std_minmax<long long>/64000               32956 ns         8590 ns
      BM_std_minmax<long long>/65536               33795 ns         8791 ns
      BM_std_minmax<long long>/70000               36084 ns         9442 ns
      BM_std_minmax<unsigned char>/1               0.714 ns         1.41 ns
      BM_std_minmax<unsigned char>/2               0.955 ns         1.96 ns
      BM_std_minmax<unsigned char>/3                1.90 ns         2.63 ns
      BM_std_minmax<unsigned char>/4                2.40 ns         3.34 ns
      BM_std_minmax<unsigned char>/5                2.87 ns         4.10 ns
      BM_std_minmax<unsigned char>/6                3.47 ns         4.88 ns
      BM_std_minmax<unsigned char>/7                4.04 ns         5.66 ns
      BM_std_minmax<unsigned char>/8                4.65 ns         6.45 ns
      BM_std_minmax<unsigned char>/9                5.18 ns         7.24 ns
      BM_std_minmax<unsigned char>/10               5.80 ns         8.05 ns
      BM_std_minmax<unsigned char>/11               6.24 ns         8.86 ns
      BM_std_minmax<unsigned char>/12               6.78 ns         9.70 ns
      BM_std_minmax<unsigned char>/13               7.30 ns         10.6 ns
      BM_std_minmax<unsigned char>/14               7.86 ns         11.4 ns
      BM_std_minmax<unsigned char>/15               8.46 ns         12.3 ns
      BM_std_minmax<unsigned char>/16               9.00 ns         2.12 ns
      BM_std_minmax<unsigned char>/17               9.58 ns         2.83 ns
      BM_std_minmax<unsigned char>/18               10.1 ns         3.37 ns
      BM_std_minmax<unsigned char>/19               10.7 ns         4.11 ns
      BM_std_minmax<unsigned char>/20               11.2 ns         4.85 ns
      BM_std_minmax<unsigned char>/21               11.9 ns         5.69 ns
      BM_std_minmax<unsigned char>/22               12.3 ns         6.77 ns
      BM_std_minmax<unsigned char>/23               13.1 ns         7.56 ns
      BM_std_minmax<unsigned char>/24               13.5 ns         8.40 ns
      BM_std_minmax<unsigned char>/25               14.2 ns         9.30 ns
      BM_std_minmax<unsigned char>/26               14.4 ns         10.1 ns
      BM_std_minmax<unsigned char>/27               15.0 ns         11.1 ns
      BM_std_minmax<unsigned char>/28               15.3 ns         11.9 ns
      BM_std_minmax<unsigned char>/29               16.2 ns         12.9 ns
      BM_std_minmax<unsigned char>/30               16.5 ns         13.9 ns
      BM_std_minmax<unsigned char>/31               17.2 ns         14.8 ns
      BM_std_minmax<unsigned char>/32               17.6 ns         2.36 ns
      BM_std_minmax<unsigned char>/64               35.6 ns         3.21 ns
      BM_std_minmax<unsigned char>/512               288 ns         6.00 ns
      BM_std_minmax<unsigned char>/1024              573 ns         8.80 ns
      BM_std_minmax<unsigned char>/4000             2222 ns         28.6 ns
      BM_std_minmax<unsigned char>/4096             2265 ns         25.9 ns
      BM_std_minmax<unsigned char>/5500             3047 ns         48.8 ns
      BM_std_minmax<unsigned char>/64000           35059 ns          480 ns
      BM_std_minmax<unsigned char>/65536           35941 ns          491 ns
      BM_std_minmax<unsigned char>/70000           38922 ns          525 ns
      BM_std_minmax<unsigned short>/1              0.711 ns         1.18 ns
      BM_std_minmax<unsigned short>/2              0.957 ns         1.65 ns
      BM_std_minmax<unsigned short>/3               2.13 ns         2.21 ns
      BM_std_minmax<unsigned short>/4               2.14 ns         2.78 ns
      BM_std_minmax<unsigned short>/5               3.06 ns         3.29 ns
      BM_std_minmax<unsigned short>/6               2.89 ns         3.87 ns
      BM_std_minmax<unsigned short>/7               3.80 ns         4.55 ns
      BM_std_minmax<unsigned short>/8               3.68 ns         2.02 ns
      BM_std_minmax<unsigned short>/9               4.53 ns         2.40 ns
      BM_std_minmax<unsigned short>/10              4.60 ns         2.94 ns
      BM_std_minmax<unsigned short>/11              5.67 ns         3.67 ns
      BM_std_minmax<unsigned short>/12              5.39 ns         4.22 ns
      BM_std_minmax<unsigned short>/13              6.58 ns         4.78 ns
      BM_std_minmax<unsigned short>/14              6.33 ns         5.54 ns
      BM_std_minmax<unsigned short>/15              7.34 ns         6.30 ns
      BM_std_minmax<unsigned short>/16              7.17 ns         2.25 ns
      BM_std_minmax<unsigned short>/17              8.19 ns         2.61 ns
      BM_std_minmax<unsigned short>/18              8.02 ns         3.19 ns
      BM_std_minmax<unsigned short>/19              9.03 ns         3.72 ns
      BM_std_minmax<unsigned short>/20              8.89 ns         4.36 ns
      BM_std_minmax<unsigned short>/21              9.77 ns         5.10 ns
      BM_std_minmax<unsigned short>/22              9.70 ns         5.55 ns
      BM_std_minmax<unsigned short>/23              10.8 ns         6.29 ns
      BM_std_minmax<unsigned short>/24              10.6 ns         2.41 ns
      BM_std_minmax<unsigned short>/25              11.6 ns         2.75 ns
      BM_std_minmax<unsigned short>/26              11.4 ns         3.26 ns
      BM_std_minmax<unsigned short>/27              12.4 ns         3.86 ns
      BM_std_minmax<unsigned short>/28              12.3 ns         4.45 ns
      BM_std_minmax<unsigned short>/29              13.2 ns         5.07 ns
      BM_std_minmax<unsigned short>/30              13.1 ns         5.77 ns
      BM_std_minmax<unsigned short>/31              13.9 ns         6.65 ns
      BM_std_minmax<unsigned short>/32              13.9 ns         2.72 ns
      BM_std_minmax<unsigned short>/64              27.8 ns         3.25 ns
      BM_std_minmax<unsigned short>/512              220 ns         8.30 ns
      BM_std_minmax<unsigned short>/1024             435 ns         14.1 ns
      BM_std_minmax<unsigned short>/4000            1703 ns         49.8 ns
      BM_std_minmax<unsigned short>/4096            1746 ns         47.9 ns
      BM_std_minmax<unsigned short>/5500            2350 ns         69.9 ns
      BM_std_minmax<unsigned short>/64000          27388 ns          953 ns
      BM_std_minmax<unsigned short>/65536          28040 ns          975 ns
      BM_std_minmax<unsigned short>/70000          29967 ns         1040 ns
      BM_std_minmax<unsigned int>/1                0.712 ns         1.18 ns
      BM_std_minmax<unsigned int>/2                0.965 ns         1.65 ns
      BM_std_minmax<unsigned int>/3                 2.13 ns         2.14 ns
      BM_std_minmax<unsigned int>/4                 2.09 ns         2.64 ns
      BM_std_minmax<unsigned int>/5                 3.02 ns         3.21 ns
      BM_std_minmax<unsigned int>/6                 2.94 ns         3.81 ns
      BM_std_minmax<unsigned int>/7                 3.91 ns         4.38 ns
      BM_std_minmax<unsigned int>/8                 3.75 ns         4.93 ns
      BM_std_minmax<unsigned int>/9                 4.71 ns         5.60 ns
      BM_std_minmax<unsigned int>/10                4.59 ns         6.26 ns
      BM_std_minmax<unsigned int>/11                5.57 ns         6.80 ns
      BM_std_minmax<unsigned int>/12                5.43 ns         7.47 ns
      BM_std_minmax<unsigned int>/13                6.45 ns         8.10 ns
      BM_std_minmax<unsigned int>/14                6.32 ns         8.69 ns
      BM_std_minmax<unsigned int>/15                7.29 ns         9.37 ns
      BM_std_minmax<unsigned int>/16                7.12 ns         9.99 ns
      BM_std_minmax<unsigned int>/17                8.24 ns         10.6 ns
      BM_std_minmax<unsigned int>/18                8.00 ns         11.2 ns
      BM_std_minmax<unsigned int>/19                8.94 ns         12.0 ns
      BM_std_minmax<unsigned int>/20                8.91 ns         12.6 ns
      BM_std_minmax<unsigned int>/21                9.73 ns         17.2 ns
      BM_std_minmax<unsigned int>/22                9.75 ns         13.8 ns
      BM_std_minmax<unsigned int>/23                10.6 ns         14.5 ns
      BM_std_minmax<unsigned int>/24                10.6 ns         15.1 ns
      BM_std_minmax<unsigned int>/25                11.5 ns         15.7 ns
      BM_std_minmax<unsigned int>/26                11.4 ns         16.3 ns
      BM_std_minmax<unsigned int>/27                12.3 ns         17.0 ns
      BM_std_minmax<unsigned int>/28                12.3 ns         17.6 ns
      BM_std_minmax<unsigned int>/29                13.2 ns         18.3 ns
      BM_std_minmax<unsigned int>/30                13.2 ns         19.0 ns
      BM_std_minmax<unsigned int>/31                14.0 ns         19.6 ns
      BM_std_minmax<unsigned int>/32                14.0 ns         3.39 ns
      BM_std_minmax<unsigned int>/64                27.6 ns         4.05 ns
      BM_std_minmax<unsigned int>/512                221 ns         14.2 ns
      BM_std_minmax<unsigned int>/1024               439 ns         25.5 ns
      BM_std_minmax<unsigned int>/4000              1720 ns         96.3 ns
      BM_std_minmax<unsigned int>/4096              1762 ns         97.8 ns
      BM_std_minmax<unsigned int>/5500              2364 ns          146 ns
      BM_std_minmax<unsigned int>/64000            27874 ns         1905 ns
      BM_std_minmax<unsigned int>/65536            28012 ns         1961 ns
      BM_std_minmax<unsigned int>/70000            29899 ns         2087 ns
      BM_std_minmax<unsigned long long>/1          0.707 ns         1.18 ns
      BM_std_minmax<unsigned long long>/2          0.909 ns         1.65 ns
      BM_std_minmax<unsigned long long>/3           1.65 ns         2.70 ns
      BM_std_minmax<unsigned long long>/4           1.93 ns         2.69 ns
      BM_std_minmax<unsigned long long>/5           2.45 ns         3.34 ns
      BM_std_minmax<unsigned long long>/6           2.78 ns         3.81 ns
      BM_std_minmax<unsigned long long>/7           3.28 ns         4.43 ns
      BM_std_minmax<unsigned long long>/8           3.70 ns         4.92 ns
      BM_std_minmax<unsigned long long>/9           4.12 ns         5.64 ns
      BM_std_minmax<unsigned long long>/10          4.44 ns         6.15 ns
      BM_std_minmax<unsigned long long>/11          4.91 ns         6.81 ns
      BM_std_minmax<unsigned long long>/12          5.31 ns         7.41 ns
      BM_std_minmax<unsigned long long>/13          5.72 ns         7.96 ns
      BM_std_minmax<unsigned long long>/14          6.05 ns         8.66 ns
      BM_std_minmax<unsigned long long>/15          6.55 ns         9.37 ns
      BM_std_minmax<unsigned long long>/16          6.89 ns         7.98 ns
      BM_std_minmax<unsigned long long>/17          7.34 ns         8.13 ns
      BM_std_minmax<unsigned long long>/18          7.73 ns         8.42 ns
      BM_std_minmax<unsigned long long>/19          8.26 ns         8.63 ns
      BM_std_minmax<unsigned long long>/20          8.54 ns         8.96 ns
      BM_std_minmax<unsigned long long>/21          9.14 ns         9.37 ns
      BM_std_minmax<unsigned long long>/22          9.39 ns         9.67 ns
      BM_std_minmax<unsigned long long>/23          10.1 ns         10.1 ns
      BM_std_minmax<unsigned long long>/24          10.4 ns         10.6 ns
      BM_std_minmax<unsigned long long>/25          11.0 ns         11.3 ns
      BM_std_minmax<unsigned long long>/26          11.3 ns         12.1 ns
      BM_std_minmax<unsigned long long>/27          11.8 ns         14.2 ns
      BM_std_minmax<unsigned long long>/28          12.1 ns         15.8 ns
      BM_std_minmax<unsigned long long>/29          12.6 ns         17.4 ns
      BM_std_minmax<unsigned long long>/30          13.1 ns         18.1 ns
      BM_std_minmax<unsigned long long>/31          13.4 ns         18.8 ns
      BM_std_minmax<unsigned long long>/32          13.8 ns         10.4 ns
      BM_std_minmax<unsigned long long>/64          27.3 ns         15.5 ns
      BM_std_minmax<unsigned long long>/512          222 ns         80.6 ns
      BM_std_minmax<unsigned long long>/1024         443 ns          156 ns
      BM_std_minmax<unsigned long long>/4000        1731 ns          591 ns
      BM_std_minmax<unsigned long long>/4096        1752 ns          609 ns
      BM_std_minmax<unsigned long long>/5500        2340 ns          819 ns
      BM_std_minmax<unsigned long long>/64000      27166 ns         9652 ns
      BM_std_minmax<unsigned long long>/65536      27869 ns         9876 ns
      BM_std_minmax<unsigned long long>/70000      29920 ns        10680 ns
      ```
      935e6991
    • Florian Hahn's avatar
      [Driver] Add missing include of std::set. · 1803d675
      Florian Hahn authored
      4ddd4ed7 added a use of std::set without including it. With some
      recent libc++, std::set isn't included transitively causing build
      failures.
      
      Add explicit include.
      1803d675
    • Florian Hahn's avatar
      [LV] Make global_alias.ll test independent of O1 pipeline. · fa8a7266
      Florian Hahn authored
      Update global_alias.ll with the IR after the O1 pipeline. Depending on
      the O1 makes the tests more fragile and also makes it more difficult to
      reason about the behavior of the tests, as it doesn't show the IR before
      LoopVectorize.
      fa8a7266
    • yronglin's avatar
      [libc++] Implement LWG3430 disallow implicit conversion of the source... · 4761e74a
      yronglin authored
      [libc++] Implement LWG3430 disallow implicit conversion of the source arguments to `std::filesystem::path` when constructing `std::basic_*fstream` (#85079)
      
      Implement [LWG3430](https://wg21.link/LWG3430
      
      ).
      
      ---------
      
      Signed-off-by: default avataryronglin <yronglin777@gmail.com>
      4761e74a
    • Florian Hahn's avatar
      233c030d
    • Ramkumar Ramachandra's avatar
      llvm-objdump/ELF: fix crash when reading dyn str table (#87519) · 0e8b61f8
      Ramkumar Ramachandra authored
      When reading the dynamic string table, llvm-objdump used to crash if the
      ELF was malformed, due to an erroneous consumption of error status.
      Instead, propogate the error status to the caller, fixing the crash, and
      printing a warning.
      0e8b61f8
    • Vlad Serebrennikov's avatar
      [clang][NFC] Introduce `SemaBase` (#87634) · d2884444
      Vlad Serebrennikov authored
      This is a follow-up to #84184. Multiple reviewers there pointed out to
      me that we should have a common base class for `Sema` and `SemaOpenACC`
      to avoid code duplication for common helpers like `getLangOpts()`. On
      top of that, `Diag()` function was requested for `SemaOpenACC`. This
      patch delivers both.
      
      The intent is to keep `SemaBase` as small as possible, as things there
      are globally available across `Sema` and its parts without any
      additional effort from usage side. Overused, this can undermine the
      whole endeavor of splitting `Sema` apart.
      
      Apart of shuffling code around, this patch introduces a helper private
      function `SemaDiagnosticBuilder::getDeviceDeferredDiags()`, the sole
      purpose of which is to encapsulate member access into (incomplete)
      `Sema` for function templates defined in the header, where `Sema` can't
      be complete.
      d2884444
    • Benjamin Kramer's avatar
      [bazel] Fix the build after 27b2d7d4 · f5d7e755
      Benjamin Kramer authored
      f5d7e755
    • Owen Pan's avatar
      684f27d3
    • Guillaume Chatelet's avatar
    • Kai Sasaki's avatar
      [mlir][complex] Support fast math flag for complex.sign op (#87148) · a522dbbd
      Kai Sasaki authored
      We are going to support the fast math flag given in `complex.sign` op in
      the conversion to standard dialect.
      
      See:
      https://discourse.llvm.org/t/rfc-fastmath-flags-support-in-complex-dialect/71981
      a522dbbd
    • Matthias Springer's avatar
      [mlir][SCF][NFC] `ValueBoundsConstraintSet`: Simplify `scf.for` implementation (#87862) · 0ba3e96b
      Matthias Springer authored
      This commit simplifies the implementation of the
      `ValueBoundsOpInterface` for `scf.for` based on the newly added
      `ValueBoundsConstraintSet::compare` API and adds additional
      documentation.
      
      Previously, the interface implementation created a new constraint set
      just to check if the yielded value and iter_arg are equal. This was
      inefficient because constraints were added multiple times (to two
      different constraint sets) for ops that are inside the loop.
      
      Note: This is a re-upload of #86239.
      0ba3e96b
    • Owen Pan's avatar
      [clang-format][NFC] Rename `kind` to `Kind` · 77020234
      Owen Pan authored
      77020234
    • Vlad Serebrennikov's avatar
      [clang] Claim conformance for CWG466 (#87748) · 0b021c4b
      Vlad Serebrennikov authored
      [CWG466](https://cplusplus.github.io/CWG/issues/466.html) "cv-qualifiers
      on pseudo-destructor type".
      Richard claimed that we don't implement this DR because of one
      ill-formed example being accepted: `a->CI::~VI();`. This example is
      testing the behavior of calling a pseudo-destructor via a qualified
      name, where components of qualified name denote the same `int` type, but
      with different cv-qualifications.
      
      Initially, the following wording from [expr.pseudo] quoted in CWG466 was
      left intact:
      > Furthermore, the two type-names in a pseudo-destructor-name of the
      form
      >
      >    `:: (opt) nested-name-specifier (opt) type-name ::~ type-name`
      >
      >shall designate the same scalar type.
      
      According to this wording, the example is indeed ill-formed.
      
      [P1131R2](https://wg21.link/p1131r2) merged wording for
      pseudo-destructors into regular destructor wording. Among other things,
      [expr.pseudo] was removed, and [expr.prim.id.qual]/2 was changed to
      read:
      
      > Where `type-name ::~ type-name` is used, the two type-names shall
      refer to the same type (ignoring cv-qualifications);
      
      I believe P1131R2 made the example well-formed.
      
      However, this wording didn't survive
      [P1787R6](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/p1787r6.html)
      "Declarations and where to find them". In that paper I don't see the
      intent to make the example ill-formed again, so I assume it confirmed
      status-quo via other wording. My _guess_ the new wording is
      http://eel.is/c++draft/basic.lookup#qual.general-4.6:
      > If a qualified name Q follows a ~: 
      > - <...>
      > - The [type-name](http://eel.is/c++draft/dcl.type.simple#nt:type-name)
      that is or contains Q shall refer to its (original) lookup context
      (ignoring cv-qualification) under the interpretation established by at
      least one (successful) lookup
      performed[.](http://eel.is/c++draft/basic.lookup#qual.general-4.6.sentence-1)
      0b021c4b
    • Vlad Serebrennikov's avatar
      [clang] Add test for CWG392 (#87744) · cd0f5b2e
      Vlad Serebrennikov authored
      [CWG392](https://cplusplus.github.io/CWG/issues/392.html) "Use of full
      expression lvalue before temporary destruction". We're testing that
      `operator bool()` is called before destructor of `C`.
      
      I'm also marking CWG388 as requiring libc++abi test instead of codegen
      test, as we need to test matching between exception object and exception
      handlers.
      cd0f5b2e
    • Vlad Serebrennikov's avatar
      [clang] Reject VLAs in `__is_layout_compatible()` (#87737) · 813f68ca
      Vlad Serebrennikov authored
      This is a follow-up to #81506. Since `__is_layout_compatible()` is a C++
      intrinsic
      (https://github.com/llvm/llvm-project/blob/ff1e72d68d1224271801ff5192a8c14fbd3be83b/clang/include/clang/Basic/TokenKinds.def#L523),
      I don't think we should define how it interacts with VLA extension
      unless we have a compelling reason to.
      
      Since #81506 was merged after 18 cut-off, we don't have to follow any
      kind of deprecation process.
      813f68ca
    • Matthias Springer's avatar
      [mlir][SCF] `ValueBoundsConstraintSet`: Support `scf.if` (branches) (#87860) · 76435f2d
      Matthias Springer authored
      This commit adds support for `scf.if` to `ValueBoundsConstraintSet`.
      
      Example:
      ```
      %0 = scf.if ... -> index {
        scf.yield %a : index
      } else {
        scf.yield %b : index
      }
      ```
      
      The following constraints hold for %0:
      * %0 >= min(%a, %b)
      * %0 <= max(%a, %b)
      
      Such constraints cannot be added to the constraint set; min/max is not
      supported by `IntegerRelation`. However, if we know which one of %a and
      %b is larger, we can add constraints for %0. E.g., if %a <= %b:
      * %0 >= %a
      * %0 <= %b
      
      This commit required a few minor changes to the
      `ValueBoundsConstraintSet` infrastructure, so that values can be
      compared while we are still in the process of traversing the IR/adding
      constraints.
      
      Note: This is a re-upload of #85895, which was reverted. The bug that
      caused the failure was fixed in #87859.
      76435f2d
    • Matthias Springer's avatar
      [mlir][Arith] Specify evaluation order of `getExpr` (#87859) · 08200fa3
      Matthias Springer authored
      The C++ standard does not specify an evaluation order for addition/...
      operands. E.g., in `a() + b()`, the compiler is free to evaluate `a` or
      `b` first.
      
      This lead to different `mlir-opt` outputs in #85895. (FileCheck passed
      when compiled with LLVM but failed when compiled with gcc.)
      08200fa3
    • Jakub Kuderski's avatar
      [ADT] Allow reverse to find free rbegin/rend functions (#87840) · c8f3d211
      Jakub Kuderski authored
      Lift the requirement that rbegin/rend must be member functions. Also
      allow the rbegin/rend to be found through Argument Dependent Lookup
      (ADL) and add `adl_rbegin`/`adl_rend` to STLExtras.
      c8f3d211
    • Jeff Niu's avatar
      [mlir][ods] Emit "trivial" ODS getter/setters inline (#87741) · 0f52f4dd
      Jeff Niu authored
      Emitting trivial getters that amount to `(*this)->getOperand(1)`
      out-of-line or `getProperties().foo` is a pretty significant performance
      hit on these basic MLIR APIs for manipulating ops (3-4x). Emit them
      inline (without adding additional dependencies to header files).
      0f52f4dd
    • Mike's avatar
      [clang-tidy] Fix readability-duplicate-include for includes with macro (#87433) · ed4e505c
      Mike authored
      Completely skip include directives that form the filename using macros.
      
      fixes #87303
      ed4e505c
    • Amir Ayupov's avatar
      [BOLT][BAT] Fix encoded NumBasicBlocks · e64eede0
      Amir Ayupov authored
      Emit the recorded number of blocks, not the number of basic block
      hashes. There might be differences in corner cases (openssl
      BN_BLINDING_convert_ex function).
      
      Test Plan:
      Updated openssl.test in https://github.com/rafaelauler/bolt-tests/pull/31
      
      Reviewers: rafaelauler, ayermolo, maksfb, dcci
      
      Reviewed By: ayermolo
      
      Pull Request: https://github.com/llvm/llvm-project/pull/87830
      e64eede0
    • Amir Ayupov's avatar
      [BOLT][BAT] Support multi-way split functions · 02276239
      Amir Ayupov authored
      BAT writeMaps encoded the assumption that functions are only split into
      two fragments (hot and cold). However, BOLT supports splitting into
      arbitrary number of fragments. Relax that assumption and look up primary
      (hot) fragment explicitly.
      
      Depends on: https://github.com/llvm/llvm-project/pull/86219
      
      Test Plan: Updated bolt/test/X86/yaml-secondary-entry-discriminator.s
      
      Reviewers: ayermolo, rafaelauler, maksfb, dcci
      
      Reviewed By: maksfb, dcci
      
      Pull Request: https://github.com/llvm/llvm-project/pull/87123
      02276239
    • Craig Topper's avatar
      [RISCV] Rename OP-P to OP-VE. (#87546) · 8bd39145
      Craig Topper authored
      This has been updated in the isa-manual
      https://github.com/riscv/riscv-isa-manual/pull/1311
      8bd39145
    • Jie Fu's avatar
      [flang] Fix -Wunused-but-set-variable in Bridge.cpp (NFC) · 3f2f7006
      Jie Fu authored
      llvm-project/flang/lib/Lower/Bridge.cpp:3775:14:
      error: variable 'nbDeviceResidentObject' set but not used [-Werror,-Wunused-but-set-variable]
          unsigned nbDeviceResidentObject = 0;
                   ^
      1 error generated.
      3f2f7006
    • Amir Ayupov's avatar
      [BOLT] Use BAT for YAML profile call target information · 2d3c827c
      Amir Ayupov authored
      Provide a mechanism to resolve call target information for calls from non-BAT
      functions to BAT functions (`YAMLProfileWriter::convert`). Make it generic for
      future use in BAT-to-BAT calls.
      
      Test Plan: Updated bolt/test/X86/bolt-address-translation-yaml.test
      
      Reviewers: ayermolo, maksfb, rafaelauler, dcci
      
      Reviewed By: maksfb
      
      Pull Request: https://github.com/llvm/llvm-project/pull/86219
      2d3c827c
    • lntue's avatar
      [libc] Add proxy header math_macros.h. (#87598) · 5748ad84
      lntue authored
      Context: https://github.com/llvm/llvm-project/pull/87017
      
      - Add proxy header `libc/hdr/math_macros.h` that will:
        - include `<math.h>` in overlay mode,
      - include `"include/llvm-libc-macros/math-macros.h"` in full build mode.
      - Its corresponding CMake target `libc.hdr.math_macros` will only depend
      on `libc.include.math` and `libc.include.llvm-libc-macros.math_macros`
      in full build mode.
      - Replace all `#include "include/llvm-libc-macros/math-macros.h"` with
      `#include "hdr/math_macros.h"`.
      - Add dependency to `libc.hdr.math_macros` CMake target when using
      `add_fp_unittest`.
      - Update the remaining dependency.
      - Update bazel overlay: add `libc:hdr_math_macros` target, and replacing
      all dependency on `libc:llvm_libc_macros_math_macros` with
      `libc:hdr_math_macros`.
      5748ad84
    • Slava Zakharin's avatar
      [NFC][flang][runtime] Moved freestanding-tools.h to use it in FortranDecimal. (#87827) · 3b337242
      Slava Zakharin authored
      I will add `toupper` implementation into it in the next PR.
      3b337242
    • Diego Caballero's avatar
      [mlir][Vector] Fix n-D vector.extract/insert lowering to LLVM (#87591) · 42a6ad7b
      Diego Caballero authored
      The lowering of n-D vector.extract/insert ops to LLVM is not supported
      but if one of these accidentally reaches the vector-to-llvm conversion
      patterns, we end up with a kind of puzzling crash. This PR fixes that
      crash and gracefully bails out in those cases.
      42a6ad7b
    • Slava Zakharin's avatar
      [flang][build] Fixed paths discrovery for the out-of-tree build. (#87822) · 92029845
      Slava Zakharin authored
      When building flang out-of-tree with relative paths in LLVM_DIR,
      CLANG_DIR and MLIR_DIR, we need to compute the absolute paths
      based on the CMake build directory (i.e. where the cmake is invoked
      from).
      92029845
    • Nick Desaulniers's avatar
      [libc][docs] Introduce docgen (#87682) · af34a5d3
      Nick Desaulniers authored
      
      This script+config should help us generate more consistent documentation wrt.
      what we currently support or not.
      
      As an example usage:
      
          $ ./libc/utils/docgen/docgen.py fenv.h
      
      Will spit out an RST formatted table that can be copy+pasted into our docs.
      
      The config is not filled out entirely, but doing so and then updating our docs
      would be great beginner bugs for new contributors.
      
      Having python+json generate things like docs, or headers (as imagined in
      https://github.com/nickdesaulniers/llvm-project/tree/hdr-gen2) is perhaps
      easier to work with than tablegen, and doesn't introduce a dependency on a host
      tool that needs to be compiled from llvm sources before building the rest of
      the libc. This can probably be merged with whatever we end up doing to replace
      libc-hdrgen.
      
      Please use
      
      https://llvm.org/docs/CodingStandards.html#python-version-and-source-code-formatting
      for keeping this file formatted.
      af34a5d3
    • Cyndy Ishida's avatar
      [cmake] Back out of making unsupported `-no_exported_symbols` linker a · fe45029d
      Cyndy Ishida authored
      fatal error for now
      
      Appeases build bots while being investigated.
      fe45029d