summaryrefslogtreecommitdiff
path: root/scripts/coccinelle/misc
diff options
context:
space:
mode:
authorJulia Lawall <Julia.Lawall@lip6.fr>2017-11-13 06:53:35 +0100
committerMasahiro Yamada <yamada.masahiro@socionext.com>2017-11-16 08:56:42 +0900
commit937c812dfc0a25343d56b07734438610a1fb7b46 (patch)
treead1f1cd178171d99fbd98e7bace9340b8f9bad13 /scripts/coccinelle/misc
parent6851ba1a1b22ba2e0800002d531bf04ced22ec18 (diff)
downloadlinux-exynos-937c812dfc0a25343d56b07734438610a1fb7b46.tar.gz
linux-exynos-937c812dfc0a25343d56b07734438610a1fb7b46.tar.bz2
linux-exynos-937c812dfc0a25343d56b07734438610a1fb7b46.zip
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>
Diffstat (limited to 'scripts/coccinelle/misc')
-rw-r--r--scripts/coccinelle/misc/orplus.cocci43
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
virtual context
@r@
-constant c;
+constant c,c1;
+identifier i,i1;
+position p;
+@@
+
+(
+ c1 + c - 1
+|
+ c1@i1 +@p c@i
+)
+
+@s@
+constant r.c, r.c1;
identifier i;
expression e;
@@
@@ -27,28 +39,31 @@ e & c@i
e |= c@i
|
e &= c@i
+|
+e | c1@i
+|
+e & c1@i
+|
+e |= c1@i
+|
+e &= c1@i
)
-@s@
-constant r.c,c1;
-identifier i1;
-position p;
+@depends on s@
+position r.p;
+constant c1,c2;
@@
-(
- c1 + c - 1
-|
-*c1@i1 +@p c
-)
+* c1 +@p c2
-@script:python depends on org@
-p << s.p;
+@script:python depends on s && org@
+p << r.p;
@@
cocci.print_main("sum of probable bitmasks, consider |",p)
-@script:python depends on report@
-p << s.p;
+@script:python depends on s && report@
+p << r.p;
@@
msg = "WARNING: sum of probable bitmasks, consider |"