As far as I can tell this should be handled by foldCastedBitwiseLogic which is called later in visitXor.
Details
Details
Diff Detail
Diff Detail
- Repository
- rL LLVM
Event Timeline
Comment Actions
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?
Comment Actions
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.