Skip to content

[InstCombine] nnan should not be propagated #143120

@dtcxzyw

Description

@dtcxzyw

Reproducer: https://alive2.llvm.org/ce/z/ugLcnT

; bin/opt -passes=instcombine test.ll -S
define float @clamp_float_fast_unordered_strict_minmax2(float %x) {
  %cmp2 = fcmp nnan ninf ugt float %x, 1.000000e+00
  %max = select nnan ninf i1 %cmp2, float %x, float 1.000000e+00
  %cmp1 = fcmp nnan ugt float %x, 2.550000e+02
  %r = select i1 %cmp1, float 2.550000e+02, float %max
  ret float %r
}
----------------------------------------
define float @clamp_float_fast_unordered_strict_minmax2(float %x) {
#0:
  %cmp2 = fcmp nnan ninf ugt float %x, 1.000000
  %max = select nnan ninf i1 %cmp2, float %x, float 1.000000
  %cmp1 = fcmp nnan ugt float %x, 255.000000
  %r = select i1 %cmp1, float 255.000000, float %max
  ret float %r
}
=>
define float @clamp_float_fast_unordered_strict_minmax2(float %x) nofree willreturn memory(none) {
#0:
  %cmp2.inv = fcmp nnan ninf ole float %x, 1.000000
  %max = select nnan ninf i1 %cmp2.inv, float 1.000000, float %x
  %.inv = fcmp nnan ole float %max, 255.000000
  %r1 = select nnan i1 %.inv, float %max, float 255.000000
  ret float %r1
}
Transformation doesn't verify!

ERROR: Target is more poisonous than source

Example:
float %x = #x7f800000 (+oo)

Source:
i1 %cmp2 = poison
float %max = poison
i1 %cmp1 = #x1 (1)
float %r = #x437f0000 (255)

Target:
i1 %cmp2.inv = poison
float %max = poison
i1 %.inv = poison
float %r1 = poison
Source value: #x437f0000 (255)
Target value: poison

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

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions