[hackers] [scc] Add idempotent optimization || Roberto E. Vargas Caballero

From: <git_AT_suckless.org>
Date: Tue, 1 Sep 2015 21:18:31 +0200 (CEST)

commit 42a2ed50d61e736f6c8c34ad78089ae9f56d6534
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
AuthorDate: Tue Sep 1 20:42:25 2015 +0200
Commit: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
CommitDate: Tue Sep 1 21:18:07 2015 +0200

    Add idempotent optimization
    
    - and ~ operands are idempotent.

diff --git a/cc1/expr.c b/cc1/expr.c
index 55b482f..0ab5e11 100644
--- a/cc1/expr.c
+++ b/cc1/expr.c
_AT_@ -130,11 +130,13 @@ numericaluop(char op, Node *np)
         switch (BTYPE(np)) {
         case INT:
         case FLOAT:
+ if (op == ONEG && np->op == ONEG)
+ return np->left;
                 if (op == OADD)
                         return np;
                 return simplify(op, np->type, np, NULL);
         default:
- error("unary operator requires integer operand");
+ error("unary operator requires numerical operand");
         }
 }
 
_AT_@ -144,6 +146,8 @@ integeruop(char op, Node *np)
         np = eval(np);
         if (BTYPE(np) != INT)
                 error("unary operator requires integer operand");
+ if (op == OCPL && np->op == OCPL)
+ return np->left;
         return simplify(op, np->type, np, NULL);
 }
 
Received on Tue Sep 01 2015 - 21:18:31 CEST

This archive was generated by hypermail 2.3.0 : Tue Sep 01 2015 - 21:24:10 CEST