diff mbox

[5/8] tcg/optimize: Handle known-zeros masks for ANDC

Message ID 1391179623-13626-6-git-send-email-rth@twiddle.net
State New
Headers show

Commit Message

Richard Henderson Jan. 31, 2014, 2:47 p.m. UTC
Signed-off-by: Richard Henderson <rth@twiddle.net>
---
 tcg/optimize.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

Comments

Aurelien Jarno Feb. 16, 2014, 6:12 p.m. UTC | #1
On Fri, Jan 31, 2014 at 08:47:00AM -0600, Richard Henderson wrote:
> Signed-off-by: Richard Henderson <rth@twiddle.net>
> ---
>  tcg/optimize.c | 11 +++++++++++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/tcg/optimize.c b/tcg/optimize.c
> index d3b099a..3291a08 100644
> --- a/tcg/optimize.c
> +++ b/tcg/optimize.c
> @@ -727,6 +727,17 @@ static TCGArg *tcg_constant_folding(TCGContext *s, uint16_t *tcg_opc_ptr,
>              mask = temps[args[1]].mask & mask;
>              break;
>  
> +        CASE_OP_32_64(andc):
> +            /* Known-zeros does not imply known-ones.  Therefore unless
> +               args[2] is constant, we can't infer anything from it.  */
> +            if (temps[args[2]].state == TCG_TEMP_CONST) {
> +                mask = ~temps[args[2]].mask;
> +                goto and_const;
> +            }
> +            /* But we certainly know nothing outside args[1] may be set. */
> +            mask = temps[args[1]].mask;
> +            break;
> +
>          case INDEX_op_sar_i32:
>              if (temps[args[2]].state == TCG_TEMP_CONST) {
>                  mask = (int32_t)temps[args[1]].mask >> temps[args[2]].val;

Reviewed-by: Aurelien Jarno <aurelien@aurel32.net>
diff mbox

Patch

diff --git a/tcg/optimize.c b/tcg/optimize.c
index d3b099a..3291a08 100644
--- a/tcg/optimize.c
+++ b/tcg/optimize.c
@@ -727,6 +727,17 @@  static TCGArg *tcg_constant_folding(TCGContext *s, uint16_t *tcg_opc_ptr,
             mask = temps[args[1]].mask & mask;
             break;
 
+        CASE_OP_32_64(andc):
+            /* Known-zeros does not imply known-ones.  Therefore unless
+               args[2] is constant, we can't infer anything from it.  */
+            if (temps[args[2]].state == TCG_TEMP_CONST) {
+                mask = ~temps[args[2]].mask;
+                goto and_const;
+            }
+            /* But we certainly know nothing outside args[1] may be set. */
+            mask = temps[args[1]].mask;
+            break;
+
         case INDEX_op_sar_i32:
             if (temps[args[2]].state == TCG_TEMP_CONST) {
                 mask = (int32_t)temps[args[1]].mask >> temps[args[2]].val;