3d6ee435cf
Bug reported by Rune, see - https://sourceforge.net/p/tack/mailman/message/35809953/ - https://github.com/davidgiven/ack/issues/62 In EM code, beq and bne pop 2 values and compare them, but teq and tne pop only 1 value and compare it with zero. We need cms to compare 2 values; other patterns may convert cmi or cmu to cms.
50 lines
933 B
C
50 lines
933 B
C
#include "test.h"
|
|
|
|
/*
|
|
* Function a() comes from this mail by Rune to tack-devel:
|
|
* https://sourceforge.net/p/tack/mailman/message/35809953/
|
|
*
|
|
* The peephole optimiser (util/opt) had a bug that rewrote
|
|
* xx(! i, i) as xx(1). It was confused with xx(i == i).
|
|
*/
|
|
|
|
void xx(int xfal, int x1234) {
|
|
ASSERT(xfal == 0);
|
|
ASSERT(x1234 == 1234);
|
|
}
|
|
|
|
void a(void) {
|
|
int i = 1234;
|
|
xx(! i, i);
|
|
}
|
|
|
|
void xxxx(int x2005, int xfal, int xn567, int x2017) {
|
|
ASSERT(x2005 == 2005);
|
|
ASSERT(xfal == 0);
|
|
ASSERT(xn567 == -567);
|
|
ASSERT(x2017 == 2017);
|
|
}
|
|
|
|
/* Like a(), but with surrounding arguments. */
|
|
void b(void) {
|
|
int i = -567;
|
|
xxxx(2005, ! i, i, 2017);
|
|
}
|
|
|
|
/*
|
|
* In c(), the fixed peephole optimiser may
|
|
* rewrite i == i as 1 and i != i as 0.
|
|
*/
|
|
void c(int i, int tru, int fal) {
|
|
ASSERT((i == i) == tru);
|
|
ASSERT((i != i) == fal);
|
|
}
|
|
|
|
/* Bypasses the CRT. */
|
|
void _m_a_i_n(void) {
|
|
a();
|
|
b();
|
|
c(62, 1, 0);
|
|
finished();
|
|
}
|