Commit 3a7b522
authored
[DAGCombiner][RISCV] Handle truncating splats in isNeutralConstant (#87338)
On RV64, we legalize zexts of i1s to (vselect m, (splat_vector i64 1),
(splat_vector i64 0)), where the splat_vectors are implicitly
truncating.
When the vselect is used by a binop we want to pull the vselect out via
foldSelectWithIdentityConstant. But because vectors with an element size
< i64 will truncate, isNeutralConstant will return false.
This patch handles truncating splats by getting the APInt value and
truncating it. We almost don't need to do this since most of the neutral
elements are either one/zero/all ones, but it will make a difference for
smax and smin.
I wasn't able to figure out a way to write the tests in terms of select,
since we need the i1 zext legalization to create a truncating
splat_vector.
This supercedes #87236. Fixed vectors are unfortunately not handled by
this patch (since they get legalized to _VL nodes), but they don't seem
to appear in the wild.1 parent e8aaa3e commit 3a7b522
File tree
4 files changed
+181
-127
lines changed- llvm
- lib/CodeGen/SelectionDAG
- test/CodeGen/RISCV
- rvv
4 files changed
+181
-127
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11545 | 11545 | | |
11546 | 11546 | | |
11547 | 11547 | | |
11548 | | - | |
| 11548 | + | |
| 11549 | + | |
| 11550 | + | |
11549 | 11551 | | |
11550 | 11552 | | |
11551 | 11553 | | |
11552 | 11554 | | |
11553 | 11555 | | |
11554 | | - | |
| 11556 | + | |
11555 | 11557 | | |
11556 | | - | |
| 11558 | + | |
11557 | 11559 | | |
11558 | 11560 | | |
11559 | | - | |
| 11561 | + | |
11560 | 11562 | | |
11561 | | - | |
| 11563 | + | |
11562 | 11564 | | |
11563 | | - | |
| 11565 | + | |
11564 | 11566 | | |
11565 | 11567 | | |
11566 | 11568 | | |
11567 | 11569 | | |
11568 | | - | |
| 11570 | + | |
11569 | 11571 | | |
11570 | 11572 | | |
11571 | | - | |
| 11573 | + | |
11572 | 11574 | | |
11573 | 11575 | | |
11574 | 11576 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
22 | | - | |
| 21 | + | |
23 | 22 | | |
24 | 23 | | |
25 | 24 | | |
26 | | - | |
27 | | - | |
28 | | - | |
| 25 | + | |
| 26 | + | |
29 | 27 | | |
30 | 28 | | |
31 | 29 | | |
| |||
41 | 39 | | |
42 | 40 | | |
43 | 41 | | |
44 | | - | |
45 | | - | |
| 42 | + | |
46 | 43 | | |
47 | 44 | | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
52 | 48 | | |
53 | 49 | | |
54 | 50 | | |
| |||
158 | 154 | | |
159 | 155 | | |
160 | 156 | | |
161 | | - | |
162 | | - | |
| 157 | + | |
163 | 158 | | |
164 | 159 | | |
165 | 160 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
0 commit comments