diff --git a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp --- a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp +++ b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp @@ -17066,8 +17066,8 @@ })) return SDValue(); - APInt V; - if (!ISD::isConstantSplatVector(Op->getOperand(1).getNode(), V)) + APInt SplatVal; + if (!ISD::isConstantSplatVector(Op->getOperand(1).getNode(), SplatVal)) return SDValue(); SDLoc DL(Op); @@ -17083,14 +17083,25 @@ if (Op0SExt && isSignedIntSetCC(CC)) { Op0ExtV = SDValue(Op0SExt, 0); Op1ExtV = DAG.getNode(ISD::SIGN_EXTEND, DL, MVT::v16i32, Op->getOperand(1)); - } else if (Op0ZExt && isUnsignedIntSetCC(CC)) { + } else if (Op0ZExt) { Op0ExtV = SDValue(Op0ZExt, 0); - Op1ExtV = DAG.getNode(ISD::ZERO_EXTEND, DL, MVT::v16i32, Op->getOperand(1)); - } else + // Try to convert signed to unsigned predicate, so zext can be used: %a >s + // -1 -> zext(%a) getOperand(1)); + } + + if (!Op0ExtV || !Op1ExtV) return SDValue(); return DAG.getNode(ISD::SETCC, DL, MVT::v16i1, Op0ExtV, Op1ExtV, - Op->getOperand(2)); + DAG.getCondCode(CC)); } static SDValue performSETCCCombine(SDNode *N, SelectionDAG &DAG) { diff --git a/llvm/test/CodeGen/AArch64/vselect-ext.ll b/llvm/test/CodeGen/AArch64/vselect-ext.ll --- a/llvm/test/CodeGen/AArch64/vselect-ext.ll +++ b/llvm/test/CodeGen/AArch64/vselect-ext.ll @@ -166,24 +166,21 @@ define <16 x i32> @same_zext_used_in_cmp_signed_pred_and_select_can_convert_to_unsigned_pred(<16 x i8> %a) { ; CHECK-LABEL: same_zext_used_in_cmp_signed_pred_and_select_can_convert_to_unsigned_pred: ; CHECK: ; %bb.0: ; %entry -; CHECK-NEXT: movi.2d v1, #0xffffffffffffffff -; CHECK-NEXT: ushll.8h v2, v0, #0 -; CHECK-NEXT: ushll2.8h v3, v0, #0 -; CHECK-NEXT: ushll.4s v4, v2, #0 -; CHECK-NEXT: cmgt.16b v0, v0, v1 -; CHECK-NEXT: ushll.4s v5, v3, #0 -; CHECK-NEXT: ushll2.4s v1, v3, #0 -; CHECK-NEXT: sshll.8h v3, v0, #0 -; CHECK-NEXT: sshll2.8h v0, v0, #0 -; CHECK-NEXT: ushll2.4s v2, v2, #0 -; CHECK-NEXT: sshll.4s v6, v3, #0 -; CHECK-NEXT: sshll.4s v7, v0, #0 -; CHECK-NEXT: sshll2.4s v0, v0, #0 -; CHECK-NEXT: sshll2.4s v16, v3, #0 -; CHECK-NEXT: and.16b v3, v1, v0 -; CHECK-NEXT: and.16b v1, v2, v16 -; CHECK-NEXT: and.16b v2, v5, v7 -; CHECK-NEXT: and.16b v0, v4, v6 +; CHECK-NEXT: movi.2d v1, #0x0000ff000000ff +; CHECK-NEXT: ushll2.8h v2, v0, #0 +; CHECK-NEXT: ushll.8h v0, v0, #0 +; CHECK-NEXT: ushll2.4s v3, v2, #0 +; CHECK-NEXT: ushll2.4s v4, v0, #0 +; CHECK-NEXT: ushll.4s v0, v0, #0 +; CHECK-NEXT: ushll.4s v2, v2, #0 +; CHECK-NEXT: cmhi.4s v5, v1, v0 +; CHECK-NEXT: cmhi.4s v6, v1, v2 +; CHECK-NEXT: cmhi.4s v7, v1, v3 +; CHECK-NEXT: cmhi.4s v1, v1, v4 +; CHECK-NEXT: and.16b v3, v3, v7 +; CHECK-NEXT: and.16b v1, v4, v1 +; CHECK-NEXT: and.16b v2, v2, v6 +; CHECK-NEXT: and.16b v0, v0, v5 ; CHECK-NEXT: ret entry: %ext = zext <16 x i8> %a to <16 x i32> @@ -195,32 +192,29 @@ define void @extension_in_loop_v16i8_to_v16i32(i8* %src, i32* %dst) { ; CHECK-LABEL: extension_in_loop_v16i8_to_v16i32: ; CHECK: ; %bb.0: ; %entry -; CHECK-NEXT: movi.2d v0, #0xffffffffffffffff +; CHECK-NEXT: movi.2d v0, #0x0000ff000000ff ; CHECK-NEXT: mov x8, xzr ; CHECK-NEXT: LBB7_1: ; %loop ; CHECK-NEXT: ; =>This Inner Loop Header: Depth=1 ; CHECK-NEXT: ldr q1, [x0, x8] ; CHECK-NEXT: add x8, x8, #16 ; CHECK-NEXT: cmp x8, #128 -; CHECK-NEXT: cmgt.16b v2, v1, v0 -; CHECK-NEXT: ushll2.8h v3, v1, #0 -; CHECK-NEXT: sshll2.8h v4, v2, #0 -; CHECK-NEXT: ushll2.4s v5, v3, #0 -; CHECK-NEXT: ushll.4s v3, v3, #0 -; CHECK-NEXT: sshll2.4s v6, v4, #0 -; CHECK-NEXT: sshll.4s v4, v4, #0 +; CHECK-NEXT: ushll2.8h v2, v1, #0 ; CHECK-NEXT: ushll.8h v1, v1, #0 -; CHECK-NEXT: sshll.8h v2, v2, #0 -; CHECK-NEXT: and.16b v5, v5, v6 -; CHECK-NEXT: and.16b v3, v3, v4 -; CHECK-NEXT: stp q3, q5, [x1, #32] -; CHECK-NEXT: sshll2.4s v4, v2, #0 -; CHECK-NEXT: sshll.4s v2, v2, #0 -; CHECK-NEXT: ushll2.4s v3, v1, #0 +; CHECK-NEXT: ushll2.4s v3, v2, #0 +; CHECK-NEXT: ushll.4s v2, v2, #0 +; CHECK-NEXT: cmhi.4s v5, v0, v3 +; CHECK-NEXT: cmhi.4s v6, v0, v2 +; CHECK-NEXT: ushll2.4s v4, v1, #0 ; CHECK-NEXT: ushll.4s v1, v1, #0 -; CHECK-NEXT: and.16b v3, v3, v4 -; CHECK-NEXT: and.16b v1, v1, v2 -; CHECK-NEXT: stp q1, q3, [x1], #64 +; CHECK-NEXT: and.16b v3, v3, v5 +; CHECK-NEXT: and.16b v2, v2, v6 +; CHECK-NEXT: cmhi.4s v7, v0, v4 +; CHECK-NEXT: stp q2, q3, [x1, #32] +; CHECK-NEXT: cmhi.4s v3, v0, v1 +; CHECK-NEXT: and.16b v2, v4, v7 +; CHECK-NEXT: and.16b v1, v1, v3 +; CHECK-NEXT: stp q1, q2, [x1], #64 ; CHECK-NEXT: b.ne LBB7_1 ; CHECK-NEXT: ; %bb.2: ; %exit ; CHECK-NEXT: ret