I an example of a 100% stock car, the system is tuned based on a particular fuel and is recomended by the manufacture. Yes the knock system is used to prevent detonation, but is there for safety in the event that either you accidently put lower grade fuel in then what is called for or if you get bad gas. Like a case here in my area recently where a new dumb ass fuel tanker guy dumped several thousand gallons of 87 octane in to the 93 octane tank at a local gas station and no one realized until a couple of days later.
A cars computer has a timing map with a maximum amount of advance based on engine conditions and will never advance more then that. This map is also done for one intended fuel. If the conditions call for lets say 30deg. of advance then thats what it does unless detonation accures then if it has a knock system then will pull timing, but will never advance more then the conditions call for based on the timing map look-up table.
I have done this and you can also, take a car that calls for 87 octane from the manufacture and run it on a dyno a few times with 87 and get an average hp and tq number then fill it up with 93 and do the same, you will see a lose of hp and tq. Also if you did the same thing but driving around and monitoring fuel usage, you will see a drop in MPG with the 93 octane. This is all why when doing any type of quote unquote tune-up work to a modern computer controled car, setting base timing is very important and the only way that you can run higher octane fuel then originally called for and gain power is to advance the base timing. If you advance the base timing then all total timing will be advanced by that same amount. i.e. if originally case for a base timing of 10*BTDC and you advance it to 12*BTDC, then every point on the map will be 2*'s higher this is because the map table is added amount to the base timing. The problem with most modern cars is that you can not change the base timing as it is locked from the factory