Skip to content

[InstCombine] Vector fptosi moved inside loop and scalarized #165793

@azwolski

Description

@azwolski

For the following IR, where the fp-to-int conversion is a vector operation:

%33 = call <4 x float> @llvm.x86.sse41.round.ps(<4 x float> %26, i32 9)
%34 = fptosi <4 x float> %33 to <4 x i32>
br label %35

35:
  %36 = phi i32 [0, %10], [ %59, %58]
  %37 = icmp samesign ult i32 %36, 4
  br i1 %37, label %38, label %60

38:
  %40 = extractelement <4 x i32> %34, i32 %36

After running the InstCombine pass, the conversion becomes scalarized and moved inside the loop:

%30 = call <4 x float> @llvm.x86.sse41.round.ps(<4 x float> %26, i32 9)
br label %31

31:
  %32 = phi i32 [0, %10], [ %59, %58]
  %33 = icmp samesign ult i32 %32, 4
  br i1 %33, label %34, label %60

34:
  %37 = extractelement <4 x float> %30, i32 %32
  %38 = fptosi float %37 to i32

This transformation appears incorrect, since it changes a vector fp-to-int conversion into a scalar one and moves it inside the loop.

I will prepare a baseline test that reproduces the issue, along with a proposal for a bug fix.

Metadata

Metadata

Assignees

Labels

llvm:instcombineCovers the InstCombine, InstSimplify and AggressiveInstCombine passes

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions