Skip to content

[X86] Poor emulation of cmpss pattern #140693

Open
@RKSimon

Description

@RKSimon

https://simd.godbolt.org/z/nqP1WxY1q

Inspired by #140563

#include <x86intrin.h>

__m128 test_cmpeqss(__m128 x, __m128 y) {
    int cmp = y[0] == x[0];
    return _mm_setr_ps(__builtin_bit_cast(float, -cmp), x[1], x[2], x[3]);
}

We never quite manage to recreate the single (v)cmpeqss

-march=x86-64

test_cmpeqss: # @test_cmpeqss
# %bb.0: # %entry
  cmpeqss %xmm0, %xmm1
  movss %xmm1, %xmm0 # xmm0 = xmm1[0],xmm0[1,2,3]
  retq

-march=x86-64-v3

test_cmpeqss: # @test_cmpeqss
# %bb.0: # %entry
  vcmpeqss %xmm0, %xmm1, %xmm1
  vmovd %xmm1, %eax
  vmovd %eax, %xmm1
  vblendps $1, %xmm1, %xmm0, %xmm0 # xmm0 = xmm1[0],xmm0[1,2,3]
  retq

-march=x86-64-v4

test_cmpeqss: # @test_cmpeqss
# %bb.0: # %entry
  vcmpeqss %xmm0, %xmm1, %k0
  kmovw %k0, %eax
  negl %eax
  vmovd %eax, %xmm1
  vblendps $1, %xmm1, %xmm0, %xmm0 # xmm0 = xmm1[0],xmm0[1,2,3]
  retq

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions