[all-commits] [llvm/llvm-project] 6d1291: [LoongArch] Add DAG combine for horizontal widenin...

hev via All-commits all-commits at lists.llvm.org
Tue Jun 16 01:49:39 PDT 2026


  Branch: refs/heads/users/hev/vhw
  Home:   https://github.com/llvm/llvm-project
  Commit: 6d12916c9d1675b23f4615ae88f7b3e11c64761b
      https://github.com/llvm/llvm-project/commit/6d12916c9d1675b23f4615ae88f7b3e11c64761b
  Author: WANG Rui <wangrui at loongson.cn>
  Date:   2026-06-16 (Tue, 16 Jun 2026)

  Changed paths:
    M llvm/lib/Target/LoongArch/LoongArchISelLowering.cpp
    M llvm/lib/Target/LoongArch/LoongArchLASXInstrInfo.td
    M llvm/lib/Target/LoongArch/LoongArchLSXInstrInfo.td

  Log Message:
  -----------
  [LoongArch] Add DAG combine for horizontal widening add/sub

Add a DAG combine to recognize horizontal widening add/subtract patterns
and lower them to the corresponding LSX/LASX instructions.

The following pattern is matched for both signed and unsigned variants:

```
  ADD/SUB(SEXT/ZEXT(BUILD_VECTOR(extract_elt(vj, 1), extract_elt(vj, 3), ...)),
          SEXT/ZEXT(BUILD_VECTOR(extract_elt(vk, 0), extract_elt(vk, 2), ...)))
```

This covers the following instructions:

```
  LSX:  VHADDW.H.B,  VHADDW.W.H,  VHADDW.D.W
        VHADDW.HU.BU, VHADDW.WU.HU, VHADDW.DU.WU
        VHSUBW.H.B,  VHSUBW.W.H,  VHSUBW.D.W
        VHSUBW.HU.BU, VHSUBW.WU.HU, VHSUBW.DU.WU

  LASX: XVHADDW.H.B,  XVHADDW.W.H,  XVHADDW.D.W
        XVHADDW.HU.BU, XVHADDW.WU.HU, XVHADDW.DU.WU
        XVHSUBW.H.B,  XVHSUBW.W.H,  XVHSUBW.D.W
        XVHSUBW.HU.BU, XVHSUBW.WU.HU, XVHSUBW.DU.WU
```

The Q_D variants (VHADDW.Q.D, VHSUBW.Q.D and their unsigned counterparts)
are not handled here because the result type v1i128 is not yet legalized
in the backend.


  Commit: 9a7e672cfda79f70443da036431d9082d1be4765
      https://github.com/llvm/llvm-project/commit/9a7e672cfda79f70443da036431d9082d1be4765
  Author: WANG Rui <wangrui at loongson.cn>
  Date:   2026-06-16 (Tue, 16 Jun 2026)

  Changed paths:
    M llvm/lib/Target/LoongArch/LoongArchISelLowering.cpp
    M llvm/test/CodeGen/LoongArch/lasx/vhaddw.ll
    M llvm/test/CodeGen/LoongArch/lasx/vhsubw.ll
    M llvm/test/CodeGen/LoongArch/lsx/vhaddw.ll
    M llvm/test/CodeGen/LoongArch/lsx/vhsubw.ll

  Log Message:
  -----------
  Fix DAG combine for illegal vector types


Compare: https://github.com/llvm/llvm-project/compare/bb593e52dfe9...9a7e672cfda7

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