From 789fcb09e06397775ae0cb6002650c166d816340 Mon Sep 17 00:00:00 2001 From: Tony Varghese Date: Thu, 11 Sep 2025 11:44:35 +0000 Subject: [PATCH] Precommit testcases for locking down the xxsel instruction support for ternary(A, X, eqv(B,C)), ternary(A, X, not(C)), ternary(A, X, not(B)), ternary(A, X, nand(B,C)) and ternary(A, X, nor(B,C)) patterns --- .../CodeGen/PowerPC/xxeval-vselect-x-eqv.ll | 327 +++++++++++ .../CodeGen/PowerPC/xxeval-vselect-x-nand.ll | 384 +++++++++++++ .../CodeGen/PowerPC/xxeval-vselect-x-nor.ll | 538 ++++++++++++++++++ .../CodeGen/PowerPC/xxeval-vselect-x-not-b.ll | 307 ++++++++++ .../CodeGen/PowerPC/xxeval-vselect-x-not-c.ll | 445 +++++++++++++++ 5 files changed, 2001 insertions(+) create mode 100644 llvm/test/CodeGen/PowerPC/xxeval-vselect-x-eqv.ll create mode 100644 llvm/test/CodeGen/PowerPC/xxeval-vselect-x-nand.ll create mode 100644 llvm/test/CodeGen/PowerPC/xxeval-vselect-x-nor.ll create mode 100644 llvm/test/CodeGen/PowerPC/xxeval-vselect-x-not-b.ll create mode 100644 llvm/test/CodeGen/PowerPC/xxeval-vselect-x-not-c.ll diff --git a/llvm/test/CodeGen/PowerPC/xxeval-vselect-x-eqv.ll b/llvm/test/CodeGen/PowerPC/xxeval-vselect-x-eqv.ll new file mode 100644 index 0000000000000..7fa576f599dc4 --- /dev/null +++ b/llvm/test/CodeGen/PowerPC/xxeval-vselect-x-eqv.ll @@ -0,0 +1,327 @@ +; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5 +; Test file to verify the emission of Vector Evaluate instructions when ternary operators are used. + +; RUN: llc -verify-machineinstrs -mcpu=pwr10 -mtriple=powerpc64le-unknown-unknown \ +; RUN: -ppc-asm-full-reg-names --ppc-vsr-nums-as-vr < %s | FileCheck %s + +; RUN: llc -verify-machineinstrs -mcpu=pwr10 -mtriple=powerpc-ibm-aix-xcoff \ +; RUN: -ppc-asm-full-reg-names --ppc-vsr-nums-as-vr < %s | FileCheck %s + +; RUN: llc -verify-machineinstrs -mcpu=pwr10 -mtriple=powerpc64-ibm-aix-xcoff \ +; RUN: -ppc-asm-full-reg-names --ppc-vsr-nums-as-vr < %s | FileCheck %s + +; Function to test ternary(A, or(B, C), eqv(B, C)) for <4 x i32> +define <4 x i32> @ternary_A_or_BC_eqv_BC_4x32(<4 x i1> %A, <4 x i32> %B, <4 x i32> %C) { +; CHECK-LABEL: ternary_A_or_BC_eqv_BC_4x32: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: xxleqv v5, v5, v5 +; CHECK-NEXT: xxlor vs0, v3, v4 +; CHECK-NEXT: xxleqv vs1, v3, v4 +; CHECK-NEXT: vslw v2, v2, v5 +; CHECK-NEXT: vsraw v2, v2, v5 +; CHECK-NEXT: xxsel v2, vs1, vs0, v2 +; CHECK-NEXT: blr +entry: + %or = or <4 x i32> %B, %C + %xor = xor <4 x i32> %B, %C + %eqv = xor <4 x i32> %xor, ; Vector eqv operation + %res = select <4 x i1> %A, <4 x i32> %or, <4 x i32> %eqv + ret <4 x i32> %res +} + +; Function to test ternary(A, or(B, C), eqv(B, C)) for <2 x i64> +define <2 x i64> @ternary_A_or_BC_eqv_BC_2x64(<2 x i1> %A, <2 x i64> %B, <2 x i64> %C) { +; CHECK-LABEL: ternary_A_or_BC_eqv_BC_2x64: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: xxlxor v5, v5, v5 +; CHECK-NEXT: xxlor vs0, v3, v4 +; CHECK-NEXT: xxleqv vs1, v3, v4 +; CHECK-NEXT: xxsplti32dx v5, 1, 63 +; CHECK-NEXT: vsld v2, v2, v5 +; CHECK-NEXT: vsrad v2, v2, v5 +; CHECK-NEXT: xxsel v2, vs1, vs0, v2 +; CHECK-NEXT: blr +entry: + %or = or <2 x i64> %B, %C + %xor = xor <2 x i64> %B, %C + %eqv = xor <2 x i64> %xor, ; Vector eqv operation + %res = select <2 x i1> %A, <2 x i64> %or, <2 x i64> %eqv + ret <2 x i64> %res +} + +; Function to test ternary(A, or(B, C), eqv(B, C)) for <16 x i8> +define <16 x i8> @ternary_A_or_BC_eqv_BC_16x8(<16 x i1> %A, <16 x i8> %B, <16 x i8> %C) { +; CHECK-LABEL: ternary_A_or_BC_eqv_BC_16x8: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: xxspltib v5, 7 +; CHECK-NEXT: xxlor vs0, v3, v4 +; CHECK-NEXT: xxleqv vs1, v3, v4 +; CHECK-NEXT: vslb v2, v2, v5 +; CHECK-NEXT: vsrab v2, v2, v5 +; CHECK-NEXT: xxsel v2, vs1, vs0, v2 +; CHECK-NEXT: blr +entry: + %or = or <16 x i8> %B, %C + %xor = xor <16 x i8> %B, %C + %eqv = xor <16 x i8> %xor, ; Vector eqv operation + %res = select <16 x i1> %A, <16 x i8> %or, <16 x i8> %eqv + ret <16 x i8> %res +} + +; Function to test ternary(A, or(B, C), eqv(B, C)) for <8 x i16> +define <8 x i16> @ternary_A_or_BC_eqv_BC_8x16(<8 x i1> %A, <8 x i16> %B, <8 x i16> %C) { +; CHECK-LABEL: ternary_A_or_BC_eqv_BC_8x16: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: xxspltiw v5, 983055 +; CHECK-NEXT: xxlor vs0, v3, v4 +; CHECK-NEXT: xxleqv vs1, v3, v4 +; CHECK-NEXT: vslh v2, v2, v5 +; CHECK-NEXT: vsrah v2, v2, v5 +; CHECK-NEXT: xxsel v2, vs1, vs0, v2 +; CHECK-NEXT: blr +entry: + %or = or <8 x i16> %B, %C + %xor = xor <8 x i16> %B, %C + %eqv = xor <8 x i16> %xor, ; Vector eqv operation + %res = select <8 x i1> %A, <8 x i16> %or, <8 x i16> %eqv + ret <8 x i16> %res +} + +; Function to test ternary(A, nor(B, C), eqv(B, C)) for <4 x i32> +define <4 x i32> @ternary_A_nor_BC_eqv_BC_4x32(<4 x i1> %A, <4 x i32> %B, <4 x i32> %C) { +; CHECK-LABEL: ternary_A_nor_BC_eqv_BC_4x32: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: xxleqv v5, v5, v5 +; CHECK-NEXT: xxlnor vs0, v3, v4 +; CHECK-NEXT: xxleqv vs1, v3, v4 +; CHECK-NEXT: vslw v2, v2, v5 +; CHECK-NEXT: vsraw v2, v2, v5 +; CHECK-NEXT: xxsel v2, vs1, vs0, v2 +; CHECK-NEXT: blr +entry: + %or = or <4 x i32> %B, %C + %nor = xor <4 x i32> %or, ; Vector NOR operation + %xor = xor <4 x i32> %B, %C + %eqv = xor <4 x i32> %xor, ; Vector eqv operation + %res = select <4 x i1> %A, <4 x i32> %nor, <4 x i32> %eqv + ret <4 x i32> %res +} + +; Function to test ternary(A, nor(B, C), eqv(B, C)) for <2 x i64> +define <2 x i64> @ternary_A_nor_BC_eqv_BC_2x64(<2 x i1> %A, <2 x i64> %B, <2 x i64> %C) { +; CHECK-LABEL: ternary_A_nor_BC_eqv_BC_2x64: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: xxlxor v5, v5, v5 +; CHECK-NEXT: xxlnor vs0, v3, v4 +; CHECK-NEXT: xxleqv vs1, v3, v4 +; CHECK-NEXT: xxsplti32dx v5, 1, 63 +; CHECK-NEXT: vsld v2, v2, v5 +; CHECK-NEXT: vsrad v2, v2, v5 +; CHECK-NEXT: xxsel v2, vs1, vs0, v2 +; CHECK-NEXT: blr +entry: + %or = or <2 x i64> %B, %C + %nor = xor <2 x i64> %or, ; Vector NOR operation + %xor = xor <2 x i64> %B, %C + %eqv = xor <2 x i64> %xor, ; Vector eqv operation + %res = select <2 x i1> %A, <2 x i64> %nor, <2 x i64> %eqv + ret <2 x i64> %res +} + +; Function to test ternary(A, nor(B, C), eqv(B, C)) for <16 x i8> +define <16 x i8> @ternary_A_nor_BC_eqv_BC_16x8(<16 x i1> %A, <16 x i8> %B, <16 x i8> %C) { +; CHECK-LABEL: ternary_A_nor_BC_eqv_BC_16x8: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: xxspltib v5, 7 +; CHECK-NEXT: xxlnor vs0, v3, v4 +; CHECK-NEXT: xxleqv vs1, v3, v4 +; CHECK-NEXT: vslb v2, v2, v5 +; CHECK-NEXT: vsrab v2, v2, v5 +; CHECK-NEXT: xxsel v2, vs1, vs0, v2 +; CHECK-NEXT: blr +entry: + %or = or <16 x i8> %B, %C + %nor = xor <16 x i8> %or, ; Vector NOR operation + %xor = xor <16 x i8> %B, %C + %eqv = xor <16 x i8> %xor, ; Vector eqv operation + %res = select <16 x i1> %A, <16 x i8> %nor, <16 x i8> %eqv + ret <16 x i8> %res +} + +; Function to test ternary(A, nor(B, C), eqv(B, C)) for <8 x i16> +define <8 x i16> @ternary_A_nor_BC_eqv_BC_8x16(<8 x i1> %A, <8 x i16> %B, <8 x i16> %C) { +; CHECK-LABEL: ternary_A_nor_BC_eqv_BC_8x16: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: xxspltiw v5, 983055 +; CHECK-NEXT: xxlnor vs0, v3, v4 +; CHECK-NEXT: xxleqv vs1, v3, v4 +; CHECK-NEXT: vslh v2, v2, v5 +; CHECK-NEXT: vsrah v2, v2, v5 +; CHECK-NEXT: xxsel v2, vs1, vs0, v2 +; CHECK-NEXT: blr +entry: + %or = or <8 x i16> %B, %C + %nor = xor <8 x i16> %or, ; Vector NOR operation + %xor = xor <8 x i16> %B, %C + %eqv = xor <8 x i16> %xor, ; Vector eqv operation + %res = select <8 x i1> %A, <8 x i16> %nor, <8 x i16> %eqv + ret <8 x i16> %res +} + +; Function to test ternary(A, not(C), eqv(B, C)) for <4 x i32> +define <4 x i32> @ternary_A_not_C_eqv_BC_4x32(<4 x i1> %A, <4 x i32> %B, <4 x i32> %C) { +; CHECK-LABEL: ternary_A_not_C_eqv_BC_4x32: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: xxleqv v5, v5, v5 +; CHECK-NEXT: xxlnor vs0, v4, v4 +; CHECK-NEXT: xxleqv vs1, v4, v3 +; CHECK-NEXT: vslw v2, v2, v5 +; CHECK-NEXT: vsraw v2, v2, v5 +; CHECK-NEXT: xxsel v2, vs1, vs0, v2 +; CHECK-NEXT: blr +entry: + %not = xor <4 x i32> %C, ; Vector not operation + %xor = xor <4 x i32> %B, %C + %eqv = xor <4 x i32> %xor, ; Vector eqv operation + %res = select <4 x i1> %A, <4 x i32> %not, <4 x i32> %eqv + ret <4 x i32> %res +} + +; Function to test ternary(A, not(C), eqv(B, C)) for <2 x i64> +define <2 x i64> @ternary_A_not_C_eqv_BC_2x64(<2 x i1> %A, <2 x i64> %B, <2 x i64> %C) { +; CHECK-LABEL: ternary_A_not_C_eqv_BC_2x64: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: xxlxor v5, v5, v5 +; CHECK-NEXT: xxlnor vs0, v4, v4 +; CHECK-NEXT: xxleqv vs1, v4, v3 +; CHECK-NEXT: xxsplti32dx v5, 1, 63 +; CHECK-NEXT: vsld v2, v2, v5 +; CHECK-NEXT: vsrad v2, v2, v5 +; CHECK-NEXT: xxsel v2, vs1, vs0, v2 +; CHECK-NEXT: blr +entry: + %not = xor <2 x i64> %C, ; Vector not operation + %xor = xor <2 x i64> %B, %C + %eqv = xor <2 x i64> %xor, ; Vector eqv operation + %res = select <2 x i1> %A, <2 x i64> %not, <2 x i64> %eqv + ret <2 x i64> %res +} + +; Function to test ternary(A, not(C), eqv(B, C)) for <16 x i8> +define <16 x i8> @ternary_A_not_C_eqv_BC_16x8(<16 x i1> %A, <16 x i8> %B, <16 x i8> %C) { +; CHECK-LABEL: ternary_A_not_C_eqv_BC_16x8: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: xxspltib v5, 7 +; CHECK-NEXT: xxlnor vs0, v4, v4 +; CHECK-NEXT: xxleqv vs1, v4, v3 +; CHECK-NEXT: vslb v2, v2, v5 +; CHECK-NEXT: vsrab v2, v2, v5 +; CHECK-NEXT: xxsel v2, vs1, vs0, v2 +; CHECK-NEXT: blr +entry: + %not = xor <16 x i8> %C, ; Vector not operation + %xor = xor <16 x i8> %B, %C + %eqv = xor <16 x i8> %xor, ; Vector eqv operation + %res = select <16 x i1> %A, <16 x i8> %not, <16 x i8> %eqv + ret <16 x i8> %res +} + +; Function to test ternary(A, not(C), eqv(B, C)) for <8 x i16> +define <8 x i16> @ternary_A_not_C_eqv_BC_8x16(<8 x i1> %A, <8 x i16> %B, <8 x i16> %C) { +; CHECK-LABEL: ternary_A_not_C_eqv_BC_8x16: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: xxspltiw v5, 983055 +; CHECK-NEXT: xxlnor vs0, v4, v4 +; CHECK-NEXT: xxleqv vs1, v4, v3 +; CHECK-NEXT: vslh v2, v2, v5 +; CHECK-NEXT: vsrah v2, v2, v5 +; CHECK-NEXT: xxsel v2, vs1, vs0, v2 +; CHECK-NEXT: blr +entry: + %not = xor <8 x i16> %C, ; Vector not operation + %xor = xor <8 x i16> %B, %C + %eqv = xor <8 x i16> %xor, ; Vector eqv operation + %res = select <8 x i1> %A, <8 x i16> %not, <8 x i16> %eqv + ret <8 x i16> %res +} + +; Function to test ternary(A, nand(B, C), eqv(B, C)) for <4 x i32> +define <4 x i32> @ternary_A_nand_BC_eqv_BC_4x32(<4 x i1> %A, <4 x i32> %B, <4 x i32> %C) { +; CHECK-LABEL: ternary_A_nand_BC_eqv_BC_4x32: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: xxleqv v5, v5, v5 +; CHECK-NEXT: xxlnand vs0, v3, v4 +; CHECK-NEXT: xxleqv vs1, v3, v4 +; CHECK-NEXT: vslw v2, v2, v5 +; CHECK-NEXT: vsraw v2, v2, v5 +; CHECK-NEXT: xxsel v2, vs1, vs0, v2 +; CHECK-NEXT: blr +entry: + %and = and <4 x i32> %B, %C + %nand = xor <4 x i32> %and, ; Vector nand operation + %xor = xor <4 x i32> %B, %C + %eqv = xor <4 x i32> %xor, ; Vector eqv operation + %res = select <4 x i1> %A, <4 x i32> %nand, <4 x i32> %eqv + ret <4 x i32> %res +} + +; Function to test ternary(A, nand(B, C), eqv(B, C)) for <2 x i64> +define <2 x i64> @ternary_A_nand_BC_eqv_BC_2x64(<2 x i1> %A, <2 x i64> %B, <2 x i64> %C) { +; CHECK-LABEL: ternary_A_nand_BC_eqv_BC_2x64: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: xxlxor v5, v5, v5 +; CHECK-NEXT: xxlnand vs0, v3, v4 +; CHECK-NEXT: xxleqv vs1, v3, v4 +; CHECK-NEXT: xxsplti32dx v5, 1, 63 +; CHECK-NEXT: vsld v2, v2, v5 +; CHECK-NEXT: vsrad v2, v2, v5 +; CHECK-NEXT: xxsel v2, vs1, vs0, v2 +; CHECK-NEXT: blr +entry: + %and = and <2 x i64> %B, %C + %nand = xor <2 x i64> %and, ; Vector nand operation + %xor = xor <2 x i64> %B, %C + %eqv = xor <2 x i64> %xor, ; Vector eqv operation + %res = select <2 x i1> %A, <2 x i64> %nand, <2 x i64> %eqv + ret <2 x i64> %res +} + +; Function to test ternary(A, nand(B, C), eqv(B, C)) for <16 x i8> +define <16 x i8> @ternary_A_nand_BC_eqv_BC_16x8(<16 x i1> %A, <16 x i8> %B, <16 x i8> %C) { +; CHECK-LABEL: ternary_A_nand_BC_eqv_BC_16x8: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: xxspltib v5, 7 +; CHECK-NEXT: xxlnand vs0, v3, v4 +; CHECK-NEXT: xxleqv vs1, v3, v4 +; CHECK-NEXT: vslb v2, v2, v5 +; CHECK-NEXT: vsrab v2, v2, v5 +; CHECK-NEXT: xxsel v2, vs1, vs0, v2 +; CHECK-NEXT: blr +entry: + %and = and <16 x i8> %B, %C + %nand = xor <16 x i8> %and, ; Vector nand operation + %xor = xor <16 x i8> %B, %C + %eqv = xor <16 x i8> %xor, ; Vector eqv operation + %res = select <16 x i1> %A, <16 x i8> %nand, <16 x i8> %eqv + ret <16 x i8> %res +} + +; Function to test ternary(A, nand(B, C), eqv(B, C)) for <8 x i16> +define <8 x i16> @ternary_A_nand_BC_eqv_BC_8x16(<8 x i1> %A, <8 x i16> %B, <8 x i16> %C) { +; CHECK-LABEL: ternary_A_nand_BC_eqv_BC_8x16: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: xxspltiw v5, 983055 +; CHECK-NEXT: xxlnand vs0, v3, v4 +; CHECK-NEXT: xxleqv vs1, v3, v4 +; CHECK-NEXT: vslh v2, v2, v5 +; CHECK-NEXT: vsrah v2, v2, v5 +; CHECK-NEXT: xxsel v2, vs1, vs0, v2 +; CHECK-NEXT: blr +entry: + %and = and <8 x i16> %B, %C + %nand = xor <8 x i16> %and, ; Vector nand operation + %xor = xor <8 x i16> %B, %C + %eqv = xor <8 x i16> %xor, ; Vector eqv operation + %res = select <8 x i1> %A, <8 x i16> %nand, <8 x i16> %eqv + ret <8 x i16> %res +} diff --git a/llvm/test/CodeGen/PowerPC/xxeval-vselect-x-nand.ll b/llvm/test/CodeGen/PowerPC/xxeval-vselect-x-nand.ll new file mode 100644 index 0000000000000..7a6733d3b5510 --- /dev/null +++ b/llvm/test/CodeGen/PowerPC/xxeval-vselect-x-nand.ll @@ -0,0 +1,384 @@ +; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5 +; Test file to verify the emission of Vector Evaluate instructions when ternary operators are used. + +; RUN: llc -verify-machineinstrs -mcpu=pwr10 -mtriple=powerpc64le-unknown-unknown \ +; RUN: -ppc-asm-full-reg-names --ppc-vsr-nums-as-vr < %s | FileCheck %s + +; RUN: llc -verify-machineinstrs -mcpu=pwr10 -mtriple=powerpc-ibm-aix-xcoff \ +; RUN: -ppc-asm-full-reg-names --ppc-vsr-nums-as-vr < %s | FileCheck %s + +; RUN: llc -verify-machineinstrs -mcpu=pwr10 -mtriple=powerpc64-ibm-aix-xcoff \ +; RUN: -ppc-asm-full-reg-names --ppc-vsr-nums-as-vr < %s | FileCheck %s + +; Function to test ternary(A, B, nand(B, C)) for <4 x i32> +define <4 x i32> @ternary_A_B_nand_BC_4x32(<4 x i1> %A, <4 x i32> %B, <4 x i32> %C) { +; CHECK-LABEL: ternary_A_B_nand_BC_4x32: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: xxleqv v5, v5, v5 +; CHECK-NEXT: xxlnand vs0, v3, v4 +; CHECK-NEXT: vslw v2, v2, v5 +; CHECK-NEXT: vsraw v2, v2, v5 +; CHECK-NEXT: xxsel v2, vs0, v3, v2 +; CHECK-NEXT: blr +entry: + %and = and <4 x i32> %B, %C + %nand = xor <4 x i32> %and, ; Vector nand operation + %res = select <4 x i1> %A, <4 x i32> %B, <4 x i32> %nand + ret <4 x i32> %res +} + +; Function to test ternary(A, B, nand(B, C)) for <2 x i64> +define <2 x i64> @ternary_A_B_nand_BC_2x64(<2 x i1> %A, <2 x i64> %B, <2 x i64> %C) { +; CHECK-LABEL: ternary_A_B_nand_BC_2x64: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: xxlxor v5, v5, v5 +; CHECK-NEXT: xxlnand vs0, v3, v4 +; CHECK-NEXT: xxsplti32dx v5, 1, 63 +; CHECK-NEXT: vsld v2, v2, v5 +; CHECK-NEXT: vsrad v2, v2, v5 +; CHECK-NEXT: xxsel v2, vs0, v3, v2 +; CHECK-NEXT: blr +entry: + %and = and <2 x i64> %B, %C + %nand = xor <2 x i64> %and, ; Vector nand operation + %res = select <2 x i1> %A, <2 x i64> %B, <2 x i64> %nand + ret <2 x i64> %res +} + +; Function to test ternary(A, B, nand(B, C)) for <16 x i8> +define <16 x i8> @ternary_A_B_nand_BC_16x8(<16 x i1> %A, <16 x i8> %B, <16 x i8> %C) { +; CHECK-LABEL: ternary_A_B_nand_BC_16x8: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: xxspltib v5, 7 +; CHECK-NEXT: xxlnand vs0, v3, v4 +; CHECK-NEXT: vslb v2, v2, v5 +; CHECK-NEXT: vsrab v2, v2, v5 +; CHECK-NEXT: xxsel v2, vs0, v3, v2 +; CHECK-NEXT: blr +entry: + %and = and <16 x i8> %B, %C + %nand = xor <16 x i8> %and, ; Vector nand operation + %res = select <16 x i1> %A, <16 x i8> %B, <16 x i8> %nand + ret <16 x i8> %res +} + +; Function to test ternary(A, B, nand(B, C)) for <8 x i16> +define <8 x i16> @ternary_A_B_nand_BC_8x16(<8 x i1> %A, <8 x i16> %B, <8 x i16> %C) { +; CHECK-LABEL: ternary_A_B_nand_BC_8x16: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: xxspltiw v5, 983055 +; CHECK-NEXT: xxlnand vs0, v3, v4 +; CHECK-NEXT: vslh v2, v2, v5 +; CHECK-NEXT: vsrah v2, v2, v5 +; CHECK-NEXT: xxsel v2, vs0, v3, v2 +; CHECK-NEXT: blr +entry: + %and = and <8 x i16> %B, %C + %nand = xor <8 x i16> %and, ; Vector nand operation + %res = select <8 x i1> %A, <8 x i16> %B, <8 x i16> %nand + ret <8 x i16> %res +} + +; Function to test ternary(A, C, nand(B, C)) for <4 x i32> +define <4 x i32> @ternary_A_C_nand_BC_4x32(<4 x i1> %A, <4 x i32> %B, <4 x i32> %C) { +; CHECK-LABEL: ternary_A_C_nand_BC_4x32: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: xxleqv v5, v5, v5 +; CHECK-NEXT: xxlnand vs0, v3, v4 +; CHECK-NEXT: vslw v2, v2, v5 +; CHECK-NEXT: vsraw v2, v2, v5 +; CHECK-NEXT: xxsel v2, vs0, v4, v2 +; CHECK-NEXT: blr +entry: + %and = and <4 x i32> %B, %C + %nand = xor <4 x i32> %and, ; Vector nand operation + %res = select <4 x i1> %A, <4 x i32> %C, <4 x i32> %nand + ret <4 x i32> %res +} + +; Function to test ternary(A, C, nand(B, C)) for <2 x i64> +define <2 x i64> @ternary_A_C_nand_BC_2x64(<2 x i1> %A, <2 x i64> %B, <2 x i64> %C) { +; CHECK-LABEL: ternary_A_C_nand_BC_2x64: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: xxlxor v5, v5, v5 +; CHECK-NEXT: xxlnand vs0, v3, v4 +; CHECK-NEXT: xxsplti32dx v5, 1, 63 +; CHECK-NEXT: vsld v2, v2, v5 +; CHECK-NEXT: vsrad v2, v2, v5 +; CHECK-NEXT: xxsel v2, vs0, v4, v2 +; CHECK-NEXT: blr +entry: + %and = and <2 x i64> %B, %C + %nand = xor <2 x i64> %and, ; Vector nand operation + %res = select <2 x i1> %A, <2 x i64> %C, <2 x i64> %nand + ret <2 x i64> %res +} + +; Function to test ternary(A, C, nand(B, C)) for <16 x i8> +define <16 x i8> @ternary_A_C_nand_BC_16x8(<16 x i1> %A, <16 x i8> %B, <16 x i8> %C) { +; CHECK-LABEL: ternary_A_C_nand_BC_16x8: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: xxspltib v5, 7 +; CHECK-NEXT: xxlnand vs0, v3, v4 +; CHECK-NEXT: vslb v2, v2, v5 +; CHECK-NEXT: vsrab v2, v2, v5 +; CHECK-NEXT: xxsel v2, vs0, v4, v2 +; CHECK-NEXT: blr +entry: + %and = and <16 x i8> %B, %C + %nand = xor <16 x i8> %and, ; Vector nand operation + %res = select <16 x i1> %A, <16 x i8> %C, <16 x i8> %nand + ret <16 x i8> %res +} + +; Function to test ternary(A, C, nand(B, C)) for <8 x i16> +define <8 x i16> @ternary_A_C_nand_BC_8x16(<8 x i1> %A, <8 x i16> %B, <8 x i16> %C) { +; CHECK-LABEL: ternary_A_C_nand_BC_8x16: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: xxspltiw v5, 983055 +; CHECK-NEXT: xxlnand vs0, v3, v4 +; CHECK-NEXT: vslh v2, v2, v5 +; CHECK-NEXT: vsrah v2, v2, v5 +; CHECK-NEXT: xxsel v2, vs0, v4, v2 +; CHECK-NEXT: blr +entry: + %and = and <8 x i16> %B, %C + %nand = xor <8 x i16> %and, ; Vector nand operation + %res = select <8 x i1> %A, <8 x i16> %C, <8 x i16> %nand + ret <8 x i16> %res +} + +; Function to test ternary(A, xor(B, C), nand(B, C)) for <4 x i32> +define <4 x i32> @ternary_A_xor_BC_nand_BC_4x32(<4 x i1> %A, <4 x i32> %B, <4 x i32> %C) { +; CHECK-LABEL: ternary_A_xor_BC_nand_BC_4x32: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: xxleqv v5, v5, v5 +; CHECK-NEXT: xxlxor vs0, v3, v4 +; CHECK-NEXT: xxlnand vs1, v3, v4 +; CHECK-NEXT: vslw v2, v2, v5 +; CHECK-NEXT: vsraw v2, v2, v5 +; CHECK-NEXT: xxsel v2, vs1, vs0, v2 +; CHECK-NEXT: blr +entry: + %xor = xor <4 x i32> %B, %C + %and = and <4 x i32> %B, %C + %nand = xor <4 x i32> %and, ; Vector nand operation + %res = select <4 x i1> %A, <4 x i32> %xor, <4 x i32> %nand + ret <4 x i32> %res +} + +; Function to test ternary(A, xor(B, C), nand(B, C)) for <2 x i64> +define <2 x i64> @ternary_A_xor_BC_nand_BC_2x64(<2 x i1> %A, <2 x i64> %B, <2 x i64> %C) { +; CHECK-LABEL: ternary_A_xor_BC_nand_BC_2x64: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: xxlxor v5, v5, v5 +; CHECK-NEXT: xxlxor vs0, v3, v4 +; CHECK-NEXT: xxlnand vs1, v3, v4 +; CHECK-NEXT: xxsplti32dx v5, 1, 63 +; CHECK-NEXT: vsld v2, v2, v5 +; CHECK-NEXT: vsrad v2, v2, v5 +; CHECK-NEXT: xxsel v2, vs1, vs0, v2 +; CHECK-NEXT: blr +entry: + %xor = xor <2 x i64> %B, %C + %and = and <2 x i64> %B, %C + %nand = xor <2 x i64> %and, ; Vector nand operation + %res = select <2 x i1> %A, <2 x i64> %xor, <2 x i64> %nand + ret <2 x i64> %res +} + +; Function to test ternary(A, xor(B, C), nand(B, C)) for <16 x i8> +define <16 x i8> @ternary_A_xor_BC_nand_BC_16x8(<16 x i1> %A, <16 x i8> %B, <16 x i8> %C) { +; CHECK-LABEL: ternary_A_xor_BC_nand_BC_16x8: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: xxspltib v5, 7 +; CHECK-NEXT: xxlxor vs0, v3, v4 +; CHECK-NEXT: xxlnand vs1, v3, v4 +; CHECK-NEXT: vslb v2, v2, v5 +; CHECK-NEXT: vsrab v2, v2, v5 +; CHECK-NEXT: xxsel v2, vs1, vs0, v2 +; CHECK-NEXT: blr +entry: + %xor = xor <16 x i8> %B, %C + %and = and <16 x i8> %B, %C + %nand = xor <16 x i8> %and, ; Vector nand operation + %res = select <16 x i1> %A, <16 x i8> %xor, <16 x i8> %nand + ret <16 x i8> %res +} + +; Function to test ternary(A, xor(B, C), nand(B, C)) for <8 x i16> +define <8 x i16> @ternary_A_xor_BC_nand_BC_8x16(<8 x i1> %A, <8 x i16> %B, <8 x i16> %C) { +; CHECK-LABEL: ternary_A_xor_BC_nand_BC_8x16: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: xxspltiw v5, 983055 +; CHECK-NEXT: xxlxor vs0, v3, v4 +; CHECK-NEXT: xxlnand vs1, v3, v4 +; CHECK-NEXT: vslh v2, v2, v5 +; CHECK-NEXT: vsrah v2, v2, v5 +; CHECK-NEXT: xxsel v2, vs1, vs0, v2 +; CHECK-NEXT: blr +entry: + %xor = xor <8 x i16> %B, %C + %and = and <8 x i16> %B, %C + %nand = xor <8 x i16> %and, ; Vector nand operation + %res = select <8 x i1> %A, <8 x i16> %xor, <8 x i16> %nand + ret <8 x i16> %res +} + +; Function to test ternary(A, or(B, C), nand(B, C)) for <4 x i32> +define <4 x i32> @ternary_A_or_BC_nand_BC_4x32(<4 x i1> %A, <4 x i32> %B, <4 x i32> %C) { +; CHECK-LABEL: ternary_A_or_BC_nand_BC_4x32: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: xxleqv v5, v5, v5 +; CHECK-NEXT: xxlor vs0, v3, v4 +; CHECK-NEXT: xxlnand vs1, v3, v4 +; CHECK-NEXT: vslw v2, v2, v5 +; CHECK-NEXT: vsraw v2, v2, v5 +; CHECK-NEXT: xxsel v2, vs1, vs0, v2 +; CHECK-NEXT: blr +entry: + %or = or <4 x i32> %B, %C + %and = and <4 x i32> %B, %C + %nand = xor <4 x i32> %and, ; Vector nand operation + %res = select <4 x i1> %A, <4 x i32> %or, <4 x i32> %nand + ret <4 x i32> %res +} + +; Function to test ternary(A, or(B, C), nand(B, C)) for <2 x i64> +define <2 x i64> @ternary_A_or_BC_nand_BC_2x64(<2 x i1> %A, <2 x i64> %B, <2 x i64> %C) { +; CHECK-LABEL: ternary_A_or_BC_nand_BC_2x64: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: xxlxor v5, v5, v5 +; CHECK-NEXT: xxlor vs0, v3, v4 +; CHECK-NEXT: xxlnand vs1, v3, v4 +; CHECK-NEXT: xxsplti32dx v5, 1, 63 +; CHECK-NEXT: vsld v2, v2, v5 +; CHECK-NEXT: vsrad v2, v2, v5 +; CHECK-NEXT: xxsel v2, vs1, vs0, v2 +; CHECK-NEXT: blr +entry: + %or = or <2 x i64> %B, %C + %and = and <2 x i64> %B, %C + %nand = xor <2 x i64> %and, ; Vector nand operation + %res = select <2 x i1> %A, <2 x i64> %or, <2 x i64> %nand + ret <2 x i64> %res +} + +; Function to test ternary(A, or(B, C), nand(B, C)) for <16 x i8> +define <16 x i8> @ternary_A_or_BC_nand_BC_16x8(<16 x i1> %A, <16 x i8> %B, <16 x i8> %C) { +; CHECK-LABEL: ternary_A_or_BC_nand_BC_16x8: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: xxspltib v5, 7 +; CHECK-NEXT: xxlor vs0, v3, v4 +; CHECK-NEXT: xxlnand vs1, v3, v4 +; CHECK-NEXT: vslb v2, v2, v5 +; CHECK-NEXT: vsrab v2, v2, v5 +; CHECK-NEXT: xxsel v2, vs1, vs0, v2 +; CHECK-NEXT: blr +entry: + %or = or <16 x i8> %B, %C + %and = and <16 x i8> %B, %C + %nand = xor <16 x i8> %and, ; Vector nand operation + %res = select <16 x i1> %A, <16 x i8> %or, <16 x i8> %nand + ret <16 x i8> %res +} + +; Function to test ternary(A, or(B, C), nand(B, C)) for <8 x i16> +define <8 x i16> @ternary_A_or_BC_nand_BC_8x16(<8 x i1> %A, <8 x i16> %B, <8 x i16> %C) { +; CHECK-LABEL: ternary_A_or_BC_nand_BC_8x16: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: xxspltiw v5, 983055 +; CHECK-NEXT: xxlor vs0, v3, v4 +; CHECK-NEXT: xxlnand vs1, v3, v4 +; CHECK-NEXT: vslh v2, v2, v5 +; CHECK-NEXT: vsrah v2, v2, v5 +; CHECK-NEXT: xxsel v2, vs1, vs0, v2 +; CHECK-NEXT: blr +entry: + %or = or <8 x i16> %B, %C + %and = and <8 x i16> %B, %C + %nand = xor <8 x i16> %and, ; Vector nand operation + %res = select <8 x i1> %A, <8 x i16> %or, <8 x i16> %nand + ret <8 x i16> %res +} + +; Function to test ternary(A, eqv(B, C), nand(B, C)) for <4 x i32> +define <4 x i32> @ternary_A_eqv_BC_nand_BC_4x32(<4 x i1> %A, <4 x i32> %B, <4 x i32> %C) { +; CHECK-LABEL: ternary_A_eqv_BC_nand_BC_4x32: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: xxleqv v5, v5, v5 +; CHECK-NEXT: xxleqv vs0, v3, v4 +; CHECK-NEXT: xxlnand vs1, v3, v4 +; CHECK-NEXT: vslw v2, v2, v5 +; CHECK-NEXT: vsraw v2, v2, v5 +; CHECK-NEXT: xxsel v2, vs1, vs0, v2 +; CHECK-NEXT: blr +entry: + %xor = xor <4 x i32> %B, %C + %eqv = xor <4 x i32> %xor, ; Vector eqv operation + %and = and <4 x i32> %B, %C + %nand = xor <4 x i32> %and, ; Vector nand operation + %res = select <4 x i1> %A, <4 x i32> %eqv, <4 x i32> %nand + ret <4 x i32> %res +} + +; Function to test ternary(A, eqv(B, C), nand(B, C)) for <2 x i64> +define <2 x i64> @ternary_A_eqv_BC_nand_BC_2x64(<2 x i1> %A, <2 x i64> %B, <2 x i64> %C) { +; CHECK-LABEL: ternary_A_eqv_BC_nand_BC_2x64: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: xxlxor v5, v5, v5 +; CHECK-NEXT: xxleqv vs0, v3, v4 +; CHECK-NEXT: xxlnand vs1, v3, v4 +; CHECK-NEXT: xxsplti32dx v5, 1, 63 +; CHECK-NEXT: vsld v2, v2, v5 +; CHECK-NEXT: vsrad v2, v2, v5 +; CHECK-NEXT: xxsel v2, vs1, vs0, v2 +; CHECK-NEXT: blr +entry: + %xor = xor <2 x i64> %B, %C + %eqv = xor <2 x i64> %xor, ; Vector eqv operation + %and = and <2 x i64> %B, %C + %nand = xor <2 x i64> %and, ; Vector nand operation + %res = select <2 x i1> %A, <2 x i64> %eqv, <2 x i64> %nand + ret <2 x i64> %res +} + +; Function to test ternary(A, eqv(B, C), nand(B, C)) for <16 x i8> +define <16 x i8> @ternary_A_eqv_BC_nand_BC_16x8(<16 x i1> %A, <16 x i8> %B, <16 x i8> %C) { +; CHECK-LABEL: ternary_A_eqv_BC_nand_BC_16x8: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: xxspltib v5, 7 +; CHECK-NEXT: xxleqv vs0, v3, v4 +; CHECK-NEXT: xxlnand vs1, v3, v4 +; CHECK-NEXT: vslb v2, v2, v5 +; CHECK-NEXT: vsrab v2, v2, v5 +; CHECK-NEXT: xxsel v2, vs1, vs0, v2 +; CHECK-NEXT: blr +entry: + %xor = xor <16 x i8> %B, %C + %eqv = xor <16 x i8> %xor, ; Vector eqv operation + %and = and <16 x i8> %B, %C + %nand = xor <16 x i8> %and, ; Vector nand operation + %res = select <16 x i1> %A, <16 x i8> %eqv, <16 x i8> %nand + ret <16 x i8> %res +} + +; Function to test ternary(A, eqv(B, C), nand(B, C)) for <8 x i16> +define <8 x i16> @ternary_A_eqv_BC_nand_BC_8x16(<8 x i1> %A, <8 x i16> %B, <8 x i16> %C) { +; CHECK-LABEL: ternary_A_eqv_BC_nand_BC_8x16: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: xxspltiw v5, 983055 +; CHECK-NEXT: xxleqv vs0, v3, v4 +; CHECK-NEXT: xxlnand vs1, v3, v4 +; CHECK-NEXT: vslh v2, v2, v5 +; CHECK-NEXT: vsrah v2, v2, v5 +; CHECK-NEXT: xxsel v2, vs1, vs0, v2 +; CHECK-NEXT: blr +entry: + %xor = xor <8 x i16> %B, %C + %eqv = xor <8 x i16> %xor, ; Vector eqv operation + %and = and <8 x i16> %B, %C + %nand = xor <8 x i16> %and, ; Vector nand operation + %res = select <8 x i1> %A, <8 x i16> %eqv, <8 x i16> %nand + ret <8 x i16> %res +} diff --git a/llvm/test/CodeGen/PowerPC/xxeval-vselect-x-nor.ll b/llvm/test/CodeGen/PowerPC/xxeval-vselect-x-nor.ll new file mode 100644 index 0000000000000..d635952e5d8f2 --- /dev/null +++ b/llvm/test/CodeGen/PowerPC/xxeval-vselect-x-nor.ll @@ -0,0 +1,538 @@ +; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5 +; Test file to verify the emission of Vector selection instructions when ternary operators are used. + +; RUN: llc -verify-machineinstrs -mcpu=pwr10 -mtriple=powerpc64le-unknown-unknown \ +; RUN: -ppc-asm-full-reg-names --ppc-vsr-nums-as-vr < %s | FileCheck %s + +; RUN: llc -verify-machineinstrs -mcpu=pwr10 -mtriple=powerpc-ibm-aix-xcoff \ +; RUN: -ppc-asm-full-reg-names --ppc-vsr-nums-as-vr < %s | FileCheck %s + +; RUN: llc -verify-machineinstrs -mcpu=pwr10 -mtriple=powerpc64-ibm-aix-xcoff \ +; RUN: -ppc-asm-full-reg-names --ppc-vsr-nums-as-vr < %s | FileCheck %s + +; Function to test ternary(A, and(B, C), nor(B,C)) for <4 x i32> +define <4 x i32> @ternary_A_and_BC_nor_BC_4x32(<4 x i1> %A, <4 x i32> %B, <4 x i32> %C) { +; CHECK-LABEL: ternary_A_and_BC_nor_BC_4x32: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: xxleqv v5, v5, v5 +; CHECK-NEXT: xxland vs0, v3, v4 +; CHECK-NEXT: xxlnor vs1, v3, v4 +; CHECK-NEXT: vslw v2, v2, v5 +; CHECK-NEXT: vsraw v2, v2, v5 +; CHECK-NEXT: xxsel v2, vs1, vs0, v2 +; CHECK-NEXT: blr +entry: + %and = and <4 x i32> %B, %C + %or = or <4 x i32> %B, %C + %nor = xor <4 x i32> %or, ; Vector NOR operation + %res = select <4 x i1> %A, <4 x i32> %and, <4 x i32> %nor + ret <4 x i32> %res +} + +; Function to test ternary(A, and(B, C), nor(B,C)) for <2 x i64> +define <2 x i64> @ternary_A_and_BC_nor_BC_2x64(<2 x i1> %A, <2 x i64> %B, <2 x i64> %C) { +; CHECK-LABEL: ternary_A_and_BC_nor_BC_2x64: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: xxlxor v5, v5, v5 +; CHECK-NEXT: xxland vs0, v3, v4 +; CHECK-NEXT: xxlnor vs1, v3, v4 +; CHECK-NEXT: xxsplti32dx v5, 1, 63 +; CHECK-NEXT: vsld v2, v2, v5 +; CHECK-NEXT: vsrad v2, v2, v5 +; CHECK-NEXT: xxsel v2, vs1, vs0, v2 +; CHECK-NEXT: blr +entry: + %and = and <2 x i64> %B, %C + %or = or <2 x i64> %B, %C + %nor = xor <2 x i64> %or, ; Vector NOR operation + %res = select <2 x i1> %A, <2 x i64> %and, <2 x i64> %nor + ret <2 x i64> %res +} + +; Function to test ternary(A, and(B, C), nor(B,C)) for <16 x i8> +define <16 x i8> @ternary_A_and_BC_nor_BC_16x8(<16 x i1> %A, <16 x i8> %B, <16 x i8> %C) { +; CHECK-LABEL: ternary_A_and_BC_nor_BC_16x8: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: xxspltib v5, 7 +; CHECK-NEXT: xxland vs0, v3, v4 +; CHECK-NEXT: xxlnor vs1, v3, v4 +; CHECK-NEXT: vslb v2, v2, v5 +; CHECK-NEXT: vsrab v2, v2, v5 +; CHECK-NEXT: xxsel v2, vs1, vs0, v2 +; CHECK-NEXT: blr +entry: + %and = and <16 x i8> %B, %C + %or = or <16 x i8> %B, %C + %nor = xor <16 x i8> %or, ; Vector NOR operation + %res = select <16 x i1> %A, <16 x i8> %and, <16 x i8> %nor + ret <16 x i8> %res +} + +; Function to test ternary(A, and(B, C), nor(B,C)) for <8 x i16> +define <8 x i16> @ternary_A_and_BC_nor_BC_8x16(<8 x i1> %A, <8 x i16> %B, <8 x i16> %C) { +; CHECK-LABEL: ternary_A_and_BC_nor_BC_8x16: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: xxspltiw v5, 983055 +; CHECK-NEXT: xxland vs0, v3, v4 +; CHECK-NEXT: xxlnor vs1, v3, v4 +; CHECK-NEXT: vslh v2, v2, v5 +; CHECK-NEXT: vsrah v2, v2, v5 +; CHECK-NEXT: xxsel v2, vs1, vs0, v2 +; CHECK-NEXT: blr +entry: + %and = and <8 x i16> %B, %C + %or = or <8 x i16> %B, %C + %nor = xor <8 x i16> %or, ; Vector NOR operation + %res = select <8 x i1> %A, <8 x i16> %and, <8 x i16> %nor + ret <8 x i16> %res +} + +; Function to test ternary(A, B, nor(B,C)) for <4 x i32> +define <4 x i32> @ternary_A_B_nor_BC_4x32(<4 x i1> %A, <4 x i32> %B, <4 x i32> %C) { +; CHECK-LABEL: ternary_A_B_nor_BC_4x32: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: xxleqv v5, v5, v5 +; CHECK-NEXT: xxlnor vs0, v3, v4 +; CHECK-NEXT: vslw v2, v2, v5 +; CHECK-NEXT: vsraw v2, v2, v5 +; CHECK-NEXT: xxsel v2, vs0, v3, v2 +; CHECK-NEXT: blr +entry: + %or = or <4 x i32> %B, %C + %nor = xor <4 x i32> %or, ; Vector NOR operation + %res = select <4 x i1> %A, <4 x i32> %B, <4 x i32> %nor + ret <4 x i32> %res +} + +; Function to test ternary(A, B, nor(B,C)) for <2 x i64> +define <2 x i64> @ternary_A_B_nor_BC_2x64(<2 x i1> %A, <2 x i64> %B, <2 x i64> %C) { +; CHECK-LABEL: ternary_A_B_nor_BC_2x64: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: xxlxor v5, v5, v5 +; CHECK-NEXT: xxlnor vs0, v3, v4 +; CHECK-NEXT: xxsplti32dx v5, 1, 63 +; CHECK-NEXT: vsld v2, v2, v5 +; CHECK-NEXT: vsrad v2, v2, v5 +; CHECK-NEXT: xxsel v2, vs0, v3, v2 +; CHECK-NEXT: blr +entry: + %or = or <2 x i64> %B, %C + %nor = xor <2 x i64> %or, ; Vector NOR operation + %res = select <2 x i1> %A, <2 x i64> %B, <2 x i64> %nor + ret <2 x i64> %res +} + +; Function to test ternary(A, B, nor(B,C)) for <16 x i8> +define <16 x i8> @ternary_A_B_nor_BC_16x8(<16 x i1> %A, <16 x i8> %B, <16 x i8> %C) { +; CHECK-LABEL: ternary_A_B_nor_BC_16x8: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: xxspltib v5, 7 +; CHECK-NEXT: xxlnor vs0, v3, v4 +; CHECK-NEXT: vslb v2, v2, v5 +; CHECK-NEXT: vsrab v2, v2, v5 +; CHECK-NEXT: xxsel v2, vs0, v3, v2 +; CHECK-NEXT: blr +entry: + %or = or <16 x i8> %B, %C + %nor = xor <16 x i8> %or, ; Vector NOR operation + %res = select <16 x i1> %A, <16 x i8> %B, <16 x i8> %nor + ret <16 x i8> %res +} + +; Function to test ternary(A, B, nor(B,C)) for <8 x i16> +define <8 x i16> @ternary_A_B_nor_BC_8x16(<8 x i1> %A, <8 x i16> %B, <8 x i16> %C) { +; CHECK-LABEL: ternary_A_B_nor_BC_8x16: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: xxspltiw v5, 983055 +; CHECK-NEXT: xxlnor vs0, v3, v4 +; CHECK-NEXT: vslh v2, v2, v5 +; CHECK-NEXT: vsrah v2, v2, v5 +; CHECK-NEXT: xxsel v2, vs0, v3, v2 +; CHECK-NEXT: blr +entry: + %or = or <8 x i16> %B, %C + %nor = xor <8 x i16> %or, ; Vector NOR operation + %res = select <8 x i1> %A, <8 x i16> %B, <8 x i16> %nor + ret <8 x i16> %res +} + +; Function to test ternary(A, C, nor(B,C)) for <4 x i32> +define <4 x i32> @ternary_A_C_nor_BC_4x32(<4 x i1> %A, <4 x i32> %B, <4 x i32> %C) { +; CHECK-LABEL: ternary_A_C_nor_BC_4x32: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: xxleqv v5, v5, v5 +; CHECK-NEXT: xxlnor vs0, v3, v4 +; CHECK-NEXT: vslw v2, v2, v5 +; CHECK-NEXT: vsraw v2, v2, v5 +; CHECK-NEXT: xxsel v2, vs0, v4, v2 +; CHECK-NEXT: blr +entry: + %or = or <4 x i32> %B, %C + %nor = xor <4 x i32> %or, ; Vector NOR operation + %res = select <4 x i1> %A, <4 x i32> %C, <4 x i32> %nor + ret <4 x i32> %res +} + +; Function to test ternary(A, C, nor(B,C)) for <2 x i64> +define <2 x i64> @ternary_A_C_nor_BC_2x64(<2 x i1> %A, <2 x i64> %B, <2 x i64> %C) { +; CHECK-LABEL: ternary_A_C_nor_BC_2x64: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: xxlxor v5, v5, v5 +; CHECK-NEXT: xxlnor vs0, v3, v4 +; CHECK-NEXT: xxsplti32dx v5, 1, 63 +; CHECK-NEXT: vsld v2, v2, v5 +; CHECK-NEXT: vsrad v2, v2, v5 +; CHECK-NEXT: xxsel v2, vs0, v4, v2 +; CHECK-NEXT: blr +entry: + %or = or <2 x i64> %B, %C + %nor = xor <2 x i64> %or, ; Vector NOR operation + %res = select <2 x i1> %A, <2 x i64> %C, <2 x i64> %nor + ret <2 x i64> %res +} + +; Function to test ternary(A, C, nor(B,C)) for <16 x i8> +define <16 x i8> @ternary_A_C_nor_BC_16x8(<16 x i1> %A, <16 x i8> %B, <16 x i8> %C) { +; CHECK-LABEL: ternary_A_C_nor_BC_16x8: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: xxspltib v5, 7 +; CHECK-NEXT: xxlnor vs0, v3, v4 +; CHECK-NEXT: vslb v2, v2, v5 +; CHECK-NEXT: vsrab v2, v2, v5 +; CHECK-NEXT: xxsel v2, vs0, v4, v2 +; CHECK-NEXT: blr +entry: + %or = or <16 x i8> %B, %C + %nor = xor <16 x i8> %or, ; Vector NOR operation + %res = select <16 x i1> %A, <16 x i8> %C, <16 x i8> %nor + ret <16 x i8> %res +} + +; Function to test ternary(A, C, nor(B,C)) for <8 x i16> +define <8 x i16> @ternary_A_C_nor_BC_8x16(<8 x i1> %A, <8 x i16> %B, <8 x i16> %C) { +; CHECK-LABEL: ternary_A_C_nor_BC_8x16: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: xxspltiw v5, 983055 +; CHECK-NEXT: xxlnor vs0, v3, v4 +; CHECK-NEXT: vslh v2, v2, v5 +; CHECK-NEXT: vsrah v2, v2, v5 +; CHECK-NEXT: xxsel v2, vs0, v4, v2 +; CHECK-NEXT: blr +entry: + %or = or <8 x i16> %B, %C + %nor = xor <8 x i16> %or, ; Vector NOR operation + %res = select <8 x i1> %A, <8 x i16> %C, <8 x i16> %nor + ret <8 x i16> %res +} + +; Function to test ternary(A, xor(B,C), nor(B,C)) for <4 x i32> +define <4 x i32> @ternary_A_xor_BC_nor_BC_4x32(<4 x i1> %A, <4 x i32> %B, <4 x i32> %C) { +; CHECK-LABEL: ternary_A_xor_BC_nor_BC_4x32: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: xxleqv v5, v5, v5 +; CHECK-NEXT: xxlxor vs0, v3, v4 +; CHECK-NEXT: xxlnor vs1, v3, v4 +; CHECK-NEXT: vslw v2, v2, v5 +; CHECK-NEXT: vsraw v2, v2, v5 +; CHECK-NEXT: xxsel v2, vs1, vs0, v2 +; CHECK-NEXT: blr +entry: + %xor = xor <4 x i32> %B, %C + %or = or <4 x i32> %B, %C + %nor = xor <4 x i32> %or, ; Vector NOR operation + %res = select <4 x i1> %A, <4 x i32> %xor, <4 x i32> %nor + ret <4 x i32> %res +} + +; Function to test ternary(A, xor(B,C), nor(B,C)) for <2 x i64> +define <2 x i64> @ternary_A_xor_BC_nor_BC_2x64(<2 x i1> %A, <2 x i64> %B, <2 x i64> %C) { +; CHECK-LABEL: ternary_A_xor_BC_nor_BC_2x64: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: xxlxor v5, v5, v5 +; CHECK-NEXT: xxlxor vs0, v3, v4 +; CHECK-NEXT: xxlnor vs1, v3, v4 +; CHECK-NEXT: xxsplti32dx v5, 1, 63 +; CHECK-NEXT: vsld v2, v2, v5 +; CHECK-NEXT: vsrad v2, v2, v5 +; CHECK-NEXT: xxsel v2, vs1, vs0, v2 +; CHECK-NEXT: blr +entry: + %xor = xor <2 x i64> %B, %C + %or = or <2 x i64> %B, %C + %nor = xor <2 x i64> %or, ; Vector NOR operation + %res = select <2 x i1> %A, <2 x i64> %xor, <2 x i64> %nor + ret <2 x i64> %res +} + +; Function to test ternary(A, xor(B,C), nor(B,C)) for <16 x i8> +define <16 x i8> @ternary_A_xor_BC_nor_BC_16x8(<16 x i1> %A, <16 x i8> %B, <16 x i8> %C) { +; CHECK-LABEL: ternary_A_xor_BC_nor_BC_16x8: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: xxspltib v5, 7 +; CHECK-NEXT: xxlxor vs0, v3, v4 +; CHECK-NEXT: xxlnor vs1, v3, v4 +; CHECK-NEXT: vslb v2, v2, v5 +; CHECK-NEXT: vsrab v2, v2, v5 +; CHECK-NEXT: xxsel v2, vs1, vs0, v2 +; CHECK-NEXT: blr +entry: + %xor = xor <16 x i8> %B, %C + %or = or <16 x i8> %B, %C + %nor = xor <16 x i8> %or, ; Vector NOR operation + %res = select <16 x i1> %A, <16 x i8> %xor, <16 x i8> %nor + ret <16 x i8> %res +} + +; Function to test ternary(A, xor(B,C), nor(B,C)) for <8 x i16> +define <8 x i16> @ternary_A_xor_BC_nor_BC_8x16(<8 x i1> %A, <8 x i16> %B, <8 x i16> %C) { +; CHECK-LABEL: ternary_A_xor_BC_nor_BC_8x16: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: xxspltiw v5, 983055 +; CHECK-NEXT: xxlxor vs0, v3, v4 +; CHECK-NEXT: xxlnor vs1, v3, v4 +; CHECK-NEXT: vslh v2, v2, v5 +; CHECK-NEXT: vsrah v2, v2, v5 +; CHECK-NEXT: xxsel v2, vs1, vs0, v2 +; CHECK-NEXT: blr +entry: + %xor = xor <8 x i16> %B, %C + %or = or <8 x i16> %B, %C + %nor = xor <8 x i16> %or, ; Vector NOR operation + %res = select <8 x i1> %A, <8 x i16> %xor, <8 x i16> %nor + ret <8 x i16> %res +} + +; Function to test ternary(A, not(C), nor(B,C)) for <4 x i32> +define <4 x i32> @ternary_A_not_C_nor_BC_4x32(<4 x i1> %A, <4 x i32> %B, <4 x i32> %C) { +; CHECK-LABEL: ternary_A_not_C_nor_BC_4x32: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: xxleqv v5, v5, v5 +; CHECK-NEXT: xxlnor vs0, v4, v4 +; CHECK-NEXT: xxlnor vs1, v3, v4 +; CHECK-NEXT: vslw v2, v2, v5 +; CHECK-NEXT: vsraw v2, v2, v5 +; CHECK-NEXT: xxsel v2, vs1, vs0, v2 +; CHECK-NEXT: blr +entry: + %not = xor <4 x i32> %C, ; Vector not operation + %or = or <4 x i32> %B, %C + %nor = xor <4 x i32> %or, ; Vector NOR operation + %res = select <4 x i1> %A, <4 x i32> %not, <4 x i32> %nor + ret <4 x i32> %res +} + +; Function to test ternary(A, not(C), nor(B,C)) for <2 x i64> +define <2 x i64> @ternary_A_not_C_nor_BC_2x64(<2 x i1> %A, <2 x i64> %B, <2 x i64> %C) { +; CHECK-LABEL: ternary_A_not_C_nor_BC_2x64: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: xxlxor v5, v5, v5 +; CHECK-NEXT: xxlnor vs0, v4, v4 +; CHECK-NEXT: xxlnor vs1, v3, v4 +; CHECK-NEXT: xxsplti32dx v5, 1, 63 +; CHECK-NEXT: vsld v2, v2, v5 +; CHECK-NEXT: vsrad v2, v2, v5 +; CHECK-NEXT: xxsel v2, vs1, vs0, v2 +; CHECK-NEXT: blr +entry: + %not = xor <2 x i64> %C, ; Vector not operation + %or = or <2 x i64> %B, %C + %nor = xor <2 x i64> %or, ; Vector NOR operation + %res = select <2 x i1> %A, <2 x i64> %not, <2 x i64> %nor + ret <2 x i64> %res +} + +; Function to test ternary(A, not(C), nor(B,C)) for <16 x i8> +define <16 x i8> @ternary_A_not_C_nor_BC_16x8(<16 x i1> %A, <16 x i8> %B, <16 x i8> %C) { +; CHECK-LABEL: ternary_A_not_C_nor_BC_16x8: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: xxspltib v5, 7 +; CHECK-NEXT: xxlnor vs0, v4, v4 +; CHECK-NEXT: xxlnor vs1, v3, v4 +; CHECK-NEXT: vslb v2, v2, v5 +; CHECK-NEXT: vsrab v2, v2, v5 +; CHECK-NEXT: xxsel v2, vs1, vs0, v2 +; CHECK-NEXT: blr +entry: + %not = xor <16 x i8> %C, ; Vector not operation + %or = or <16 x i8> %B, %C + %nor = xor <16 x i8> %or, ; Vector NOR operation + %res = select <16 x i1> %A, <16 x i8> %not, <16 x i8> %nor + ret <16 x i8> %res +} + +; Function to test ternary(A, not(C), nor(B,C)) for <8 x i16> +define <8 x i16> @ternary_A_not_C_nor_BC_8x16(<8 x i1> %A, <8 x i16> %B, <8 x i16> %C) { +; CHECK-LABEL: ternary_A_not_C_nor_BC_8x16: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: xxspltiw v5, 983055 +; CHECK-NEXT: xxlnor vs0, v4, v4 +; CHECK-NEXT: xxlnor vs1, v3, v4 +; CHECK-NEXT: vslh v2, v2, v5 +; CHECK-NEXT: vsrah v2, v2, v5 +; CHECK-NEXT: xxsel v2, vs1, vs0, v2 +; CHECK-NEXT: blr +entry: + %not = xor <8 x i16> %C, ; Vector not operation + %or = or <8 x i16> %B, %C + %nor = xor <8 x i16> %or, ; Vector NOR operation + %res = select <8 x i1> %A, <8 x i16> %not, <8 x i16> %nor + ret <8 x i16> %res +} + +; Function to test ternary(A, not(B), nor(B,C)) for <4 x i32> +define <4 x i32> @ternary_A_not_B_nor_BC_4x32(<4 x i1> %A, <4 x i32> %B, <4 x i32> %C) { +; CHECK-LABEL: ternary_A_not_B_nor_BC_4x32: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: xxleqv v5, v5, v5 +; CHECK-NEXT: xxlnor vs0, v3, v3 +; CHECK-NEXT: xxlnor vs1, v3, v4 +; CHECK-NEXT: vslw v2, v2, v5 +; CHECK-NEXT: vsraw v2, v2, v5 +; CHECK-NEXT: xxsel v2, vs1, vs0, v2 +; CHECK-NEXT: blr +entry: + %not = xor <4 x i32> %B, ; Vector not operation + %or = or <4 x i32> %B, %C + %nor = xor <4 x i32> %or, ; Vector NOR operation + %res = select <4 x i1> %A, <4 x i32> %not, <4 x i32> %nor + ret <4 x i32> %res +} + +; Function to test ternary(A, not(B), nor(B,C)) for <2 x i64> +define <2 x i64> @ternary_A_not_B_nor_BC_2x64(<2 x i1> %A, <2 x i64> %B, <2 x i64> %C) { +; CHECK-LABEL: ternary_A_not_B_nor_BC_2x64: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: xxlxor v5, v5, v5 +; CHECK-NEXT: xxlnor vs0, v3, v3 +; CHECK-NEXT: xxlnor vs1, v3, v4 +; CHECK-NEXT: xxsplti32dx v5, 1, 63 +; CHECK-NEXT: vsld v2, v2, v5 +; CHECK-NEXT: vsrad v2, v2, v5 +; CHECK-NEXT: xxsel v2, vs1, vs0, v2 +; CHECK-NEXT: blr +entry: + %not = xor <2 x i64> %B, ; Vector not operation + %or = or <2 x i64> %B, %C + %nor = xor <2 x i64> %or, ; Vector NOR operation + %res = select <2 x i1> %A, <2 x i64> %not, <2 x i64> %nor + ret <2 x i64> %res +} + +; Function to test ternary(A, not(B), nor(B,C)) for <16 x i8> +define <16 x i8> @ternary_A_not_B_nor_BC_16x8(<16 x i1> %A, <16 x i8> %B, <16 x i8> %C) { +; CHECK-LABEL: ternary_A_not_B_nor_BC_16x8: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: xxspltib v5, 7 +; CHECK-NEXT: xxlnor vs0, v3, v3 +; CHECK-NEXT: xxlnor vs1, v3, v4 +; CHECK-NEXT: vslb v2, v2, v5 +; CHECK-NEXT: vsrab v2, v2, v5 +; CHECK-NEXT: xxsel v2, vs1, vs0, v2 +; CHECK-NEXT: blr +entry: + %not = xor <16 x i8> %B, ; Vector not operation + %or = or <16 x i8> %B, %C + %nor = xor <16 x i8> %or, ; Vector NOR operation + %res = select <16 x i1> %A, <16 x i8> %not, <16 x i8> %nor + ret <16 x i8> %res +} + +; Function to test ternary(A, not(B), nor(B,C)) for <8 x i16> +define <8 x i16> @ternary_A_not_B_nor_BC_8x16(<8 x i1> %A, <8 x i16> %B, <8 x i16> %C) { +; CHECK-LABEL: ternary_A_not_B_nor_BC_8x16: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: xxspltiw v5, 983055 +; CHECK-NEXT: xxlnor vs0, v3, v3 +; CHECK-NEXT: xxlnor vs1, v3, v4 +; CHECK-NEXT: vslh v2, v2, v5 +; CHECK-NEXT: vsrah v2, v2, v5 +; CHECK-NEXT: xxsel v2, vs1, vs0, v2 +; CHECK-NEXT: blr +entry: + %not = xor <8 x i16> %B, ; Vector not operation + %or = or <8 x i16> %B, %C + %nor = xor <8 x i16> %or, ; Vector NOR operation + %res = select <8 x i1> %A, <8 x i16> %not, <8 x i16> %nor + ret <8 x i16> %res +} + +; Function to test ternary(A, nand(B,C), nor(B,C)) for <4 x i32> +define <4 x i32> @ternary_A_nand_BC_nor_BC_4x32(<4 x i1> %A, <4 x i32> %B, <4 x i32> %C) { +; CHECK-LABEL: ternary_A_nand_BC_nor_BC_4x32: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: xxleqv v5, v5, v5 +; CHECK-NEXT: xxlnand vs0, v3, v4 +; CHECK-NEXT: xxlnor vs1, v3, v4 +; CHECK-NEXT: vslw v2, v2, v5 +; CHECK-NEXT: vsraw v2, v2, v5 +; CHECK-NEXT: xxsel v2, vs1, vs0, v2 +; CHECK-NEXT: blr +entry: + %and = and <4 x i32> %B, %C + %nand = xor <4 x i32> %and, ; Vector nand operation + %or = or <4 x i32> %B, %C + %nor = xor <4 x i32> %or, ; Vector NOR operation + %res = select <4 x i1> %A, <4 x i32> %nand, <4 x i32> %nor + ret <4 x i32> %res +} + +; Function to test ternary(A, nand(B,C), nor(B,C)) for <2 x i64> +define <2 x i64> @ternary_A_nand_BC_nor_BC_2x64(<2 x i1> %A, <2 x i64> %B, <2 x i64> %C) { +; CHECK-LABEL: ternary_A_nand_BC_nor_BC_2x64: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: xxlxor v5, v5, v5 +; CHECK-NEXT: xxlnand vs0, v3, v4 +; CHECK-NEXT: xxlnor vs1, v3, v4 +; CHECK-NEXT: xxsplti32dx v5, 1, 63 +; CHECK-NEXT: vsld v2, v2, v5 +; CHECK-NEXT: vsrad v2, v2, v5 +; CHECK-NEXT: xxsel v2, vs1, vs0, v2 +; CHECK-NEXT: blr +entry: + %and = and <2 x i64> %B, %C + %nand = xor <2 x i64> %and, ; Vector nand operation + %or = or <2 x i64> %B, %C + %nor = xor <2 x i64> %or, ; Vector NOR operation + %res = select <2 x i1> %A, <2 x i64> %nand, <2 x i64> %nor + ret <2 x i64> %res +} + +; Function to test ternary(A, nand(B,C), nor(B,C)) for <16 x i8> +define <16 x i8> @ternary_A_nand_BC_nor_BC_16x8(<16 x i1> %A, <16 x i8> %B, <16 x i8> %C) { +; CHECK-LABEL: ternary_A_nand_BC_nor_BC_16x8: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: xxspltib v5, 7 +; CHECK-NEXT: xxlnand vs0, v3, v4 +; CHECK-NEXT: xxlnor vs1, v3, v4 +; CHECK-NEXT: vslb v2, v2, v5 +; CHECK-NEXT: vsrab v2, v2, v5 +; CHECK-NEXT: xxsel v2, vs1, vs0, v2 +; CHECK-NEXT: blr +entry: + %and = and <16 x i8> %B, %C + %nand = xor <16 x i8> %and, ; Vector nand operation + %or = or <16 x i8> %B, %C + %nor = xor <16 x i8> %or, ; Vector NOR operation + %res = select <16 x i1> %A, <16 x i8> %nand, <16 x i8> %nor + ret <16 x i8> %res +} + +; Function to test ternary(A, nand(B,C), nor(B,C)) for <8 x i16> +define <8 x i16> @ternary_A_nand_BC_nor_BC_8x16(<8 x i1> %A, <8 x i16> %B, <8 x i16> %C) { +; CHECK-LABEL: ternary_A_nand_BC_nor_BC_8x16: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: xxspltiw v5, 983055 +; CHECK-NEXT: xxlnand vs0, v3, v4 +; CHECK-NEXT: xxlnor vs1, v3, v4 +; CHECK-NEXT: vslh v2, v2, v5 +; CHECK-NEXT: vsrah v2, v2, v5 +; CHECK-NEXT: xxsel v2, vs1, vs0, v2 +; CHECK-NEXT: blr +entry: + %and = and <8 x i16> %B, %C + %nand = xor <8 x i16> %and, ; Vector nand operation + %or = or <8 x i16> %B, %C + %nor = xor <8 x i16> %or, ; Vector NOR operation + %res = select <8 x i1> %A, <8 x i16> %nand, <8 x i16> %nor + ret <8 x i16> %res +} diff --git a/llvm/test/CodeGen/PowerPC/xxeval-vselect-x-not-b.ll b/llvm/test/CodeGen/PowerPC/xxeval-vselect-x-not-b.ll new file mode 100644 index 0000000000000..6203a96555395 --- /dev/null +++ b/llvm/test/CodeGen/PowerPC/xxeval-vselect-x-not-b.ll @@ -0,0 +1,307 @@ +; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5 +; Test file to verify the emission of Vector Evaluate instructions when ternary operators are used. + +; RUN: llc -verify-machineinstrs -mcpu=pwr10 -mtriple=powerpc64le-unknown-unknown \ +; RUN: -ppc-asm-full-reg-names --ppc-vsr-nums-as-vr < %s | FileCheck %s + +; RUN: llc -verify-machineinstrs -mcpu=pwr10 -mtriple=powerpc-ibm-aix-xcoff \ +; RUN: -ppc-asm-full-reg-names --ppc-vsr-nums-as-vr < %s | FileCheck %s + +; RUN: llc -verify-machineinstrs -mcpu=pwr10 -mtriple=powerpc64-ibm-aix-xcoff \ +; RUN: -ppc-asm-full-reg-names --ppc-vsr-nums-as-vr < %s | FileCheck %s + +; Function to test ternary(A, and(B, C), not(B)) for <4 x i32> +define <4 x i32> @ternary_A_and_BC_not_B_4x32(<4 x i1> %A, <4 x i32> %B, <4 x i32> %C) { +; CHECK-LABEL: ternary_A_and_BC_not_B_4x32: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: xxleqv v5, v5, v5 +; CHECK-NEXT: xxland vs0, v3, v4 +; CHECK-NEXT: xxlnor vs1, v3, v3 +; CHECK-NEXT: vslw v2, v2, v5 +; CHECK-NEXT: vsraw v2, v2, v5 +; CHECK-NEXT: xxsel v2, vs1, vs0, v2 +; CHECK-NEXT: blr +entry: + %and = and <4 x i32> %B, %C + %not = xor <4 x i32> %B, ; Vector not operation + %res = select <4 x i1> %A, <4 x i32> %and, <4 x i32> %not + ret <4 x i32> %res +} + +; Function to test ternary(A, and(B, C), not(B)) for <2 x i64> +define <2 x i64> @ternary_A_and_BC_not_B_2x64(<2 x i1> %A, <2 x i64> %B, <2 x i64> %C) { +; CHECK-LABEL: ternary_A_and_BC_not_B_2x64: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: xxlxor v5, v5, v5 +; CHECK-NEXT: xxland vs0, v3, v4 +; CHECK-NEXT: xxlnor vs1, v3, v3 +; CHECK-NEXT: xxsplti32dx v5, 1, 63 +; CHECK-NEXT: vsld v2, v2, v5 +; CHECK-NEXT: vsrad v2, v2, v5 +; CHECK-NEXT: xxsel v2, vs1, vs0, v2 +; CHECK-NEXT: blr +entry: + %and = and <2 x i64> %B, %C + %not = xor <2 x i64> %B, ; Vector not operation + %res = select <2 x i1> %A, <2 x i64> %and, <2 x i64> %not + ret <2 x i64> %res +} + +; Function to test ternary(A, and(B, C), not(B)) for <16 x i8> +define <16 x i8> @ternary_A_and_BC_not_B_16x8(<16 x i1> %A, <16 x i8> %B, <16 x i8> %C) { +; CHECK-LABEL: ternary_A_and_BC_not_B_16x8: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: xxspltib v5, 7 +; CHECK-NEXT: xxland vs0, v3, v4 +; CHECK-NEXT: xxlnor vs1, v3, v3 +; CHECK-NEXT: vslb v2, v2, v5 +; CHECK-NEXT: vsrab v2, v2, v5 +; CHECK-NEXT: xxsel v2, vs1, vs0, v2 +; CHECK-NEXT: blr +entry: + %and = and <16 x i8> %B, %C + %not = xor <16 x i8> %B, ; Vector not operation + %res = select <16 x i1> %A, <16 x i8> %and, <16 x i8> %not + ret <16 x i8> %res +} + +; Function to test ternary(A, and(B, C), not(B)) for <8 x i16> +define <8 x i16> @ternary_A_and_BC_not_B_8x16(<8 x i1> %A, <8 x i16> %B, <8 x i16> %C) { +; CHECK-LABEL: ternary_A_and_BC_not_B_8x16: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: xxspltiw v5, 983055 +; CHECK-NEXT: xxland vs0, v3, v4 +; CHECK-NEXT: xxlnor vs1, v3, v3 +; CHECK-NEXT: vslh v2, v2, v5 +; CHECK-NEXT: vsrah v2, v2, v5 +; CHECK-NEXT: xxsel v2, vs1, vs0, v2 +; CHECK-NEXT: blr +entry: + %and = and <8 x i16> %B, %C + %not = xor <8 x i16> %B, ; Vector not operation + %res = select <8 x i1> %A, <8 x i16> %and, <8 x i16> %not + ret <8 x i16> %res +} + +; Function to test ternary(A, xor(B, C), not(B)) for <4 x i32> +define <4 x i32> @ternary_A_xor_BC_not_B_4x32(<4 x i1> %A, <4 x i32> %B, <4 x i32> %C) { +; CHECK-LABEL: ternary_A_xor_BC_not_B_4x32: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: xxleqv v5, v5, v5 +; CHECK-NEXT: xxlxor vs0, v3, v4 +; CHECK-NEXT: xxlnor vs1, v3, v3 +; CHECK-NEXT: vslw v2, v2, v5 +; CHECK-NEXT: vsraw v2, v2, v5 +; CHECK-NEXT: xxsel v2, vs1, vs0, v2 +; CHECK-NEXT: blr +entry: + %xor = xor <4 x i32> %B, %C + %not = xor <4 x i32> %B, ; Vector not operation + %res = select <4 x i1> %A, <4 x i32> %xor, <4 x i32> %not + ret <4 x i32> %res +} + +; Function to test ternary(A, xor(B, C), not(B)) for <2 x i64> +define <2 x i64> @ternary_A_xor_BC_not_B_2x64(<2 x i1> %A, <2 x i64> %B, <2 x i64> %C) { +; CHECK-LABEL: ternary_A_xor_BC_not_B_2x64: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: xxlxor v5, v5, v5 +; CHECK-NEXT: xxlxor vs0, v3, v4 +; CHECK-NEXT: xxlnor vs1, v3, v3 +; CHECK-NEXT: xxsplti32dx v5, 1, 63 +; CHECK-NEXT: vsld v2, v2, v5 +; CHECK-NEXT: vsrad v2, v2, v5 +; CHECK-NEXT: xxsel v2, vs1, vs0, v2 +; CHECK-NEXT: blr +entry: + %xor = xor <2 x i64> %B, %C + %not = xor <2 x i64> %B, ; Vector not operation + %res = select <2 x i1> %A, <2 x i64> %xor, <2 x i64> %not + ret <2 x i64> %res +} + +; Function to test ternary(A, xor(B, C), not(B)) for <16 x i8> +define <16 x i8> @ternary_A_xor_BC_not_B_16x8(<16 x i1> %A, <16 x i8> %B, <16 x i8> %C) { +; CHECK-LABEL: ternary_A_xor_BC_not_B_16x8: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: xxspltib v5, 7 +; CHECK-NEXT: xxlxor vs0, v3, v4 +; CHECK-NEXT: xxlnor vs1, v3, v3 +; CHECK-NEXT: vslb v2, v2, v5 +; CHECK-NEXT: vsrab v2, v2, v5 +; CHECK-NEXT: xxsel v2, vs1, vs0, v2 +; CHECK-NEXT: blr +entry: + %xor = xor <16 x i8> %B, %C + %not = xor <16 x i8> %B, ; Vector not operation + %res = select <16 x i1> %A, <16 x i8> %xor, <16 x i8> %not + ret <16 x i8> %res +} + +; Function to test ternary(A, xor(B, C), not(B)) for <8 x i16> +define <8 x i16> @ternary_A_xor_BC_not_B_8x16(<8 x i1> %A, <8 x i16> %B, <8 x i16> %C) { +; CHECK-LABEL: ternary_A_xor_BC_not_B_8x16: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: xxspltiw v5, 983055 +; CHECK-NEXT: xxlxor vs0, v3, v4 +; CHECK-NEXT: xxlnor vs1, v3, v3 +; CHECK-NEXT: vslh v2, v2, v5 +; CHECK-NEXT: vsrah v2, v2, v5 +; CHECK-NEXT: xxsel v2, vs1, vs0, v2 +; CHECK-NEXT: blr +entry: + %xor = xor <8 x i16> %B, %C + %not = xor <8 x i16> %B, ; Vector not operation + %res = select <8 x i1> %A, <8 x i16> %xor, <8 x i16> %not + ret <8 x i16> %res +} + +; Function to test ternary(A, or(B, C), not(B)) for <4 x i32> +define <4 x i32> @ternary_A_or_BC_not_B_4x32(<4 x i1> %A, <4 x i32> %B, <4 x i32> %C) { +; CHECK-LABEL: ternary_A_or_BC_not_B_4x32: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: xxleqv v5, v5, v5 +; CHECK-NEXT: xxlor vs0, v3, v4 +; CHECK-NEXT: xxlnor vs1, v3, v3 +; CHECK-NEXT: vslw v2, v2, v5 +; CHECK-NEXT: vsraw v2, v2, v5 +; CHECK-NEXT: xxsel v2, vs1, vs0, v2 +; CHECK-NEXT: blr +entry: + %or = or <4 x i32> %B, %C + %not = xor <4 x i32> %B, ; Vector not operation + %res = select <4 x i1> %A, <4 x i32> %or, <4 x i32> %not + ret <4 x i32> %res +} + +; Function to test ternary(A, or(B, C), not(B)) for <2 x i64> +define <2 x i64> @ternary_A_or_BC_not_B_2x64(<2 x i1> %A, <2 x i64> %B, <2 x i64> %C) { +; CHECK-LABEL: ternary_A_or_BC_not_B_2x64: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: xxlxor v5, v5, v5 +; CHECK-NEXT: xxlor vs0, v3, v4 +; CHECK-NEXT: xxlnor vs1, v3, v3 +; CHECK-NEXT: xxsplti32dx v5, 1, 63 +; CHECK-NEXT: vsld v2, v2, v5 +; CHECK-NEXT: vsrad v2, v2, v5 +; CHECK-NEXT: xxsel v2, vs1, vs0, v2 +; CHECK-NEXT: blr +entry: + %or = or <2 x i64> %B, %C + %not = xor <2 x i64> %B, ; Vector not operation + %res = select <2 x i1> %A, <2 x i64> %or, <2 x i64> %not + ret <2 x i64> %res +} + +; Function to test ternary(A, or(B, C), not(B)) for <16 x i8> +define <16 x i8> @ternary_A_or_BC_not_B_16x8(<16 x i1> %A, <16 x i8> %B, <16 x i8> %C) { +; CHECK-LABEL: ternary_A_or_BC_not_B_16x8: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: xxspltib v5, 7 +; CHECK-NEXT: xxlor vs0, v3, v4 +; CHECK-NEXT: xxlnor vs1, v3, v3 +; CHECK-NEXT: vslb v2, v2, v5 +; CHECK-NEXT: vsrab v2, v2, v5 +; CHECK-NEXT: xxsel v2, vs1, vs0, v2 +; CHECK-NEXT: blr +entry: + %or = or <16 x i8> %B, %C + %not = xor <16 x i8> %B, ; Vector not operation + %res = select <16 x i1> %A, <16 x i8> %or, <16 x i8> %not + ret <16 x i8> %res +} + +; Function to test ternary(A, or(B, C), not(B)) for <8 x i16> +define <8 x i16> @ternary_A_or_BC_not_B_8x16(<8 x i1> %A, <8 x i16> %B, <8 x i16> %C) { +; CHECK-LABEL: ternary_A_or_BC_not_B_8x16: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: xxspltiw v5, 983055 +; CHECK-NEXT: xxlor vs0, v3, v4 +; CHECK-NEXT: xxlnor vs1, v3, v3 +; CHECK-NEXT: vslh v2, v2, v5 +; CHECK-NEXT: vsrah v2, v2, v5 +; CHECK-NEXT: xxsel v2, vs1, vs0, v2 +; CHECK-NEXT: blr +entry: + %or = or <8 x i16> %B, %C + %not = xor <8 x i16> %B, ; Vector not operation + %res = select <8 x i1> %A, <8 x i16> %or, <8 x i16> %not + ret <8 x i16> %res +} + +; Function to test ternary(A, nand(B, C), not(B)) for <4 x i32> +define <4 x i32> @ternary_A_nand_BC_not_B_4x32(<4 x i1> %A, <4 x i32> %B, <4 x i32> %C) { +; CHECK-LABEL: ternary_A_nand_BC_not_B_4x32: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: xxleqv v5, v5, v5 +; CHECK-NEXT: xxlnand vs0, v3, v4 +; CHECK-NEXT: xxlnor vs1, v3, v3 +; CHECK-NEXT: vslw v2, v2, v5 +; CHECK-NEXT: vsraw v2, v2, v5 +; CHECK-NEXT: xxsel v2, vs1, vs0, v2 +; CHECK-NEXT: blr +entry: + %and = and <4 x i32> %B, %C + %nand = xor <4 x i32> %and, ; Vector nand operation + %not = xor <4 x i32> %B, ; Vector not operation + %res = select <4 x i1> %A, <4 x i32> %nand, <4 x i32> %not + ret <4 x i32> %res +} + +; Function to test ternary(A, nand(B, C), not(B)) for <2 x i64> +define <2 x i64> @ternary_A_nand_BC_not_B_2x64(<2 x i1> %A, <2 x i64> %B, <2 x i64> %C) { +; CHECK-LABEL: ternary_A_nand_BC_not_B_2x64: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: xxlxor v5, v5, v5 +; CHECK-NEXT: xxlnand vs0, v3, v4 +; CHECK-NEXT: xxlnor vs1, v3, v3 +; CHECK-NEXT: xxsplti32dx v5, 1, 63 +; CHECK-NEXT: vsld v2, v2, v5 +; CHECK-NEXT: vsrad v2, v2, v5 +; CHECK-NEXT: xxsel v2, vs1, vs0, v2 +; CHECK-NEXT: blr +entry: + %and = and <2 x i64> %B, %C + %nand = xor <2 x i64> %and, ; Vector nand operation + %not = xor <2 x i64> %B, ; Vector not operation + %res = select <2 x i1> %A, <2 x i64> %nand, <2 x i64> %not + ret <2 x i64> %res +} + +; Function to test ternary(A, nand(B, C), not(B)) for <16 x i8> +define <16 x i8> @ternary_A_nand_BC_not_B_16x8(<16 x i1> %A, <16 x i8> %B, <16 x i8> %C) { +; CHECK-LABEL: ternary_A_nand_BC_not_B_16x8: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: xxspltib v5, 7 +; CHECK-NEXT: xxlnand vs0, v3, v4 +; CHECK-NEXT: xxlnor vs1, v3, v3 +; CHECK-NEXT: vslb v2, v2, v5 +; CHECK-NEXT: vsrab v2, v2, v5 +; CHECK-NEXT: xxsel v2, vs1, vs0, v2 +; CHECK-NEXT: blr +entry: + %and = and <16 x i8> %B, %C + %nand = xor <16 x i8> %and, ; Vector nand operation + %not = xor <16 x i8> %B, ; Vector not operation + %res = select <16 x i1> %A, <16 x i8> %nand, <16 x i8> %not + ret <16 x i8> %res +} + +; Function to test ternary(A, nand(B, C), not(B)) for <8 x i16> +define <8 x i16> @ternary_A_nand_BC_not_B_8x16(<8 x i1> %A, <8 x i16> %B, <8 x i16> %C) { +; CHECK-LABEL: ternary_A_nand_BC_not_B_8x16: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: xxspltiw v5, 983055 +; CHECK-NEXT: xxlnand vs0, v3, v4 +; CHECK-NEXT: xxlnor vs1, v3, v3 +; CHECK-NEXT: vslh v2, v2, v5 +; CHECK-NEXT: vsrah v2, v2, v5 +; CHECK-NEXT: xxsel v2, vs1, vs0, v2 +; CHECK-NEXT: blr +entry: + %and = and <8 x i16> %B, %C + %nand = xor <8 x i16> %and, ; Vector nand operation + %not = xor <8 x i16> %B, ; Vector not operation + %res = select <8 x i1> %A, <8 x i16> %nand, <8 x i16> %not + ret <8 x i16> %res +} diff --git a/llvm/test/CodeGen/PowerPC/xxeval-vselect-x-not-c.ll b/llvm/test/CodeGen/PowerPC/xxeval-vselect-x-not-c.ll new file mode 100644 index 0000000000000..3479d949439be --- /dev/null +++ b/llvm/test/CodeGen/PowerPC/xxeval-vselect-x-not-c.ll @@ -0,0 +1,445 @@ +; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5 +; Test file to verify the emission of Vector Evaluate instructions when ternary operators are used. + +; RUN: llc -verify-machineinstrs -mcpu=pwr10 -mtriple=powerpc64le-unknown-unknown \ +; RUN: -ppc-asm-full-reg-names --ppc-vsr-nums-as-vr < %s | FileCheck %s + +; RUN: llc -verify-machineinstrs -mcpu=pwr10 -mtriple=powerpc-ibm-aix-xcoff \ +; RUN: -ppc-asm-full-reg-names --ppc-vsr-nums-as-vr < %s | FileCheck %s + +; RUN: llc -verify-machineinstrs -mcpu=pwr10 -mtriple=powerpc64-ibm-aix-xcoff \ +; RUN: -ppc-asm-full-reg-names --ppc-vsr-nums-as-vr < %s | FileCheck %s + +; Function to test ternary(A, and(B, C), not(C)) for <4 x i32> +define <4 x i32> @ternary_A_and_BC_not_C_4x32(<4 x i1> %A, <4 x i32> %B, <4 x i32> %C) { +; CHECK-LABEL: ternary_A_and_BC_not_C_4x32: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: xxleqv v5, v5, v5 +; CHECK-NEXT: xxland vs0, v3, v4 +; CHECK-NEXT: xxlnor vs1, v4, v4 +; CHECK-NEXT: vslw v2, v2, v5 +; CHECK-NEXT: vsraw v2, v2, v5 +; CHECK-NEXT: xxsel v2, vs1, vs0, v2 +; CHECK-NEXT: blr +entry: + %and = and <4 x i32> %B, %C + %not = xor <4 x i32> %C, ; Vector not operation + %res = select <4 x i1> %A, <4 x i32> %and, <4 x i32> %not + ret <4 x i32> %res +} + +; Function to test ternary(A, and(B, C), not(C)) for <2 x i64> +define <2 x i64> @ternary_A_and_BC_not_C_2x64(<2 x i1> %A, <2 x i64> %B, <2 x i64> %C) { +; CHECK-LABEL: ternary_A_and_BC_not_C_2x64: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: xxlxor v5, v5, v5 +; CHECK-NEXT: xxland vs0, v3, v4 +; CHECK-NEXT: xxlnor vs1, v4, v4 +; CHECK-NEXT: xxsplti32dx v5, 1, 63 +; CHECK-NEXT: vsld v2, v2, v5 +; CHECK-NEXT: vsrad v2, v2, v5 +; CHECK-NEXT: xxsel v2, vs1, vs0, v2 +; CHECK-NEXT: blr +entry: + %and = and <2 x i64> %B, %C + %not = xor <2 x i64> %C, ; Vector not operation + %res = select <2 x i1> %A, <2 x i64> %and, <2 x i64> %not + ret <2 x i64> %res +} + +; Function to test ternary(A, and(B, C), not(C)) for <16 x i8> +define <16 x i8> @ternary_A_and_BC_not_C_16x8(<16 x i1> %A, <16 x i8> %B, <16 x i8> %C) { +; CHECK-LABEL: ternary_A_and_BC_not_C_16x8: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: xxspltib v5, 7 +; CHECK-NEXT: xxland vs0, v3, v4 +; CHECK-NEXT: xxlnor vs1, v4, v4 +; CHECK-NEXT: vslb v2, v2, v5 +; CHECK-NEXT: vsrab v2, v2, v5 +; CHECK-NEXT: xxsel v2, vs1, vs0, v2 +; CHECK-NEXT: blr +entry: + %and = and <16 x i8> %B, %C + %not = xor <16 x i8> %C, ; Vector not operation + %res = select <16 x i1> %A, <16 x i8> %and, <16 x i8> %not + ret <16 x i8> %res +} + +; Function to test ternary(A, and(B, C), not(C)) for <8 x i16> +define <8 x i16> @ternary_A_and_BC_not_C_8x16(<8 x i1> %A, <8 x i16> %B, <8 x i16> %C) { +; CHECK-LABEL: ternary_A_and_BC_not_C_8x16: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: xxspltiw v5, 983055 +; CHECK-NEXT: xxland vs0, v3, v4 +; CHECK-NEXT: xxlnor vs1, v4, v4 +; CHECK-NEXT: vslh v2, v2, v5 +; CHECK-NEXT: vsrah v2, v2, v5 +; CHECK-NEXT: xxsel v2, vs1, vs0, v2 +; CHECK-NEXT: blr +entry: + %and = and <8 x i16> %B, %C + %not = xor <8 x i16> %C, ; Vector not operation + %res = select <8 x i1> %A, <8 x i16> %and, <8 x i16> %not + ret <8 x i16> %res +} + +; Function to test ternary(A, B, not(C)) for <4 x i32> +define <4 x i32> @ternary_A_B_not_C_4x32(<4 x i1> %A, <4 x i32> %B, <4 x i32> %C) { +; CHECK-LABEL: ternary_A_B_not_C_4x32: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: xxleqv v5, v5, v5 +; CHECK-NEXT: xxlnor vs0, v4, v4 +; CHECK-NEXT: vslw v2, v2, v5 +; CHECK-NEXT: vsraw v2, v2, v5 +; CHECK-NEXT: xxsel v2, vs0, v3, v2 +; CHECK-NEXT: blr +entry: + %not = xor <4 x i32> %C, ; Vector not operation + %res = select <4 x i1> %A, <4 x i32> %B, <4 x i32> %not + ret <4 x i32> %res +} + +; Function to test ternary(A, B, not(C)) for <2 x i64> +define <2 x i64> @ternary_A_B_not_C_2x64(<2 x i1> %A, <2 x i64> %B, <2 x i64> %C) { +; CHECK-LABEL: ternary_A_B_not_C_2x64: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: xxlxor v5, v5, v5 +; CHECK-NEXT: xxlnor vs0, v4, v4 +; CHECK-NEXT: xxsplti32dx v5, 1, 63 +; CHECK-NEXT: vsld v2, v2, v5 +; CHECK-NEXT: vsrad v2, v2, v5 +; CHECK-NEXT: xxsel v2, vs0, v3, v2 +; CHECK-NEXT: blr +entry: + %not = xor <2 x i64> %C, ; Vector not operation + %res = select <2 x i1> %A, <2 x i64> %B, <2 x i64> %not + ret <2 x i64> %res +} + +; Function to test ternary(A, B, not(C)) for <16 x i8> +define <16 x i8> @ternary_A_B_not_C_16x8(<16 x i1> %A, <16 x i8> %B, <16 x i8> %C) { +; CHECK-LABEL: ternary_A_B_not_C_16x8: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: xxspltib v5, 7 +; CHECK-NEXT: xxlnor vs0, v4, v4 +; CHECK-NEXT: vslb v2, v2, v5 +; CHECK-NEXT: vsrab v2, v2, v5 +; CHECK-NEXT: xxsel v2, vs0, v3, v2 +; CHECK-NEXT: blr +entry: + %not = xor <16 x i8> %C, ; Vector not operation + %res = select <16 x i1> %A, <16 x i8> %B, <16 x i8> %not + ret <16 x i8> %res +} + +; Function to test ternary(A, B, not(C)) for <8 x i16> +define <8 x i16> @ternary_A_B_not_C_8x16(<8 x i1> %A, <8 x i16> %B, <8 x i16> %C) { +; CHECK-LABEL: ternary_A_B_not_C_8x16: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: xxspltiw v5, 983055 +; CHECK-NEXT: xxlnor vs0, v4, v4 +; CHECK-NEXT: vslh v2, v2, v5 +; CHECK-NEXT: vsrah v2, v2, v5 +; CHECK-NEXT: xxsel v2, vs0, v3, v2 +; CHECK-NEXT: blr +entry: + %not = xor <8 x i16> %C, ; Vector not operation + %res = select <8 x i1> %A, <8 x i16> %B, <8 x i16> %not + ret <8 x i16> %res +} + +; Function to test ternary(A, xor(B, C), not(C)) for <4 x i32> +define <4 x i32> @ternary_A_xor_BC_not_C_4x32(<4 x i1> %A, <4 x i32> %B, <4 x i32> %C) { +; CHECK-LABEL: ternary_A_xor_BC_not_C_4x32: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: xxleqv v5, v5, v5 +; CHECK-NEXT: xxlxor vs0, v3, v4 +; CHECK-NEXT: xxlnor vs1, v4, v4 +; CHECK-NEXT: vslw v2, v2, v5 +; CHECK-NEXT: vsraw v2, v2, v5 +; CHECK-NEXT: xxsel v2, vs1, vs0, v2 +; CHECK-NEXT: blr +entry: + %xor = xor <4 x i32> %B, %C + %not = xor <4 x i32> %C, ; Vector not operation + %res = select <4 x i1> %A, <4 x i32> %xor, <4 x i32> %not + ret <4 x i32> %res +} + +; Function to test ternary(A, xor(B, C), not(C)) for <2 x i64> +define <2 x i64> @ternary_A_xor_BC_not_C_2x64(<2 x i1> %A, <2 x i64> %B, <2 x i64> %C) { +; CHECK-LABEL: ternary_A_xor_BC_not_C_2x64: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: xxlxor v5, v5, v5 +; CHECK-NEXT: xxlxor vs0, v3, v4 +; CHECK-NEXT: xxlnor vs1, v4, v4 +; CHECK-NEXT: xxsplti32dx v5, 1, 63 +; CHECK-NEXT: vsld v2, v2, v5 +; CHECK-NEXT: vsrad v2, v2, v5 +; CHECK-NEXT: xxsel v2, vs1, vs0, v2 +; CHECK-NEXT: blr +entry: + %xor = xor <2 x i64> %B, %C + %not = xor <2 x i64> %C, ; Vector not operation + %res = select <2 x i1> %A, <2 x i64> %xor, <2 x i64> %not + ret <2 x i64> %res +} + +; Function to test ternary(A, xor(B, C), not(C)) for <16 x i8> +define <16 x i8> @ternary_A_xor_BC_not_C_16x8(<16 x i1> %A, <16 x i8> %B, <16 x i8> %C) { +; CHECK-LABEL: ternary_A_xor_BC_not_C_16x8: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: xxspltib v5, 7 +; CHECK-NEXT: xxlxor vs0, v3, v4 +; CHECK-NEXT: xxlnor vs1, v4, v4 +; CHECK-NEXT: vslb v2, v2, v5 +; CHECK-NEXT: vsrab v2, v2, v5 +; CHECK-NEXT: xxsel v2, vs1, vs0, v2 +; CHECK-NEXT: blr +entry: + %xor = xor <16 x i8> %B, %C + %not = xor <16 x i8> %C, ; Vector not operation + %res = select <16 x i1> %A, <16 x i8> %xor, <16 x i8> %not + ret <16 x i8> %res +} + +; Function to test ternary(A, xor(B, C), not(C)) for <8 x i16> +define <8 x i16> @ternary_A_xor_BC_not_C_8x16(<8 x i1> %A, <8 x i16> %B, <8 x i16> %C) { +; CHECK-LABEL: ternary_A_xor_BC_not_C_8x16: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: xxspltiw v5, 983055 +; CHECK-NEXT: xxlxor vs0, v3, v4 +; CHECK-NEXT: xxlnor vs1, v4, v4 +; CHECK-NEXT: vslh v2, v2, v5 +; CHECK-NEXT: vsrah v2, v2, v5 +; CHECK-NEXT: xxsel v2, vs1, vs0, v2 +; CHECK-NEXT: blr +entry: + %xor = xor <8 x i16> %B, %C + %not = xor <8 x i16> %C, ; Vector not operation + %res = select <8 x i1> %A, <8 x i16> %xor, <8 x i16> %not + ret <8 x i16> %res +} + +; Function to test ternary(A, or(B, C), not(C)) for <4 x i32> +define <4 x i32> @ternary_A_or_BC_not_C_4x32(<4 x i1> %A, <4 x i32> %B, <4 x i32> %C) { +; CHECK-LABEL: ternary_A_or_BC_not_C_4x32: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: xxleqv v5, v5, v5 +; CHECK-NEXT: xxlor vs0, v3, v4 +; CHECK-NEXT: xxlnor vs1, v4, v4 +; CHECK-NEXT: vslw v2, v2, v5 +; CHECK-NEXT: vsraw v2, v2, v5 +; CHECK-NEXT: xxsel v2, vs1, vs0, v2 +; CHECK-NEXT: blr +entry: + %or = or <4 x i32> %B, %C + %not = xor <4 x i32> %C, ; Vector not operation + %res = select <4 x i1> %A, <4 x i32> %or, <4 x i32> %not + ret <4 x i32> %res +} + +; Function to test ternary(A, or(B, C), not(C)) for <2 x i64> +define <2 x i64> @ternary_A_or_BC_not_C_2x64(<2 x i1> %A, <2 x i64> %B, <2 x i64> %C) { +; CHECK-LABEL: ternary_A_or_BC_not_C_2x64: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: xxlxor v5, v5, v5 +; CHECK-NEXT: xxlor vs0, v3, v4 +; CHECK-NEXT: xxlnor vs1, v4, v4 +; CHECK-NEXT: xxsplti32dx v5, 1, 63 +; CHECK-NEXT: vsld v2, v2, v5 +; CHECK-NEXT: vsrad v2, v2, v5 +; CHECK-NEXT: xxsel v2, vs1, vs0, v2 +; CHECK-NEXT: blr +entry: + %or = or <2 x i64> %B, %C + %not = xor <2 x i64> %C, ; Vector not operation + %res = select <2 x i1> %A, <2 x i64> %or, <2 x i64> %not + ret <2 x i64> %res +} + +; Function to test ternary(A, or(B, C), not(C)) for <16 x i8> +define <16 x i8> @ternary_A_or_BC_not_C_16x8(<16 x i1> %A, <16 x i8> %B, <16 x i8> %C) { +; CHECK-LABEL: ternary_A_or_BC_not_C_16x8: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: xxspltib v5, 7 +; CHECK-NEXT: xxlor vs0, v3, v4 +; CHECK-NEXT: xxlnor vs1, v4, v4 +; CHECK-NEXT: vslb v2, v2, v5 +; CHECK-NEXT: vsrab v2, v2, v5 +; CHECK-NEXT: xxsel v2, vs1, vs0, v2 +; CHECK-NEXT: blr +entry: + %or = or <16 x i8> %B, %C + %not = xor <16 x i8> %C, ; Vector not operation + %res = select <16 x i1> %A, <16 x i8> %or, <16 x i8> %not + ret <16 x i8> %res +} + +; Function to test ternary(A, or(B, C), not(C)) for <8 x i16> +define <8 x i16> @ternary_A_or_BC_not_C_8x16(<8 x i1> %A, <8 x i16> %B, <8 x i16> %C) { +; CHECK-LABEL: ternary_A_or_BC_not_C_8x16: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: xxspltiw v5, 983055 +; CHECK-NEXT: xxlor vs0, v3, v4 +; CHECK-NEXT: xxlnor vs1, v4, v4 +; CHECK-NEXT: vslh v2, v2, v5 +; CHECK-NEXT: vsrah v2, v2, v5 +; CHECK-NEXT: xxsel v2, vs1, vs0, v2 +; CHECK-NEXT: blr +entry: + %or = or <8 x i16> %B, %C + %not = xor <8 x i16> %C, ; Vector not operation + %res = select <8 x i1> %A, <8 x i16> %or, <8 x i16> %not + ret <8 x i16> %res +} + +; Function to test ternary(A, not(B), not(C)) for <4 x i32> +define <4 x i32> @ternary_A_not_B_not_C_4x32(<4 x i1> %A, <4 x i32> %B, <4 x i32> %C) { +; CHECK-LABEL: ternary_A_not_B_not_C_4x32: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: xxleqv v5, v5, v5 +; CHECK-NEXT: xxlnor vs0, v3, v3 +; CHECK-NEXT: xxlnor vs1, v4, v4 +; CHECK-NEXT: vslw v2, v2, v5 +; CHECK-NEXT: vsraw v2, v2, v5 +; CHECK-NEXT: xxsel v2, vs1, vs0, v2 +; CHECK-NEXT: blr +entry: + %not_b = xor <4 x i32> %B, ; Vector not operation + %not_c = xor <4 x i32> %C, ; Vector not operation + %res = select <4 x i1> %A, <4 x i32> %not_b, <4 x i32> %not_c + ret <4 x i32> %res +} + +; Function to test ternary(A, not(B), not(C)) for <2 x i64> +define <2 x i64> @ternary_A_not_B_not_C_2x64(<2 x i1> %A, <2 x i64> %B, <2 x i64> %C) { +; CHECK-LABEL: ternary_A_not_B_not_C_2x64: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: xxlxor v5, v5, v5 +; CHECK-NEXT: xxlnor vs0, v3, v3 +; CHECK-NEXT: xxlnor vs1, v4, v4 +; CHECK-NEXT: xxsplti32dx v5, 1, 63 +; CHECK-NEXT: vsld v2, v2, v5 +; CHECK-NEXT: vsrad v2, v2, v5 +; CHECK-NEXT: xxsel v2, vs1, vs0, v2 +; CHECK-NEXT: blr +entry: + %not_b = xor <2 x i64> %B, ; Vector not operation + %not_c = xor <2 x i64> %C, ; Vector not operation + %res = select <2 x i1> %A, <2 x i64> %not_b, <2 x i64> %not_c + ret <2 x i64> %res +} + +; Function to test ternary(A, not(B), not(C)) for <16 x i8> +define <16 x i8> @ternary_A_not_B_not_C_16x8(<16 x i1> %A, <16 x i8> %B, <16 x i8> %C) { +; CHECK-LABEL: ternary_A_not_B_not_C_16x8: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: xxspltib v5, 7 +; CHECK-NEXT: xxlnor vs0, v3, v3 +; CHECK-NEXT: xxlnor vs1, v4, v4 +; CHECK-NEXT: vslb v2, v2, v5 +; CHECK-NEXT: vsrab v2, v2, v5 +; CHECK-NEXT: xxsel v2, vs1, vs0, v2 +; CHECK-NEXT: blr +entry: + %not_b = xor <16 x i8> %B, ; Vector not operation + %not_c = xor <16 x i8> %C, ; Vector not operation + %res = select <16 x i1> %A, <16 x i8> %not_b, <16 x i8> %not_c + ret <16 x i8> %res +} + +; Function to test ternary(A, not(B), not(C)) for <8 x i16> +define <8 x i16> @ternary_A_not_B_not_C_8x16(<8 x i1> %A, <8 x i16> %B, <8 x i16> %C) { +; CHECK-LABEL: ternary_A_not_B_not_C_8x16: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: xxspltiw v5, 983055 +; CHECK-NEXT: xxlnor vs0, v3, v3 +; CHECK-NEXT: xxlnor vs1, v4, v4 +; CHECK-NEXT: vslh v2, v2, v5 +; CHECK-NEXT: vsrah v2, v2, v5 +; CHECK-NEXT: xxsel v2, vs1, vs0, v2 +; CHECK-NEXT: blr +entry: + %not_b = xor <8 x i16> %B, ; Vector not operation + %not_c = xor <8 x i16> %C, ; Vector not operation + %res = select <8 x i1> %A, <8 x i16> %not_b, <8 x i16> %not_c + ret <8 x i16> %res +} + +; Function to test ternary(A, nand(B, C), not(C)) for <4 x i32> +define <4 x i32> @ternary_A_nand_BC_not_C_4x32(<4 x i1> %A, <4 x i32> %B, <4 x i32> %C) { +; CHECK-LABEL: ternary_A_nand_BC_not_C_4x32: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: xxleqv v5, v5, v5 +; CHECK-NEXT: xxlnand vs0, v3, v4 +; CHECK-NEXT: xxlnor vs1, v4, v4 +; CHECK-NEXT: vslw v2, v2, v5 +; CHECK-NEXT: vsraw v2, v2, v5 +; CHECK-NEXT: xxsel v2, vs1, vs0, v2 +; CHECK-NEXT: blr +entry: + %and = and <4 x i32> %B, %C + %nand = xor <4 x i32> %and, ; Vector nand operation + %not = xor <4 x i32> %C, ; Vector not operation + %res = select <4 x i1> %A, <4 x i32> %nand, <4 x i32> %not + ret <4 x i32> %res +} + +; Function to test ternary(A, nand(B, C), not(C)) for <2 x i64> +define <2 x i64> @ternary_A_nand_BC_not_C_2x64(<2 x i1> %A, <2 x i64> %B, <2 x i64> %C) { +; CHECK-LABEL: ternary_A_nand_BC_not_C_2x64: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: xxlxor v5, v5, v5 +; CHECK-NEXT: xxlnand vs0, v3, v4 +; CHECK-NEXT: xxlnor vs1, v4, v4 +; CHECK-NEXT: xxsplti32dx v5, 1, 63 +; CHECK-NEXT: vsld v2, v2, v5 +; CHECK-NEXT: vsrad v2, v2, v5 +; CHECK-NEXT: xxsel v2, vs1, vs0, v2 +; CHECK-NEXT: blr +entry: + %and = and <2 x i64> %B, %C + %nand = xor <2 x i64> %and, ; Vector nand operation + %not = xor <2 x i64> %C, ; Vector not operation + %res = select <2 x i1> %A, <2 x i64> %nand, <2 x i64> %not + ret <2 x i64> %res +} + +; Function to test ternary(A, nand(B, C), not(C)) for <16 x i8> +define <16 x i8> @ternary_A_nand_BC_not_C_16x8(<16 x i1> %A, <16 x i8> %B, <16 x i8> %C) { +; CHECK-LABEL: ternary_A_nand_BC_not_C_16x8: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: xxspltib v5, 7 +; CHECK-NEXT: xxlnand vs0, v3, v4 +; CHECK-NEXT: xxlnor vs1, v4, v4 +; CHECK-NEXT: vslb v2, v2, v5 +; CHECK-NEXT: vsrab v2, v2, v5 +; CHECK-NEXT: xxsel v2, vs1, vs0, v2 +; CHECK-NEXT: blr +entry: + %and = and <16 x i8> %B, %C + %nand = xor <16 x i8> %and, ; Vector nand operation + %not = xor <16 x i8> %C, ; Vector not operation + %res = select <16 x i1> %A, <16 x i8> %nand, <16 x i8> %not + ret <16 x i8> %res +} + +; Function to test ternary(A, nand(B, C), not(C)) for <8 x i16> +define <8 x i16> @ternary_A_nand_BC_not_C_8x16(<8 x i1> %A, <8 x i16> %B, <8 x i16> %C) { +; CHECK-LABEL: ternary_A_nand_BC_not_C_8x16: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: xxspltiw v5, 983055 +; CHECK-NEXT: xxlnand vs0, v3, v4 +; CHECK-NEXT: xxlnor vs1, v4, v4 +; CHECK-NEXT: vslh v2, v2, v5 +; CHECK-NEXT: vsrah v2, v2, v5 +; CHECK-NEXT: xxsel v2, vs1, vs0, v2 +; CHECK-NEXT: blr +entry: + %and = and <8 x i16> %B, %C + %nand = xor <8 x i16> %and, ; Vector nand operation + %not = xor <8 x i16> %C, ; Vector not operation + %res = select <8 x i1> %A, <8 x i16> %nand, <8 x i16> %not + ret <8 x i16> %res +}