[llvm-branch-commits] [llvm] ead71a2 - [PowerPC][AIX]Do not emit xxspltd mnemonic on AIX.

Sean Fertile via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Mon Jan 18 06:30:40 PST 2021


Author: Sean Fertile
Date: 2021-01-18T09:25:31-05:00
New Revision: ead71a23edde5f8a1acfdd75bd01f1fa6e0c4014

URL: https://github.com/llvm/llvm-project/commit/ead71a23edde5f8a1acfdd75bd01f1fa6e0c4014
DIFF: https://github.com/llvm/llvm-project/commit/ead71a23edde5f8a1acfdd75bd01f1fa6e0c4014.diff

LOG: [PowerPC][AIX]Do not emit xxspltd mnemonic on AIX.

A bug in the system assembler can assemble the xxspltd extended
menemonic into the wrong instruction (extracting the wrong element).
Emit the full xxpermdi with all operands to work around the problem.

Differential Revision: https://reviews.llvm.org/D94419

Added: 
    llvm/test/CodeGen/PowerPC/xxpermdi_mnemonics.s

Modified: 
    llvm/lib/Target/PowerPC/PPCInstrVSX.td
    llvm/test/MC/PowerPC/modern-aix-as.s

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/PowerPC/PPCInstrVSX.td b/llvm/lib/Target/PowerPC/PPCInstrVSX.td
index 136a53e66d62..2e45d731c953 100644
--- a/llvm/lib/Target/PowerPC/PPCInstrVSX.td
+++ b/llvm/lib/Target/PowerPC/PPCInstrVSX.td
@@ -4647,20 +4647,24 @@ def : InstAlias<"xvmovdp $XT, $XB",
 def : InstAlias<"xvmovsp $XT, $XB",
                 (XVCPSGNSP vsrc:$XT, vsrc:$XB, vsrc:$XB)>;
 
-def : InstAlias<"xxspltd $XT, $XB, 0",
-                (XXPERMDI vsrc:$XT, vsrc:$XB, vsrc:$XB, 0)>;
-def : InstAlias<"xxspltd $XT, $XB, 1",
-                (XXPERMDI vsrc:$XT, vsrc:$XB, vsrc:$XB, 3)>;
+// Certain versions of the AIX assembler may missassemble these mnemonics.
+let Predicates = [ModernAs] in {
+  def : InstAlias<"xxspltd $XT, $XB, 0",
+                  (XXPERMDI vsrc:$XT, vsrc:$XB, vsrc:$XB, 0)>;
+  def : InstAlias<"xxspltd $XT, $XB, 1",
+                  (XXPERMDI vsrc:$XT, vsrc:$XB, vsrc:$XB, 3)>;
+  def : InstAlias<"xxspltd $XT, $XB, 0",
+                  (XXPERMDIs vsrc:$XT, vsfrc:$XB, 0)>;
+  def : InstAlias<"xxspltd $XT, $XB, 1",
+                  (XXPERMDIs vsrc:$XT, vsfrc:$XB, 3)>;
+}
+
 def : InstAlias<"xxmrghd $XT, $XA, $XB",
                 (XXPERMDI vsrc:$XT, vsrc:$XA, vsrc:$XB, 0)>;
 def : InstAlias<"xxmrgld $XT, $XA, $XB",
                 (XXPERMDI vsrc:$XT, vsrc:$XA, vsrc:$XB, 3)>;
 def : InstAlias<"xxswapd $XT, $XB",
                 (XXPERMDI vsrc:$XT, vsrc:$XB, vsrc:$XB, 2)>;
-def : InstAlias<"xxspltd $XT, $XB, 0",
-                (XXPERMDIs vsrc:$XT, vsfrc:$XB, 0)>;
-def : InstAlias<"xxspltd $XT, $XB, 1",
-                (XXPERMDIs vsrc:$XT, vsfrc:$XB, 3)>;
 def : InstAlias<"xxswapd $XT, $XB",
                 (XXPERMDIs vsrc:$XT, vsfrc:$XB, 2)>;
 def : InstAlias<"mfvrd $rA, $XT",

