[PATCH 2/2 v2] RISC-V: Constant synthesis of inverted halves

2024-09-05 Thread Raphael Moreira Zinsly
Changes since v1: - Fix synthesis-15.c. -- >8 -- Improve handling of constants where the high half can be constructed by inverting the lower half. gcc/ChangeLog: * config/riscv/riscv.cc (riscv_build_integer): Detect constants were the higher half is the lower half inverte

[PATCH 1/2 v2] RISC-V: Additional large constant synthesis improvements

2024-09-05 Thread Raphael Moreira Zinsly
Changes since v1: - Fix bit31. - Remove negative shift checks. - Fix synthesis-7.c expected output. -- >8 -- Improve handling of large constants in riscv_build_integer, generate better code for constants where the high half can be constructed by shifting/shiftNadding the l

[PATCH 3/3] RISC-V: Constant synthesis of inverted halves

2024-09-02 Thread Raphael Moreira Zinsly
Improve handling of constants where the high half can be constructed by inverting the lower half. gcc/ChangeLog: * config/riscv/riscv.cc (riscv_build_integer): Detect constants were the higher half is the lower half inverted. gcc/testsuite/ChangeLog: * gcc.target/riscv/syn

[PATCH 2/3] RISC-V: Additional large constant synthesis improvements

2024-09-02 Thread Raphael Moreira Zinsly
Improve handling of large constants in riscv_build_integer, generate better code for constants where the high half can be constructed by shifting/shiftNadding the low half or if the halves differ by less than 2k. gcc/ChangeLog: * config/riscv/riscv.cc (riscv_build_integer): Detect new case

[PATCH 1/3] RISC-V: Improve codegen for negative repeating large constants

2024-09-02 Thread Raphael Moreira Zinsly
Improve handling of constants where its upper and lower 32-bit halves are the same and have negative values. e.g. for: unsigned long f (void) { return 0xf0f0f0f0f0f0f0f0UL; } Without the patch: li a0,-252645376 addia0,a0,240 li a5,-252645376 addia5,a5,241 sllia5,a5,32 add

[PATCH] RISC-V: Fix vector cfi notes for stack-clash protection

2024-08-21 Thread Raphael Moreira Zinsly
The stack-clash code is generating wrong cfi directives in riscv_v_adjust_scalable_frame because REG_CFA_DEF_CFA has a different encoding than REG_FRAME_RELATED_EXPR, this patch fixes the offset sign in prologue and starts using REG_CFA_DEF_CFA in the epilogue. gcc/ChangeLog: * config/ris

[PATCH 2/2] RISC-V: Constant synthesis by shifting the lower half

2024-08-08 Thread Raphael Moreira Zinsly
Improve handling of constants where the high half can be constructed by shifting the low half. gcc/ChangeLog: * config/riscv/riscv.cc (riscv_build_integer): Detect constants were the higher half is a shift of the lower half. gcc/testsuite/ChangeLog: * gcc.target/riscv/synt

[PATCH 1/2] RISC-V: Constant synthesis with same upper and lower halves

2024-08-08 Thread Raphael Moreira Zinsly
From: Raphael Zinsly Improve handling of constants where its upper and lower 32-bit halves are the same and Zbkb is not available in riscv_move_integer. riscv_split_integer already handles this but the changes in riscv_build_integer makes it possible to improve code generation for negative values

[PATCH v2] RISC-V: Add support to vector stack-clash protection

2024-08-01 Thread Raphael Moreira Zinsly
Changes since v1: - Changed RISCV_STACK_CLASH_VECTOR_CFA_REGNUM to t3. -- >8 -- Adds basic support to vector stack-clash protection using a loop to do the probing and stack adjustments. gcc/ChangeLog: * config/riscv/riscv.cc (riscv_allocate_and_probe_stack_loop): New func

[PATCH 3/5] RISC-V: Stack-clash protection implemention

2024-07-24 Thread Raphael Moreira Zinsly
This implements stack-clash protection for riscv, with riscv_allocate_and_probe_stack_space being based of aarch64_allocate_and_probe_stack_space from aarch64's implementation. We enforce the probing interval and the guard size to always be equal, their default value is 4Kb which is riscv page size

[PATCH 5/5] RISC-V: Enable stack clash in alloca

2024-07-24 Thread Raphael Moreira Zinsly
Add the TARGET_STACK_CLASH_PROTECTION_ALLOCA_PROBE_RANGE to riscv in order to enable stack clash protection when using alloca. The code and tests are the same used by aarch64. gcc/ChangeLog: * config/riscv/riscv.cc (riscv_compute_frame_info): Update outgoing args size.

[PATCH 4/5] RISC-V: Add support to vector stack-clash protection

2024-07-24 Thread Raphael Moreira Zinsly
Adds basic support to vector stack-clash protection using a loop to do the probing and stack adjustments. gcc/ChangeLog: * config/riscv/riscv.cc (riscv_allocate_and_probe_stack_loop): New function. (riscv_v_adjust_scalable_frame): Add stack-clash protection support.

[PATCH 2/5] RISC-V: Move riscv_v_adjust_scalable_frame

2024-07-24 Thread Raphael Moreira Zinsly
Move riscv_v_adjust_scalable_frame () in preparation for the stack clash protection support. gcc/ChangeLog: * config/riscv/riscv.cc (riscv_v_adjust_scalable_frame): Move closer to riscv_expand_prologue. --- gcc/config/riscv/riscv.cc | 62 +++

[PATCH 1/5] RISC-V: Small stack tie changes

2024-07-24 Thread Raphael Moreira Zinsly
Enable the register used by riscv_emit_stack_tie () to be passed as an argument so we can tie the stack with other registers besides hard_frame_pointer_rtx. Also don't allow operand 1 of stack_tie to be optimized to sp in preparation for the stack clash protection support. gcc/ChangeLog: *

[PATCH 0/5] RISC-V: Enable stack-clash protection

2024-07-24 Thread Raphael Moreira Zinsly
Hi All, This patch series implements stack-clash protection for RISC-V using 4K probes as default. The non-vector implementation is based on AArch64’s as the generated stack frame is similar. The tests are also adapted from AArch64. Thanks, Raphael Raphael Moreira Zinsly (5): RISC-V: Small

[PATCH] RISC-V: Add Veyron V1 pipeline description

2023-06-07 Thread Raphael Moreira Zinsly
gcc/ChangeLog: * config/riscv/riscv-cores.def: Add veyron-v1 core and tune info. * config/riscv/riscv-opts.h (riscv_microarchitecture_type): Add veyron-v1. * config/riscv/riscv.cc (veyron_v1_tune_info): New. * config/riscv/riscv.md: Include veyron-v1

[PATCH v2] RISC-V: Fix CTZ unnecessary sign extension [PR #106888]

2023-05-08 Thread Raphael Moreira Zinsly
Changes since v1: - Remove subreg from operand 1. -- >8 -- We were not able to match the CTZ sign extend pattern on RISC-V because it gets optimized to zero extend and/or to ANDI patterns. For the ANDI case, combine scrambles the RTL and generates the extension by using subregs.

[PATCH v2] RISC-V: Add bext pattern for ZBS

2023-05-08 Thread Raphael Moreira Zinsly
Changes since v1: - Removed name clash change. - Fix new pattern indentation. -- >8 -- When (a & (1 << bit_no)) is tested inside an IF we can use a bit extract. gcc/ChangeLog: * config/riscv/bitmanip.md (branch_bext): New split pattern.

[PATCH] RISC-V: Fix CTZ unnecessary sign extension [PR #106888]

2023-05-04 Thread Raphael Moreira Zinsly
We were not able to match the CTZ sign extend pattern on RISC-V because it get optimized to zero extend and/or to ANDI patterns. For the ANDI case, combine scrambles the RTL and generates the extension by using subregs. gcc/ChangeLog: PR target/106888 * conf

[PATCH] RISC-V: Add bext pattern for ZBS

2023-05-04 Thread Raphael Moreira Zinsly
When (a & (1 << bit_no)) is tested inside an IF we can use a bit extract. gcc/ChangeLog: * config/riscv/bitmanip.md (bext): Rename one to avoid name clash. (branch_bext): New split pattern. gcc/testsuite/ChangeLog: *

[PATCH] RISC-V: Optimize min/max with SImode sources on 64-bit

2022-12-28 Thread Raphael Moreira Zinsly
The Zbb min/max pattern was not matching 32-bit sources when compiling for 64-bit. This patch separates the pattern into SImode and DImode, and use a define_expand to handle SImode on 64-bit. zbb-min-max-02.c generates different code as a result of the new expander.  The resulting code is as effici

[PATCH v2] RISC-V: Produce better code with complex constants [PR95632] [PR106602]

2022-12-09 Thread Raphael Moreira Zinsly
ions with big constants combine is failing to match such operations and is not being able to produce optimal code as it keeps splitting them. By pretending we can do those operations we can get more opportunities for simplification of surrounding instructions. 2022-12-06 Raphael Moreira Zinsly

[PATCH] RISC-V: Produce better code with complex constants [PR95632] [PR106602]

2022-12-07 Thread Raphael Moreira Zinsly
. 2022-12-06 Raphael Moreira Zinsly Jeff Law gcc/Changelog: PR target/95632 PR target/106602 * config/riscv/riscv.md: New pattern to simulate complex const_int loads. gcc/testsuite/ChangeLog: * gcc.target/riscv/pr95632.c: New test

[PATCH v2] libgcc: fix backtrace fallback on PowerPC Big-endian. [PR103004]

2021-11-11 Thread Raphael Moreira Zinsly via Gcc-patches
Changes since v1: - Removed -Wmissing-prototypes fix. - Fixed formatting of Changelog and patch. --->8--- At the end of the backtrace stream _Unwind_Find_FDE() may not be able to find the frame unwind info and will later call the backtrace fallback instead of finishing. This occur

[PATCH] libgcc: fix backtrace fallback on PowerPC Big-endian. [PR103004]

2021-11-10 Thread Raphael Moreira Zinsly via Gcc-patches
At the end of the backtrace stream _Unwind_Find_FDE() may not be able to find the frame unwind info and will later call the backtrace fallback instead of finishing. This occurs when using an old libc on ppc64 due to dl_iterate_phdr() not being able to set the fde in the last trace. When this occurs

[PATCH v3] libgcc: Add a backchain fallback to _Unwind_Backtrace() on PowerPC

2021-10-05 Thread Raphael Moreira Zinsly via Gcc-patches
Without dwarf2 unwind tables available _Unwind_Backtrace() is not able to return the full backtrace. This patch adds a fallback function on powerpc to get the backtrace by doing a backchain, this code was originally at glibc. libgcc/ChangeLog: * config/rs6000/linux-unwind.h (struct rt_sig

[PATCH v2] libgcc: Add a backchain fallback to _Unwind_Backtrace() on PowerPC

2021-08-26 Thread Raphael Moreira Zinsly via Gcc-patches
Without dwarf2 unwind tables available _Unwind_Backtrace() is not able to return the full backtrace. This patch adds a fallback function on powerpc to get the backtrace by doing a backchain, this code was originally at glibc. libgcc/ChangeLog: * config/rs6000/linux-unwind.h (struct rt_sig

[PATCH] libgcc: Add a backchain fallback to _Unwind_Backtrace() on PowerPC

2021-08-13 Thread Raphael Moreira Zinsly via Gcc-patches
This is followup to this RFC: https://gcc.gnu.org/pipermail/gcc-patches/2021-June/573954.html ---8<--- Without dwarf2 unwind tables available _Unwind_Backtrace() is not able to return the full backtrace. This patch adds a fallback function on powerpc to get the backtrace by doing a backchain, th

[PATCH] [RFC] libgcc: Add a backchain fallback to _Unwind_Backtrace() on PowerPC

2021-06-29 Thread Raphael Moreira Zinsly via Gcc-patches
have the trace_arg struct here or should this be handled by the trace function passed to _Unwind_Backtrace()? Any comments are appreciated. Best Regards, Raphael Moreira Zinsly [1] https://sourceware.org/pipermail/libc-alpha/2021-February/122600.html --- libgcc/config/rs6000/linux-unwind.h | 58