1. A computer implemented method for accessing threadprivate memory for threadprivate variables in a parallel program during compilation, comprising: aggregating ones of the threadprivate variables in the parallel program that do not requiring static initializations; replacing threadprivate references within a defined procedure with indirect references using base address of the threadprivate aggregate; responsive to replacing threadprivate references within the defined procedure with indirect references, determining whether the defined procedure is one of a main procedure or a procedure called by an undefined procedure; responsive to determining the defined procedure is one of a main procedure or a procedure called by an undefined procedure, moving address load operations of the threadprivated variables within the defined procedure such that there is only one address load operation for each threadprivate variable in a control flow path; responsive to the defined procedure is not one of a main procedure and not a procedure called by an undefined procedure, moving the address load operations of the threadprivate variables outside of the defined procedure using an inter-procedural code motion; and replacing the address load operations of the threadprivate variables with calls to runtime routines to access the threadprivate memory.