diff  --git a/llvm/test/CodeGen/PowerPC/xxpermdi_mnemonics.s b/llvm/test/CodeGen/PowerPC/xxpermdi_mnemonics.s
new file mode 100644
index 000000000000..ec2e2646de8f
--- /dev/null
+++ b/llvm/test/CodeGen/PowerPC/xxpermdi_mnemonics.s
@@ -0,0 +1,53 @@
+; RUN: llc -mtriple powerpc64-ibm-aix-xcoff -mcpu=pwr8 --vec-extabi < %s | FileCheck --check-prefixes=CHECK,OLD %s
+; RUN: llc -mtriple powerpc-ibm-aix-xcoff -mcpu=pwr8 --vec-extabi < %s | FileCheck --check-prefixes=CHECK,OLD %s
+
+; RUN: llc -mtriple powerpc64-unknown-linux-gnu -mcpu=pwr8 < %s | FileCheck --check-prefixes=CHECK,MODERN  %s
+; RUN: llc -mtriple powerpc64-ibm-aix-xcoff -mcpu=pwr8 -mattr=+modern-aix-as --vec-extabi < %s | FileCheck --check-prefixes=CHECK,MODERN %s
+; RUN: llc -mtriple powerpc-ibm-aix-xcoff -mcpu=pwr8 -mattr=+modern-aix-as --vec-extabi < %s | FileCheck --check-prefixes=CHECK,MODERN %s
+
+define <2 x double> @splat1(<2 x double> %A, <2 x double> %B) {
+entry:
+  %0 = shufflevector <2 x double> %B, <2 x double> undef, <2 x i32> <i32 0, i32 0>
+  ret <2 x double> %0
+}
+
+; CHECK-LABEL: splat1
+; OLD:    xxmrghd 34, 35, 35
+; MODERN: xxspltd 34, 35, 0
+
+define <2 x double> @splat2(<2 x double> %A, <2 x double> %B) {
+entry:
+  %0 = shufflevector <2 x double> %B, <2 x double> undef, <2 x i32> <i32 1, i32 1>
+  ret <2 x double> %0
+}
+
+; CHECK-LABEL: splat2
+; OLD:    xxmrgld 34, 35, 35
+; MODERN: xxspltd 34, 35, 1
+
+define <2 x double> @swap(<2 x double> %A, <2 x double> %B) {
+entry:
+  %0 = shufflevector <2 x double> %B, <2 x double> undef, <2 x i32> <i32 1, i32 0>
+  ret <2 x double> %0
+}
+
+; CHECK-LABEL: swap
+; CHECK: xxswapd 34, 35
+
+define <2 x double> @mergehi(<2 x double> %A, <2 x double> %B) {
+entry:
+  %0 = shufflevector <2 x double> %A, <2 x double> %B, <2 x i32> <i32 0, i32 2>
+  ret <2 x double> %0
+}
+
+; CHECK-LABEL: mergehi
+; CHECK: xxmrghd 34, 34, 35
+
+define <2 x double> @mergelo(<2 x double> %A, <2 x double> %B) {
+entry:
+  %0 = shufflevector <2 x double> %A, <2 x double> %B, <2 x i32> <i32 1, i32 3>
+  ret <2 x double> %0
+}
+
+; CHECK-LABEL: mergelo
+; CHECK: xxmrgld 34, 34, 35

diff  --git a/llvm/test/MC/PowerPC/modern-aix-as.s b/llvm/test/MC/PowerPC/modern-aix-as.s
index 45f88a42d771..b36d2b625a14 100644
--- a/llvm/test/MC/PowerPC/modern-aix-as.s
+++ b/llvm/test/MC/PowerPC/modern-aix-as.s
@@ -12,5 +12,14 @@
             mtudscr 2
 # CHECK-BE: mfudscr 2                       # encoding: [0x7c,0x43,0x02,0xa6]
 # CHECK-LE: mfudscr 2                       # encoding: [0xa6,0x02,0x43,0x7c]
+# CHECK-OLD: instruction use requires an option to be enabled
             mfudscr 2
+# CHECK-BE: xxspltd 2, 3, 0                 # encoding: [0xf0,0x43,0x18,0x50]
+# CHECK-LE: xxspltd 2, 3, 0                 # encoding: [0x50,0x18,0x43,0xf0]
+# CHECK-OLD: instruction use requires an option to be enabled
+            xxspltd 2, 3, 0
 
+# CHECK-BE: xxspltd 2, 3, 1                 # encoding: [0xf0,0x43,0x1b,0x50]
+# CHECK-LE: xxspltd 2, 3, 1                 # encoding: [0x50,0x1b,0x43,0xf0]
+# CHECK-OLD: instruction use requires an option to be enabled
+            xxspltd 2, 3, 1


        


More information about the llvm-branch-commits mailing list