[PATCH] D18604: Target hook to control Switch lowering.

Hans Wennborg via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 30 15:25:15 PDT 2016


hans added a comment.

In http://reviews.llvm.org/D18604#387052, @kariddi wrote:

> Hmm, that is actually a possible interesting approach. Right now processSwitchInst is not callable from outside, the LowerSwitch pass, but maybe we could make it a utility function, like SimplifyCFG.


I think that might be a good approach. It already lives in lib/Transforms/Utils after all :-)

> Otherwise, the original idea of the patch is to give more control to the target about the way switches are lowered.

> 

> You are right that the SelectionDAGBuilder lowering wouldn't be addressed by this and I'm wondering if it would actually make sense to add a custom lowering hook in SelectionDAGBuilder to be able to emit a target instruction representing a switch instead of an expansion of branches that would be very difficult to understand we are dealing with a switch and roll it back.

> 

> What do you think? I'm not very familiar on how the selectiondagbuilder emits the expansion. It seems to be creating the same kind of tree if jump tables are not available and creates additional basic blocks, so doesn't look easily "rollbackable".


Yes, it would be very hard to roll back what SelectionDAGBuilder does to switches.

Having a hook to allow a custom switch lowering in SelectionDAGBuilder would work, I suppose.


Repository:
  rL LLVM

http://reviews.llvm.org/D18604





More information about the llvm-commits mailing list