From 5929f3dd0e3a16a1c499bfdde768fe4cf7a38621 Mon Sep 17 00:00:00 2001 From: ceriel Date: Tue, 30 Jan 1990 13:41:36 +0000 Subject: [PATCH] Fix: illegal optimizations of muls --- mach/m68020/top/table | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/mach/m68020/top/table b/mach/m68020/top/table index 3b3b9d22e..d806885a8 100644 --- a/mach/m68020/top/table +++ b/mach/m68020/top/table @@ -145,6 +145,9 @@ move.l A, B : bra LAB : labdef L1 : move.l A, B : labdef LAB labdef LAB ; /* some strength reduction */ mulu.l #NUM,DREG -> muls.l #NUM,DREG ; +muls.l #NUM,DREG + {isshift_once(NUM,X,Y)} -> asl.l #X,DREG : + asl.l #Y,DREG ; muls.l #NUM,DREG {is_shift_twice(NUM,X,Y)} -> asl.l #X,DREG : move.l DREG,-(sp) : @@ -179,6 +182,38 @@ int no_side_effects(s) /* NOTREACHED */ } +int isshift_once(s, c1, c2) + char *s, *c1, *c2; +{ + long atol(); + register int i = 0; + long val = atol(s), pow = 1; + + while (i <= 8) { + if (pow & val) { + val -= pow; + sprintf(c1, "%d", i); + strcpy(c2, "0"); + if (val == 0) return 1; + return 0; + } + pow <<= 1; + i++; + } + i = 0; + strcpy(c1, "8"); + while (i <= 8) { + if (pow & val) { + val -= pow; + sprintf(c2, "%d", i); + if (val == 0) return 1; + return 0; + } + pow <<= 1; + i++; + } + return 0; +} int is_shift_twice(s, c1, c2) char *s, *c1, *c2; @@ -196,6 +231,7 @@ int is_shift_twice(s, c1, c2) pow <<= 1; i++; } + if (i > 8) return 0; if (pow > 0 && val) { i = 0; while (i <= 8) { -- 2.34.1