[PATCH] D147368: [LoongArch] Optimize bitwise and with immediates

WÁNG Xuěruì via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 31 23:56:12 PDT 2023


xen0n added inline comments.


================
Comment at: llvm/test/CodeGen/LoongArch/ir-instruction/and.ll:311-312
 ; LA64:       # %bb.0:
-; LA64-NEXT:    lu12i.w $a1, 15
-; LA64-NEXT:    ori $a1, $a1, 4080
-; LA64-NEXT:    and $a0, $a0, $a1
+; LA64-NEXT:    bstrpick.d $a0, $a0, 11, 0
+; LA64-NEXT:    slli.d $a0, $a0, 4
 ; LA64-NEXT:    ret
----------------
Seems wrong? The intended operation is to retain only `a[15:4]` so we should `bstrpick.d $a0, $a0, 15, 4` to retain bits, then `slli.d $a0, $a0, 4` to restore the LSB position. (LoongArch `bstrpick` invariably stores to `rd`'s LSB side, and will not retain the original relative position.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147368



More information about the llvm-commits mailing list