Skip to content

[X86] AVX512 integer compare fails to use icmp_sle(x,0) instead of icmp_slt(x,1) #216660

Description

@RKSimon

Noticed while investigating SIGN patterns:

define i16 @cmp_sle_1(<16 x i8> %x) {
  %c = icmp sle <16 x i8> %x, splat (i8 0)
  %x = bitcast <16 x i1> %c to i16
  ret i16 %x
}

Both InstCombine and DAG fold this to:

define i16 @cmp_sle_1(<16 x i8> %x) {
  %c = icmp slt <16 x i8> %x, splat (i8 1)
  %x = bitcast <16 x i1> %c to i16
  ret i16 %x
}

-mcpu=x86-64-v3 - no ICMP_SLE handling so uses NOT(ICMP_SGT)

cmp_sle_1: # @cmp_sle_1
# %bb.0:
  vpxor %xmm0, %xmm0, %xmm0
  vpcmpgtb %xmm0, %xmm1, %xmm0
  vpmovmskb %xmm0, %eax
  notl %eax
  # kill: def $ax killed $ax killed $eax
  retq
  # -- End function

-mcpu=x86-64-v4 - VPCMP can use all condcodes, but chooses to load a constant:

.LCPI0_0:
  .zero 16,1
cmp_sle_1: # @cmp_sle_1
# %bb.0:
  vpcmpltb .LCPI0_0(%rip), %xmm1, %k0
  kmovd %k0, %eax
  # kill: def $ax killed $ax killed $eax
  retq
  # -- End function

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions