This is an archive of the discontinued LLVM Phabricator instance.

[DAGCombiner] Fold avg(x, x) --> x
ClosedPublic

Authored by junaire on Apr 2 2023, 12:21 AM.

Details

Summary

Signed-off-by: Jun Zhang <jun@junz.org>

Diff Detail

Event Timeline

junaire created this revision.Apr 2 2023, 12:21 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 2 2023, 12:21 AM
junaire requested review of this revision.Apr 2 2023, 12:21 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 2 2023, 12:21 AM

Can you add coverage to aarch64 so we catch all ISD::AVG node types?

junaire updated this revision to Diff 510329.Apr 2 2023, 2:39 AM

arc diff git merge-base HEAD origin --update D147404 to fix patch application failure.

Can you add coverage to aarch64 so we catch all ISD::AVG node types?

I've created a parent revision. Let me know if that's what you want, please :)

junaire updated this revision to Diff 510331.Apr 2 2023, 2:44 AM

I screw it up with arc, sorry.

Thanks for the patch. I'm not sure about the X86 changes but I think if you add extra tests then all the AArch64 variants looks good.

RKSimon added inline comments.Apr 2 2023, 5:02 AM
llvm/test/CodeGen/AArch64/avg.ll
2 ↗(On Diff #510331)

Maybe just add coverage to https://github.com/llvm/llvm-project/blob/main/llvm/test/CodeGen/AArch64/hadd-combine.ll where the rest of the combines are already for ? AArch64 uses the term 'hadd' for halving-add averages AVGFLOORS/AVGFLOORU/AVGCEILS/AVGCEILU.

pengfei added inline comments.Apr 2 2023, 6:08 AM
llvm/test/CodeGen/X86/avg.ll
758–759

This and below are regressions.

junaire added inline comments.Apr 2 2023, 7:01 AM
llvm/test/CodeGen/X86/avg.ll
758–759

What makes AVX512F/BW so special? I have no clue about what happened.

junaire updated this revision to Diff 510398.Apr 2 2023, 10:14 PM

Perform combine after the types are legalized.

pengfei accepted this revision.Apr 3 2023, 1:02 AM

LGTM, thanks!

This revision is now accepted and ready to land.Apr 3 2023, 1:02 AM
junaire updated this revision to Diff 510428.Apr 3 2023, 1:54 AM

Update aarch64 tests

This revision was landed with ongoing or failed builds.Apr 3 2023, 1:58 AM
This revision was automatically updated to reflect the committed changes.