Commit 40625f3
committed
[CIR] Add support for ExtVectorBoolType element assignment, comparisons, and logical NOT
This commit implements three previously missing operations for ExtVectorBoolType:
1. Element assignment (v[i] = value): Converts the packed integer representation
to a padded vector, performs the element insertion, and converts back to
integer form while preserving padding bits.
2. Vector comparisons (==, !=, etc.): Extracts actual elements from padded
storage using shufflevector, performs element-wise comparison, then pads
the result back to storage size with undef for padding bits.
3. Logical NOT (!v): Implemented as element-wise comparison with zero vector,
following the same extract-operate-pad pattern as other comparisons.
All operations follow the ExtVectorBoolType storage model where N bool elements
are stored in an integer padded to at least 8 bits (1 byte). The implementation:
- Bitcasts the integer storage to <P x i1> vector (P = padded storage size)
- Uses shufflevector to extract <N x i1> (actual elements)
- Performs the operation on actual elements
- Uses shufflevector to pad result back to <P x i1> (undef for padding)
- Bitcasts back to integer storage
This approach ensures padding bits remain undefined/unchanged and mirrors how
LLVM CodeGen handles these operations.
Test Plan:
- Added comprehensive tests for element assignment, comparisons, and logical NOT
- Tests verify both CIR output and LLVM lowering
- All existing CIR CodeGen tests pass (395 tests, 380 passed, 14 unsupported, 1 expected fail)
- Specific vector tests pass: vector.cpp, vectype.cpp, vectype-issized.c, vectype-ext.cpp
The implementation closely follows CodeGen patterns in CGExprScalar.cpp and
CGExpr.cpp, maintaining consistency with the original implementation approach.
ghstack-source-id: a9c5e91
Pull-Request: #20041 parent c620112 commit 40625f3
File tree
3 files changed
+280
-20
lines changed- clang
- lib/CIR/CodeGen
- test/CIR/CodeGen
3 files changed
+280
-20
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
902 | 902 | | |
903 | 903 | | |
904 | 904 | | |
| 905 | + | |
| 906 | + | |
| 907 | + | |
| 908 | + | |
905 | 909 | | |
906 | 910 | | |
907 | 911 | | |
908 | 912 | | |
909 | | - | |
910 | | - | |
911 | | - | |
| 913 | + | |
| 914 | + | |
| 915 | + | |
| 916 | + | |
| 917 | + | |
| 918 | + | |
| 919 | + | |
| 920 | + | |
| 921 | + | |
| 922 | + | |
| 923 | + | |
| 924 | + | |
| 925 | + | |
| 926 | + | |
| 927 | + | |
| 928 | + | |
| 929 | + | |
| 930 | + | |
| 931 | + | |
| 932 | + | |
| 933 | + | |
| 934 | + | |
| 935 | + | |
| 936 | + | |
| 937 | + | |
| 938 | + | |
| 939 | + | |
| 940 | + | |
| 941 | + | |
| 942 | + | |
| 943 | + | |
| 944 | + | |
| 945 | + | |
| 946 | + | |
| 947 | + | |
| 948 | + | |
912 | 949 | | |
913 | 950 | | |
914 | 951 | | |
915 | 952 | | |
916 | | - | |
917 | | - | |
918 | | - | |
919 | | - | |
920 | | - | |
| 953 | + | |
| 954 | + | |
| 955 | + | |
921 | 956 | | |
922 | 957 | | |
923 | 958 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1003 | 1003 | | |
1004 | 1004 | | |
1005 | 1005 | | |
1006 | | - | |
1007 | | - | |
| 1006 | + | |
| 1007 | + | |
1008 | 1008 | | |
1009 | 1009 | | |
1010 | 1010 | | |
1011 | 1011 | | |
1012 | 1012 | | |
1013 | | - | |
1014 | | - | |
1015 | | - | |
| 1013 | + | |
| 1014 | + | |
| 1015 | + | |
| 1016 | + | |
| 1017 | + | |
| 1018 | + | |
| 1019 | + | |
| 1020 | + | |
| 1021 | + | |
| 1022 | + | |
| 1023 | + | |
| 1024 | + | |
| 1025 | + | |
| 1026 | + | |
| 1027 | + | |
| 1028 | + | |
| 1029 | + | |
| 1030 | + | |
| 1031 | + | |
| 1032 | + | |
| 1033 | + | |
| 1034 | + | |
| 1035 | + | |
| 1036 | + | |
| 1037 | + | |
| 1038 | + | |
| 1039 | + | |
| 1040 | + | |
| 1041 | + | |
| 1042 | + | |
| 1043 | + | |
| 1044 | + | |
| 1045 | + | |
| 1046 | + | |
| 1047 | + | |
| 1048 | + | |
| 1049 | + | |
| 1050 | + | |
| 1051 | + | |
| 1052 | + | |
| 1053 | + | |
| 1054 | + | |
| 1055 | + | |
| 1056 | + | |
| 1057 | + | |
| 1058 | + | |
| 1059 | + | |
| 1060 | + | |
| 1061 | + | |
| 1062 | + | |
| 1063 | + | |
| 1064 | + | |
| 1065 | + | |
| 1066 | + | |
1016 | 1067 | | |
1017 | 1068 | | |
1018 | 1069 | | |
| |||
1036 | 1087 | | |
1037 | 1088 | | |
1038 | 1089 | | |
1039 | | - | |
1040 | | - | |
| 1090 | + | |
| 1091 | + | |
1041 | 1092 | | |
1042 | 1093 | | |
1043 | 1094 | | |
1044 | 1095 | | |
1045 | | - | |
| 1096 | + | |
1046 | 1097 | | |
1047 | 1098 | | |
1048 | 1099 | | |
| |||
2119 | 2170 | | |
2120 | 2171 | | |
2121 | 2172 | | |
2122 | | - | |
2123 | | - | |
2124 | | - | |
| 2173 | + | |
| 2174 | + | |
| 2175 | + | |
| 2176 | + | |
| 2177 | + | |
| 2178 | + | |
| 2179 | + | |
| 2180 | + | |
| 2181 | + | |
| 2182 | + | |
| 2183 | + | |
| 2184 | + | |
| 2185 | + | |
| 2186 | + | |
| 2187 | + | |
| 2188 | + | |
| 2189 | + | |
| 2190 | + | |
| 2191 | + | |
| 2192 | + | |
| 2193 | + | |
| 2194 | + | |
| 2195 | + | |
| 2196 | + | |
| 2197 | + | |
| 2198 | + | |
| 2199 | + | |
| 2200 | + | |
| 2201 | + | |
| 2202 | + | |
| 2203 | + | |
| 2204 | + | |
| 2205 | + | |
| 2206 | + | |
| 2207 | + | |
| 2208 | + | |
| 2209 | + | |
| 2210 | + | |
| 2211 | + | |
| 2212 | + | |
| 2213 | + | |
| 2214 | + | |
| 2215 | + | |
| 2216 | + | |
| 2217 | + | |
| 2218 | + | |
| 2219 | + | |
| 2220 | + | |
2125 | 2221 | | |
2126 | 2222 | | |
2127 | 2223 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
6 | 6 | | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
7 | 18 | | |
8 | 19 | | |
9 | 20 | | |
| |||
204 | 215 | | |
205 | 216 | | |
206 | 217 | | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
0 commit comments