Skip to content

Attributor special casing of return select interferes with nofpclass inference #63404

@arsenm

Description

@arsenm

Noticed this when working on https://reviews.llvm.org/D153089

Attributor seems to specially treat return of select, such that computeKnownFPClass is never called on the select instruction. In this example, it fails to add nofpclass(nan) to the return value. If you obscure the return value with some kind of call, it works:

define float @ret_select_nnan_flag(i1 %cond, float %arg0, float %arg1) {
  %select = select nnan i1 %cond, float %arg0, float %arg1
  ret float %select
}

declare float @llvm.arithmetic.fence.f32(float)

define float @ret_fence_select_nnan_flag(i1 %cond, float %arg0, float %arg1) {
  %select = select nnan i1 %cond, float %arg0, float %arg1
  %fence = call float @llvm.arithmetic.fence.f32(float %select)
  ret float %fence
}

This will miss instruction flags and select clamping patterns computeKnownFPClass could recognize

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions