diff --git a/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp b/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp --- a/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp +++ b/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp @@ -1318,11 +1318,6 @@ (Mask->getOperand(1).getImm() != 31)) return false; - // Fallthough to simply remove the PTEST. - } else if ((Mask == Pred) && (PredIsPTestLike || PredIsWhileLike)) { - // For PTEST(PG, PG), PTEST is redundant when PG is the result of an - // instruction that sets the flags as PTEST would. - // Fallthough to simply remove the PTEST. } else if (PredIsPTestLike) { // For PTEST(PG, PTEST_LIKE(PG, ...)), the PTEST is redundant since the diff --git a/llvm/test/CodeGen/AArch64/sve-ptest-removal-cmple.ll b/llvm/test/CodeGen/AArch64/sve-ptest-removal-cmple.ll --- a/llvm/test/CodeGen/AArch64/sve-ptest-removal-cmple.ll +++ b/llvm/test/CodeGen/AArch64/sve-ptest-removal-cmple.ll @@ -192,6 +192,7 @@ ; CHECK-LABEL: cmp8_ptest_first_xx: ; CHECK: // %bb.0: ; CHECK-NEXT: cmpge p0.b, p0/z, z0.b, z1.b +; CHECK-NEXT: ptest p0, p0.b ; CHECK-NEXT: cset w0, mi ; CHECK-NEXT: ret %1 = tail call @llvm.aarch64.sve.cmpge.nxv16i8( %pg, %a, %b) @@ -207,6 +208,7 @@ ; CHECK-LABEL: cmp8_ptest_last_xx: ; CHECK: // %bb.0: ; CHECK-NEXT: cmpge p0.b, p0/z, z0.b, z1.b +; CHECK-NEXT: ptest p0, p0.b ; CHECK-NEXT: cset w0, lo ; CHECK-NEXT: ret %1 = tail call @llvm.aarch64.sve.cmpge.nxv16i8( %pg, %a, %b) @@ -221,6 +223,7 @@ ; CHECK-LABEL: cmp8_ptest_any_xx: ; CHECK: // %bb.0: ; CHECK-NEXT: cmpge p0.b, p0/z, z0.b, z1.b +; CHECK-NEXT: ptest p0, p0.b ; CHECK-NEXT: cset w0, ne ; CHECK-NEXT: ret %1 = tail call @llvm.aarch64.sve.cmpge.nxv16i8( %pg, %a, %b) @@ -236,6 +239,7 @@ ; CHECK-LABEL: cmp32_ptest_first_xx: ; CHECK: // %bb.0: ; CHECK-NEXT: cmpge p0.s, p0/z, z0.s, z1.s +; CHECK-NEXT: ptest p0, p0.b ; CHECK-NEXT: cset w0, mi ; CHECK-NEXT: ret %1 = tail call @llvm.aarch64.sve.convert.from.svbool.nxv4i1( %pg) @@ -252,6 +256,7 @@ ; CHECK-LABEL: cmp32_ptest_last_xx: ; CHECK: // %bb.0: ; CHECK-NEXT: cmpge p0.s, p0/z, z0.s, z1.s +; CHECK-NEXT: ptest p0, p0.b ; CHECK-NEXT: cset w0, lo ; CHECK-NEXT: ret %1 = tail call @llvm.aarch64.sve.convert.from.svbool.nxv4i1( %pg) @@ -267,6 +272,7 @@ ; CHECK-LABEL: cmp32_ptest_any_xx: ; CHECK: // %bb.0: ; CHECK-NEXT: cmpge p0.s, p0/z, z0.s, z1.s +; CHECK-NEXT: ptest p0, p0.b ; CHECK-NEXT: cset w0, ne ; CHECK-NEXT: ret %1 = tail call @llvm.aarch64.sve.convert.from.svbool.nxv4i1( %pg) diff --git a/llvm/test/CodeGen/AArch64/sve-ptest-removal-whilegt.mir b/llvm/test/CodeGen/AArch64/sve-ptest-removal-whilegt.mir --- a/llvm/test/CodeGen/AArch64/sve-ptest-removal-whilegt.mir +++ b/llvm/test/CodeGen/AArch64/sve-ptest-removal-whilegt.mir @@ -462,7 +462,7 @@ liveins: $w0, $w1 ; CHECK-LABEL: name: whilegt_b8_s32_ptest_with_matching_operands - ; CHECK-NOT: PTEST + ; CHECK: PTEST %1:gpr32 = COPY $w1 %0:gpr32 = COPY $w0 %2:ppr = WHILEGT_PWW_B %0, %1, implicit-def dead $nzcv