From 0da248dced7b3fdf3062ba02b610bd0815b2f8c2 Mon Sep 17 00:00:00 2001 From: David Given Date: Sat, 7 Jan 2017 01:03:15 +0100 Subject: [PATCH] Use a better NOT; and after remembering that PowerPC bit numbers are all backwards in the documentation, rewrote IFEQ/IFLT/IFLE to actually work. Probably. Thanks to the B test suite for spotting this. --- mach/powerpc/mcg/table | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/mach/powerpc/mcg/table b/mach/powerpc/mcg/table index 8511dbb5b..b72990c36 100644 --- a/mach/powerpc/mcg/table +++ b/mach/powerpc/mcg/table @@ -572,26 +572,26 @@ PATTERNS out:(int)reg = IFEQ.I(in:(cr)cr) emit "mfcr %out" /* get cr0 */ - emit "rlwinm %out, %out, [32-2], 2, 31" /* extract just EQ */ + emit "rlwinm %out, %out, 3, 31, 31" /* extract just EQ */ cost 8; +#if 0 out:(int)reg = IFEQ.I(in:(int)reg) emit "cntlzw %out, %in" /* returns 0..32 */ - emit "rlwinm %out, %out, [32-5], 5, 31" /* if 32, return 1, otherwise 0 */ + emit "rlwinm %out, %out, [32-5], 31, 31" /* if 32, return 1, otherwise 0 */ cost 8; +#endif out:(int)reg = IFLT.I(in:(cr)cr) emit "mfcr %out" /* get cr0 */ - emit "andi. %out, %out, 1" /* leave just LT */ + emit "rlwinm %out, %out, 1, 31, 31" /* leave just LT */ cost 8; out:(int)reg = IFLE.I(in:(cr)cr) emit "mfcr %out" /* get cr0 */ - emit "andi. %out, %out, 5" /* leave just LT and EQ */ - emit "cntlzw %out, %out" /* returns 0..32 */ - emit "rlwinm %out, %out, [32-5], 5, 31" /* if 32, return 1, otherwise 0 */ + emit "rlwinm %out, %out, 2, 31, 31" /* leave just GT */ emit "xori %out, %out, 1" /* negate */ - cost 8; + cost 12; @@ -673,10 +673,9 @@ PATTERNS emit "neg %out, %left" cost 4; - out:(int)reg = NOT.I(left:(int)reg) - emit "cntlzw %out, %left" - emit "rlwinm %out, %out, 32-5, 5, 31" - cost 8; + out:(int)reg = NOT.I(in:(int)reg) + emit "nor %out, %in, %in" + cost 4; ALUR(AND.I, "and") ALUCC(AND.I, "andi.") -- 2.34.1