This is an archive of the discontinued LLVM Phabricator instance.

[SVE][CodeGen][DAGCombiner] Fix TypeSize warning in redundant store elimination
ClosedPublic

Authored by peterwaller-arm on Oct 19 2020, 7:30 AM.

Details

Summary

The modified code in visitSTORE was missing a scalable vector check, and still
using the now deprecated implicit cast of TypeSize to uint64_t through the
overloaded operator. This patch fixes these issues.

This brings the logic in line with the comment on the context line immediately
above the added precondition.

Add a test in sve-redundant-store.ll that the warning is not triggered.

Diff Detail

Event Timeline

peterwaller-arm requested review of this revision.Oct 19 2020, 7:30 AM
sdesmalen added inline comments.Oct 19 2020, 7:49 AM
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
17329

Now that we have the isKnownGE functions in TypeSize, it should be possible to check if the second store is greater than the first one, and if so, still mark the first one as redundant. But that may be more something to move into BaseIndexOffset::contains instead, and probably not something to do in this patch.

llvm/test/CodeGen/AArch64/Redundantstore.ll
1 ↗(On Diff #299046)

In other tests we've done this with:

; RUN: llc [commands here] < %s 2>%t | FileCheck %s
; RUN: FileCheck --check-prefix=WARN --allow-empty %s <%t

With a reference to some README file in case people run into this failure:

; If this check fails please read test/CodeGen/AArch64/README for instructions on how to resolve it.
; WARN-NOT: warning
38 ↗(On Diff #299046)

Missing CHECK lines to check that the optimisation is not applied?

Is it perhaps worth renaming the test to have sve in the name, i.e. sve-redundant-stores.ll? We've been following this convention for other tests.

peterwaller-arm marked an inline comment as done.Oct 19 2020, 8:50 AM

Is it perhaps worth renaming the test to have sve in the name, i.e. sve-redundant-stores.ll? We've been following this convention for other tests.

The other test in this file (to do with redundant stores) is not sve-specific. Should I put the new test in a separate file?

llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
17329

Agreed.

llvm/test/CodeGen/AArch64/Redundantstore.ll
1 ↗(On Diff #299046)

Ah, nifty thanks.

38 ↗(On Diff #299046)

Is this desirable? For the time being I was trying to prevent the reappearance of the warning. It seems to me that the optimization is legitimate.

peterwaller-arm marked an inline comment as done.

Address review comments.

  • Move test into its own file sve-redundant-stores.ll
  • Use WARN-NOT idiom
sdesmalen added inline comments.Oct 20 2020, 2:54 AM
llvm/test/CodeGen/AArch64/Redundantstore.ll
38 ↗(On Diff #299046)

I think it's desirable because the code will now do something different (i.e. it will no longer apply the transformation), so that's worth verifying.

llvm/test/CodeGen/AArch64/sve-redundant-store.ll
20

nit: you can also pass this as operand to the function.

peterwaller-arm edited the summary of this revision. (Show Details)

Address review comments:

  • Update llc test using utils/update_llc_test_checks.py.
  • Pass vector as operand to function to shrink test.
peterwaller-arm marked 3 inline comments as done.Oct 20 2020, 10:16 AM

Put back subject [tags] stripped by git am.

peterwaller-arm retitled this revision from Fix TypeSize warning in redundant store elimination to [SVE][CodeGen][DAGCombiner] Fix TypeSize warning in redundant store elimination.Oct 20 2020, 10:20 AM
david-arm accepted this revision.Oct 20 2020, 11:51 PM
This revision is now accepted and ready to land.Oct 20 2020, 11:51 PM
sdesmalen accepted this revision.Oct 21 2020, 1:10 AM

Thanks for the changes @peterwaller-arm, LGTM!