[llvm] [AMDGPU] Prevent folding of the negative i32 literals as i64 (PR #70274)

Jay Foad via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 26 02:48:36 PDT 2023


================
@@ -5500,6 +5500,15 @@ bool SIInstrInfo::isOperandLegal(const MachineInstr &MI, unsigned OpIdx,
     if (Is64BitOp && !AMDGPU::isValid32BitLiteral(Imm, Is64BitFPOp) &&
         !AMDGPU::isInlinableLiteral64(Imm, ST.hasInv2PiInlineImm()))
       return false;
+
+    // FIXME: We can use sign extended 64-bit literals, but only for signed
+    //        operands. At the moment we do not know if an operand is signed.
+    //        Such operand will be encoded as its low 32 bits and then either
+    //        correctly sign extended or incorrectly zero extended by HW.
+    if (Is64BitOp && !Is64BitFPOp && isInt<32>(Imm) &&
----------------
jayfoad wrote:

I don't understand what the `isInt<32>` check is for. This should also apply to the `isUInt<32>` case, shouldn't it? So just remove that part?

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


More information about the llvm-commits mailing list