Solicit code review (change to CodeGen)

Hi,

   The attached is the fix to radar://11663049. The optimization can be outlined by following rules:

     (select (x != c), e, c) -> select (x != c), e, x),
     (select (x == c), c, e) -> select (x == c), x, e)
where the <c> is an integer constant.

   The reason for this change is that : on x86, conditional-move-from-constant needs two instructions;
however, conditional-move-from-register need only one instruction.

    While the LowerSELECT() sounds to be the most convenient place for this optimization, it turns out to be a bad place.The reason is that by replacing the constant <c> with a symbolic value, it obscure some instruction-combining opportunities which would otherwise be very easy to spot. For that reason, I have to postpone the change to last instruction-combining phase.

    The change passes the test of "make check-all -C <build-root/test" and "make -C project/test-suite/SingleSource".

Thanks
Shuxin

diff.patch (2.7 KB)

LGTM.

I will commit.

Hi All,

I just started with the API of LLVM and have a beginner's question.

I'm trying to JIT compile the attached C program "getinmemory" to an inmemory module by a my attached example LLVM program.
After linking of this inmemory module against libc.so.6 I call the main routine of the C program.

Why do I have still malloc as a unresoveld externals ? Contains the module "module_ex" not an fully executable program ?

Here are the printouts ( Linux):

compile_to_module-return.cpp (3.64 KB)

getinmemory.c (3.32 KB)

Makefile (1.63 KB)