From 2de729ee4e7a464508a6d9ac0419adefd904f748 Mon Sep 17 00:00:00 2001 From: Sleigh-InSPECtor <166091708+Sleigh-InSPECtor@users.noreply.github.com> Date: Thu, 16 May 2024 14:41:31 +0930 Subject: [PATCH] riscv: reduced branches in fmin/fmax --- .../RISCV/data/languages/riscv.rv32d.sinc | 32 +++++++------------ .../RISCV/data/languages/riscv.rv32f.sinc | 32 +++++++------------ 2 files changed, 24 insertions(+), 40 deletions(-) diff --git a/Ghidra/Processors/RISCV/data/languages/riscv.rv32d.sinc b/Ghidra/Processors/RISCV/data/languages/riscv.rv32d.sinc index e8d298bfbe..37db9da5a6 100644 --- a/Ghidra/Processors/RISCV/data/languages/riscv.rv32d.sinc +++ b/Ghidra/Processors/RISCV/data/languages/riscv.rv32d.sinc @@ -122,32 +122,24 @@ # fmax.d D,S,T 2a001053 fe00707f SIMPLE (0, 0) :fmax.d frd,frs1D,frs2D is frs1D & frd & frs2D & op0001=0x3 & op0204=0x4 & op0506=0x2 & funct3=0x1 & funct7=0x15 { - #TODO redo this - local tmpfrs1 = frs1D; - local tmpfrs2 = frs2D; - frd = tmpfrs1; - if (nan(tmpfrs1) && nan(tmpfrs2)) goto inst_next; - if (nan(tmpfrs2)) goto inst_next; - frd = tmpfrs2; - if (nan(tmpfrs1)) goto inst_next; - if (tmpfrs2 f> tmpfrs1) goto inst_next; - frd = tmpfrs1; + local tmp:$(DFLEN) = frs1D; + if (frs1D f> frs2D) goto ; + if (nan(frs2D)) goto ; + tmp = frs2D; + + frd = tmp; } # fmin.d D,S,T 2a000053 fe00707f SIMPLE (0, 0) :fmin.d frd,frs1D,frs2D is frs1D & frd & frs2D & op0001=0x3 & op0204=0x4 & op0506=0x2 & funct3=0x0 & funct7=0x15 { - #TODO redo this - local tmpfrs1 = frs1D; - local tmpfrs2 = frs2D; - frd = tmpfrs1; - if (nan(tmpfrs1) && nan(tmpfrs2)) goto inst_next; - if (nan(tmpfrs2)) goto inst_next; - frd = tmpfrs2; - if (nan(tmpfrs1)) goto inst_next; - if (tmpfrs2 f<= tmpfrs1) goto inst_next; - frd = tmpfrs1; + local tmp:$(DFLEN) = frs1D; + if (frs1D f< frs2D) goto ; + if (nan(frs2D)) goto ; + tmp = frs2D; + + frd = tmp; } diff --git a/Ghidra/Processors/RISCV/data/languages/riscv.rv32f.sinc b/Ghidra/Processors/RISCV/data/languages/riscv.rv32f.sinc index e830008391..6844a61fa5 100644 --- a/Ghidra/Processors/RISCV/data/languages/riscv.rv32f.sinc +++ b/Ghidra/Processors/RISCV/data/languages/riscv.rv32f.sinc @@ -107,32 +107,24 @@ # fmax.s D,S,T 28001053 fe00707f SIMPLE (0, 0) :fmax.s frd,frs1S,frs2S is frs1S & frd & frs2S & op0001=0x3 & op0204=0x4 & op0506=0x2 & funct3=0x1 & funct7=0x14 { - #TODO redo this - local tmpfrs1 = frs1S; - local tmpfrs2 = frs2S; - fassignS(frd, tmpfrs1); - if (nan(tmpfrs1) && nan(tmpfrs2)) goto inst_next; - if (nan(tmpfrs2)) goto inst_next; - fassignS(frd, tmpfrs2); - if (nan(tmpfrs1)) goto inst_next; - if (tmpfrs2 f>= tmpfrs1) goto inst_next; - fassignS(frd, tmpfrs1); + local tmp:$(SFLEN) = frs1S; + if (frs1S f> frs2S) goto ; + if (nan(frs2S)) goto ; + tmp = frs2S; + + fassignS(frd, tmp); } # fmin.s D,S,T 28000053 fe00707f SIMPLE (0, 0) :fmin.s frd,frs1S,frs2S is frs1S & frd & frs2S & op0001=0x3 & op0204=0x4 & op0506=0x2 & funct3=0x0 & funct7=0x14 { - #TODO redo this - local tmpfrs1 = frs1S; - local tmpfrs2 = frs2S; - fassignS(frd, tmpfrs1); - if (nan(tmpfrs1) && nan(tmpfrs2)) goto inst_next; - if (nan(tmpfrs2)) goto inst_next; - fassignS(frd, tmpfrs2); - if (nan(tmpfrs1)) goto inst_next; - if (tmpfrs2 f<= tmpfrs1) goto inst_next; - fassignS(frd, tmpfrs1); + local tmp:$(SFLEN) = frs1S; + if (frs1S f< frs2S) goto ; + if (nan(frs2S)) goto ; + tmp = frs2S; + + fassignS(frd, tmp); }