Index: lib/Target/PowerPC/PPCInstrVSX.td =================================================================== --- lib/Target/PowerPC/PPCInstrVSX.td +++ lib/Target/PowerPC/PPCInstrVSX.td @@ -958,6 +958,13 @@ def : Pat<(v4i32 (vnot_ppc v4i32:$A)), (v4i32 (XXLNOR $A, $A))>; +def : Pat<(v4i32 (or (and (vnot_ppc v4i32:$C), v4i32:$A), + (and v4i32:$B, v4i32:$C))), + (v4i32 (XXSEL $A, $B, $C))>; +def : Pat<(v4i32 (or (and v4i32:$A, (vnot_ppc v4i32:$C)), + (and v4i32:$B, v4i32:$C))), + (v4i32 (XXSEL $A, $B, $C))>; + let Predicates = [IsBigEndian] in { def : Pat<(v2f64 (scalar_to_vector f64:$A)), (v2f64 (SUBREG_TO_REG (i64 1), $A, sub_64))>; Index: test/CodeGen/PowerPC/vec-select.ll =================================================================== --- test/CodeGen/PowerPC/vec-select.ll +++ test/CodeGen/PowerPC/vec-select.ll @@ -0,0 +1,41 @@ +; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py +; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu \ +; RUN: -mcpu=pwr7 -ppc-asm-full-reg-names < %s | FileCheck %s +define dso_local <4 x i32> @test(<4 x i32> %a, <4 x i32> %b, <4 x i32> %c) { +; CHECK-LABEL: test: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: xxsel vs34, vs34, vs35, vs36 +; CHECK-NEXT: blr +entry: + %neg.i = xor <4 x i32> %c, + %and.i = and <4 x i32> %neg.i, %a + %and1.i = and <4 x i32> %c, %b + %or.i = or <4 x i32> %and.i, %and1.i + ret <4 x i32> %or.i +} + +define dso_local <8 x i16> @test2(<8 x i16> %a, <8 x i16> %b, <8 x i16> %c) { +; CHECK-LABEL: test2: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: xxsel vs34, vs34, vs35, vs36 +; CHECK-NEXT: blr +entry: + %neg.i = xor <8 x i16> %c, + %and.i = and <8 x i16> %neg.i, %a + %and1.i = and <8 x i16> %c, %b + %or.i = or <8 x i16> %and.i, %and1.i + ret <8 x i16> %or.i +} + +define dso_local <16 x i8> @test3(<16 x i8> %a, <16 x i8> %b, <16 x i8> %c) { +; CHECK-LABEL: test3: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: xxsel vs34, vs34, vs35, vs36 +; CHECK-NEXT: blr +entry: + %neg.i = xor <16 x i8> %c, + %and.i = and <16 x i8> %neg.i, %a + %and1.i = and <16 x i8> %c, %b + %or.i = or <16 x i8> %and.i, %and1.i + ret <16 x i8> %or.i +}