diff mbox

[for-2.11,22/23] tcg/ppc: Look for shifted constants

Message ID 20170804054426.10590-23-rth@twiddle.net (mailing list archive)
State New, archived
Headers show

Commit Message

Richard Henderson Aug. 4, 2017, 5:44 a.m. UTC
Signed-off-by: Richard Henderson <rth@twiddle.net>
---
 tcg/ppc/tcg-target.inc.c | 9 +++++++++
 1 file changed, 9 insertions(+)

Comments

Philippe Mathieu-Daudé Aug. 4, 2017, 4:39 p.m. UTC | #1
Hi Richard,

On 08/04/2017 02:44 AM, Richard Henderson wrote:
> Signed-off-by: Richard Henderson <rth@twiddle.net>
> ---
>   tcg/ppc/tcg-target.inc.c | 9 +++++++++
>   1 file changed, 9 insertions(+)
> 
> diff --git a/tcg/ppc/tcg-target.inc.c b/tcg/ppc/tcg-target.inc.c
> index bc14d2c9c6..4b32809217 100644
> --- a/tcg/ppc/tcg-target.inc.c
> +++ b/tcg/ppc/tcg-target.inc.c
> @@ -598,6 +598,7 @@ static void tcg_out_movi_int(TCGContext *s, TCGType type, TCGReg ret,
>   {
>       intptr_t tb_diff;
>       int32_t high;
> +    int lsb;
>   
>       tcg_debug_assert(TCG_TARGET_REG_BITS == 64 || type == TCG_TYPE_I32);
>   
> @@ -638,6 +639,14 @@ static void tcg_out_movi_int(TCGContext *s, TCGType type, TCGReg ret,
>           return;
>       }
>   
> +    lsb = ctz64(arg);
> +    high = arg >> lsb;
> +    if (arg == (int16_t)arg) {

Can you move these here?

+    lsb = ctz64(arg);
+    high = arg >> lsb;

> +        tcg_out32(s, ADDI | TAI(ret, 0, high));
> +        tcg_out_shli64(s, ret, ret, lsb);
> +        return;
> +    }
> +
>       high = arg >> 31 >> 1;
>       tcg_out_movi(s, TCG_TYPE_I32, ret, high);
>       if (high) {
> 

Regards,

Phil.
Richard Henderson Aug. 4, 2017, 4:58 p.m. UTC | #2
On 08/04/2017 09:39 AM, Philippe Mathieu-Daudé wrote:
>>   @@ -638,6 +639,14 @@ static void tcg_out_movi_int(TCGContext *s, TCGType
>> type, TCGReg ret,
>>           return;
>>       }
>>   +    lsb = ctz64(arg);
>> +    high = arg >> lsb;
>> +    if (arg == (int16_t)arg) {
> 
> Can you move these here?
> 
> +    lsb = ctz64(arg);
> +    high = arg >> lsb;

No, because you've found a bug -- the if should be testing high, not arg.  ;-)

Thanks,


r~
diff mbox

Patch

diff --git a/tcg/ppc/tcg-target.inc.c b/tcg/ppc/tcg-target.inc.c
index bc14d2c9c6..4b32809217 100644
--- a/tcg/ppc/tcg-target.inc.c
+++ b/tcg/ppc/tcg-target.inc.c
@@ -598,6 +598,7 @@  static void tcg_out_movi_int(TCGContext *s, TCGType type, TCGReg ret,
 {
     intptr_t tb_diff;
     int32_t high;
+    int lsb;
 
     tcg_debug_assert(TCG_TARGET_REG_BITS == 64 || type == TCG_TYPE_I32);
 
@@ -638,6 +639,14 @@  static void tcg_out_movi_int(TCGContext *s, TCGType type, TCGReg ret,
         return;
     }
 
+    lsb = ctz64(arg);
+    high = arg >> lsb;
+    if (arg == (int16_t)arg) {
+        tcg_out32(s, ADDI | TAI(ret, 0, high));
+        tcg_out_shli64(s, ret, ret, lsb);
+        return;
+    }
+
     high = arg >> 31 >> 1;
     tcg_out_movi(s, TCG_TYPE_I32, ret, high);
     if (high) {