I have encountered a problem in optimizing my kernel. I just found the number of registers increase and the performance decreases when some local variables recalled after several other computation or memory oprations which are not related to these variables.
For example，100 variables are defined in one kernal. First，three of them， a，b，c， are called by assinment like a ＝ d＋f，b=ef，c=g/h. Then， some oprations of other variables(don’t include a,b,c) are processed. Finally，a,b,c are recalled and updated with their former values e.g. a＝ a+s，b＝b-k，c=ch. I found it does little effect with the register and the performance if a， b，c are just reassigned with nnew values not related to the former valued，e.g. a=1，b＝2,
c=k， while invoking former values causes bad effect. Also， if the first call and the second call are neighboled，or there are less operations between the two calls， the performance and register are almost unchanged.
There is another example， 7 double local variables are recalled with their former values after some operations，and the runtime goes up to 168ms and the number of registers is increased to 154， while when the 7 variables are updated without their former values，the number of regiters is 120 and the runtime is 112ms.
I don’t known the reason. Could you Please give me some instructions about this problem？ Thank you very much.