[llvm] [AMDGPU] SIFoldOperands check that shrunk op is valid (PR #156298)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 3 01:10:53 PDT 2025


================
@@ -868,6 +868,8 @@ bool SIFoldOperandsImpl::tryAddToFoldList(
       // Make sure to get the 32-bit version of the commuted opcode.
       unsigned MaybeCommutedOpc = MI->getOpcode();
       Op32 = AMDGPU::getVOPe32(MaybeCommutedOpc);
+      if (TII->pseudoToMCOpcode(Op32) == -1)
----------------
arsenm wrote:

I think this check should be pulled into a helper function in SIInstrInfo instead of directly using pseudoToMCOpcode. We already have hasVALU32BitEncoding, but it returns a bool instead of the new opcode. Can you generalize that to return the shrunk opcode if valid?

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


More information about the llvm-commits mailing list