Implemented WidenScalar for G_PHI.
Details
Diff Detail
Event Timeline
Hi Aditya,
Looks mostly good.
Couple of comments inlined + we need more tests and reduce them (e.g., remove the frameInfo stuff and so on).
Cheers,
-Quentin
lib/CodeGen/GlobalISel/LegalizerHelper.cpp | ||
---|---|---|
668 | NonTermIt may not be an instruction, thus we cannot dereference it.
| |
676 | No bracket for one line block | |
690 | Can't we merge the two loops and get rid of the temporary NewRegs. |
Hi Aditya,
The code looks good to me. Minor nitpicks inlined.
Regarding the test cases, could you:
- Add a test case with a cycle on a phi (e.g., a = phi a)
- Add a test case with an empty predecessor
- Add a comment before every test case explaining what we are checking
- Add a test case for s8
- Add a test case with def feeding into two different phis:
- In the same destination block
- with the same type
- with different types
- In different basic block (one on the true branch, one on the false branch)
- with the same type
- with different types
- In the same destination block
I know that most of these test cases are going to exercise the same code path, but I still like to add more and stranger tests to make sure still things pass if we change the implementation underneath. For instance if we start doing CSE when creating the EXTs.
Cheers,
-Quentin
include/llvm/CodeGen/GlobalISel/MachineIRBuilder.h | ||
---|---|---|
432 | Add a newline | |
lib/CodeGen/GlobalISel/MachineIRBuilder.cpp | ||
353 | Formatting looks weird. Is this clang-formatted? | |
test/CodeGen/AArch64/GlobalISel/legalize-phi.mir | ||
51 | You can get rid of the frameInfo, fixedStack, stack and constants sections |
I see that the test cases I thought I updated (and added) are not there (and can't find them in my tree). I'll recreate them and add them to the review again.
lib/CodeGen/GlobalISel/MachineIRBuilder.cpp | ||
---|---|---|
353 | Yup. This is clang-formatted.. |
I miss these test cases:
- Add a test case with def feeding into two different phis:
- In the same destination block
- In different basic block (one on the true branch, one on the false branch)
In other words:
bb1:
def =
...
bb2:
... = phi def
... = phi def
and
def =
...
condbr bb2, b33
bb2
... = phi def
bb3
... = phi def
Added 2 more tests (This caught a bug where we broke the invariant of PHI being the first in the BB). Fixed.
LGTM.
Few more nitpicks, no need for more reviews.
lib/CodeGen/GlobalISel/LegalizerHelper.cpp | ||
---|---|---|
687 | Haha, nice catch! How did this work previously?! | |
test/CodeGen/AArch64/GlobalISel/legalize-phi.mir | ||
123 | Is there any interest in keeping the IR around? | |
337 | Could you check that we insert the G_TRUNC at the right place? | |
404 | Ditto. |
lib/CodeGen/GlobalISel/LegalizerHelper.cpp | ||
---|---|---|
687 | Previously I only had one G_PHI at a time in a test. If we setInsertPt to MI (the G_PHI being legalized) and then With 2 G_PHIs, we would end up with | |
test/CodeGen/AArch64/GlobalISel/legalize-phi.mir | ||
123 | My only use of the IR is that I find it easier to read LLVM-IR than MIR to see what the function is doing. That said, in this test (with a test description), we shouldn't need it. I'll clean this up before pushing. |
Add a newline