In mach/i386/ncg/table, the EM patterns for cmi 4 and cmu 4 have wrong rules. They reverse the comparison, turning a < b into a > b. This is almost never a problem, because most code uses cmi txx or cmi zxx, and those patterns have correct rules.
One way to use the wrong rule is when ack -Ropt-n disables peephole optimization. The next example shows the problem.
#include <stdio.h>
int g = 1;
int main(void) {
if (g < 2) {
puts("good: 1 < 2");
return 0;
} else {
puts("bad: !(1 < 2)");
return 1;
}
}
The EM code from ack -c.e is loe g loc 2 cmi 4 zlt *3 bra *4 to branch 3 if g < 2, else branch 4. The opt pattern cmi zlt $1==w: blt $2 would handle this, but -Ropt-n disables all opt patterns and exposes the wrong cmi rule.
I suspect that I can easily write a test case in EM and fix the rules, but I haven't done so. I also don't know if cmi, cmu are broken in other machines.
In mach/i386/ncg/table, the EM patterns for
cmi 4
andcmu 4
have wrong rules. They reverse the comparison, turning a < b into a > b. This is almost never a problem, because most code uses cmi txx or cmi zxx, and those patterns have correct rules.One way to use the wrong rule is when
ack -Ropt-n
disables peephole optimization. The next example shows the problem.The EM code from ack -c.e is
loe g loc 2 cmi 4 zlt *3 bra *4
to branch 3 if g < 2, else branch 4. The opt patterncmi zlt $1==w: blt $2
would handle this, but -Ropt-n disables all opt patterns and exposes the wrong cmi rule.I suspect that I can easily write a test case in EM and fix the rules, but I haven't done so. I also don't know if cmi, cmu are broken in other machines.