Skip to content

[X86] InstCombine change breaks blsic matching #209718

Description

@nikic

https://llvm.godbolt.org/z/TzceKT4vK

target triple = "x86_64-unknown-linux-gnu"

define i32 @_blsic_u32(i32 %x) #0 {
  %_2 = xor i32 %x, -1
  %_0.i = add i32 %x, -1
  %_0 = or i32 %_0.i, %_2
  ret i32 %_0
}

attributes #0 = { "target-features"="+tbm" }

Now becomes:

define i32 @_blsic_u32(i32 %x) #0 {
  %1 = sub i32 0, %x
  %2 = and i32 %x, %1
  %_0 = xor i32 %2, -1
  ret i32 %_0
}

With TBM, this previously lowered to:

_blsic_u32:                             # @_blsic_u32
        blsic   eax, edi
        ret

Now it produces:

_blsic_u32:                             # @_blsic_u32
        mov     eax, edi
        neg     eax
        and     eax, edi
        not     eax
        ret

This is due to #186722. It succeeded in making blsi match, but broke blsic matching in the process.

I don't really have a strong opinion on the canonical form here, so I'm fine with adjusting the pattern matching in the backend.

Metadata

Metadata

Assignees

Type

No type

Projects

Status
Done

Relationships

None yet

Development

No branches or pull requests

Issue actions