Skip to content

[amdgpu] some VOP3 instructions not defined as commutable #111205

Closed
@yxsamliu

Description

@yxsamliu

some VOP3 instructions are commutable but are not defined as such. e.g.

# RUN: llc -mtriple=amdgcn -mcpu=gfx1030 -run-pass=machine-cse -verify-machineinstrs %s -o - 2>&1 | FileCheck --check-prefix=GCN %s
---
name: test_machine_cse_op_sel
body: |
  bb.0:
    %0:vgpr_32 = IMPLICIT_DEF
    %1:vgpr_32 = IMPLICIT_DEF
    %2:vgpr_32 = V_ADD_NC_U16_e64 0, %0, 0, %1, 0, 0, implicit $mode, implicit $exec
    %3:vgpr_32 = V_ADD_NC_U16_e64 0, %1, 0, %0, 0, 0, implicit $mode, implicit $exec
    DS_WRITE2_B32_gfx9 undef %4:vgpr_32, %2, %3, 0, 1, 0, implicit $exec
...

V_ADD_NC_U16_e64 is commutable but are not merged by machine-cse.

This issue was found during reviewing #106920

Two changes are needed:

  1. td files need to be updated for commutable VOP3 insts
  2. SIInstrInfo::commuteInstructionImpl need to be fixed to handle op_sel

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions