From 39cfa67b4f56e0c79afb352b1e9bf5c914b774ca Mon Sep 17 00:00:00 2001 From: shyouhei Date: Mon, 15 Jan 2018 02:35:18 +0000 Subject: __builtin_assume_aligned for *(foo *) casts These casts are guarded. Must be safe to assume alignments. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61829 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- string.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'string.c') diff --git a/string.c b/string.c index 63b4d57f82..9902b0feb3 100644 --- a/string.c +++ b/string.c @@ -481,8 +481,15 @@ search_nonascii(const char *p, const char *e) } } #endif - s = (const uintptr_t *)p; - t = (const uintptr_t *)(e - (SIZEOF_VOIDP-1)); +#ifdef HAVE_BUILTIN___BUILTIN_ASSUME_ALIGNED +#define aligned_ptr(value) \ + __builtin_assume_aligned((value), sizeof(uintptr_t *)) +#else +#define aligned_ptr(value) (uintptr_t *)(value) +#endif + s = aligned_ptr(p); + t = aligned_ptr(e - (SIZEOF_VOIDP-1)); +#undef aligned_ptr for (;s < t; s++) { if (*s & NONASCII_MASK) { #ifdef WORDS_BIGENDIAN -- cgit v1.2.3