Skip to content

[X86][GlobalIsel] Missing Bitwise Combine Optimization #162248

@mahesh-attarde

Description

@mahesh-attarde

I was working on one of G_IS_FPCLASS expansion and noticed we are not combining simple cases as compare to SDAG.

; RUN: llc < %s -mtriple=x86_64-linux -global-isel -global-isel-abort=1 | FileCheck %s -check-prefixes=X64,X64-GISEL
; RUN: llc < %s -mtriple=x86_64-linux | FileCheck %s -check-prefixes=X64,X64-SDAGISEL

; X64-SDAGISEL-LABEL: not_isinf_f:
; X64-SDAGISEL:       # %bb.0: # %entry
; X64-SDAGISEL-NEXT:    movd %xmm0, %eax
; X64-SDAGISEL-NEXT:    andl $2147483647, %eax # imm = 0x7FFFFFFF
; X64-SDAGISEL-NEXT:    cmpl $2139095040, %eax # imm = 0x7F800000
; X64-SDAGISEL-NEXT:    setne %al
; X64-SDAGISEL-NEXT:    retq

; X64-GISEL-LABEL: not_isinf_f:
; X64-GISEL:       # %bb.0: # %entry
; X64-GISEL-NEXT:    movd %xmm0, %eax
; X64-GISEL-NEXT:    andl $2147483647, %eax # imm = 0x7FFFFFFF
; X64-GISEL-NEXT:    xorl %ecx, %ecx
; X64-GISEL-NEXT:    cmpl $2139095040, %eax # imm = 0x7F800000
; X64-GISEL-NEXT:    setb %dl
; X64-GISEL-NEXT:    orb %cl, %dl
; X64-GISEL-NEXT:    cmpl $2139095040, %eax # imm = 0x7F800000
; X64-GISEL-NEXT:    seta %al
; X64-GISEL-NEXT:    orb %dl, %al
; X64-GISEL-NEXT:    retq

define i1 @not_isinf_f(float %x) nounwind {
entry:
  %0 = tail call i1 @llvm.is.fpclass.f32(float %x, i32 507)  ; ~0x204 = "~inf"
  ret i1 %0
}

In above example sequence "xorl %ecx, %ecx" and " orb %cl, %dl" is zero with OR. It is redundant.

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