This is an archive of the discontinued LLVM Phabricator instance.

Fix i1 vector reduction miscompilation
ClosedPublic

Authored by Sp00ph on Apr 18 2023, 4:30 PM.

Details

Summary

Previously, vecreduce_{and,or} vNi1 could lead to miscompilations because the legalizer first decides to any_ext the operand (which is correct for vecreduce_{and,or}) and then decides to use vecreduce_u{min,max} instead (for which any_ext is incorrect). This patch changes it so the vecreduce_u{min,max} operations use sign_ext instead of any_ext.

Issue: https://github.com/llvm/llvm-project/issues/62211

Diff Detail

Event Timeline

Sp00ph created this revision.Apr 18 2023, 4:30 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 18 2023, 4:30 PM
Sp00ph requested review of this revision.Apr 18 2023, 4:30 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 18 2023, 4:30 PM
Sp00ph updated this revision to Diff 514781.Apr 18 2023, 4:34 PM
craig.topper added inline comments.
llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
2303

Should this follow TLI.getBooleanContents?

Sp00ph updated this revision to Diff 514877.Apr 19 2023, 2:55 AM

Use getBooleanContents to decide how to extend the vectors. Also update some codegen tests which I forgot to update in the previous revision.

Sp00ph updated this revision to Diff 514916.Apr 19 2023, 5:25 AM
This revision is now accepted and ready to land.Apr 19 2023, 1:57 PM

I don't think I have commit access, so I believe someone else will have to commit the changes for me.

I don't think I have commit access, so I believe someone else will have to commit the changes for me.

I can do that. What name and email address should I use for the git commit log?

Make it Sp00ph and markuseverling@gmail.com please. Thank you!

This revision was landed with ongoing or failed builds.Apr 20 2023, 3:27 PM
This revision was automatically updated to reflect the committed changes.