[LLVMdev] SCCP and undef branches

Nick Lewycky nicholas at mxc.ca
Tue Jun 6 08:13:20 PDT 2006


Daniel Berlin wrote:
> Nick Lewycky wrote:
> 
>>I found that "undef" was disappearing early into the optimization chain.
>>SCCP was the culprit, transforming:
>>
>>  br bool undef, label %T, label %F
>>
>>into
>>
>>  br bool true, label %T, label %F
>>
>>While that sounds like a great optimization, it shouldn't be happening
>>that early. 
> 
> Uh, why?

It might not always be optimal to replace undef with true at that point.
If the true branch does a lot of work, and the false branch is empty,
and the program is valid either way, you'd rather choose the false
branch. I admit that it's minor (undef isn't supposed to happen a whole
lot anyways), but we should be deciding this sort of thing at link time
where the behaviour of the two branches is guaranteed to be visible.

For some reason I thought that ADCE already did that sort of resolution
on 'br bool undef', but I seem to have mistested. Before anyone applies
this patch, you should probably wait for a patch to the ADCE so that it
removes 'br undef'. In practise, it'll just replace undef with true, so
until someone writes a better replacement, we'll end up par anyways.

Nick



More information about the llvm-dev mailing list