diff options
author | Maciej W. Rozycki <macro@embecosm.com> | 2023-11-22 01:18:25 +0000 |
---|---|---|
committer | Maciej W. Rozycki <macro@embecosm.com> | 2023-11-22 01:18:25 +0000 |
commit | db9d825b212994e89dabc710c61944552eb1fe90 (patch) | |
tree | b2d25deb137190055d571b86beef875f2a7e19d1 | |
parent | 814485b2564a453ce9c0731344282f18e12ed0b5 (diff) | |
download | gcc-db9d825b212994e89dabc710c61944552eb1fe90.zip gcc-db9d825b212994e89dabc710c61944552eb1fe90.tar.gz gcc-db9d825b212994e89dabc710c61944552eb1fe90.tar.bz2 |
RISC-V: Also invert the cond-move condition for GEU and LEU
Update `riscv_expand_conditional_move' and handle the missing GEU and
LEU operators there, avoiding an extraneous conditional set operation,
such as with this output:
sgtu a0,a0,a1
seqz a1,a0
czero.eqz a3,a3,a1
czero.nez a1,a2,a1
or a0,a1,a3
produced when optimizing for Zicond targets from:
int
movsigtu (int w, int x, int y, int z)
{
return w > x ? y : z;
}
These operators can be inverted producing optimal code such as this:
sgtu a1,a0,a1
czero.nez a3,a3,a1
czero.eqz a1,a2,a1
or a0,a1,a3
which this change causes to happen.
gcc/
* config/riscv/riscv.cc (riscv_expand_conditional_move): Also
invert the condition for GEU and LEU.
-rw-r--r-- | gcc/config/riscv/riscv.cc | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/gcc/config/riscv/riscv.cc b/gcc/config/riscv/riscv.cc index e5f09c0..c7de772 100644 --- a/gcc/config/riscv/riscv.cc +++ b/gcc/config/riscv/riscv.cc @@ -4171,7 +4171,7 @@ riscv_expand_conditional_move (rtx dest, rtx op, rtx cons, rtx alt) /* If riscv_expand_int_scc inverts the condition, then it will flip the value of INVERT. We need to know where so that we can adjust it for our needs. */ - if (code == LE || code == GE) + if (code == LE || code == LEU || code == GE || code == GEU) invert_ptr = &invert; /* Emit an scc like instruction into a temporary |