Skip to content

Incorrect transformation of minnum with nnan flag #44823

Description

@zhengyang92
Bugzilla Link 45478
Resolution FIXED
Resolved on Apr 24, 2020 09:46
Version trunk
OS All
CC @efriedma-quic,@ecnelises,@aqjune,@LebedevRI,@zhengyang92,@nunoplopes,@regehr,@rotateright,@yuanfang-chen
Fixed by commit(s) e4175ff

Extended Description

As stated in LangRef, if either operand for llvm.minnum is a NaN, returns the other non-NaN operand. If llvm.minnum is attached with nnan flag, when an argument is a NaN, it produces a poison value.

See below the incorrect transformation. When input %x is NaN, the source program returns 0.0, while the target program returns poison. Target is more poisonous than source.

llvm/test/Transforms/InstCombine/minnum.ll

define float @​minnum_f32_1_minnum_p0_val_nnan_ninf(float %x) {
; CHECK-LABEL: @​minnum_f32_1_minnum_p0_val_nnan_ninf(
; CHECK-NEXT: [[TMP1:%.]] = call nnan ninf float @​llvm.minnum.f32(float [[X:%.]], float 0.000000e+00)
; CHECK-NEXT: ret float [[TMP1]]
;
%y = call float @​llvm.minnum.f32(float 0.0, float %x)
%z = call nnan ninf float @​llvm.minnum.f32(float %y, float 1.0)
ret float %z
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugzillaIssues migrated from bugzilla

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions