Skip to content

[InstCombine] Incorrect propagation of nsz from fneg to fdiv #48998

Description

@nunoplopes
Bugzilla Link 49654
Resolution FIXED
Resolved on Jun 10, 2021 11:26
Version trunk
OS All
CC @andykaylor,@efriedma-quic,@fhahn,@aqjune,@LebedevRI,@RKSimon,@regehr,@rotateright
Fixed by commit(s) 4675bea

Extended Description

This is from Transforms/InstCombine/fneg.ll, reduced from fast to just nsz.
The issue is that the original fdiv has no nsz but the optimized one has. In this case, nsz can be propagated, but not added (even if fneg is nsz).

define float @​fdiv_op0_constant_fneg_fmf(float %x) {
%d = fdiv float 42.000000, %x
%r = fneg nsz float %d
ret float %r
}
=>
define float @​fdiv_op0_constant_fneg_fmf(float %x) {
%r = fdiv nsz float -42.000000, %x
ret float %r
}
Transformation doesn't verify!
ERROR: Value mismatch

Example:
float %x = #x80000000 (-0.0)

Source:
float %d = #xff800000 (-oo)
float %r = #x7f800000 (+oo)

Target:
float %r = #xff800000 (-oo)
Source value: #x7f800000 (+oo)
Target value: #xff800000 (-oo)

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions