HomePhabricator

[InstCombine] `insertelement` is negatible if both sources are negatible

Authored by lebedev.ri on Wed, May 20, 11:37 AM.

Description

[InstCombine] insertelement is negatible if both sources are negatible


define <2 x i4> @negate_insertelement(<2 x i4> %src, i4 %a, i32 %x, <2 x i4> %b) {
%0:

%t0 = sub <2 x i4> { 0, 0 }, %src
%t1 = sub i4 0, %a
%t2 = insertelement <2 x i4> %t0, i4 %t1, i32 %x
%t3 = sub <2 x i4> %b, %t2
ret <2 x i4> %t3

}

>

define <2 x i4> @negate_insertelement(<2 x i4> %src, i4 %a, i32 %x, <2 x i4> %b) {
%0:

%t2.neg = insertelement <2 x i4> %src, i4 %a, i32 %x
%t3 = add <2 x i4> %t2.neg, %b
ret <2 x i4> %t3

}
Transformation seems to be correct!

Details

Committed
lebedev.riWed, May 20, 11:44 AM
Parents
rGa6097cebe9cd: [NFC][InstCombine] Negator: tests for insertelement negation
Branches
Unknown
Tags
Unknown