HomePhabricator

[InstCombine] Negator: `extractelement` is negatible if src is negatible

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

Description

[InstCombine] Negator: extractelement is negatible if src is negatible


define i4 @negate_extractelement(<2 x i4> %x, i32 %y, i4 %z) {
%0:

%t0 = sub <2 x i4> { 0, 0 }, %x
call void @use_v2i4(<2 x i4> %t0)
%t1 = extractelement <2 x i4> %t0, i32 %y
%t2 = sub i4 %z, %t1
ret i4 %t2

}

>

define i4 @negate_extractelement(<2 x i4> %x, i32 %y, i4 %z) {
%0:

%t0 = sub <2 x i4> { 0, 0 }, %x
call void @use_v2i4(<2 x i4> %t0)
%t1.neg = extractelement <2 x i4> %x, i32 %y
%t2 = add i4 %t1.neg, %z
ret i4 %t2

}
Transformation seems to be correct!

Details

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