This was noted as a regression in the post-commit feedback for D112634 (where we canonicalized IR differently).
For x86, this saves a few instruction bytes. AArch64 seems neutral.
Paths
| Differential D139363
[SDAG] try to convert bit set/clear to signbit test when trunc is free ClosedPublic Authored by spatel on Dec 5 2022, 1:09 PM.
Details Summary This was noted as a regression in the post-commit feedback for D112634 (where we canonicalized IR differently). For x86, this saves a few instruction bytes. AArch64 seems neutral.
Diff Detail
Event TimelineHerald added subscribers: StephenFan, frasercrmck, luismarques and 24 others. · View Herald Transcript Comment Actions What about if we limited this to just feeding select / brcond ?
Comment Actions Oh I also had started working on the same thing (should have been more clear that about that when talking in the other diff). Anyway you went for the same solution (and managed to do in a couple fewer lines than me), thanks for working on it! Added a comment about interesting effects in some tests, either way LGTM.
This revision is now accepted and ready to land.Dec 5 2022, 2:05 PM spatel added inline comments.
spatel marked an inline comment as done. Comment ActionsPatch updated:
Comment Actions
There's a maze of potential setcc and shift/logic folds, but I think this is the right match (more limited for now at least by the legality checks). It should be better (less likely to miss folds) to adjust the larger pattern matches that reduce and/or of setcc via shifts/masks to recognize this form if needed. This revision was landed with ongoing or failed builds.Dec 6 2022, 8:36 AM Closed by commit rGadc7c589c3dd: [SDAG] try to convert bit set/clear to signbit test when trunc is free (authored by spatel). · Explain Why This revision was automatically updated to reflect the committed changes.
Revision Contents
Diff 480506 llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
llvm/test/CodeGen/AArch64/signbit-test.ll
llvm/test/CodeGen/X86/btq.ll
llvm/test/CodeGen/X86/masked_compressstore.ll
llvm/test/CodeGen/X86/masked_expandload.ll
llvm/test/CodeGen/X86/masked_gather.ll
llvm/test/CodeGen/X86/masked_load.ll
llvm/test/CodeGen/X86/masked_store.ll
llvm/test/CodeGen/X86/masked_store_trunc.ll
llvm/test/CodeGen/X86/masked_store_trunc_ssat.ll
llvm/test/CodeGen/X86/masked_store_trunc_usat.ll
llvm/test/CodeGen/X86/omit-urem-of-power-of-two-or-zero-when-comparing-with-zero.ll
llvm/test/CodeGen/X86/signbit-test.ll
llvm/test/CodeGen/X86/test-vs-bittest.ll
|
Move hasOneUse() to end of the if() condition as its heaviest test?