[PATCH] [llgo] irgen: generate switch instructions

Peter Collingbourne peter at pcc.me.uk
Wed Jan 7 11:05:13 PST 2015


> adding a check to each "ssa.If" would mean we have a performance hit in the frontend for each If instruction


I very much doubt that the performance impact would be measurable. Remember that the switch analysis has to look at each if instruction anyway.

Regardless, I agree that both approaches are a little messy, and I can't see a neater way without modifying go/ssa, so LGTM.

> I don't know if this will ever be necessary, but another option is for llgo to grow its own IR on top of go/ssa. I'd rather not go there for this, though.


Agreed. FWIW, the long term direction I'd like to see is attempting to extend go/ssa with what we need (in this particular case, a native switch instruction).

> I did look to see if there was an existing pass, but again I couldn't see anything that looked relevant


If you grep for `SimplifyCFGOpt::FoldValueComparisonIntoPredecessors` you should find something.

> Geo-mean improvement of 0.49% (0.23% - 0.75% @ 95% CI)


Great! I'm a little surprised that we can do better than LLVM on its own, but maybe I don't understand what the simplifycfg code is doing.


REPOSITORY
  rL LLVM

http://reviews.llvm.org/D6831

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the llvm-commits mailing list