]> granicus.if.org Git - llvm/commitdiff
[X86] Make PLCMULQDQ instructions commutable during isel to fold loads.
authorCraig Topper <craig.topper@intel.com>
Sat, 16 Sep 2017 23:18:50 +0000 (23:18 +0000)
committerCraig Topper <craig.topper@intel.com>
Sat, 16 Sep 2017 23:18:50 +0000 (23:18 +0000)
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

lib/Target/X86/X86InstrSSE.td

index 18cd3e0de749c0caf6917e422eac6638460f2bd3..272dad13f9db5f133c6cf6f0a0e4f57eb8b8d111 100644 (file)
@@ -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 : SDNodeXForm<imm, [{
+  uint8_t Imm = N->getZExtValue();
+  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<string asm, int immop> {
   def : InstAlias<!strconcat("pclmul", asm, "dq {$src, $dst|$dst, $src}"),