Skip to content

Wrong folding to fabs #141538

Open
Open
@bongjunj

Description

@bongjunj

Alive2 report: https://alive2.llvm.org/ce/z/iPnYcf

----------------------------------------
define float @select_nnan_ninf_nsz_fcmp_nnan_nsz_olt_negzero.2(float %x) {
#0:
  %#1 = fcmp oge float %x, -0.000000
  %negx = fsub nnan nsz float -0.000000, %x
  %fabs = select nnan ninf nsz i1 %#1, float %negx, float %x
  %#2 = fabs float %fabs
  ret float %#2
}
=>
define float @select_nnan_ninf_nsz_fcmp_nnan_nsz_olt_negzero.2(float %x) nofree willreturn memory(none) {
#0:
  %#1 = fabs nnan ninf nsz float %x
  ret float %#1
}
Transformation doesn't verify!

ERROR: Value mismatch

Example:
float %x = #x00000000 (+0.0)

Source:
i1 %#1 = #x1 (1)
float %negx = #x00000000 (+0.0)
float %fabs = #x00000000 (+0.0)
float %#2 = #x00000000 (+0.0)

Target:
float %#1 = #x80000000 (-0.0)
Source value: #x00000000 (+0.0)
Target value: #x80000000 (-0.0)

Summary:
  0 correct transformations
  1 incorrect transformations
  0 failed-to-prove transformations
  0 Alive2 errors

Is it an expected behavior for the signbit to flip?
I think this is introduced recently from d13947b

Metadata

Metadata

Assignees

No one assigned

    Labels

    floating-pointFloating-point mathllvm:instcombineCovers the InstCombine, InstSimplify and AggressiveInstCombine passesmiscompilation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions