[llvm] [AMDGPU] Fix VOP3P NEG fold to check the use opcode, not the def (PR #219728)

Arseniy Obolenskiy via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 8 02:30:20 PDT 2026


================
@@ -5163,9 +5164,37 @@ calcNextStatus(std::pair<Register, SrcStatus> Curr,
   return std::nullopt;
 }
 
-/// This is used to control valid status that current MI supports. For example,
-/// non floating point intrinsic such as @llvm.amdgcn.sdot2 does not support NEG
-/// bit on VOP3P.
+/// Packed integer VOP3P opcodes ignore NEG/NEG_HI, so folding a G_FNEG into
+/// them would silently drop the negation.
+static bool usesFPSrcMods(const MachineInstr &MI) {
+  unsigned Opc = MI.getOpcode();
+  if (isPreISelGenericFloatingPointOpcode(Opc))
+    return true;
+
+  // To re-audit, collect the direct parent of each "(VOP3PMods" in
+  // AMDGPUGenGlobalISel.inc.
+  switch (Opc) {
+  case TargetOpcode::G_STRICT_FADD:
+  case TargetOpcode::G_STRICT_FMUL:
+  case TargetOpcode::G_STRICT_FMA:
----------------
aobolensk wrote:

Moved

https://github.com/llvm/llvm-project/pull/219728


More information about the llvm-commits mailing list