[llvm-bugs] [Bug 49081] New: [x86] Failure to optimize vector shuffle in conversion

via llvm-bugs llvm-bugs at lists.llvm.org
Sun Feb 7 13:07:55 PST 2021


https://bugs.llvm.org/show_bug.cgi?id=49081

            Bug ID: 49081
           Summary: [x86] Failure to optimize vector shuffle in conversion
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Backend: X86
          Assignee: unassignedbugs at nondot.org
          Reporter: gabravier at gmail.com
                CC: craig.topper at gmail.com, llvm-bugs at lists.llvm.org,
                    llvm-dev at redking.me.uk, pengfei.wang at intel.com,
                    spatel+llvm at rotateright.com

typedef int v4si __attribute__((vector_size(16)));
typedef float v4sf __attribute__((vector_size(16)));

v4sf f(v4si f)
{
    return (v4sf){(float)f[1], (float)f[1], (float)f[2], (float)f[3]};
}

With -O3, GCC outputs this:

f(int __vector(4)):
  pshufd xmm0, xmm0, 229
  cvtdq2ps xmm0, xmm0
  ret

LLVM outputs this:

f(int __vector(4)):
  pshufd xmm1, xmm0, 85 # xmm1 = xmm0[1,1,1,1]
  cvtdq2ps xmm1, xmm1
  pshufd xmm2, xmm0, 238 # xmm2 = xmm0[2,3,2,3]
  cvtdq2ps xmm2, xmm2
  pshufd xmm0, xmm0, 255 # xmm0 = xmm0[3,3,3,3]
  cvtdq2ps xmm0, xmm0
  unpcklps xmm2, xmm0 # xmm2 = xmm2[0],xmm0[0],xmm2[1],xmm0[1]
  shufps xmm1, xmm2, 64 # xmm1 = xmm1[0,0],xmm2[0,1]
  movaps xmm0, xmm1
  ret

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210207/640e7ea6/attachment-0001.html>


More information about the llvm-bugs mailing list