diff options
author | Roger Sayle <roger@nextmovesoftware.com> | 2023-11-13 09:11:42 +0000 |
---|---|---|
committer | Roger Sayle <roger@nextmovesoftware.com> | 2023-11-13 09:11:42 +0000 |
commit | e9d59a2a5a8e8ce667847372cc480215fa862aa4 (patch) | |
tree | c7ec6f4663a575f1c94651e4bdbe34b689550fba /gcc/rust | |
parent | 0a140730c970870a5125beb1114f6c01679a040e (diff) | |
download | gcc-e9d59a2a5a8e8ce667847372cc480215fa862aa4.zip gcc-e9d59a2a5a8e8ce667847372cc480215fa862aa4.tar.gz gcc-e9d59a2a5a8e8ce667847372cc480215fa862aa4.tar.bz2 |
ARC: Provide a TARGET_FOLD_BUILTIN target hook.
This patch implements a arc_fold_builtin target hook to allow ARC
builtins to be folded at the tree-level. Currently this function
converts __builtin_arc_swap into a LROTATE_EXPR at the tree-level,
and evaluates __builtin_arc_norm and __builtin_arc_normw of integer
constant arguments at compile-time. Because ARC_BUILTIIN_SWAP is
now handled at the tree-level, UNSPEC_ARC_SWAP no longer used,
allowing it and the "swap" define_insn to be removed.
An example benefit of folding things at compile-time is that
calling __builtin_arc_swap on the result of __builtin_arc_swap
now eliminates both and generates no code, and likewise calling
__builtin_arc_swap of a constant integer argument is evaluated
at compile-time.
2023-11-13 Roger Sayle <roger@nextmovesoftware.com>
gcc/ChangeLog
* config/arc/arc.cc (TARGET_FOLD_BUILTIN): Define to
arc_fold_builtin.
(arc_fold_builtin): New function. Convert ARC_BUILTIN_SWAP
into a rotate. Evaluate ARC_BUILTIN_NORM and
ARC_BUILTIN_NORMW of constant arguments.
* config/arc/arc.md (UNSPEC_ARC_SWAP): Delete.
(normw): Make output template/assembler whitespace consistent.
(swap): Remove define_insn, only use of SWAP UNSPEC.
* config/arc/builtins.def: Tweak indentation.
(SWAP): Expand using rotlsi2_cnt16 instead of using swap.
gcc/testsuite/ChangeLog
* gcc.target/arc/builtin_norm-1.c: New test case.
* gcc.target/arc/builtin_norm-2.c: Likewise.
* gcc.target/arc/builtin_normw-1.c: Likewise.
* gcc.target/arc/builtin_normw-2.c: Likewise.
* gcc.target/arc/builtin_swap-1.c: Likewise.
* gcc.target/arc/builtin_swap-2.c: Likewise.
* gcc.target/arc/builtin_swap-3.c: Likewise.
Diffstat (limited to 'gcc/rust')
0 files changed, 0 insertions, 0 deletions