This is an archive of the discontinued LLVM Phabricator instance.

[ARM] Enable and/cmp0 folding
ClosedPublic

Authored by chill on Sep 21 2022, 6:51 AM.

Details

Summary

The CodeGenPrepare pass can sink bitwise and used by compare to
zero into the basic blocks where the users are. This operation is
guarded by lowering hook, which is disabled for ARM. In the ARM
architecture versions from v7-M up these two operations can be folded
into tst rN, #imm instruction. Sinking of and can also enable
the cmov-to-bfi DAG combiner.

This patch fixes some benchmark regressions caused
by https://reviews.llvm.org/D129370 as well scoring slightly better overall.

Diff Detail

Event Timeline

chill created this revision.Sep 21 2022, 6:51 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 21 2022, 6:51 AM
chill requested review of this revision.Sep 21 2022, 6:51 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 21 2022, 6:51 AM
dmgreen added inline comments.Sep 21 2022, 7:28 AM
llvm/lib/Target/ARM/ARMISelLowering.cpp
21204

Can this be called with a typesize > 64bits?

chill added inline comments.Sep 21 2022, 8:21 AM
llvm/lib/Target/ARM/ARMISelLowering.cpp
21204

Good point, I guess any bit width may come this way.

chill updated this revision to Diff 461908.Sep 21 2022, 8:37 AM
chill marked an inline comment as done.
efriedma added inline comments.Sep 21 2022, 11:55 AM
llvm/lib/Target/ARM/ARMISelLowering.cpp
21204

getSOImmVal() only applies in ARM mode, right? The Thumb equivalent is getT2SOImmVal().

chill updated this revision to Diff 462211.Sep 22 2022, 9:39 AM
chill marked an inline comment as done.Sep 22 2022, 9:39 AM
chill added inline comments.
llvm/lib/Target/ARM/ARMISelLowering.cpp
21204

Thanks! Fixed.

dmgreen accepted this revision.Sep 23 2022, 12:21 AM

Thanks. LGTM

This revision is now accepted and ready to land.Sep 23 2022, 12:21 AM
This revision was automatically updated to reflect the committed changes.
chill marked an inline comment as done.