Skip to content

bug in minnum and maxnum #1201

@regehr

Description

@regehr

I think these functions are incorrect in one corner case.

take this IR:

declare float @llvm.min.f32(float, float)
declare float @llvm.max.f32(float, float)

declare float @llvm.minnum.f32(float, float)
declare float @llvm.maxnum.f32(float, float)

declare float @llvm.minimum.f32(float, float)
declare float @llvm.maximum.f32(float, float)

declare float @llvm.minimumnum.f32(float, float)
declare float @llvm.maximumnum.f32(float, float)

define float @f() {
  %2 = call float @llvm.maxnum.f32(float 0x0000000000000000, float 0x8000000000000000)
  ret float %2
}

here's what alive-exec says:

~/svn/code/alive2/fp$ ~/alive2-regehr/build/alive-exec tmp.ll 

----------------------------------------
define float @f() {
#0:
  %#1 = fmax float 0.000000, -0.000000
  ret float %#1
}
Executing %#0
%#1 = #x80000000
Returned #x80000000 / true
~/svn/code/alive2/fp$ 

but LangRef says that "-0.0 < +0.0 for the purposes of this intrinsic."

the analogous case for minnum is also wrong:

~/svn/code/alive2/fp$ ~/alive2-regehr/build/alive-exec tmp.ll 

----------------------------------------
define float @f() {
#0:
  %#1 = fmin float -0.000000, 0.000000
  ret float %#1
}
Executing %#0
%#1 = #x00000000
Returned #x00000000 / true

Metadata

Metadata

Assignees

No one assigned

    Labels

    floatsFloating-point support

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions