Gap's (GPS -3.83%) turnaround took another step forward last quarter -- no thanks to its namesake brand. Fast-growing Old Navy and Athleta continue to drive strong results for the specialty retail giant, despite ongoing market share losses for the flagship Gap brand and the upscale Banana Republic brand.

While Gap stock has rallied nicely over the past year, it has pulled back significantly from the multiyear high reached a few months ago. That has created an attractive entry point for long-term investors.

GPS Chart

Gap stock performance, data by YCharts.

Still a mixed bag

In the second quarter, Gap's sales reached $4.2 billion, up 5.1% from the second quarter of fiscal 2019. Comparable sales jumped 12% over that period, partially offset by the impact of strategic store closures and divestitures.

However, Gap's four major brands aren't contributing equally to its financial performance. On the positive side, Old Navy and Athleta continue to grow quickly. Old Navy's sales rose 21% over Q2 2019 on 18% comp sales growth, while Athleta's top line jumped 35% on a 27% comp sales gain. Both brands had reported even faster growth in the first quarter, but their second-quarter results were extremely strong by any objective standard.

By contrast, sales trends for the Gap and Banana Republic brands improved somewhat sequentially but remained quite poor overall. Net sales fell 10% versus Q2 2019 for Gap and dropped 15% at Banana Republic. Comparable sales increased 3% for Gap -- including a 12% gain in North America -- but this reflected a substantial benefit from store closures over the past two years. Meanwhile, Banana Republic's comparable sales slumped 5% relative to the second quarter of fiscal 2019.

A solid earnings beat and guidance increase

Gap's second-quarter gross margin increased by 4.4 percentage points over fiscal 2019, reaching 43.3%. Lower discounting, strong comp sales growth, and rent reductions for certain locations all contributed to this improvement. The company's gross margin expansion more than offset the impact of wage inflation and higher marketing expenses, boosting Gap's adjusted operating margin to 10.2% (up from 8.3% two years earlier).

This enabled Gap to post adjusted earnings per share of $0.70, compared to $0.63 two years earlier. On average, analysts had expected EPS of just $0.46.

The exterior of an Old Navy store.

Image source: Gap, Inc.

Gap raised its full-year guidance following its excellent second-quarter results. Management now expects to post adjusted EPS between $2.10 and $2.25 on 30% year-over-year revenue growth. This forecast implies that revenue growth will accelerate in the second half of fiscal 2021 and that Gap's top line will rise to nearly $18 billion on a full-year basis.

If anything, Gap's earnings guidance may be conservative. Management appears to be anticipating significant margin pressure later this year. But if the company can hit its sales targets, it has a good chance of beating its 2021 margin target, driving EPS even higher.

The valuation is more attractive now

After a healthy pullback in recent months, Gap stock looks like an intriguing bet for long-term investors. The stock's Monday closing price of $26.74 translates to just 12 times the midpoint of the company's 2021 adjusted EPS guidance. If Gap outperforms its earnings guidance, as I expect, the stock would be even cheaper.

The Old Navy and Athleta brands both have ample room for store expansion and online growth. Meanwhile, management plans to continue trimming the Gap and Banana Republic store counts. By 2023, Old Navy and Athleta will together generate about 70% of the company's sales, up from 55% in fiscal 2019.

This mix shift makes Gap's 2023 operating margin target of 10% look very achievable. In recent years, Gap and Banana Republic's traditional specialty stores have generally lost money, whereas Old Navy and Athleta are highly profitable. Thus, shuttering underperforming stores from the former pair of brands while adding Old Navy and Athleta stores should be margin accretive.

If Gap can hit its 2023 margin target, it would probably post EPS of at least $3.50. That would give Gap shares plenty of upside from today's level.