diff options
author | Julia Lawall <Julia.Lawall@lip6.fr> | 2017-11-13 00:53:35 -0500 |
---|---|---|
committer | Masahiro Yamada <yamada.masahiro@socionext.com> | 2017-11-15 18:56:42 -0500 |
commit | 937c812dfc0a25343d56b07734438610a1fb7b46 (patch) | |
tree | ad1f1cd178171d99fbd98e7bace9340b8f9bad13 | |
parent | 6851ba1a1b22ba2e0800002d531bf04ced22ec18 (diff) |
coccinelle: orplus: reorganize to improve performance
Adding two #define constants is less common than performing & and |
operations on them, so put the addition first to reduce the set of cases
that have to be considered in detail. At the same time, add & and |
patterns for both arguments of +, to account for commutativity and obtain
more results.
Running time is divided by 3 when applying this to the whole kernel on my
laptop with an Intel i5-6200U CPU.
Signed-off-by: Julia Lawall <julia.lawall@lip6.fr>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
-rw-r--r-- | scripts/coccinelle/misc/orplus.cocci | 43 |
1 files changed, 29 insertions, 14 deletions
diff --git a/scripts/coccinelle/misc/orplus.cocci b/scripts/coccinelle/misc/orplus.cocci index 81fabf379390..08de5be73693 100644 --- a/scripts/coccinelle/misc/orplus.cocci +++ b/scripts/coccinelle/misc/orplus.cocci | |||
@@ -14,7 +14,19 @@ virtual report | |||
14 | virtual context | 14 | virtual context |
15 | 15 | ||
16 | @r@ | 16 | @r@ |
17 | constant c; | 17 | constant c,c1; |
18 | identifier i,i1; | ||
19 | position p; | ||
20 | @@ | ||
21 | |||
22 | ( | ||
23 | c1 + c - 1 | ||
24 | | | ||
25 | c1@i1 +@p c@i | ||
26 | ) | ||
27 | |||
28 | @s@ | ||
29 | constant r.c, r.c1; | ||
18 | identifier i; | 30 | identifier i; |
19 | expression e; | 31 | expression e; |
20 | @@ | 32 | @@ |
@@ -27,28 +39,31 @@ e & c@i | |||
27 | e |= c@i | 39 | e |= c@i |
28 | | | 40 | | |
29 | e &= c@i | 41 | e &= c@i |
42 | | | ||
43 | e | c1@i | ||
44 | | | ||
45 | e & c1@i | ||
46 | | | ||
47 | e |= c1@i | ||
48 | | | ||
49 | e &= c1@i | ||
30 | ) | 50 | ) |
31 | 51 | ||
32 | @s@ | 52 | @depends on s@ |
33 | constant r.c,c1; | 53 | position r.p; |
34 | identifier i1; | 54 | constant c1,c2; |
35 | position p; | ||
36 | @@ | 55 | @@ |
37 | 56 | ||
38 | ( | 57 | * c1 +@p c2 |
39 | c1 + c - 1 | ||
40 | | | ||
41 | *c1@i1 +@p c | ||
42 | ) | ||
43 | 58 | ||
44 | @script:python depends on org@ | 59 | @script:python depends on s && org@ |
45 | p << s.p; | 60 | p << r.p; |
46 | @@ | 61 | @@ |
47 | 62 | ||
48 | cocci.print_main("sum of probable bitmasks, consider |",p) | 63 | cocci.print_main("sum of probable bitmasks, consider |",p) |
49 | 64 | ||
50 | @script:python depends on report@ | 65 | @script:python depends on s && report@ |
51 | p << s.p; | 66 | p << r.p; |
52 | @@ | 67 | @@ |
53 | 68 | ||
54 | msg = "WARNING: sum of probable bitmasks, consider |" | 69 | msg = "WARNING: sum of probable bitmasks, consider |" |