aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/MachineFunction.cpp
diff options
context:
space:
mode:
authorSanjay Patel <spatel@rotateright.com>2022-06-17 10:41:00 -0400
committerSanjay Patel <spatel@rotateright.com>2022-06-17 10:51:57 -0400
commitbfde8619355a06d9f1a199e9cb3f8d41aef5c05b (patch)
tree6364dba516b8741ba69ad5473c092bfbfb78176a /llvm/lib/CodeGen/MachineFunction.cpp
parent1a02c963e338100a3000734b91f5956da9b8c95e (diff)
downloadllvm-bfde8619355a06d9f1a199e9cb3f8d41aef5c05b.zip
llvm-bfde8619355a06d9f1a199e9cb3f8d41aef5c05b.tar.gz
llvm-bfde8619355a06d9f1a199e9cb3f8d41aef5c05b.tar.bz2
[InstCombine] convert mask and shift of power-of-2 to cmp+select
When the mask is a power-of-2 constant and op0 is a shifted-power-of-2 constant, test if the shift amount equals the offset bit index: (ShiftC << X) & C --> X == (log2(C) - log2(ShiftC)) ? C : 0 (ShiftC >> X) & C --> X == (log2(ShiftC) - log2(C)) ? C : 0 This is an alternate to D127610 with a more general pattern. We match only shift+and instead of the trailing xor, so we see a few more tests diffs. I think we discussed this initially in D126617. Here are proofs for shifts in both directions: https://alive2.llvm.org/ce/z/CFrLs4 The test diffs look equal or better for IR, and this makes the patterns more uniform in IR. The backend can partially invert this in both cases if that is profitable. It is not trivially reversible, however, so if we find perf regressions that are not easy to undo, then we may want to revert this. Differential Revision: https://reviews.llvm.org/D127801
Diffstat (limited to 'llvm/lib/CodeGen/MachineFunction.cpp')
0 files changed, 0 insertions, 0 deletions