qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] tcg: Optimize inline dup_const for MO_64
@ 2021-01-19 18:55 Richard Henderson
  2021-01-19 18:55 ` [PATCH 1/2] qemu/compiler: Split out qemu_build_not_reached_always Richard Henderson
  2021-01-19 18:55 ` [PATCH 2/2] tcg: Optimize inline dup_const for MO_64 Richard Henderson
  0 siblings, 2 replies; 5+ messages in thread
From: Richard Henderson @ 2021-01-19 18:55 UTC (permalink / raw)
  To: qemu-devel; +Cc: david

I found this hanging about in an old branch, and updated it a
bit for mainline.  IIRC, there are some cases in target/s390x
where (via cpp pasting) we "dup" a 64-bit value to itself.


r~


Richard Henderson (2):
  qemu/compiler: Split out qemu_build_not_reached_always
  tcg: Optimize inline dup_const for MO_64

 include/qemu/compiler.h | 5 +++--
 include/tcg/tcg.h       | 3 ++-
 2 files changed, 5 insertions(+), 3 deletions(-)

-- 
2.25.1



^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/2] qemu/compiler: Split out qemu_build_not_reached_always
  2021-01-19 18:55 [PATCH 0/2] tcg: Optimize inline dup_const for MO_64 Richard Henderson
@ 2021-01-19 18:55 ` Richard Henderson
  2021-01-19 22:13   ` Philippe Mathieu-Daudé
  2021-01-19 18:55 ` [PATCH 2/2] tcg: Optimize inline dup_const for MO_64 Richard Henderson
  1 sibling, 1 reply; 5+ messages in thread
From: Richard Henderson @ 2021-01-19 18:55 UTC (permalink / raw)
  To: qemu-devel; +Cc: david

Provide a symbol that can always be used to signal an error,
regardless of optimization.  Usage of this should be protected
by e.g. __builtin_constant_p, which guards for optimization.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 include/qemu/compiler.h | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/include/qemu/compiler.h b/include/qemu/compiler.h
index d620a841e4..cf28bb2bcd 100644
--- a/include/qemu/compiler.h
+++ b/include/qemu/compiler.h
@@ -215,9 +215,10 @@
  * supports QEMU_ERROR, this will be reported at compile time; otherwise
  * this will be reported at link time due to the missing symbol.
  */
-#if defined(__OPTIMIZE__) && !defined(__NO_INLINE__)
 extern void QEMU_NORETURN QEMU_ERROR("code path is reachable")
-    qemu_build_not_reached(void);
+    qemu_build_not_reached_always(void);
+#if defined(__OPTIMIZE__) && !defined(__NO_INLINE__)
+#define qemu_build_not_reached()  qemu_build_not_reached_always()
 #else
 #define qemu_build_not_reached()  g_assert_not_reached()
 #endif
-- 
2.25.1



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/2] tcg: Optimize inline dup_const for MO_64
  2021-01-19 18:55 [PATCH 0/2] tcg: Optimize inline dup_const for MO_64 Richard Henderson
  2021-01-19 18:55 ` [PATCH 1/2] qemu/compiler: Split out qemu_build_not_reached_always Richard Henderson
@ 2021-01-19 18:55 ` Richard Henderson
  2021-01-19 19:25   ` David Hildenbrand
  1 sibling, 1 reply; 5+ messages in thread
From: Richard Henderson @ 2021-01-19 18:55 UTC (permalink / raw)
  To: qemu-devel; +Cc: david

Avoid the out-of-line function call for immediate MO_64.
In addition, diagnose all invalid constants at compile-time.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 include/tcg/tcg.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/include/tcg/tcg.h b/include/tcg/tcg.h
index 504c5e9bb0..c5a9d65d5f 100644
--- a/include/tcg/tcg.h
+++ b/include/tcg/tcg.h
@@ -1325,7 +1325,8 @@ uint64_t dup_const(unsigned vece, uint64_t c);
      ? (  (VECE) == MO_8  ? 0x0101010101010101ull * (uint8_t)(C)   \
         : (VECE) == MO_16 ? 0x0001000100010001ull * (uint16_t)(C)  \
         : (VECE) == MO_32 ? 0x0000000100000001ull * (uint32_t)(C)  \
-        : dup_const(VECE, C))                                      \
+        : (VECE) == MO_64 ? (uint64_t)(C)                          \
+        : (qemu_build_not_reached_always(), 0))                    \
      : dup_const(VECE, C))
 
 
-- 
2.25.1



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/2] tcg: Optimize inline dup_const for MO_64
  2021-01-19 18:55 ` [PATCH 2/2] tcg: Optimize inline dup_const for MO_64 Richard Henderson
@ 2021-01-19 19:25   ` David Hildenbrand
  0 siblings, 0 replies; 5+ messages in thread
From: David Hildenbrand @ 2021-01-19 19:25 UTC (permalink / raw)
  To: Richard Henderson, qemu-devel

On 19.01.21 19:55, Richard Henderson wrote:
> Avoid the out-of-line function call for immediate MO_64.
> In addition, diagnose all invalid constants at compile-time.
> 
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
>  include/tcg/tcg.h | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/include/tcg/tcg.h b/include/tcg/tcg.h
> index 504c5e9bb0..c5a9d65d5f 100644
> --- a/include/tcg/tcg.h
> +++ b/include/tcg/tcg.h
> @@ -1325,7 +1325,8 @@ uint64_t dup_const(unsigned vece, uint64_t c);
>       ? (  (VECE) == MO_8  ? 0x0101010101010101ull * (uint8_t)(C)   \
>          : (VECE) == MO_16 ? 0x0001000100010001ull * (uint16_t)(C)  \
>          : (VECE) == MO_32 ? 0x0000000100000001ull * (uint32_t)(C)  \
> -        : dup_const(VECE, C))                                      \
> +        : (VECE) == MO_64 ? (uint64_t)(C)                          \
> +        : (qemu_build_not_reached_always(), 0))                    \
>       : dup_const(VECE, C))
>  
>  
> 

Looks good to me!

Reviewed-by: David Hildenbrand <david@redhat.com>

-- 
Thanks,

David / dhildenb



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/2] qemu/compiler: Split out qemu_build_not_reached_always
  2021-01-19 18:55 ` [PATCH 1/2] qemu/compiler: Split out qemu_build_not_reached_always Richard Henderson
@ 2021-01-19 22:13   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 5+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-01-19 22:13 UTC (permalink / raw)
  To: Richard Henderson, qemu-devel; +Cc: david

On 1/19/21 7:55 PM, Richard Henderson wrote:
> Provide a symbol that can always be used to signal an error,
> regardless of optimization.  Usage of this should be protected
> by e.g. __builtin_constant_p, which guards for optimization.
> 
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
>  include/qemu/compiler.h | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-01-19 22:15 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-19 18:55 [PATCH 0/2] tcg: Optimize inline dup_const for MO_64 Richard Henderson
2021-01-19 18:55 ` [PATCH 1/2] qemu/compiler: Split out qemu_build_not_reached_always Richard Henderson
2021-01-19 22:13   ` Philippe Mathieu-Daudé
2021-01-19 18:55 ` [PATCH 2/2] tcg: Optimize inline dup_const for MO_64 Richard Henderson
2021-01-19 19:25   ` David Hildenbrand

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 NNTP newsgroup(s).