[PATCH] D102893: [RISCV] Optimize xor/or with immediate in the zbs extension

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu May 20 22:14:30 PDT 2021


craig.topper added inline comments.


================
Comment at: llvm/test/CodeGen/RISCV/rv64zbs.ll:1426
 ; RV64IB:       # %bb.0:
-; RV64IB-NEXT:    lui a1, 2
-; RV64IB-NEXT:    addiw a1, a1, -2045
-; RV64IB-NEXT:    or a0, a0, a1
+; RV64IB-NEXT:    ori a0, a0, 3
+; RV64IB-NEXT:    bseti a0, a0, 11
----------------
benshi001 wrote:
> craig.topper wrote:
> > This isn't really an improvement.
> It saves an extra register.
With 32 registers, is that an important optimization? Are we also going to implement (BSETI (BSETI (BSETI))) for cases with 3 set bits where none are in the lower 11 bits so we can't use ORI/XORI? It starts getting out of hand.


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

https://reviews.llvm.org/D102893



More information about the llvm-commits mailing list