diff options
author | Craig Topper <craig.topper@sifive.com> | 2022-05-11 10:58:10 -0700 |
---|---|---|
committer | Craig Topper <craig.topper@sifive.com> | 2022-05-11 11:13:17 -0700 |
commit | 0ebb02b90a47b43e039cb7040cc9fb7dd5ec5fce (patch) | |
tree | 55bea2569c89bb9cf436cb873973413b0fee1e89 /clang/lib/Frontend/CompilerInvocation.cpp | |
parent | 99ef341ce9436e0471eb5502a8521fcaddaf851c (diff) | |
download | llvm-0ebb02b90a47b43e039cb7040cc9fb7dd5ec5fce.zip llvm-0ebb02b90a47b43e039cb7040cc9fb7dd5ec5fce.tar.gz llvm-0ebb02b90a47b43e039cb7040cc9fb7dd5ec5fce.tar.bz2 |
[RISCV] Override TargetLowering::shouldProduceAndByConstByHoistingConstFromShiftsLHSOfAnd.
This hook determines if SimplifySetcc transforms (X & (C l>>/<< Y))
==/!= 0 into ((X <</l>> Y) & C) ==/!= 0. Where C is a constant and
X might be a constant.
The default implementation favors doing the transform if X is not
a constant. Otherwise the code is left alone. There is a provision
that if the target supports a bit test instruction then the transform
will favor ((1 << Y) & X) ==/!= 0. RISCV does not say it has a variable
bit test operation.
RISCV with Zbs does have a BEXT instruction that performs (X >> Y) & 1.
Without Zbs, (X >> Y) & 1 still looks preferable to ((1 << Y) & X) since
we can fold use ANDI instead of putting a 1 in a register for SLL.
This patch overrides this hook to favor bit extract patterns and
otherwise falls back to the "do the transform if X is not a constant"
heuristic.
I've added tests where both C and X are constants with both the shl form
and lshr form. I've also added a test for a switch statement that lowers
to a bit test. That was my original motivation for looking at this.
Reviewed By: asb
Differential Revision: https://reviews.llvm.org/D124639
Diffstat (limited to 'clang/lib/Frontend/CompilerInvocation.cpp')
0 files changed, 0 insertions, 0 deletions