[LLVMdev] Optimisation of select/cmp/br

Rafael Espíndola
Wed, 05 Feb 2014 23:32:07 -0000

On 4 February 2014 23:37, Pete Calvert <prc33 at cam.ac.uk>
wrote:
> Hi,
>
> Is there anyway I can coerce LLVM into performing the following
> transformation?
>
>   %1 = icmp eq i32 %flag, 1
>   %2 = select i1 %1, %foo* %data, %struct.cell_t* null
>   %3 = icmp eq %foo* %2, null
>   br i1 %3, label %failure, label %success
>

It seems something that GVN should be able to handle if expressed with
branches instead of select. Unfortunately it currently doesn't :-(

It is a long project, but one way to fix this might be to extend
(rewrite?) GVN PRE (pr13307, pr10254) and then make GVN handle selects
too (on way to fix pr13590 and hopefully your example).

Cheers,
Rafael