[all-commits] [llvm/llvm-project] e9bcd2: [LoongArch] Optimize *W Instructions at MI level (...

hev via All-commits all-commits at lists.llvm.org
Mon May 6 01:41:47 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: e9bcd2bf6775483a394e24772b66c2bbdf8f4c30
      https://github.com/llvm/llvm-project/commit/e9bcd2bf6775483a394e24772b66c2bbdf8f4c30
  Author: hev <wangrui at loongson.cn>
  Date:   2024-05-06 (Mon, 06 May 2024)

  Changed paths:
    M llvm/lib/Target/LoongArch/CMakeLists.txt
    M llvm/lib/Target/LoongArch/LoongArch.h
    M llvm/lib/Target/LoongArch/LoongArch.td
    M llvm/lib/Target/LoongArch/LoongArchISelLowering.cpp
    M llvm/lib/Target/LoongArch/LoongArchInstrInfo.cpp
    M llvm/lib/Target/LoongArch/LoongArchInstrInfo.h
    M llvm/lib/Target/LoongArch/LoongArchMachineFunctionInfo.h
    A llvm/lib/Target/LoongArch/LoongArchOptWInstrs.cpp
    M llvm/lib/Target/LoongArch/LoongArchTargetMachine.cpp
    M llvm/test/CodeGen/LoongArch/atomicrmw-uinc-udec-wrap.ll
    M llvm/test/CodeGen/LoongArch/gep-imm.ll
    M llvm/test/CodeGen/LoongArch/ir-instruction/add.ll
    M llvm/test/CodeGen/LoongArch/ir-instruction/atomic-cmpxchg.ll
    M llvm/test/CodeGen/LoongArch/ir-instruction/atomicrmw-fp.ll
    M llvm/test/CodeGen/LoongArch/ir-instruction/atomicrmw-minmax.ll
    M llvm/test/CodeGen/LoongArch/ir-instruction/atomicrmw.ll
    M llvm/test/CodeGen/LoongArch/opt-pipeline.ll
    A llvm/test/CodeGen/LoongArch/prefer-w-inst.ll
    M llvm/test/CodeGen/LoongArch/preferred-alignments.ll
    M llvm/test/CodeGen/LoongArch/sextw-removal.ll
    M llvm/utils/gn/secondary/llvm/lib/Target/LoongArch/BUILD.gn

  Log Message:
  -----------
  [LoongArch] Optimize *W Instructions at MI level (#90463)

Referring to RISC-V, adding an MI level pass to optimize *W instructions
for LoongArch.

First it removes unneeded sext(addi.w rd, rs, 0) instructions. Either
because the sign extended bits aren't consumed or because the input was
already sign extended by an earlier instruction.

Then:
1. Unless explicit disabled or the target prefers instructions with W
suffix, it removes the -w suffix from opw instructions whenever all
users are dependent only on the lower word of the result of the
instruction. The cases handled are:
* addi.w because it helps reduce test differences between LA32 and LA64
w/o being a pessimization.

2. Or if explicit enabled or the target prefers instructions with W
suffix, it adds the W suffix to the instruction whenever all users are
dependent only on the lower word of the result of the instruction. The
cases handled are:
   * add.d/addi.d/sub.d/mul.d.
   * slli.d with imm < 32.
   * ld.d/ld.wu.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list