/****************************************************************************** * FILE: loop06.c * DESCRIPTION: * Demonstrates invarient IF code optimization ******************************************************************************/ #include #include #include #define ARRAY_SIZE 100 #define SEED 1995 float a[ARRAY_SIZE], b[ARRAY_SIZE]; float aa[ARRAY_SIZE], bb[ARRAY_SIZE]; float x, xx; struct timeval start_time, end_time; main() { int i, j; initialize_data(); /*****************************************************************************/ /* Untuned Loop */ /*****************************************************************************/ gettimeofday(&start_time, (struct timeval*)0); for(i=0;i= 100.0) b[i] = a[i] - 3.7; x = x + a[j] + b[i]; } } gettimeofday(&end_time, (struct timeval*)0); /* after time */ printf("Execution time for the untuned loops:\n"); print_execution_times(); /*****************************************************************************/ /* Tuned Loop */ /*****************************************************************************/ gettimeofday(&start_time, (struct timeval*)0); for(i=0;i= 100.0) bb[i] = aa[i] - 3.7; for(j=0;j