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 @@ -17517,10 +17517,12 @@ if (SelectA != SelectB.getOperand(0)) return SDValue(); - ISD::CondCode CC = cast(SetCC->getOperand(2))->get(); - auto InverseSetCC = DAG.getSetCC( - SDLoc(SetCC), SetCC.getValueType(), SetCC.getOperand(0), - SetCC.getOperand(1), ISD::getSetCCInverse(CC, SetCC.getValueType())); + ISD::CondCode CC = cast(SetCC.getOperand(2))->get(); + ISD::CondCode InverseCC = + ISD::getSetCCInverse(CC, SetCC.getOperand(0).getValueType()); + auto InverseSetCC = + DAG.getSetCC(SDLoc(SetCC), SetCC.getValueType(), SetCC.getOperand(0), + SetCC.getOperand(1), InverseCC); return DAG.getNode(ISD::VSELECT, SDLoc(N), NTy, {InverseSetCC, SelectB, SelectA}); diff --git a/llvm/test/CodeGen/AArch64/sve-select.ll b/llvm/test/CodeGen/AArch64/sve-select.ll --- a/llvm/test/CodeGen/AArch64/sve-select.ll +++ b/llvm/test/CodeGen/AArch64/sve-select.ll @@ -547,7 +547,8 @@ ; CHECK-LABEL: select_f32_invert_fmul: ; CHECK: // %bb.0: ; CHECK-NEXT: ptrue p0.s -; CHECK-NEXT: fcmne p0.s, p0/z, z0.s, #0.0 +; CHECK-NEXT: fcmeq p1.s, p0/z, z0.s, #0.0 +; CHECK-NEXT: not p0.b, p0/z, p1.b ; CHECK-NEXT: fmul z0.s, p0/m, z0.s, z1.s ; CHECK-NEXT: ret %p = fcmp oeq %a, zeroinitializer @@ -560,7 +561,8 @@ ; CHECK-LABEL: select_f32_invert_fadd: ; CHECK: // %bb.0: ; CHECK-NEXT: ptrue p0.s -; CHECK-NEXT: fcmne p0.s, p0/z, z0.s, #0.0 +; CHECK-NEXT: fcmeq p1.s, p0/z, z0.s, #0.0 +; CHECK-NEXT: not p0.b, p0/z, p1.b ; CHECK-NEXT: fadd z0.s, p0/m, z0.s, z1.s ; CHECK-NEXT: ret %p = fcmp oeq %a, zeroinitializer @@ -569,14 +571,14 @@ ret %sel } -define @select_f32_invert_fsub( %a, %b) { +define @select_f32_invert_fsub( %a, %b, %c) { ; CHECK-LABEL: select_f32_invert_fsub: ; CHECK: // %bb.0: ; CHECK-NEXT: ptrue p0.s -; CHECK-NEXT: fcmne p0.s, p0/z, z0.s, #0.0 +; CHECK-NEXT: cmpne p0.s, p0/z, z2.s, #0 ; CHECK-NEXT: fsub z0.s, p0/m, z0.s, z1.s ; CHECK-NEXT: ret - %p = fcmp oeq %a, zeroinitializer + %p = icmp eq %c, zeroinitializer %fsub = fsub %a, %b %sel = select %p, %a, %fsub ret %sel