From ead71a23edde5f8a1acfdd75bd01f1fa6e0c4014 Mon Sep 17 00:00:00 2001 From: Sean Fertile Date: Fri, 15 Jan 2021 16:36:50 -0500 Subject: [PATCH] [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 --- llvm/lib/Target/PowerPC/PPCInstrVSX.td | 20 ++++++---- llvm/test/CodeGen/PowerPC/xxpermdi_mnemonics.s | 53 ++++++++++++++++++++++++++ llvm/test/MC/PowerPC/modern-aix-as.s | 9 +++++ 3 files changed, 74 insertions(+), 8 deletions(-) create mode 100644 llvm/test/CodeGen/PowerPC/xxpermdi_mnemonics.s diff --git a/llvm/lib/Target/PowerPC/PPCInstrVSX.td b/llvm/lib/Target/PowerPC/PPCInstrVSX.td index 136a53e..2e45d73 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 0000000..ec2e264 --- /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> + 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> + 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> + 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> + 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> + 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 45f88a4..b36d2b6 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 -- 2.7.4