Skip to content

Commit

Permalink
Fix constant optimization on RV32F instructions
Browse files Browse the repository at this point in the history
Because some RV32F instructions use the interger register, we need to
handle these instructions in constant optimization.

Close: sysprog21#258
  • Loading branch information
qwe661234 committed Dec 15, 2023
1 parent 49f89a1 commit 42fbdd1
Showing 1 changed file with 28 additions and 7 deletions.
35 changes: 28 additions & 7 deletions src/rv32_constopt.c
Original file line number Diff line number Diff line change
Expand Up @@ -650,29 +650,50 @@ CONSTOPT(fmaxs, {})
*/

/* FCVT.W.S */
CONSTOPT(fcvtws, {})
CONSTOPT(fcvtws, {
if (ir->rd)
info->is_constant[ir->rd] = false;
})

/* FCVT.WU.S */
CONSTOPT(fcvtwus, {})
CONSTOPT(fcvtwus, {
if (ir->rd)
info->is_constant[ir->rd] = false;
})

/* FMV.X.W */
CONSTOPT(fmvxw, {})
CONSTOPT(fmvxw, {
if (ir->rd)
info->is_constant[ir->rd] = false;
})

/* FEQ.S performs a quiet comparison: it only sets the invalid operation
* exception flag if either input is a signaling NaN.
*/
CONSTOPT(feqs, {})
CONSTOPT(feqs, {
if (ir->rd)
info->is_constant[ir->rd] = false;
})

/* FLT.S and FLE.S perform what the IEEE 754-2008 standard refers to as
* signaling comparisons: that is, they set the invalid operation exception
* flag if either input is NaN.
*/
CONSTOPT(flts, {})
CONSTOPT(flts, {
if (ir->rd)
info->is_constant[ir->rd] = false;
})

CONSTOPT(fles, {})
CONSTOPT(fles, {
if (ir->rd)
info->is_constant[ir->rd] = false;
})

/* FCLASS.S */
CONSTOPT(fclasss, {})
CONSTOPT(fclasss, {
if (ir->rd)
info->is_constant[ir->rd] = false;
})

/* FCVT.S.W */
CONSTOPT(fcvtsw, {})
Expand Down

0 comments on commit 42fbdd1

Please sign in to comment.