[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: &, &&, and CPU cycles
From: |
Bruno Haible |
Subject: |
Re: &, &&, and CPU cycles |
Date: |
Fri, 5 Sep 2008 00:35:53 +0200 |
User-agent: |
KMail/1.5.4 |
Hi Ralf,
> > > I count ca. 2 CPU
> > > cycles for a memory access and ca. 8 CPU cycles for a conditional jump,
> > > therefore I would say that the change slows down the program a bit.
>
> For what little it's worth, this code cycle argument does not take into
> account the optimization features of recent GCC versions AFAIK.
Which gcc versions are you alluding at? The attached program, compiled
with -O2 -S for i686, yields 3 conditional branches in shortcircuit_and
and 1 conditional branch in binary_and, with gcc 4.3.0 - same as with
previous versions of gcc. It it improved in gcc 4.4 snapshots?
Bruno
========================================================================
#include <stdbool.h>
extern bool show_all_fs;
extern bool show_listed_fs;
int binary_and (int x)
{
if (x == 3 & !show_all_fs & !show_listed_fs)
return x;
return -x;
}
int shortcircuit_and (int x)
{
if (x == 3 && !show_all_fs && !show_listed_fs)
return x;
return -x;
}
========================================================================
- Re: [PATCH] df: new option: --total (-c) to produce grand total (in the same way as du), Eric Blake, 2008/09/03
- Re: [PATCH] df: new option: --total (-c) to produce grand total (in the same way as du), Jim Meyering, 2008/09/03
- Re: [PATCH] df: new option: --total (-c) to produce grand total (in the same way as du), Bruno Haible, 2008/09/03
- Re: [PATCH] df: new option: --total (-c) to produce grand total (in the same way as du), Jim Meyering, 2008/09/04
- Re: [PATCH] df: new option: --total (-c) to produce grand total (in the same way as du), Ralf Wildenhues, 2008/09/04
- Re: &, &&, and CPU cycles,
Bruno Haible <=
- Re: &, &&, and CPU cycles, Paolo Bonzini, 2008/09/05
- Re: [PATCH] df: new option: --total (-c) to produce grand total (in the same way as du), Paolo Bonzini, 2008/09/08