Skip to contentSkip to conversation

Staging: xgifb: Loop optimization.

PATCH In review Navya Sri Nizamkari 2 participants 2 messages Oct 22, 2015 – Oct 25, 2015 Staging

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Staging: xgifb: Loop optimization.

Put operations involving loop constants outside
the loop.

---
 drivers/staging/xgifb/vb_setmode.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/staging/xgifb/vb_setmode.c +4 -5
index c886dd2..78ee191 100644
@@ -1138,19 +1138,18 @@ static void XGI_LoadDAC(struct vb_device_info *pVBInfo)
 		dl = 0;
 
 		for (n = 0; n < 3; n++) {
+			ah = table[di];
+			al = table[bx];
 			for (o = 0; o < 5; o++) {
 				dh = table[si];
-				ah = table[di];
-				al = table[bx];
 				si++;
 				XGI_WriteDAC(dl, ah, al, dh, pVBInfo);
 			}
 
 			si -= 2;
-
+			dh = table[bx];
+			ah = table[di];
 			for (o = 0; o < 3; o++) {
-				dh = table[bx];
-				ah = table[di];
 				al = table[si];
 				si--;
 				XGI_WriteDAC(dl, ah, al, dh, pVBInfo);
Signature · 1 line
1.9.1
maintainer
#1 lore raw
Quoted 26 lines · Navya Sri Nizamkari

Put operations involving loop constants outside
the loop.

---
 drivers/staging/xgifb/vb_setmode.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/staging/xgifb/vb_setmode.c +2 -2
index c886dd2..78ee191 100644
@@ -1138,19 +1138,18 @@ static void XGI_LoadDAC(struct vb_device_info *pVBInfo)
 		dl = 0;
 
 		for (n = 0; n < 3; n++) {
+			ah = table[di];
+			al = table[bx];
 			for (o = 0; o < 5; o++) {
 				dh = table[si];
-				ah = table[di];
-				al = table[bx];
 				si++;
 				XGI_WriteDAC(dl, ah, al, dh, pVBInfo);
 			}
 

drivers/staging/xgifb/vb_setmode.c static void XGI_LoadDAC(struct vb_device_info *pVBInfo) · line 1155

Quoted 10 lines
drivers/staging/xgifb/vb_setmode.c +2 -3
 			si -= 2;
-
+			dh = table[bx];
+			ah = table[di];
 			for (o = 0; o < 3; o++) {
-				dh = table[bx];
-				ah = table[di];
 				al = table[si];
 				si--;
 				XGI_WriteDAC(dl, ah, al, dh, pVBInfo);

Doesn't the compiler already do this?

Can you measure a difference here?

thanks,

greg k-h