linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] coccinelle: orplus: reodganize to improve performance
@ 2017-11-12 18:41 Julia Lawall
  2017-11-13  4:32 ` Masahiro Yamada
  0 siblings, 1 reply; 2+ messages in thread
From: Julia Lawall @ 2017-11-12 18:41 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: Michal Marek, Gilles Muller, Nicolas Palix, linux-kernel, cocci

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 while kernel on my
laptop with an Intel i5-6200U CPU.

---

diff --git a/scripts/coccinelle/misc/orplus.cocci b/scripts/coccinelle/misc/orplus.cocci
index 81fabf3..08de5be 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 |"

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] coccinelle: orplus: reodganize to improve performance
  2017-11-12 18:41 [PATCH] coccinelle: orplus: reodganize to improve performance Julia Lawall
@ 2017-11-13  4:32 ` Masahiro Yamada
  0 siblings, 0 replies; 2+ messages in thread
From: Masahiro Yamada @ 2017-11-13  4:32 UTC (permalink / raw)
  To: Julia Lawall
  Cc: Michal Marek, Gilles Muller, Nicolas Palix,
	Linux Kernel Mailing List, cocci

Hi Julia,


2017-11-13 3:41 GMT+09:00 Julia Lawall <julia.lawall@lip6.fr>:
> 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 while kernel on my
> laptop with an Intel i5-6200U CPU.
>

Nit:

Missing Signed-off-by.


>
> diff --git a/scripts/coccinelle/misc/orplus.cocci b/scripts/coccinelle/misc/orplus.cocci
> index 81fabf3..08de5be 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 |"



-- 
Best Regards
Masahiro Yamada

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-11-13  4:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-12 18:41 [PATCH] coccinelle: orplus: reodganize to improve performance Julia Lawall
2017-11-13  4:32 ` Masahiro Yamada

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).