This is an archive of the discontinued LLVM Phabricator instance.

The return value of a comparison operator is -1 if true and 0 if false
ClosedPublic

Authored by void on May 13 2018, 1:13 AM.

Details

Reviewers
echristo
niravd
Summary

Correct compatibility with the GNU Assembler's handling of the comparison operators. GAS returns -1 for a comparison operator if the result is true and 0 if false.

https://www.sourceware.org/binutils/docs-2.12/as.info/Infix-Ops.html#Infix%20Ops

Diff Detail

Event Timeline

void created this revision.May 13 2018, 1:13 AM
void updated this revision to Diff 146504.May 13 2018, 2:22 AM

Add fix for MIPS test.

niravd added inline comments.May 13 2018, 3:02 AM
lib/MC/MCExpr.cpp
805

The docs say Land and LOr must be 0 or 1.

test/MC/Mips/memory-offsets.s
21 ↗(On Diff #146504)

This should be reverted given above.

void marked an inline comment as done.May 13 2018, 5:23 PM
void added inline comments.
lib/MC/MCExpr.cpp
805

Ah! Good catch. Done.

void updated this revision to Diff 146534.May 13 2018, 5:23 PM

Fix logical operators. They return 1 or 0, not -1 or 0.

niravd accepted this revision.May 13 2018, 8:12 PM

LGTM.

This revision is now accepted and ready to land.May 13 2018, 8:12 PM
void closed this revision.May 13 2018, 10:29 PM