This is an archive of the discontinued LLVM Phabricator instance.

[AArch64] precommit tests for D136623, NFC
AbandonedPublic

Authored by Allen on Oct 27 2022, 8:28 PM.

Diff Detail

Event Timeline

Allen created this revision.Oct 27 2022, 8:28 PM
Herald added a project: Restricted Project. · View Herald TranscriptOct 27 2022, 8:28 PM
Allen requested review of this revision.Oct 27 2022, 8:28 PM
Herald added a project: Restricted Project. · View Herald TranscriptOct 27 2022, 8:28 PM
spatel added inline comments.Oct 28 2022, 7:01 AM
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.

Allen updated this revision to Diff 471556.Oct 28 2022, 8:06 AM

a) Add 2 more case, one use + vector
b) rename the values based on the operation

Allen marked an inline comment as done.Oct 28 2022, 8:10 AM
Allen added inline comments.
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.

spatel added inline comments.Oct 28 2022, 8:26 AM
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.

Allen marked an inline comment as done.Oct 28 2022, 8:48 AM
Allen added inline comments.
llvm/test/Transforms/InstCombine/add4.ll
169

Yes, the case mul_add_common_factor_commute1 has the operand mul on the operand 1, and
mul_add_common_factor_commute2 has the operand mul on the operand 0.

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.

Allen updated this revision to Diff 471575.Oct 28 2022, 9:09 AM

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.
spatel added inline comments.Oct 28 2022, 9:10 AM
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?

Allen added inline comments.Oct 28 2022, 9:23 AM
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:

  1. You said that we would not test shl patterns, but the tests have shl (X * 4) --> (X << 2)
  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):

  1. Rename the set of variables above with unique names (and adjust the code comments to match).
  2. Rename the set of variables here with unique names (and adjust the code comments to match).
  3. Create a helper function for the Factorization set of folds, so there is no confusion.
Allen marked an inline comment as done.Oct 29 2022, 6:12 AM
Allen added inline comments.
llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
775 ↗(On Diff #471575)

Thanks for suggestion, addressed in https://reviews.llvm.org/D137019

Allen updated this revision to Diff 471833.Oct 30 2022, 6:53 AM
Allen marked an inline comment as done.
Allen retitled this revision from [AArch64] precommit tests and code format for D136623, NFC to [AArch64] precommit tests for D136623, NFC.
Allen added reviewers: xbolva00, RKSimon, efriedma.

rebase as D137019 and address the remained comment
a) Add commute case mul_add_common_factor_2_commute
b) Add shl tests

Allen marked 3 inline comments as done.Oct 30 2022, 6:57 AM
Allen added inline comments.
llvm/test/Transforms/InstCombine/add4.ll
169

Added new case mul_add_common_factor_2_commute to commute operands for %a0

170

Added both mul and shl tests, thanks.

spatel resigned from this revision.Nov 8 2022, 5:00 AM
spatel added inline comments.
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.
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.

spatel added a subscriber: spatel.Nov 8 2022, 5:14 AM
Allen planned changes to this revision.Nov 10 2022, 2:44 AM
Allen marked an inline comment as done.
Allen updated this revision to Diff 493841.Jan 31 2023, 11:38 PM

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

Allen added inline comments.Jan 31 2023, 11:40 PM
llvm/test/Transforms/InstCombine/add4.ll
151

Sorry for missing addressing

Allen abandoned this revision.Jul 2 2023, 8:32 PM