[LLVMdev] is createCFGSimplificationPass unused?

Rafael EspĂ­ndola rafael.espindola at gmail.com
Thu Nov 2 18:55:59 PST 2006


> Please don't do that.  Instead, please implement the TargetInstrInfo
> branch analysis hooks so that the branch folding pass can do this.
> Given info about branches, the pass already does various things to
> optimize away many of the things that simplify cfg does.
>
> I'm planning several extensions to the pass, in particular to support
> limited forms of "predication" (PPC's conditional return for sure, perhaps
> some better cmov formation, etc).  This may be generalizable for IA64/ARM,
> but it depends on how much time I have to work on it.
>
> If there are specific cases like this where simplify cfg produces better
> code than branch folding (with the hooks implemented) please file
> bugzilla bugs to track them.
The branch folding works after instruction selection, right? It looks
strange to me that it will be able to convert a branch sequence into a
select. IMHO this transformation can be better performed with a higher
level representation.

> Long term, I'd like to get the code generator to the point where running
> the code generator doesn't modify from the input LLVM IR. Running
> llvm->llvm passes breaks this property.
I see that this is a desired property. If I recall correctly, you need
this to remove the remaining annotations.

Maybe llvm-gcc should run CFGSimplification. It would then compile "if
(a) return 0; else return 1" into

%tmp = seteq int %a, 0
%tmp1 = select bool %tmp, int 0, int 1
ret int %tmp1

Thanks,
Rafael



More information about the llvm-dev mailing list