This is an archive of the discontinued LLVM Phabricator instance.

[GlobalISel] Implement commuting shl (add/or x, c1), c2 -> add/or (shl x, c2), c1 << c2
ClosedPublic

Authored by aemerson on May 7 2023, 10:16 PM.

Details

Summary

There's a target hook that's called in DAGCombiner that we stub here, I'll
implement the equivalent override for AArch64 in a subsequent patch since it's
used by different shift combine.

This change by itself has minor code size improvements on arm64 -Os CTMark:

Program                                       size.__text
                                              outputg181ppyy output8av1cxfn diff
consumer-typeset/consumer-typeset             410648.00      410648.00       0.0%
tramp3d-v4/tramp3d-v4                         364176.00      364176.00       0.0%
kimwitu++/kc                                  449216.00      449212.00      -0.0%
7zip/7zip-benchmark                           576128.00      576120.00      -0.0%
sqlite3/sqlite3                               285108.00      285100.00      -0.0%
SPASS/SPASS                                   411720.00      411688.00      -0.0%
ClamAV/clamscan                               379868.00      379764.00      -0.0%
Bullet/bullet                                 452064.00      451928.00      -0.0%
mafft/pairlocalalign                          246184.00      246108.00      -0.0%
lencod/lencod                                 428524.00      428152.00      -0.1%
                           Geomean difference                               -0.0%

Diff Detail

Event Timeline

aemerson created this revision.May 7 2023, 10:16 PM
aemerson requested review of this revision.May 7 2023, 10:16 PM
tschuett added inline comments.
llvm/include/llvm/CodeGen/TargetLowering.h
4043

MI?

aemerson updated this revision to Diff 520430.May 8 2023, 10:13 AM

Fix comment.

paquette added inline comments.May 8 2023, 10:24 AM
llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp
1647

should this go before the calls to mi_match?

aemerson updated this revision to Diff 520484.May 8 2023, 2:58 PM

Move target hook call earlier.

paquette accepted this revision.May 8 2023, 3:39 PM

LGTM

This revision is now accepted and ready to land.May 8 2023, 3:39 PM