Skip to content

InstCombine: incorrect fabs formation #59279

Closed
@nunoplopes

Description

@nunoplopes

Test Transforms/InstCombine/fabs.ll shows the following transformation:

define double @select_fcmp_ole_zero(double %x) {
  %lezero = fcmp ole double %x, 0.000000
  %negx = fsub double 0.000000, %x, exceptions=ignore
  %fabs = select i1 %lezero, double %negx, double %x
  ret double %fabs
}
=>
define double @select_fcmp_ole_zero(double %x) {
  %1 = fabs double %x, exceptions=ignore
  ret double %1
}

This is not correct as fabs produces a non-deterministic NaN payload, while the original function preserved the NaN payload when x > 0.

cc @arsenm @jcranmer-intel @jyknight @rotateright

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