Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RISCV] Add test case for CASE_VFMA_CHANGE_OPCODE_VV to handle MF4 pseudos #88947

Merged
merged 2 commits into from
Apr 18, 2024

Conversation

michaelmaitland
Copy link
Contributor

@michaelmaitland michaelmaitland commented Apr 16, 2024

The fix was committed in 8cee94e. This adds a test.

@llvmbot
Copy link
Collaborator

llvmbot commented Apr 16, 2024

@llvm/pr-subscribers-backend-risc-v

Author: Michael Maitland (michaelmaitland)

Changes

This was a mistake that I did not realize and we did not have coverage for.


Full diff: https://github.com/llvm/llvm-project/pull/88947.diff

2 Files Affected:

  • (modified) llvm/lib/Target/RISCV/RISCVInstrInfo.cpp (+1-1)
  • (added) llvm/test/CodeGen/RISCV/rvv/change-vmadd-to-vmacc.mir (+45)
diff --git a/llvm/lib/Target/RISCV/RISCVInstrInfo.cpp b/llvm/lib/Target/RISCV/RISCVInstrInfo.cpp
index 508f607fab20fd..ccabee2e32c4b0 100644
--- a/llvm/lib/Target/RISCV/RISCVInstrInfo.cpp
+++ b/llvm/lib/Target/RISCV/RISCVInstrInfo.cpp
@@ -2950,7 +2950,7 @@ bool RISCVInstrInfo::findCommutedOpIndices(const MachineInstr &MI,
   CASE_VFMA_CHANGE_OPCODE_LMULS_M1(OLDOP, NEWOP, TYPE, SEW)
 
 #define CASE_VFMA_CHANGE_OPCODE_VV(OLDOP, NEWOP)                               \
-  CASE_VFMA_CHANGE_OPCODE_LMULS_MF2(OLDOP, NEWOP, VV, E16)                     \
+  CASE_VFMA_CHANGE_OPCODE_LMULS_MF4(OLDOP, NEWOP, VV, E16)                     \
   CASE_VFMA_CHANGE_OPCODE_LMULS_MF2(OLDOP, NEWOP, VV, E32)                     \
   CASE_VFMA_CHANGE_OPCODE_LMULS_M1(OLDOP, NEWOP, VV, E64)
 
diff --git a/llvm/test/CodeGen/RISCV/rvv/change-vmadd-to-vmacc.mir b/llvm/test/CodeGen/RISCV/rvv/change-vmadd-to-vmacc.mir
new file mode 100644
index 00000000000000..81d36890ccae79
--- /dev/null
+++ b/llvm/test/CodeGen/RISCV/rvv/change-vmadd-to-vmacc.mir
@@ -0,0 +1,45 @@
+# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py UTC_ARGS: --version 4
+# RUN: llc -mtriple=riscv32 -mattr=+v,+zfh,+zvfh,+f,+d -riscv-v-vector-bits-min=128 -run-pass=machine-cse -o - %s | FileCheck %s
+
+---
+name:   test
+alignment:       4
+tracksRegLiveness: true
+constants:
+  - id:              0
+    value:           half 0xHC200
+    alignment:       2
+    isTargetSpecific: false
+  - id:              1
+    value:           half 0xH3C00
+    alignment:       2
+    isTargetSpecific: false
+  - id:              2
+    value:           half 0xHB800
+    alignment:       2
+    isTargetSpecific: false
+body:             |
+  bb.0:
+    ; CHECK-LABEL: name: test
+    ; CHECK: [[LUI:%[0-9]+]]:gpr = LUI target-flags(riscv-hi) %const.0
+    ; CHECK-NEXT: [[ADDI:%[0-9]+]]:gpr = ADDI killed [[LUI]], target-flags(riscv-lo) %const.0
+    ; CHECK-NEXT: [[PseudoVLSE16_V_MF4_:%[0-9]+]]:vr = PseudoVLSE16_V_MF4 $noreg, killed [[ADDI]], $x0, 2, 4 /* e16 */, 3 /* ta, ma */ :: (load (s16) from constant-pool)
+    ; CHECK-NEXT: [[LUI1:%[0-9]+]]:gpr = LUI target-flags(riscv-hi) %const.1
+    ; CHECK-NEXT: [[ADDI1:%[0-9]+]]:gpr = ADDI killed [[LUI1]], target-flags(riscv-lo) %const.1
+    ; CHECK-NEXT: [[PseudoVLSE16_V_MF4_1:%[0-9]+]]:vr = PseudoVLSE16_V_MF4 $noreg, killed [[ADDI1]], $x0, 2, 4 /* e16 */, 3 /* ta, ma */ :: (load (s16) from constant-pool)
+    ; CHECK-NEXT: [[PseudoVFRSQRT7_V_MF4_E16_:%[0-9]+]]:vr = nofpexcept PseudoVFRSQRT7_V_MF4_E16 $noreg, killed [[PseudoVLSE16_V_MF4_1]], 2, 4 /* e16 */, 3 /* ta, ma */
+    ; CHECK-NEXT: [[PseudoVFMADD_VV_MF4_E16_:%[0-9]+]]:vr = ninf contract afn nofpexcept PseudoVFMADD_VV_MF4_E16 [[PseudoVFRSQRT7_V_MF4_E16_]], [[PseudoVFRSQRT7_V_MF4_E16_]], killed [[PseudoVLSE16_V_MF4_]], 7, 2, 4 /* e16 */, 3 /* ta, ma */, implicit $frm
+    ; CHECK-NEXT: $v8 = COPY [[PseudoVFMADD_VV_MF4_E16_]]
+    ; CHECK-NEXT: PseudoRET implicit $v8
+    %0:gpr = LUI target-flags(riscv-hi) %const.0
+    %1:gpr = ADDI killed %0, target-flags(riscv-lo) %const.0
+    %2:vr = PseudoVLSE16_V_MF4 $noreg, killed %1, $x0, 2, 4 /* e16 */, 3 :: (load (s16) from constant-pool)
+    %3:gpr = LUI target-flags(riscv-hi) %const.1
+    %4:gpr = ADDI killed %3, target-flags(riscv-lo) %const.1
+    %5:vr = PseudoVLSE16_V_MF4 $noreg, killed %4, $x0, 2, 4 /* e16 */, 3 :: (load (s16) from constant-pool)
+    %6:vr = nofpexcept PseudoVFRSQRT7_V_MF4_E16 $noreg, killed %5, 2, 4 /* e16 */, 3 /* ta, ma */
+    %7:vr = ninf contract afn nofpexcept PseudoVFMADD_VV_MF4_E16 %6, %6, killed %2, 7, 2, 4 /* e16 */, 3 /* ta, ma */, implicit $frm
+    $v8 = COPY %7
+    PseudoRET implicit $v8
+
+...

Copy link
Contributor

@wangpc-pp wangpc-pp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@@ -2950,7 +2950,7 @@ bool RISCVInstrInfo::findCommutedOpIndices(const MachineInstr &MI,
CASE_VFMA_CHANGE_OPCODE_LMULS_M1(OLDOP, NEWOP, TYPE, SEW)

#define CASE_VFMA_CHANGE_OPCODE_VV(OLDOP, NEWOP) \
CASE_VFMA_CHANGE_OPCODE_LMULS_MF2(OLDOP, NEWOP, VV, E16) \
CASE_VFMA_CHANGE_OPCODE_LMULS_MF4(OLDOP, NEWOP, VV, E16) \
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was already commited in 8cee94e

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rebased and updated title/description

@michaelmaitland michaelmaitland changed the title [RISCV] Fix CASE_VFMA_CHANGE_OPCODE_VV to handle MF4 pseudos [RISCV] Add test case for CASE_VFMA_CHANGE_OPCODE_VV to handle MF4 pseudos Apr 17, 2024
Copy link
Collaborator

@topperc topperc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@michaelmaitland michaelmaitland merged commit e6ee191 into llvm:main Apr 18, 2024
3 of 4 checks passed
@michaelmaitland michaelmaitland deleted the fix-mf4-vfma branch April 18, 2024 13:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants