public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/vendors/riscv/heads/gcc-13-with-riscv-opts)] RISC-V: Sanitise NEED_EQ_NE_P case with `riscv_emit_int_compare'
@ 2023-11-22 5:09 Jeff Law
0 siblings, 0 replies; only message in thread
From: Jeff Law @ 2023-11-22 5:09 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:4ac898303c3a0f6e5839eda17bccde2d5fb81911
commit 4ac898303c3a0f6e5839eda17bccde2d5fb81911
Author: Maciej W. Rozycki <macro@embecosm.com>
Date: Wed Nov 22 01:18:23 2023 +0000
RISC-V: Sanitise NEED_EQ_NE_P case with `riscv_emit_int_compare'
For the NEED_EQ_NE_P `riscv_emit_int_compare' is documented to only emit
EQ or NE comparisons against zero, however it does not catch incorrect
use where a non-equality comparison has been requested and falls through
to the general case then. Add a safety guard to catch such a case then.
Arguably the NEED_EQ_NE_P case would best be moved into a function of
its own, but let's leave it for a separate cleanup.
gcc/
* config/riscv/riscv.cc (riscv_emit_int_compare): Bail out if
NEED_EQ_NE_P but the comparison is neither EQ nor NE.
(cherry picked from commit 9f5aa4e210cbcb621ead82f4b56482deaa548c13)
Diff:
---
gcc/config/riscv/riscv.cc | 1 +
1 file changed, 1 insertion(+)
diff --git a/gcc/config/riscv/riscv.cc b/gcc/config/riscv/riscv.cc
index 60d3f617395..453c5f17196 100644
--- a/gcc/config/riscv/riscv.cc
+++ b/gcc/config/riscv/riscv.cc
@@ -3808,6 +3808,7 @@ riscv_emit_int_compare (enum rtx_code *code, rtx *op0, rtx *op1,
*op1 = const0_rtx;
return;
}
+ gcc_unreachable ();
}
if (splittable_const_int_operand (*op1, VOIDmode))
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-11-22 5:09 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-22 5:09 [gcc(refs/vendors/riscv/heads/gcc-13-with-riscv-opts)] RISC-V: Sanitise NEED_EQ_NE_P case with `riscv_emit_int_compare' Jeff Law
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).