Page MenuHomePhabricator

[InstCombine] Remove explicit code for folding (xor(zext(cmp)), 1) and (xor(sext(cmp)), -1) to ext(!cmp).
ClosedPublic

Authored by craig.topper on Aug 1 2017, 11:58 PM.

Details

Diff Detail

Repository
rL LLVM

Event Timeline

craig.topper created this revision.Aug 1 2017, 11:58 PM
spatel edited edge metadata.Aug 2 2017, 10:18 AM

Double-check to make sure, but I think the sext variant isn't handled if we remove this block (sadly, there's no regression test for it):

define i8 @xor_ext_cmp(i8 %x, i8 %y) {

%cmp = icmp sgt i8 %x, %y
%ext = sext i1 %cmp to i8
%xor = xor i8 %ext, -1
ret i8 %xor

}

Enhance foldLogicCastConstant() to handle sext? Should we also be calling foldXorOfICmps at the end of foldCastedBitwiseLogic() instead of bailing out there?

Please add the sext test to this patch. I assume a zext variant already exists - if not, we could use one of those too.
That way we'll be sure that the intended folds are still happening via other mechanisms.

I pre-commited a sext case in r309839.

spatel accepted this revision.Aug 2 2017, 1:04 PM

LGTM.

This revision is now accepted and ready to land.Aug 2 2017, 1:04 PM
This revision was automatically updated to reflect the committed changes.