public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/vendors/ARM/heads/morello)] builtins: Add a log2_nbytes_int_mode helper
@ 2022-05-06 14:43 Matthew Malcomson
  0 siblings, 0 replies; only message in thread
From: Matthew Malcomson @ 2022-05-06 14:43 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:eed938d8feccc73e2d5663f99bad3760411f600e

commit eed938d8feccc73e2d5663f99bad3760411f600e
Author: Richard Sandiford <richard.sandiford@arm.com>
Date:   Fri Apr 22 10:08:37 2022 +0100

    builtins: Add a log2_nbytes_int_mode helper
    
    BUILT_IN_SPECULATION_SAFE_VALUE_* currently follow the same
    numbering scheme as the sync builtins, so the code that handled
    them used get_builtin_sync_mode to get the associated data mode.
    However, later patches change the numbering scheme of the sync
    builtins, making it necessary to do something else for
    BUILT_IN_SPECULATION_SAFE_VALUE_*.

Diff:
---
 gcc/builtins.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/gcc/builtins.c b/gcc/builtins.c
index 25987297529..91f12af878a 100644
--- a/gcc/builtins.c
+++ b/gcc/builtins.c
@@ -6622,6 +6622,14 @@ expand_builtin_fork_or_exec (tree fn, tree exp, rtx target, int ignore)
 
 
 \f
+/* Return an integer mode that has exactly 2**NBYTES_LOG2 bytes.  */
+
+static scalar_int_mode
+log2_nbytes_int_mode (int nbytes_log2)
+{
+  return int_mode_for_size (BITS_PER_UNIT << nbytes_log2, 0).require ();
+}
+
 /* Reconstitute a mode for a __sync intrinsic operation.  Since the type of
    the pointer in these functions is void*, the tree optimizers may remove
    casts.  The mode computed in expand_builtin isn't reliable either, due
@@ -8963,7 +8971,7 @@ expand_builtin (tree exp, rtx target, rtx subtarget, machine_mode mode,
     case BUILT_IN_SPECULATION_SAFE_VALUE_4:
     case BUILT_IN_SPECULATION_SAFE_VALUE_8:
     case BUILT_IN_SPECULATION_SAFE_VALUE_16:
-      mode = get_builtin_sync_mode (fcode - BUILT_IN_SPECULATION_SAFE_VALUE_1);
+      mode = log2_nbytes_int_mode (fcode - BUILT_IN_SPECULATION_SAFE_VALUE_1);
       return expand_speculation_safe_value (mode, exp, target, ignore);
 
     default:	/* just do library call, if unknown builtin */


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-05-06 14:43 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-06 14:43 [gcc(refs/vendors/ARM/heads/morello)] builtins: Add a log2_nbytes_int_mode helper Matthew Malcomson

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).