[Bug middle-end/100738] New: Gimple failed to simplify ((v4si) ~a) < 0 ? c : d to ((v4si)a) >= 0 ? c : d

crazylht at gmail dot com gcc-bugzilla@gcc.gnu.org
Mon May 24 08:21:42 GMT 2021


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

            Bug ID: 100738
           Summary: Gimple failed to simplify ((v4si) ~a) < 0 ? c : d to
                    ((v4si)a) >= 0 ? c : d
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: crazylht at gmail dot com
                CC: hjl.tools at gmail dot com
  Target Milestone: ---
              Host: x86_64-pc-linux-gnu
            Target: x86_64-*-* i?86-*-*

cat test.c



typedef int v4si __attribute__((vector_size (16)));
typedef char v16qi __attribute__((vector_size (16)));
v4si
foo (v16qi a, v4si b, v4si c, v4si d)
{
    return ((v4si)~a) < 0 ? c : d;
}

gcc -Ofast -mavx2

foo(char __vector(16), int __vector(4), int __vector(4), int __vector(4)):
        vpcmpeqd        %xmm1, %xmm1, %xmm1
        vpxor   %xmm1, %xmm0, %xmm0
        vblendvps       %xmm0, %xmm2, %xmm3, %xmm0
        ret

it can be better with 

        vblendvps       xmm0, xmm3, xmm2, xmm0

gimple failed to simplify  ((v4si)~a) < 0 ? c : d to ((v4si)a) >= 0 ? c : d

With https://gcc.gnu.org/pipermail/gcc-patches/2021-May/571056.html, i observe
rtl also won't simplify things like (vec_merge op1 op2 (lt (subreg (not op3) 0)
const0_rtx)) to (vec_merge op2 op1 (lt (subreg op3 0) const0_rtx))


More information about the Gcc-bugs mailing list