In this year’s annual Tom Cruise sci-fi epic, he plays a future soldier condemned to repeat the same botched D-Day invasion until he triumphs against the alien beasties who keep killing him and forcing him to start this waking nightmare again.

Titles worth considering — “Groundhog D-Day”? Or maybe, “A Million Ways to Die in the Future?”

“Edge of Tomorrow” could have been another “Next” or “Knowing,” lame variations on a Nic Cage-knows-the-future theme. But it’s almost as good as Jake Gyllenhaal’s earlier take on this sort of plot, “Source Code,” a thriller about a time traveler dealing with a steep learning curve as he frantically tries to work through variations of who set off a bomb on a train.

“Edge,” based on a Hiroshi Sakurazaka novel, script partly credited to Christopher McQuarrie and directed by Doug Liman, gets its juice from its action and its life from its humor. No kidding, almost every time Major Cage (Cruise) dies, it’s a laugh. That’s because he figures out that he’s going through this nightmare for a reason, and there’s one soldier in it with him, the “Angel of Verdun” (Emily Blunt) who knows what he’s experiencing and knows if he makes a mistake, she can shoot him in the head as a way of hitting this battle’s reset button. Yeah, that’s funny after a bit.

Cage, an Army media relations officer, is a confirmed coward in the film’s opening scenes. The general in charge (Brendan Gleeson) has condemned Cage to embed with the first wave hitting the French beaches as the world’s armies converge on spider-like aliens called “Mimics.” So Cage wakes up every day to the sound of a sergeant bellowing “On your feet, MAGGOT.”

It’s a version of that dream where you’re speaking in public and you forgot to put on your pants. Untrained for combat — he doesn’t even know how to switch the safety off on the ordnance attached to his exoskeleton armor — Cage is hurled into a chaotic lost battle where he meets the heroine, Sgt. Rita (Blunt). With reasoning and a LOT of practice deaths, he and she work out how to survive the fight just a little longer each time out with an eye toward foiling these aliens before they do what Hitler never could — cross the English Channel and end human civilization.

The script has Cage taking stupid chances, sure in the knowledge that he will get a do-over if he screws up. It has him dreading each version of the mission’s failure, the array of explosions, impalings, or head shots by Sgt. Rita that punch that reset button.

And like Bill Murray in “Groundhog Day” and Gyllenhaal in “Source Code,” and even Sigourney Weaver in “Alien 3,” it has Cage dealing with his own coming death and the futility of fighting it. “Edge of Tomorrow” gets its heart from Elizabeth Kubler-Ross’ Five Stages of Grief from “On Death and Dying.”

Cage is in frantic “denial” this is happening. He rages in “anger” at his circumstances. He starts “bargaining” his way through it, trying to convince others they’re in the nightmare with him. He hits the wall — “depression.” “We’re done.” And, as Kubler-Ross predicted, he reaches “acceptance” — making the best of his fate.

Liman lays a solid hour of brisk, brutal and brutally funny action on us — introducing and reintroducing the demoted and humiliated Cage to his sergeant (Bill Paxton), who serves him the same bromide — combat is “the fiery crucible in which true heroes are forged” — and introduces him to J-Squad, the jump team he will watch die all around him as they try, again and again, to win this unwinnable scenario.

The constant resets after working one’s way through another section of the battlefield are straight out of video gaming, something fans will pick up on right away. But unlike the rest of this cinematic deja vu, the more somber Five Stages of Grief stuff sneaks up on you. That gives this popcorn-weight action pic some nice gravitas to go with the “Million Ways Tom Cruise Gets to Die” jokes.

Tom Cruise and Emily Blunt have only as much chemistry as the script allows, which becomes plain as the film finally slows down enough to catch its breath one hour in, but as far as summer sci-fi epics go, this one has plenty of action — and humor.