[Ffmpeg-cvslog] r8474 - trunk/libavcodec/resample2.c

Michael Niedermayer michaelni
Thu Mar 22 23:39:42 CET 2007


Hi

On Thu, Mar 22, 2007 at 10:58:38PM +0100, Michael Niedermayer wrote:
> Hi
> 
> On Thu, Mar 22, 2007 at 12:32:29PM -0500, Rich Felker wrote:
> > On Thu, Mar 22, 2007 at 05:20:17PM +0100, Michael Niedermayer wrote:
> > > Hi
> > > 
> > > On Thu, Mar 22, 2007 at 10:18:04AM -0500, Rich Felker wrote:
> > > > On Thu, Mar 22, 2007 at 11:47:01AM +0100, Michael Niedermayer wrote:
> > > > > to factor out the pow() your needing algebraic identities depends on how pow
> > > > > is defined either way the associative law for multiplication is enough and
> > > > 
> > > > Associative law is false with floats. Think of
> > > > 
> > > > A = FLOAT_MAX
> > > > B = FLOAT_MAX
> > > > C = 1.0/FLOAT_MAX
> > > 
> > > yes i did think of it, and i just tested:
> > > [...]
> > 
> > This was not intended as C code, just as abstract explanation. In C,
> > all floating point expressions are evaulated as doubles or larger. You
> > need DBL_MAX or whatever for it to work. The results will be:
> > 
> > (A*B)*C = +Inf
> > A*(B*C) = A
> 
> probably true, but what i meant was that pow() can be split into
> multiplications or more generally the associative law holds approximatley
> at x86 asm level with a,b,c and a*b*c being doubles and intermedeates in
> registers so that a compiler could use the law to simplify an expression
> 
> i didnt mean that (a*b)*c == a*(b*c) with all intermediates stored as
> the same type as a,b,c would work, it of course doesnt
> 
> such tricks work with integers though i doubt gcc is smart enough for
> that either

just tried:
-----
int test(int a){
    a*=3;
    a+=1;
    a*=-1431655765;
    a-=-1431655765;
    return a;
}

main(){
    int i;

    for(i=0; i<100000000; i++){
        if(test(i) != i)
            printf("OPSI %d %d\n", i, test(i));
    }
}
-----

gcc 4.0.4 succeeds in realizing that the check in main cannot fail :)
sadly it doesnt realize that the loop can also be removed then
nor does it realize that test() really is just the identity function
it keeps all the multiply and add in the test function ...

gcc 4.1.2 missompiles the code causing the printf() to be executed

every time i test gcc iam more disappointed after the test than before...

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

I do not agree with what you have to say, but I'll defend to the death your
right to say it. -- Voltaire
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-cvslog/attachments/20070322/dfbe4e32/attachment.pgp>



More information about the ffmpeg-cvslog mailing list