llvm / llvm/llvm-project

[InstCombine] Lost scalarization of vector fdiv with dead lanes

Open
#190,929 0 comments 0 reactions 0 assignees View on GitHub
llvm:instcombine
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

the Following IR:

```llvm
define <2 x float> @test_fdiv(float %a, float %b, i1 %cmp) {
%splatinsert = insertelement <2 x float> poison, float %a, i32 0
%denom = insertelement <2 x float> , float 1.000000e+00, i32 1
%t1 = fdiv <2 x float> %splatinsert, %denom
%freeze.ins = freeze <2 x float> %t1
%splat.op = shufflevector <2 x float> %freeze.ins, <2 x float> undef, <2 x i32>
%t2 = select i1 %cmp, <2 x float> , <2 x float> %splat.op
ret <2 x float> %t2
}
```

was optimized as following by `opt 22.1.0` https://godbolt.org/z/v8cW6xv8z

```llvm
define <2 x float> @test_fdiv(float %a, float %b, i1 %cmp) local_unnamed_addr #0 {
%splatinsert = insertelement <2 x float> poison, float %a, i64 0
%splatinsert.fr = freeze <2 x float> %splatinsert
%t1 = fdiv <2 x float> %splatinsert.fr,
%splat.op = shufflevector <2 x float> %t1, <2 x float> poison, <2 x i32>
%t2 = select i1 %cmp, <2 x float> , <2 x float> %splat.op
ret <2 x float> %t2
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) }
```

but in the opt `20.0.0` used in online Alive-tv (https://alive2.llvm.org/ce/), we can observe the following optimization https://alive2.llvm.org/ce/z/M3gkK7 :

```llvm
define <2 x float> @test_fdiv(float %a, float %b, i1 %cmp) local_unnamed_addr #0 {
%a.fr = freeze float %a
%splat.op.scalar = fdiv float %a.fr, 3.000000e+00
%splat.op = insertelement <2 x float> poison, float %splat.op.scalar, i64 1
%t2 = select i1 %cmp, <2 x float> , <2 x float> %splat.op
ret <2 x float> %t2
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) }
```

How can we get the exact commit hash that was used to build opt?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.