Vector 'getelementptr' with scalar base is an opportunity for gather/scatter intrinsic to generate a better sequence.
While looking for uniform base, we want to use the scalar base pointer of GEP, if exists.
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
Vector 'getelementptr' with scalar base is an opportunity for gather/scatter intrinsic to generate a better sequence.
While looking for uniform base, we want to use the scalar base pointer of GEP, if exists.
| lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp | ||
|---|---|---|
| 3083 ↗ | (On Diff #29518) | unform -> uniform |
| 3084 ↗ | (On Diff #29518) | receive -> take, perhaps? |
| 3085 ↗ | (On Diff #29518) | Perhaps IR examples for both representations might be helpful? |
| 3111–3112 ↗ | (On Diff #29518) | else on the same line? |
| 3116–3117 ↗ | (On Diff #29518) | Should we check that the insertelement index is 0? (or even generalize and check that the broadcast and insertelement have the same index, though that sounds unnecessary) |
| 3121 ↗ | (On Diff #29518) | inside -> inside the |
| 3129 ↗ | (On Diff #29518) | unnecessary end-of-line whitespace? |
| 3140 ↗ | (On Diff #29518) | I'm a bit uneasy with changing IndexVal outside the if(): when the latter fails, IndexVal will be incorrect for subsequent users. Not sure it's better, but what about something like: Value *OrigIndexVal = ...;
if (SDB->findValue(OrigIndexVal)) {
IndexVal = OrigIndexVal;
...
} |
| 3146 ↗ | (On Diff #29518) | Why not EVT? |
Ahmed,
Thanks a lot for the review. I addressed all your comments and uploaded a new patch.
| lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp | ||
|---|---|---|
| 3084 ↗ | (On Diff #29518) | Vector of pointers is the first argument of Gather/Scatter |
| 3116–3117 ↗ | (On Diff #29518) | I submitted another patch with getSplatValue() as vector utility and planned to use it here, but it is stuck on review. |
| 3140 ↗ | (On Diff #29518) | Actually, I don't need the IndexVal any more, but I changed the code. |
| 3146 ↗ | (On Diff #29518) | The same interface in EVT requires Context. But I changed, the result is the same. |
This LGTM, but let's get getSplatValue figured out, commit that, and then commit this patch using getSplatValue.
| lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp | ||
|---|---|---|
| 3122 ↗ | (On Diff #29879) | I suppose you'll replace this logic with getSplatValue when that lands. |
I use the new interface getSplatValue().
I added more tests, Hal and James asked for.