We have studied the spontaneously formed long-range Al-rich and Ga-rich AlxGa1-xAs/AlyGa1-yAs superlattices in both (111)A and (111)B AlGaAs during epitaxial growth. The spontaneously formed compositional modulation has been investigated by cross-sectional transmission electron microscopy in AlxGa1-xAs (x=0.3-0.4) grown on (111)A and (111)B GaAs substrates at 600-700°C. In contrast, similar superstructures are not observed in layers simultaneously grown on (100) substrates. The observed structural compositional modulation is closely related to the large peak energy redshift and peak intensity enhancement in 15 K photoluminescence (PL) of samples grown on both (111)A and (111)B orientations to those on (100). The respective redshifts of PL peak energy for (111)A and (111)B Al0.27Ga0.73As to that of (100) are 137 and 45 meV, while the PL integrated intensity enhancement to (100) amounts to 200 and 2000 times, respectively. The effect of compositional modulation is reduced with the increasing growth temperatures as shown in the considerably less compositionally modulated (111)A and (111)B Al0.40Ga0.60As grown at 700°C.