[llvm-branch-commits] [llvm] [LoongArch] Optimize for immediate value materialization using BSTRINS_D instruction (PR #106332)
via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Wed Aug 28 01:54:47 PDT 2024
================
@@ -41,11 +43,82 @@ LoongArchMatInt::InstSeq LoongArchMatInt::generateInstSeq(int64_t Val) {
Insts.push_back(Inst(LoongArch::ORI, Lo12));
}
+ // hi32
+ // Higher20
if (SignExtend32<1>(Hi20 >> 19) != SignExtend32<20>(Higher20))
Insts.push_back(Inst(LoongArch::LU32I_D, SignExtend64<20>(Higher20)));
+ // Highest12
if (SignExtend32<1>(Higher20 >> 19) != SignExtend32<12>(Highest12))
Insts.push_back(Inst(LoongArch::LU52I_D, SignExtend64<12>(Highest12)));
+ size_t N = Insts.size();
+ if (N < 3)
+ return Insts;
+
+ // When the number of instruction sequences is greater than 2, we have the
+ // opportunity to optimize using the BSTRINS_D instruction. The scenario is as
+ // follows:
+ //
+ // N of Insts = 3
+ // 1. ORI + LU32I_D + LU52I_D => ORI + BSTRINS_D, TmpVal = ORI
+ // 2. ADDI_W + LU32I_D + LU32I_D => ADDI_W + BSTRINS_D, TmpVal = ADDI_W
----------------
heiher wrote:
ADDI_W + LU32I_D + LU{52}I_D
https://github.com/llvm/llvm-project/pull/106332
More information about the llvm-branch-commits
mailing list