[llvm] [InstCombine] Fix a cycle when folding fneg(select) with scalable vector types (PR #112465)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 16 03:00:08 PDT 2024


nikic wrote:

> > > 1. if we are dealing with scalable vector constants as there is no
> > >    immediate representation for a negative scalable zeroinitializer.
> > 
> > 
> > I thought there was a splat constant for these, this would just be a splat of -0
> 
> Thanks for having a look, Matt. Would a better approach be to generate the following, instead of giving up?
> 
> define <vscale x 2 x double> @test_fneg_select_svec(<vscale x 2 x i1> %cond, <vscale x 2 x double> %b) { %1 = fneg fast <vscale x 2 x double> %b %2 = select <vscale x 2 x i1> %cond, <vscale x 2 x double> splat(double -0.0), <vscale x 2 x double> %1 ret <vscale x 2 x double> %2 }

Yes. It looks like ConstantFoldUnaryInstruction is currently missing splat support for scalable vectors. Adding that should resolve the issue.


https://github.com/llvm/llvm-project/pull/112465


More information about the llvm-commits mailing list