Skip to content

InstSimplify: incorrect frexp(frexp(x)) -> frexp(x) fold #138819

Closed
@nunoplopes

Description

@nunoplopes

It's not ok to fold frexp(frexp(x)) to frexp(x):

; Transforms/InstSimplify/frexp.ll

define {float, i32} @frexp_frexp(float %x) {
  %frexp0 = frexp float %x
  %frexp0.0 = extractvalue {float, i32} %frexp0, 0
  %frexp1 = frexp float %frexp0.0
  ret {float, i32} %frexp1
}
=>
define {float, i32} @frexp_frexp(float %x) {
  %frexp0 = frexp float %x
  ret {float, i32} %frexp0
}
Transformation doesn't verify!

ERROR: Value mismatch

Example:
float %x = #x0000000a (0.000000000000?)

Source:
{float, i32} %frexp0 = { #x3f200000 (0.625), #xffffff6f (4294967151, -145) }
float %frexp0.0 = #x3f200000 (0.625)
{float, i32} %frexp1 = { #x3f200000 (0.625), #x00000000 (0) }

Target:
{float, i32} %frexp0 = { #x3f200000 (0.625), #xffffff6f (4294967151, -145) }
Source value: { #x3f200000 (0.625), #x00000000 (0) }
Target value: { #x3f200000 (0.625), #xffffff6f (4294967151, -145) }

cc @arsenm

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions