[PATCH] D121598: [RISCV] Select SRLI+SLLI for AND with leading ones mask

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 14 10:10:41 PDT 2022


craig.topper added inline comments.


================
Comment at: llvm/test/CodeGen/RISCV/and.ll:103
+; RV64I-NEXT:    lui a1, 256
+; RV64I-NEXT:    addiw a1, a1, -1
+; RV64I-NEXT:    slli a1, a1, 12
----------------
Should we use srliw and slliw here?


================
Comment at: llvm/test/CodeGen/RISCV/copysign-casts.ll:32
 ; RV32I:       # %bb.0:
-; RV32I-NEXT:    lui a3, 524288
-; RV32I-NEXT:    and a2, a2, a3
+; RV32I-NEXT:    srli a2, a2, 31
+; RV32I-NEXT:    slli a2, a2, 31
----------------
Is this worse if the AND is in a loop? The LUI could be hoisted out of the out loop, but the shifts can't.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D121598/new/

https://reviews.llvm.org/D121598



More information about the llvm-commits mailing list