[PATCH] D147368: [LoongArch] Optimize bitwise and with immediates
Ben Shi via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sat Apr 1 00:18:43 PDT 2023
benshi001 marked an inline comment as done.
benshi001 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
----------------
xen0n wrote:
> 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.)
Thanks. I should not make such as mistake :(
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