Skip to content

[InstCombine] Freeze is incorrectly dropped #161524

@dtcxzyw

Description

@dtcxzyw

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

; bin/opt -passes=instcombine test.ll -S
define float @test(float %arg) {
entry:
  %cond = tail call i1 @llvm.is.fpclass.f32(float %arg, i32 144)
  %0 = freeze i1 %cond
  br i1 %0, label %if.then, label %if.exit

if.then:                                          ; preds = %entry
  %fadd = fadd float %arg, 1.0
  br label %if.exit

if.exit:                                          ; preds = %if.then, %entry
  %ret = phi ninf float [ %fadd, %if.then ], [ %arg, %entry ]
  %1 = freeze float %ret
  ret float %1
}
=>
define float @test(float %arg) {
entry:
  %arg.fr = freeze float %arg
  %cond = is.fpclass float %arg.fr, i32 144
  br i1 %cond, label %if.then, label %if.exit

if.then:
  %fadd = fadd float %arg.fr, 1.000000
  br label %if.exit

if.exit:
  %ret = phi ninf float [ %fadd, %if.then ], [ %arg.fr, %entry ]
  ret float %ret
}
Transformation doesn't verify!

ERROR: Target is more poisonous than source

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

Source:
i1 %cond = #x0 (0)
i1 %#0 = #x0 (0)
  >> Jump to %if.exit
float %ret = poison
float %#1 = #x00000003 (0.000000000000?)

Target:
float %arg.fr = #xff800000 (-oo)
i1 %cond = #x0 (0)
  >> Jump to %if.exit
float %ret = poison
Source value: #x00000003 (0.000000000000?)
Target value: poison

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions