https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110118

            Bug ID: 110118
           Summary: Miss CSE optimization for vptest after
                    r14-1466-g3635e8c67e13e3da7e1e23a617dd9952218e93e0
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: crazylht at gmail dot com
  Target Milestone: ---

#include <immintrin.h>

int do_stuff(__m256i Y0, __m256i Y1, __m128i X2) {
  __m256i And01 = _mm256_and_si256(Y0, Y1);
  int TestResult = _mm256_testc_si256(And01, And01);
  int t1 = _mm256_testz_si256(And01, And01);
  return TestResult + t1;
}


GCC 12.2 generates

do_stuff:
        vpand   %ymm1, %ymm0, %ymm0
        xorl    %eax, %eax
        vptest  %ymm0, %ymm0
        sete    %al
        adcl    $0, %eax
        ret

GCC trunk generates

do_stuff:
        vpand   %ymm1, %ymm0, %ymm0
        xorl    %eax, %eax
        vptest  %ymm0, %ymm0
        setc    %al
        xorl    %edx, %edx
        vptest  %ymm0, %ymm0
        sete    %dl
        addl    %edx, %eax
        ret

Reply via email to