[llvm] AMDGPU: Fix packed 16-bit inline constants (PR #76522)

Nicolai Hähnle via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 3 08:35:46 PST 2024


================
@@ -125,15 +125,6 @@ defm V_PK_LSHRREV_B16 : VOP3PInst<"v_pk_lshrrev_b16", VOP3P_Profile<VOP_V2I16_V2
 
 let SubtargetPredicate = HasVOP3PInsts in {
 
-// Undo sub x, c -> add x, -c canonicalization since c is more likely
-// an inline immediate than -c.
-// The constant will be emitted as a mov, and folded later.
-// TODO: We could directly encode the immediate now
-def : GCNPat<
-  (add (v2i16 (VOP3PMods v2i16:$src0, i32:$src0_modifiers)), NegSubInlineConstV216:$src1),
-  (V_PK_SUB_U16 $src0_modifiers, $src0, SRCMODS.OP_SEL_1, NegSubInlineConstV216:$src1)
->;
-
----------------
nhaehnle wrote:

* It didn't apply to GlobalISel
* It was redundant (and even in some cases counter-productive) with the logic in SIFoldOperands

I suppose the alternative would be to remove the corresponding logic in SIFoldOperands, fix it properly, and figure out how to appease the GlobalISel pattern matching gods. Though that would then still lead to there being multiple places that worry about optimizing these inline constants.

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


More information about the llvm-commits mailing list