From 692caa2b0a2d48bffe421c9b509ea6a0fc51a1eb Mon Sep 17 00:00:00 2001 From: David Given Date: Tue, 18 Sep 2018 00:19:40 +0200 Subject: [PATCH] Add unsigned comparison rules. --- mach/mips/mcg/table | 51 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/mach/mips/mcg/table b/mach/mips/mcg/table index de7b9b248..584416fa0 100644 --- a/mach/mips/mcg/table +++ b/mach/mips/mcg/table @@ -555,6 +555,57 @@ PATTERNS emit "nop" cost 20; + /* Unsigned integer comparisons against a constant */ + + CJUMPLT(COMPARESI.I(COMPAREUI.I(left:(int)reg, right:CONST.I), alwayszero:CONST.I), PAIR(true:BLOCK.I, false:BLOCK.I)) + when signed_constant(%right, 16) + when specific_constant(%alwayszero, 0) + emit "sltiu at, %left, $right" + emit "bne at, zero, $true" + emit "nop" + emit "b $false" + emit "nop" + cost 16; + + CJUMPLE(COMPARESI.I(COMPAREUI.I(left:(int)reg, right:CONST.I), alwayszero:CONST.I), PAIR(true:BLOCK.I, false:BLOCK.I)) + when constant_within_inclusive_range(%right, -0x8000, 0x7ffe) + when specific_constant(%alwayszero, 0) + emit "sltiu at, %left, 1+$right" + emit "bne at, zero, $true" + emit "nop" + emit "b $false" + emit "nop" + cost 20; + + /* Unsigned integer comparisons against registers */ + + CJUMPEQ(COMPARESI.I(COMPAREUI.I(left:(int)reg, right:(int)reg), alwayszero:CONST.I), PAIR(true:BLOCK.I, false:BLOCK.I)) + when specific_constant(%alwayszero, 0) + emit "beq %left, %right, $true" + emit "nop" + emit "b $false" + emit "nop" + cost 16; + + CJUMPLT(COMPARESI.I(COMPAREUI.I(left:(int)reg, right:(int)reg), alwayszero:CONST.I), PAIR(true:BLOCK.I, false:BLOCK.I)) + when specific_constant(%alwayszero, 0) + emit "sltu at, %left, %right" + emit "bne at, zero, $true" + emit "nop" + emit "b $false" + emit "nop" + cost 16; + + CJUMPLE(COMPARESI.I(COMPAREUI.I(left:(int)reg, right:(int)reg), alwayszero:CONST.I), PAIR(true:BLOCK.I, false:BLOCK.I)) + when specific_constant(%alwayszero, 0) + emit "sltu at, %right, %left" + emit "beq at, zero, $true" + emit "nop" + emit "b $false" + emit "nop" + cost 16; + + /* Comparisons */