[all-commits] [llvm/llvm-project] b645bc: [RISCV] Generalize (srl (and X, 0xffff), C) -> (sr...
Craig Topper via All-commits
all-commits at lists.llvm.org
Sun Jan 9 23:38:07 PST 2022
Author: Craig Topper <craig.topper at sifive.com>
Date: 2022-01-09 (Sun, 09 Jan 2022)
[RISCV] Generalize (srl (and X, 0xffff), C) -> (srli (slli X, (XLen-16), (XLen-16) + C) optimization.
This can be generalized to (srl (and X, C2), C) ->
(srli (slli X, (XLen-C3), (XLen-C3) + C). Where C2 is a mask with
C3 trailing ones.
This can avoid constant materialization for C2. This is beneficial
even when C2 can be selected to ANDI because the SLLI can become
C.SLLI, but C.ANDI cannot cover all the immediates of ANDI.
This also enables CSE in some cases of i8 sdiv by constant codegen.
More information about the All-commits