Skip to content

Wrong select (fcmp ...) (fadd ...) folding to llvm max intrinsic #139041

@bongjunj

Description

@bongjunj
define float @test_fcmp_ogt_fadd_select_rewrite_and_fastmath.2(float %in) {
  %cmp1 = fcmp nnan ogt float %in, 0.000000e+00
  %2 = fadd float %in, 1.000000e+00
  %sel = select fast i1 %cmp1, float %2, float 1.000000e+00
  ret float %sel
}
define float @test_fcmp_ogt_fadd_select_rewrite_and_fastmath(float %in) {
#0:
  %cmp1 = fcmp nnan ogt float %in, 0.000000
  %add = fadd float %in, 1.000000
  %sel = select fast i1 %cmp1, float %add, float 1.000000
  ret float %sel
}
=>
define float @test_fcmp_ogt_fadd_select_rewrite_and_fastmath(float %in) {
#0:
  %sel = fmax nnan ninf nsz float %in, 0.000000
  %add = fadd nnan ninf nsz float %sel, 1.000000
  ret float %add
}
Transformation doesn't verify!

ERROR: Target is more poisonous than source

Example:
float %in = #xff800000 (-oo)

Source:
i1 %cmp1 = #x0 (0)
float %add = #xff800000 (-oo)
float %sel = #x00000000 (+0.0)

Target:
float %sel = poison
float %add = poison
Source value: #x00000000 (+0.0)
Target value: poison

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

While the alive2 site (https://alive2.llvm.org/ce/z/50KuQH) complains that it used approximation so it could not conclude,
I think it may have nothing to do with approximation.

Targeted Commit of Test: a0c4876

In addition, the alive2 proof in the commit message is also failing: https://alive2.llvm.org/ce/z/tVrvYo

Metadata

Metadata

Assignees

Labels

floating-pointFloating-point mathllvm:instcombineCovers the InstCombine, InstSimplify and AggressiveInstCombine passesmiscompilationobsoleteIssues with old (unsupported) versions of LLVM

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions