Diff Detail
Event Timeline
llvm/test/Transforms/InstCombine/add4.ll | ||
---|---|---|
161 | This doesn't match the code. Did you intend to commute the final add operands? In general, I find it easier to follow the pattern progression if you name the values based on the operation. For example: %m = mul i32 %x, 5 %a = add i32 %x, 42 |
We should have tests with extra uses too, so it's clear that the transforms are not creating too many instructions.
Also, change at least one test to use vector types, so we know it works across different types.
llvm/test/Transforms/InstCombine/add4.ll | ||
---|---|---|
161 | Yes, at the 1st step, I'll swap the add operands when the mul on the right. Thanks for your demo case, I rename the values. |
llvm/test/Transforms/InstCombine/add4.ll | ||
---|---|---|
169 | This isn't a different commuted pattern than above. Did you want to commute operands for %a0? | |
170 | I don't understand the motivation to include tests that will be converted to something else (shl) when we also have an explicit test for the shl patterns below here. If we make this mul with some arbitrary constant (for example, 42), then it is clear that we are testing the various commuted pattern possibilities for a real mul (there should be 4 of those?). If you want to add more tests to verify that shl transforms are working, then write the IR and the test comments in that form to begin, so we are not relying on some other transform to produce the pattern that is tested. |
llvm/test/Transforms/InstCombine/add4.ll | ||
---|---|---|
169 | Yes, the case mul_add_common_factor_commute1 has the operand mul on the operand 1, and So I'll swap the operands for mul_add_common_factor_commute1 at the 1st step. Does it make sense ? or I add more detail comment for this tests? | |
170 | ok, I'll delete the case shl_add_common_factor_commute2 with shl as it relies other transform. |
a) delete the case shl_add_common_factor_commute2 with shl as it relies other transform
b) rename all the cases and delete the _commute to avoid the misunderstand.
we only the operands when the **mul **operand on the 2nd operand, so in fact it is not commute.
llvm/test/Transforms/InstCombine/add4.ll | ||
---|---|---|
170 | If the code patch is going to affect patterns with shl, then we must have tests that include shl. Do we need both mul and shl tests? |
llvm/test/Transforms/InstCombine/add4.ll | ||
---|---|---|
170 |
|
Please add other reviewers to help review this.
There is some miscommunication happening, and I'm not sure how to fix it:
- You said that we would not test shl patterns, but the tests have shl (X * 4) --> (X << 2)
- I asked about commuting %a0 (currently at line 169), but there is still no coverage for %a0 = add i32 %y, %x ?
llvm/lib/Transforms/InstCombine/InstructionCombining.cpp | ||
---|---|---|
775 ↗ | (On Diff #471575) | The brackets that you are proposing to remove are likely protecting against shadow variable declaration compile-time warnings. Please remove this diff from this patch. I suggest one of the following to improve this code (as a separate commit):
|
llvm/lib/Transforms/InstCombine/InstructionCombining.cpp | ||
---|---|---|
775 ↗ | (On Diff #471575) | Thanks for suggestion, addressed in https://reviews.llvm.org/D137019 |
rebase as D137019 and address the remained comment
a) Add commute case mul_add_common_factor_2_commute
b) Add shl tests
llvm/test/Transforms/InstCombine/add4.ll | ||
---|---|---|
151 | As I wrote previously, this is not a good test of "x*4". It is a test of "x<<2" as shown by the CHECKs. Hopefully, other reviewers can explain this better. Since I can't seem to get this point across, I'll resign. |
Delete all the case with "x*4", as it is in fact same to the test of "x<<2", such as mul_add_common_factor_1 and shl_add_common_factor_1
llvm/test/Transforms/InstCombine/add4.ll | ||
---|---|---|
151 | Sorry for missing addressing |
As I wrote previously, this is not a good test of "x*4". It is a test of "x<<2" as shown by the CHECKs.
Unit-tests should avoid other transforms, so they do not break or become meaningless from independent changes.
Hopefully, other reviewers can explain this better. Since I can't seem to get this point across, I'll resign.