Commit 7e439d5
authored
[VectorCombine] Skip foldShuffleOfIntrinsics when operand types differ (#201241)
Example:
```llvm
define <4 x i32> @t(<2 x float> %a, <2 x double> %b) {
%fa = call <2 x i32> @llvm.fptosi.sat.v2i32.v2f32(<2 x float> %a)
%fb = call <2 x i32> @llvm.fptosi.sat.v2i32.v2f64(<2 x double> %b)
%s = shufflevector <2 x i32> %fa, <2 x i32> %fb, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
ret <4 x i32> %s
}
```
In this code, `foldShuffleOfIntrinsics` folds `shuffle(intrinsic(x),
intrinsic(y))` into `intrinsic(shuffle(x, y))`, but only checks the
result type, not the operand types. Since `fptosi.sat` is overloaded on
its operand type, the two calls share an `<2 x i32>` result but have
different operands (`<2 x float>` vs `<2 x double>`), so the new
`shufflevector` gets mismatched operands and trips `isValidOperands`.
Fix: bail out when the intrinsics' shuffled operands have different
types.1 parent 517308a commit 7e439d5
2 files changed
Lines changed: 35 additions & 3 deletions
File tree
- llvm
- lib/Transforms/Vectorize
- test/Transforms/VectorCombine/X86
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3291 | 3291 | | |
3292 | 3292 | | |
3293 | 3293 | | |
3294 | | - | |
3295 | | - | |
3296 | | - | |
| 3294 | + | |
| 3295 | + | |
| 3296 | + | |
| 3297 | + | |
| 3298 | + | |
| 3299 | + | |
| 3300 | + | |
| 3301 | + | |
| 3302 | + | |
| 3303 | + | |
| 3304 | + | |
| 3305 | + | |
3297 | 3306 | | |
| 3307 | + | |
| 3308 | + | |
3298 | 3309 | | |
3299 | 3310 | | |
3300 | 3311 | | |
| |||
Lines changed: 21 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
233 | 233 | | |
234 | 234 | | |
235 | 235 | | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
0 commit comments