This is an archive of the discontinued LLVM Phabricator instance.

[TargetLowering] Move the setBooleanContents check on (xor (setcc), (setcc)) == / != 1 -> (setcc) != / == (setcc) to the right place
ClosedPublic

Authored by craig.topper on Oct 27 2019, 11:16 AM.

Details

Summary

We need to be checking the value types for the inner setccs not
the outer setcc. We need to ensure those setccs produce a 0/1
value or that the xor is on the i1 type. I think at the time
this code was originally written, getBooleanContents didn't
take any arguments so this was probably correct. But now we can
have a different boolean contents for integer and floating point.

Not sure why the other combines below the xor were also checking
the boolean contents. None of them involve any setccs other than
the outer one and they only produce a new setcc.

Diff Detail

Event Timeline

craig.topper created this revision.Oct 27 2019, 11:16 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 27 2019, 11:16 AM
Herald added a subscriber: hiraditya. · View Herald Transcript

Test case?

I don't have one. Would need a target that has different boolean contents for scalar fp and scalar int. I think maybe one of the subtargets have mips has the mix? And then you would need to mix an fp compare and int compare. And you'd have to delay the combine until after type legalization so that you don't hit the i1 check. Any suggestions how to do that?

RKSimon accepted this revision.Nov 1 2019, 9:42 AM

OK, lets's go with this. LGTM

This revision is now accepted and ready to land.Nov 1 2019, 9:42 AM
This revision was automatically updated to reflect the committed changes.