[all-commits] [llvm/llvm-project] c010b7: [HEXAGON] AddrModeOpt support for HVX and optimize...

Abinaya Saravanan via All-commits all-commits at lists.llvm.org
Fri Sep 13 16:48:55 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: c010b72e9b4e3b1ae7467eb86102fc43c338fe19
      https://github.com/llvm/llvm-project/commit/c010b72e9b4e3b1ae7467eb86102fc43c338fe19
  Author: Abinaya Saravanan <quic_asaravan at quicinc.com>
  Date:   2024-09-13 (Fri, 13 Sep 2024)

  Changed paths:
    M llvm/lib/Target/Hexagon/HexagonOptAddrMode.cpp
    A llvm/test/CodeGen/Hexagon/autohvx/addi-offset-opt-addr-mode.ll
    A llvm/test/CodeGen/Hexagon/autohvx/addi-opt-predicated-def-bug.ll
    M llvm/test/CodeGen/Hexagon/vgather-opt-addr.ll
    A llvm/test/CodeGen/MIR/Hexagon/addrmode-opt-nonreaching.mir

  Log Message:
  -----------
  [HEXAGON] AddrModeOpt support for HVX and optimize adds (#106368)

This patch does 3 things:
1. Add support for optimizing the address mode of HVX load/store
instructions
2. Reduce the value of Add instruction immediates by replacing with the
difference from other Addi instructions that share common base:

For Example, If we have the below sequence of instructions: r1 =
add(r2,# 1024) ... r3 = add(r2,# 1152) ... r4 = add(r2,# 1280)

Where the register r2 has the same reaching definition, They get
modified to the below sequence:

       r1 = add(r2,# 1024)
            ...
       r3 = add(r1,# 128)
            ...
       r4 = add(r1,# 256)
3. Fixes a bug pass where the addi instructions were modified based on a
predicated register definition, leading to incorrect output.

Eg:
         INST-1: if (p0) r2 = add(r13,# 128)
         INST-2: r1 = add(r2,# 1024)
         INST-3: r3 = add(r2,# 1152)
         INST-4: r5 = add(r2,# 1280)

In the above case, since r2's definition is predicated, we do not want
to modify the uses of r2 in INST-3/INST-4 with add(r1,#128/256)

4.Fixes a corner case

It looks like we never check whether the offset register is actually
live (not clobbered) at optimization site. Add the check whether it is
live at MBB entrance. The rest should have already been verified.

5. Fixes a bad codegen

For whatever reason we do transformation without checking if the value
in register actually reaches the user. This is second identical fix for
this pass.

   Co-authored-by: Anirudh Sundar <quic_sanirudh at quicinc.com>
   Co-authored-by: Sergei Larin <slarin at quicinc.com>



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