From: Craig Topper Date: Sat, 16 Sep 2017 23:18:50 +0000 (+0000) Subject: [X86] Make PLCMULQDQ instructions commutable during isel to fold loads. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f0a489a5b254ed0bc96f675c4368f031c9e7e789;p=llvm [X86] Make PLCMULQDQ instructions commutable during isel to fold loads. This adds new patterns and SDNodeXForm to enable the immediate to commuted. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@313472 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Target/X86/X86InstrSSE.td b/lib/Target/X86/X86InstrSSE.td index 18cd3e0de74..272dad13f9d 100644 --- a/lib/Target/X86/X86InstrSSE.td +++ b/lib/Target/X86/X86InstrSSE.td @@ -7315,6 +7315,27 @@ def PCLMULQDQrm : PCLMULIi8<0x44, MRMSrcMem, (outs VR128:$dst), Sched<[WriteCLMulLd, ReadAfterLd]>; } // Constraints = "$src1 = $dst" +// Immediate transform to help with commuting. +def PCLMULCommuteImm : SDNodeXFormgetZExtValue(); + return getI8Imm((uint8_t)((Imm >> 4) | (Imm << 4)), SDLoc(N)); +}]>; + +// We can commute a load in the first operand by swapping the sources and +// rotating the immediate. +let Predicates = [HasAVX, HasPCLMUL] in { + def : Pat<(int_x86_pclmulqdq (loadv2i64 addr:$src2), VR128:$src1, + (i8 imm:$src3)), + (VPCLMULQDQrm VR128:$src1, addr:$src2, + (PCLMULCommuteImm imm:$src3))>; +} + +let Predicates = [NoAVX, HasPCLMUL] in { + def : Pat<(int_x86_pclmulqdq (loadv2i64 addr:$src2), VR128:$src1, + (i8 imm:$src3)), + (PCLMULQDQrm VR128:$src1, addr:$src2, + (PCLMULCommuteImm imm:$src3))>; +} multiclass pclmul_alias { def : InstAlias