[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <2c0942db0804301119r430b3b86t880437da1f7ce513@mail.gmail.com>
Date: Wed, 30 Apr 2008 11:19:31 -0700
From: "Ray Lee" <ray@...rabbit.org>
To: "Soumyadip Das Mahapatra" <dip_kernel@...oo.co.in>
Cc: linux-kernel@...r.kernel.org
Subject: Re: Improved Swaping Method In sort.c
On Wed, Apr 30, 2008 at 11:09 AM, Soumyadip Das Mahapatra
<dip_kernel@...oo.co.in> wrote:
> Thanks Jan,
> Actually it should be
> static void u32_swap(void *a, void *b)
> {
> *(u32 *)b ^= *(u32 *)a;
> *(u32 *)a ^= *(u32 *)b;
> *(u32 *)b ^= *(u32 *)a;
> }
> But this code saves memory equaling two integers. What about that ?
The above prevents gcc from storing the intermediary in a register. So
you're trading fast register access for slow memory access.
Really, you shouldn't be prosing optimizations unless you do two
things: check the output of gcc (on at least one platform, but really
should be several), and include timings of before/after.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists