This is an archive of the discontinued LLVM Phabricator instance.

[SLP] Use vector types for cmp alt instructions costs
ClosedPublic

Authored by dmgreen on Jun 22 2023, 1:09 AM.

Details

Summary

Similar to the other code that costs main/alt instructions, the cmp should be using the VecTy for the costs, not the ScalarTy.

One of the tests look like it gets worse just because it is not simplified to 0.

Diff Detail

Event Timeline

dmgreen created this revision.Jun 22 2023, 1:09 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 22 2023, 1:09 AM
Herald added a subscriber: hiraditya. · View Herald Transcript
dmgreen requested review of this revision.Jun 22 2023, 1:09 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 22 2023, 1:09 AM

The test patch won't apply cleanly to top of trunk.

llvm/test/Transforms/SLPVectorizer/AArch64/extracts-from-scalarizable-vector.ll
2

Perhaps set the -slp-threshold such that it gets vectorized?

The test patch won't apply cleanly to top of trunk.

Yeah I have not committed the updated tests yet. It is common practice to split them out to show just the differences, and I tend to keep them locally until the patch gets further into a review in case they need more adjustment. I can commit them if it's useful, but you can grab the new file using the View Options -> Show Raw File (Right) button. Or do you mean the code in the SLPVectorizer? I think that sound apply to a recent checkout.

llvm/test/Transforms/SLPVectorizer/AArch64/extracts-from-scalarizable-vector.ll
2

The idea is that these shouldn't be vectorized. The degenerate case would get simplified by instsimplify to ret 0, so is not interesting. The with_inputs case doesn't gain anything from vectorization (the f128 fcmp's will just be scalarized, so the vectorized version has are twice as many fcmp, plus extra shuffles and the reduce).

Yeah I have not committed the updated tests yet. It is common practice to split them out to show just the differences, and I tend to keep them locally until the patch gets further into a review in case they need more adjustment. I can commit them if it's useful, but you can grab the new file using the View Options -> Show Raw File (Right) button. Or do you mean the code in the SLPVectorizer? I think that sound apply to a recent checkout.

I meant to say the test hunk, sorry about that. You don't need to commit the first part, but it sometimes helps if it is shared on phabricator. In this case I was a bit confused as I could not tell what changes were made in the test compared to the existing version. In particular, I could not see the original @test function, but I could see a function named @degenerate which looked very much like @test, but it was not immediately obvious if only the its name was changed or if there were changes in its body.

llvm/test/Transforms/SLPVectorizer/AArch64/extracts-from-scalarizable-vector.ll
2

I understand that this can be simplified, but isn't this test checking that SLP matches and generates the llvm.vector.reduce.and pattern? Or is there a separate test for that?

dmgreen added inline comments.Jun 28 2023, 10:21 AM
llvm/test/Transforms/SLPVectorizer/AArch64/extracts-from-scalarizable-vector.ll
2

According to https://reviews.llvm.org/rG403bd583a8cc1f041430ff1b236ab296a2acdc85 it was just added to protect against a crash. I left this version of the test as-is to make sure it remains valid.

This revision is now accepted and ready to land.Jun 28 2023, 10:24 AM
This revision was landed with ongoing or failed builds.Jun 28 2023, 1:02 PM
This revision was automatically updated to reflect the committed changes.