This is an archive of the discontinued LLVM Phabricator instance.

[Scalarizer] InsertElement handling w/ constant insert index
ClosedPublic

Authored by lebedev.ri on Jul 2 2020, 3:30 PM.

Details

Summary

As it can be clearly seen from the diff, this results in nicer IR.

Diff Detail

Event Timeline

lebedev.ri created this revision.Jul 2 2020, 3:30 PM
lebedev.ri marked an inline comment as done.Jul 2 2020, 3:35 PM
lebedev.ri added inline comments.
llvm/test/Transforms/Scalarizer/basic.ll
542

Previously we'd end up with https://godbolt.org/z/NyExWc

%val0 = load <4 x i32>, <4 x i32>* %src, align 16
%val1 = insertelement <4 x i32> %val0, i32 %repl, i32 3
%val0.i0 = extractelement <4 x i32> %val0, i32 0
%val2.i0 = shl i32 1, %val0.i0
%val0.i1 = extractelement <4 x i32> %val0, i32 1
%val2.i1 = shl i32 2, %val0.i1
%val0.i2 = extractelement <4 x i32> %val0, i32 2
%val2.i2 = shl i32 3, %val0.i2
%val2.i3 = shl i32 4, %repl
%val2.upto0 = insertelement <4 x i32> undef, i32 %val2.i0, i32 0
%val2.upto1 = insertelement <4 x i32> %val2.upto0, i32 %val2.i1, i32 1
%val2.upto2 = insertelement <4 x i32> %val2.upto1, i32 %val2.i2, i32 2
%val2 = insertelement <4 x i32> %val2.upto2, i32 %val2.i3, i32 3
ret <4 x i32> %val2
lebedev.ri updated this revision to Diff 275260.Jul 2 2020, 4:54 PM
lebedev.ri retitled this revision from [Scalarizer] Constant InsertElement Hanlding to [Scalarizer] InsertElement handling w/ constant insert index.
lebedev.ri edited the summary of this revision. (Show Details)

Reordered, precommitted tests.

jdoerfert accepted this revision.Jul 2 2020, 5:03 PM

LGTM.

This revision is now accepted and ready to land.Jul 2 2020, 5:03 PM
This revision was automatically updated to reflect the committed changes.