[LLVMdev] simple optimization question

Bjorn De Sutter bjorn.desutter at elis.ugent.be
Fri Jan 18 02:49:28 PST 2013


currently the following two lines of code with integer variables get compiled completely differently:

if (d0<tmp) d0=tmp;

d0 = d0<tmp? tmp : do; 

The first is compiled into two separate basic blocks, which my backend then optimizes into a conditional move with if-conversion (after instruction selection so not much optimization possible anymore). The second line is compiled into select operations, which my backend is able to compile into much more efficient max instructions. 

Shouldn't the first form be optimized into the second somewhere in the compiler front-end? In other words, do we already have a pass that should optimize this, and if not, is it worthwhile working on one?


Bjorn De Sutter
Computer Systems Lab
Ghent University

More information about the llvm-dev mailing list