This is an archive of the discontinued LLVM Phabricator instance.

[CodeGen] Fix incorrectly detected reduction bug in ComplexDeinterleaving pass
ClosedPublic

Authored by igor.kirillov on Jul 6 2023, 5:08 AM.

Details

Summary

Using ACLE intrinsics, it is possible to create a loop that the
deinterleaving pass incorrectly classified as a reduction loop.
For example, for fixed-width vectors the loop was like below:

vector.body:

%a = phi <4 x float> [ %init.a, %entry ], [ %updated.a, %vector.body ]
%b = phi <4 x float> [ %init.b, %entry ], [ %updated.b, %vector.body ]
...

; Does not depend on %a or %b:

%updated.a = ...
%updated.b = ...

Diff Detail

Event Timeline

igor.kirillov created this revision.Jul 6 2023, 5:08 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 6 2023, 5:08 AM
igor.kirillov requested review of this revision.Jul 6 2023, 5:08 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 6 2023, 5:08 AM
mgabka added a comment.Jul 6 2023, 5:28 AM

Could you improve commit message description as well?

llvm/test/CodeGen/AArch64/complex-deinterleaving-reductions.ll
241

there is no attribute like that, I guess it can be removed, or if attribute was relevant for this test it needs to be added

241

I have a general comment about this test, to me looks like it can be simplified and do not use the aarch64 specific intrinsics, isn't it the case that we have only fadd here but no load/store instructions?

igor.kirillov edited the summary of this revision. (Show Details)

Update test and commit message

igor.kirillov marked 2 inline comments as done.Jul 6 2023, 8:53 AM
glandium resigned from this revision.Jul 6 2023, 12:38 PM

That fixes the crash for me.

In the proposed new commit message you mention neon, but to me looks like the bug isn't neon specific, and could be triggered by scalable vectors, am I correct?
shall we have a separate test for scalable vectors?

If that is correct could you adjust the commit message?

llvm/test/CodeGen/AArch64/complex-deinterleaving-reductions.ll
241

Thanks Igor for adjusting the test, I have a few more comments/requests:

  1. Could you change the function name to something more descriptive? Like incorrect_reduction_pattern or something similar
  2. remove the numbers fro, variable names (it will make it easier to read)
igor.kirillov edited the summary of this revision. (Show Details)

Update test and commit message

igor.kirillov marked an inline comment as done.Jul 7 2023, 4:15 AM

I adjusted the commit message rather than adding a test. It doesn't matter if vectors are scalable or fixed-width cause code that processes PHINodes does not behave differently. So I think adding a scalable test doesn't add more coverage.

mgabka accepted this revision.Jul 10 2023, 3:03 AM

Hi Igor,
"Advanced SIMD" in aarch64 means neon.

Could you change the commit message to something like:

By using ACLE intrinsics, it is possible to create a loop that the deinterleaving pass incorrectly classified as a reduction loop.
For example for fixed width vectors the loop was like below:

vector.body:

%a = phi <4 x float> [ %init.a, %entry ], [ %updated.a, %vector.body ]
%b = phi <4 x float> [ %init.b, %entry ], [ %updated.b, %vector.body ]
...
; Does not depend on %a or %b:

%updated.a = ...
%updated.b = ...

This revision is now accepted and ready to land.Jul 10 2023, 3:03 AM
igor.kirillov edited the summary of this revision. (Show Details)

Rebase and update commit message