[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PULL 11/24] tcg/optimize: Use tcg_constant_internal with constant f
From: |
Eric Blake |
Subject: |
Re: [PULL 11/24] tcg/optimize: Use tcg_constant_internal with constant folding |
Date: |
Thu, 4 Feb 2021 10:52:02 -0600 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.0 |
On 2/4/21 10:04 AM, Philippe Mathieu-Daudé wrote:
>>> Isn't it kind of weird that this would only affect an s390 host? I
>>> don't understand why the host would make a difference if we're doing
>>> TCG.
>>
>> I assume an existing BUG in the s390x TCG backend ... which makes it
>> harder to debug :)
>
> This seems to fix it:
>
> -- >8 --
> diff --git a/tcg/s390/tcg-target.c.inc b/tcg/s390/tcg-target.c.inc
> index 8517e552323..32d03dbfbaf 100644
> --- a/tcg/s390/tcg-target.c.inc
> +++ b/tcg/s390/tcg-target.c.inc
> @@ -1094,10 +1094,16 @@ static int tgen_cmp(TCGContext *s, TCGType type,
> TCGCond c, TCGReg r1,
> op = (is_unsigned ? RIL_CLFI : RIL_CFI);
> tcg_out_insn_RIL(s, op, r1, c2);
> goto exit;
> - } else if (c2 == (is_unsigned ? (uint32_t)c2 : (int32_t)c2)) {
In this code, you are comparing c2 to the type promotion of uint32_t and
int32_t. That is, the conversion rules are as if you had done:
(common_type) c2 == (common_type) (uint32_t) (is_unsigned ? (uint32_t)c2
: (uint32_t)(int32_t)c2)
> - op = (is_unsigned ? RIL_CLGFI : RIL_CGFI);
> - tcg_out_insn_RIL(s, op, r1, c2);
> - goto exit;
> + } else if (is_unsigned) {
> + if (c2 == (uint32_t)c2) {
whereas this is:
(common_type_unsigned)c2 == (common_type_unsigned)(uint32_t)c2
> + tcg_out_insn_RIL(s, RIL_CLGFI, r1, c2);
> + goto exit;
> + }
> + } else {
> + if (c2 == (int32_t)c2) {
and this is:
(common_type_signed)c2 == (common_type_signed)(int32_t)c2
and the two may indeed use a different type.
I'm not sure (from the context shown here) what the type of c2 was, to
determine what the common types are, but as an example, on my 64-bit system,
(long)-1 == (int32_t)-1
is true (the 64-bit value (long)-1 is equal to the sign-extended 64-bit
value created from the signed 32-bit value (int32_t)-1), while
(unsigned long)-1 == (uint32_t)(int32_t)-1
is false (the 32-bit unsigned value (uint32_t) -1 promotes without sign
extension to the 64-bit (unsigned long) type, and 0xffffffffffffffff is
not equal to 0x00000000ffffffff).
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3226
Virtualization: qemu.org | libvirt.org
- Re: [PULL 11/24] tcg/optimize: Use tcg_constant_internal with constant folding, (continued)
- Re: [PULL 11/24] tcg/optimize: Use tcg_constant_internal with constant folding, Richard W.M. Jones, 2021/02/04
- Re: [PULL 11/24] tcg/optimize: Use tcg_constant_internal with constant folding, Richard W.M. Jones, 2021/02/04
- Re: [PULL 11/24] tcg/optimize: Use tcg_constant_internal with constant folding, David Hildenbrand, 2021/02/04
- Re: [PULL 11/24] tcg/optimize: Use tcg_constant_internal with constant folding, Philippe Mathieu-Daudé, 2021/02/04
- Re: [PULL 11/24] tcg/optimize: Use tcg_constant_internal with constant folding, Philippe Mathieu-Daudé, 2021/02/04
- Re: [PULL 11/24] tcg/optimize: Use tcg_constant_internal with constant folding, David Hildenbrand, 2021/02/04
- Re: [PULL 11/24] tcg/optimize: Use tcg_constant_internal with constant folding, David Hildenbrand, 2021/02/04
- Re: [PULL 11/24] tcg/optimize: Use tcg_constant_internal with constant folding, Eric Blake, 2021/02/04
- Re: [PULL 11/24] tcg/optimize: Use tcg_constant_internal with constant folding, Richard Henderson, 2021/02/04
- Re: [PULL 11/24] tcg/optimize: Use tcg_constant_internal with constant folding, Richard W.M. Jones, 2021/02/04
- Re: [PULL 11/24] tcg/optimize: Use tcg_constant_internal with constant folding,
Eric Blake <=