diff --git a/llvm/lib/Target/PowerPC/P9InstrResources.td b/llvm/lib/Target/PowerPC/P9InstrResources.td --- a/llvm/lib/Target/PowerPC/P9InstrResources.td +++ b/llvm/lib/Target/PowerPC/P9InstrResources.td @@ -64,6 +64,7 @@ XXLAND, XXLANDC, XXLEQV, + XXLEQVOnes, XXLNAND, XXLNOR, XXLOR, diff --git a/llvm/lib/Target/PowerPC/PPCInstrFormats.td b/llvm/lib/Target/PowerPC/PPCInstrFormats.td --- a/llvm/lib/Target/PowerPC/PPCInstrFormats.td +++ b/llvm/lib/Target/PowerPC/PPCInstrFormats.td @@ -1209,7 +1209,7 @@ let Inst{31} = XT{5}; } -class XX3Form_Zero opcode, bits<8> xo, dag OOL, dag IOL, string asmstr, +class XX3Form_SameOp opcode, bits<8> xo, dag OOL, dag IOL, string asmstr, InstrItinClass itin, list pattern> : XX3Form { let XA = XT; diff --git a/llvm/lib/Target/PowerPC/PPCInstrInfo.cpp b/llvm/lib/Target/PowerPC/PPCInstrInfo.cpp --- a/llvm/lib/Target/PowerPC/PPCInstrInfo.cpp +++ b/llvm/lib/Target/PowerPC/PPCInstrInfo.cpp @@ -335,6 +335,7 @@ case PPC::XXLXORz: case PPC::XXLXORspz: case PPC::XXLXORdpz: + case PPC::XXLEQVOnes: case PPC::V_SET0B: case PPC::V_SET0H: case PPC::V_SET0: diff --git a/llvm/lib/Target/PowerPC/PPCInstrVSX.td b/llvm/lib/Target/PowerPC/PPCInstrVSX.td --- a/llvm/lib/Target/PowerPC/PPCInstrVSX.td +++ b/llvm/lib/Target/PowerPC/PPCInstrVSX.td @@ -855,7 +855,7 @@ let isCodeGenOnly = 1, isMoveImm = 1, isAsCheapAsAMove = 1, isReMaterializable = 1 in { - def XXLXORz : XX3Form_Zero<60, 154, (outs vsrc:$XT), (ins), + def XXLXORz : XX3Form_SameOp<60, 154, (outs vsrc:$XT), (ins), "xxlxor $XT, $XT, $XT", IIC_VecGeneral, [(set v4i32:$XT, (v4i32 immAllZerosV))]>; def XXLXORdpz : XX3Form_SetZero<60, 154, @@ -1284,10 +1284,20 @@ [(set v4i32:$XT, (vnot_ppc (and v4i32:$XA, v4i32:$XB)))]>; } // isCommutable - + def : Pat<(int_ppc_vsx_xxleqv v4i32:$A, v4i32:$B), (XXLEQV $A, $B)>; + let isCodeGenOnly = 1, isMoveImm = 1, isAsCheapAsAMove = 1, + isReMaterializable = 1 in { + def XXLEQVOnes : XX3Form_SameOp<60, 186, (outs vsrc:$XT), (ins), + "xxleqv $XT, $XT, $XT", IIC_VecGeneral, + [(set v4i32:$XT, (v4i32 immAllOnesV))]>; + } + + def : Pat<(v4i32 (bitconvert (v16i8 immAllOnesV))), + (XXLEQVOnes)>; + def XXLORC : XX3Form<60, 170, (outs vsrc:$XT), (ins vsrc:$XA, vsrc:$XB), "xxlorc $XT, $XA, $XB", IIC_VecGeneral, @@ -2407,6 +2417,7 @@ // Materialize a zero-vector of long long def : Pat<(v2i64 immAllZerosV), (v2i64 (XXLXORz))>; + } def AlignValues { @@ -4076,14 +4087,6 @@ immAnyExt8:$A, immAnyExt8:$A, immAnyExt8:$A, immAnyExt8:$A)), (v16i8 (COPY_TO_REGCLASS (XXSPLTIB imm:$A), VSRC))>; - def : Pat<(v16i8 immAllOnesV), - (v16i8 (COPY_TO_REGCLASS (XXSPLTIB 255), VSRC))>; - def : Pat<(v8i16 immAllOnesV), - (v8i16 (COPY_TO_REGCLASS (XXSPLTIB 255), VSRC))>; - def : Pat<(v4i32 immAllOnesV), - (v4i32 (XXSPLTIB 255))>; - def : Pat<(v2i64 immAllOnesV), - (v2i64 (XXSPLTIB 255))>; def : Pat<(v4i32 (scalar_to_vector FltToIntLoad.A)), (v4i32 (XVCVSPSXWS (LXVWSX xoaddr:$A)))>; def : Pat<(v4i32 (scalar_to_vector FltToUIntLoad.A)), diff --git a/llvm/test/CodeGen/PowerPC/build-vector-tests.ll b/llvm/test/CodeGen/PowerPC/build-vector-tests.ll --- a/llvm/test/CodeGen/PowerPC/build-vector-tests.ll +++ b/llvm/test/CodeGen/PowerPC/build-vector-tests.ll @@ -758,22 +758,22 @@ define <4 x i32> @allOnei() { ; P9BE-LABEL: allOnei: ; P9BE: # %bb.0: # %entry -; P9BE-NEXT: xxspltib v2, 255 +; P9BE-NEXT: xxleqv v2, v2, v2 ; P9BE-NEXT: blr ; ; P9LE-LABEL: allOnei: ; P9LE: # %bb.0: # %entry -; P9LE-NEXT: xxspltib v2, 255 +; P9LE-NEXT: xxleqv v2, v2, v2 ; P9LE-NEXT: blr ; ; P8BE-LABEL: allOnei: ; P8BE: # %bb.0: # %entry -; P8BE-NEXT: vspltisb v2, -1 +; P8BE-NEXT: xxleqv v2, v2, v2 ; P8BE-NEXT: blr ; ; P8LE-LABEL: allOnei: ; P8LE: # %bb.0: # %entry -; P8LE-NEXT: vspltisb v2, -1 +; P8LE-NEXT: xxleqv v2, v2, v2 ; P8LE-NEXT: blr entry: ret <4 x i32> @@ -2342,22 +2342,22 @@ define <4 x i32> @allOneui() { ; P9BE-LABEL: allOneui: ; P9BE: # %bb.0: # %entry -; P9BE-NEXT: xxspltib v2, 255 +; P9BE-NEXT: xxleqv v2, v2, v2 ; P9BE-NEXT: blr ; ; P9LE-LABEL: allOneui: ; P9LE: # %bb.0: # %entry -; P9LE-NEXT: xxspltib v2, 255 +; P9LE-NEXT: xxleqv v2, v2, v2 ; P9LE-NEXT: blr ; ; P8BE-LABEL: allOneui: ; P8BE: # %bb.0: # %entry -; P8BE-NEXT: vspltisb v2, -1 +; P8BE-NEXT: xxleqv v2, v2, v2 ; P8BE-NEXT: blr ; ; P8LE-LABEL: allOneui: ; P8LE: # %bb.0: # %entry -; P8LE-NEXT: vspltisb v2, -1 +; P8LE-NEXT: xxleqv v2, v2, v2 ; P8LE-NEXT: blr entry: ret <4 x i32> diff --git a/llvm/test/CodeGen/PowerPC/sat-add.ll b/llvm/test/CodeGen/PowerPC/sat-add.ll --- a/llvm/test/CodeGen/PowerPC/sat-add.ll +++ b/llvm/test/CodeGen/PowerPC/sat-add.ll @@ -506,12 +506,12 @@ ; CHECK-LABEL: unsigned_sat_constant_v4i32_using_cmp_sum: ; CHECK: # %bb.0: ; CHECK-NEXT: addis 3, 2, .LCPI31_0@toc@ha -; CHECK-NEXT: vspltisb 4, -1 +; CHECK-NEXT: xxleqv 0, 0, 0 ; CHECK-NEXT: addi 3, 3, .LCPI31_0@toc@l ; CHECK-NEXT: lvx 3, 0, 3 ; CHECK-NEXT: vadduwm 3, 2, 3 ; CHECK-NEXT: vcmpgtuw 2, 2, 3 -; CHECK-NEXT: xxsel 34, 35, 36, 34 +; CHECK-NEXT: xxsel 34, 35, 0, 34 ; CHECK-NEXT: blr %a = add <4 x i32> %x, %c = icmp ugt <4 x i32> %x, %a @@ -523,7 +523,7 @@ ; CHECK-LABEL: unsigned_sat_constant_v4i32_using_cmp_notval: ; CHECK: # %bb.0: ; CHECK-NEXT: addis 3, 2, .LCPI32_1@toc@ha -; CHECK-NEXT: vspltisb 5, -1 +; CHECK-NEXT: xxleqv 0, 0, 0 ; CHECK-NEXT: addi 3, 3, .LCPI32_1@toc@l ; CHECK-NEXT: lvx 3, 0, 3 ; CHECK-NEXT: addis 3, 2, .LCPI32_0@toc@ha @@ -531,7 +531,7 @@ ; CHECK-NEXT: vcmpgtuw 3, 2, 3 ; CHECK-NEXT: lvx 4, 0, 3 ; CHECK-NEXT: vadduwm 2, 2, 4 -; CHECK-NEXT: xxsel 34, 34, 37, 35 +; CHECK-NEXT: xxsel 34, 34, 0, 35 ; CHECK-NEXT: blr %a = add <4 x i32> %x, %c = icmp ugt <4 x i32> %x, @@ -705,9 +705,9 @@ ; CHECK-LABEL: unsigned_sat_variable_v4i32_using_cmp_sum: ; CHECK: # %bb.0: ; CHECK-NEXT: vadduwm 3, 2, 3 -; CHECK-NEXT: vspltisb 4, -1 +; CHECK-NEXT: xxleqv 0, 0, 0 ; CHECK-NEXT: vcmpgtuw 2, 2, 3 -; CHECK-NEXT: xxsel 34, 35, 36, 34 +; CHECK-NEXT: xxsel 34, 35, 0, 34 ; CHECK-NEXT: blr %a = add <4 x i32> %x, %y %c = icmp ugt <4 x i32> %x, %a @@ -719,10 +719,10 @@ ; CHECK-LABEL: unsigned_sat_variable_v4i32_using_cmp_notval: ; CHECK: # %bb.0: ; CHECK-NEXT: xxlnor 36, 35, 35 -; CHECK-NEXT: vspltisb 5, -1 +; CHECK-NEXT: xxleqv 0, 0, 0 ; CHECK-NEXT: vcmpgtuw 4, 2, 4 ; CHECK-NEXT: vadduwm 2, 2, 3 -; CHECK-NEXT: xxsel 34, 34, 37, 36 +; CHECK-NEXT: xxsel 34, 34, 0, 36 ; CHECK-NEXT: blr %noty = xor <4 x i32> %y, %a = add <4 x i32> %x, %y diff --git a/llvm/test/CodeGen/PowerPC/setcc-logic.ll b/llvm/test/CodeGen/PowerPC/setcc-logic.ll --- a/llvm/test/CodeGen/PowerPC/setcc-logic.ll +++ b/llvm/test/CodeGen/PowerPC/setcc-logic.ll @@ -325,7 +325,7 @@ define <4 x i1> @all_sign_bits_clear_vec(<4 x i32> %P, <4 x i32> %Q) { ; CHECK-LABEL: all_sign_bits_clear_vec: ; CHECK: # %bb.0: -; CHECK-NEXT: vspltisb 4, -1 +; CHECK-NEXT: xxleqv 36, 36, 36 ; CHECK-NEXT: xxlor 34, 34, 35 ; CHECK-NEXT: vcmpgtsw 2, 2, 4 ; CHECK-NEXT: blr @@ -338,7 +338,7 @@ define <4 x i1> @all_bits_set_vec(<4 x i32> %P, <4 x i32> %Q) { ; CHECK-LABEL: all_bits_set_vec: ; CHECK: # %bb.0: -; CHECK-NEXT: vspltisb 4, -1 +; CHECK-NEXT: xxleqv 36, 36, 36 ; CHECK-NEXT: xxland 34, 34, 35 ; CHECK-NEXT: vcmpequw 2, 2, 4 ; CHECK-NEXT: blr @@ -391,7 +391,7 @@ define <4 x i1> @any_bits_clear_vec(<4 x i32> %P, <4 x i32> %Q) { ; CHECK-LABEL: any_bits_clear_vec: ; CHECK: # %bb.0: -; CHECK-NEXT: vspltisb 4, -1 +; CHECK-NEXT: xxleqv 36, 36, 36 ; CHECK-NEXT: xxland 34, 34, 35 ; CHECK-NEXT: vcmpequw 2, 2, 4 ; CHECK-NEXT: xxlnor 34, 34, 34 @@ -405,7 +405,7 @@ define <4 x i1> @any_sign_bits_clear_vec(<4 x i32> %P, <4 x i32> %Q) { ; CHECK-LABEL: any_sign_bits_clear_vec: ; CHECK: # %bb.0: -; CHECK-NEXT: vspltisb 4, -1 +; CHECK-NEXT: xxleqv 36, 36, 36 ; CHECK-NEXT: xxland 34, 34, 35 ; CHECK-NEXT: vcmpgtsw 2, 2, 4 ; CHECK-NEXT: blr diff --git a/llvm/test/CodeGen/PowerPC/signbit-shift.ll b/llvm/test/CodeGen/PowerPC/signbit-shift.ll --- a/llvm/test/CodeGen/PowerPC/signbit-shift.ll +++ b/llvm/test/CodeGen/PowerPC/signbit-shift.ll @@ -29,7 +29,7 @@ define <4 x i32> @add_zext_ifpos_vec_splat(<4 x i32> %x) { ; CHECK-LABEL: add_zext_ifpos_vec_splat: ; CHECK: # %bb.0: -; CHECK-NEXT: vspltisb 3, -1 +; CHECK-NEXT: xxleqv 35, 35, 35 ; CHECK-NEXT: addis 3, 2, .LCPI2_0@toc@ha ; CHECK-NEXT: addi 3, 3, .LCPI2_0@toc@l ; CHECK-NEXT: vcmpgtsw 2, 2, 3 @@ -81,7 +81,7 @@ define <4 x i32> @add_sext_ifpos_vec_splat(<4 x i32> %x) { ; CHECK-LABEL: add_sext_ifpos_vec_splat: ; CHECK: # %bb.0: -; CHECK-NEXT: vspltisb 3, -1 +; CHECK-NEXT: xxleqv 35, 35, 35 ; CHECK-NEXT: addis 3, 2, .LCPI6_0@toc@ha ; CHECK-NEXT: addi 3, 3, .LCPI6_0@toc@l ; CHECK-NEXT: vcmpgtsw 2, 2, 3 diff --git a/llvm/test/CodeGen/PowerPC/vselect-constants.ll b/llvm/test/CodeGen/PowerPC/vselect-constants.ll --- a/llvm/test/CodeGen/PowerPC/vselect-constants.ll +++ b/llvm/test/CodeGen/PowerPC/vselect-constants.ll @@ -130,9 +130,9 @@ ; CHECK-LABEL: sel_0_or_minus1_vec: ; CHECK: # %bb.0: ; CHECK-NEXT: vspltisw 3, 1 -; CHECK-NEXT: vspltisb 4, -1 ; CHECK-NEXT: xxland 34, 34, 35 -; CHECK-NEXT: vadduwm 2, 2, 4 +; CHECK-NEXT: xxleqv 35, 35, 35 +; CHECK-NEXT: vadduwm 2, 2, 3 ; CHECK-NEXT: blr %add = select <4 x i1> %cond, <4 x i32> , <4 x i32> ret <4 x i32> %add