From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1164f8,ae6d7754224e7cfb X-Google-Attributes: gid1164f8,public X-Google-Thread: fee84,ae6d7754224e7cfb X-Google-Attributes: gidfee84,public From: roy@mchip00.med.nyu.edu (Roy Smith) Subject: Re: horrible "cc -O" bug (DU 3.2c) Date: 1997/05/11 Message-ID: <5l5i98$hbk$1@news.nyu.edu>#1/1 X-Deja-AN: 240943962 References: <5kvqsu$18d$1@news.iastate.edu> <5l33qi$6fg$1@news.nyu.edu> <33763487.7250953E@highway1.com> Organization: New York University, School of Medicine Newsgroups: comp.unix.osf.osf1,comp.sys.dec "Gerald A. Feldman" writes: >First of all, from looking at the code, it does not appear to be a code >generation bug at all. It is only a bug if the code beyond the && would >cause a side effect, such as invoke a function, modify a variable, or >cause an exception. That's like saying that if the code generated for "x = 3" actually assigns the value 4 to x, it's only a bug if the value of x is used later in the program. The language semantics say that in "x && y", y is not evaluated unless x is true. This lets you do things like "xp && *xp". Or "is_valid(foo) && get_value(foo)". Or "x < 3 && x++". Some of those may be ugly, but they are legal, and all require that the part after the && not be evaluated if the part before the && is false. Maybe I just misunderstood what is going on, but if the compiler doesn't guarantee that behavior, it's broken (and I can start having nightmares). If the compiler does indeed guarantee it, then I guess I just misunderstood the original post. > The newer Alpha chips quad issue instructions, which means that the chip > can execute 4 instructions in parallel. All Digital compilers and > assemblers schedule the generated code for optimal execution. The > instructions are rearranged based on latencies and other interactions. The > scheduler knows the issue rules, and tries to schedule the instructions to > take advantage of this. Multiple instruction scheduling is a kind of black magic invented to give the hardware guys nightmares. As long as they did their job right (i.e. invested a sufficient number of sleepless nights sitting bolt upright in bed at 3AM in a cold sweat), us software types can sleep nights knowing that the language semantics are being obeyed, no matter how ugly it may get inside that funny looking chip with the cooling fins. -- Roy Smith New York University School of Medicine Copyright 1997 Roy Smith For-profit redistribution prohibited