You can use profile-directed feedback (PDF) to tune the performance of your application for a typical usage scenario. The compiler optimizes the application based on an analysis of how often branches are taken and blocks of code are run.
Use PDF process after other debugging and tuning is finished, as one of the last steps before putting the application into production. Other optimizations such as the -qipa option and optimization levels -O4 and -O5 can also benefit when using with PDF process.
The following diagram illustrates the PDF process:

To use the PDF process to optimize your application, follow these steps:
Compile some or all of the source files in a program with the -qpdf1 option. You must specify at least the -O2 optimization level.
Run the resulting application with a typical data set. When the application exits, profile information is written to a PDF file. You can run the resulting application multiple times with different data sets. The profiling information is accumulated to provide a count of how often branches are taken and blocks of code are run, based on the input data used. By default, the PDF file is named ._pdf, and it is placed in the current working directory or the directory specified by the PDFDIR environment variable. If the PDFDIR environment variable is set but the specified directory does not exist, the compiler issues a warning message. To override the defaults, use the -qpdf1=pdfname or -qpdf1=exename option.
If you recompile your program by using either of the -qpdf1=level=0 or -qpdf1=level=1 option, single-pass profiling is supported. The compiler removes the existing PDF file before generating a new application.
If you recompile your program by using -qpdf1=level=2 option, multiple-pass profiling is supported. You can repeat compiling your program and running the resulting application, then new PDF files are generated up to five times.
mergepdf -r 53 path1 -r 32 path2 -r 15 path3
Recompile your program using the same compiler options as before, but change -qpdf1 to -qpdf2. In this second compilation, the accumulated profiling information is used to fine-tune the optimizations. The resulting program contains no profiling overhead and runs at full speed.
If you want to erase the PDF information, use the cleanpdf or resetpdf utility.
Instead of step 4, you can use the -qpdf2 option to link the object files created during the -qpdf1 phase without recompiling your program during the -qpdf2 phase. This alternative approach can save considerable time and help tune large applications for optimization.
#Set the PDFDIR variable
export PDFDIR=$HOME/project_dir
#Compile most of the files with -qpdf1
xlc -qpdf1 -O3 -c file1.c file2.c file3.c
#This file does not need optimization
xlc -c file4.c
#Non-PDF object files such as file4.o can be linked
xlc -qpdf1 -O3 file1.o file2.o file3.o file4.o
#Run several times with different input data
./a.out < polar_orbit.data
./a.out < elliptical_orbit.data
./a.out < geosynchronous_orbit.data
#No need to recompile the source of non-PDF object files
#(file4.c).
xlc -qpdf2 -O3 file1.c file2.c file3.c
#Link all the object files into the final application
xlc -qpdf2 -O3 file1.o file2.o file3.o file4.o
#Compile source with -qpdf1
xlc -c -qpdf1 -O3 file1.c file2.c
#Link object files
xlc -qpdf1 -O3 file1.o file2.o
#Run with one set of input data
./a.out < sample.data
#Link the mix of pdf1 and pdf2 objects
xlc -qpdf2 -O3 file1.o file2.o