As promised, "Riverdale's" fourth season premiere Wednesday night on CW was an emotional tribute to the late Luke Perry. Perry, who played Archie Andrews' father, Fred, died after a stroke earlier this year at age 52. 

The episode, titled "In Memoriam," was a stand-alone episode centering on Fred's death and how his family and friends process it, according to The New York Post and Gizmodo

We learn Fred died after being hit by passing car as he was helping a mystery woman who had a flat tire. That mystery woman was played by Shannen Doherty, who played Perry's love interest -- Brenda Walsh -- 30 years ago on "Beverly Hills, 90210." Doherty's character tells his family that Fred pushed her out of the way when the car approached, taking the brunt of the collision.

Perry died earlier this year, when the show's third season was still in production. For the remainder of the season, Fred was on a business trip, and Molly Ringwald reprised her role as Archie's mother for the rest of the season. "In Memoriam" could have aired at the end of the third season, but showrunner Roberto Aguirre-Sacasa told the New York Post he didn't want to rush the episode.

RELATED: Luke Perry: Co-stars, fans react to actor's death

RELATED: Luke Perry, '90210' and 'Riverdale' star, dies at 52

“We wanted to be very respectful and honor both Luke and [his character] Fred Andrews,” Aguirre-Sacasa said. “That suggested we should take a more grounded, character-based episode that allowed us to track the emotions. 

Doherty said being part of the episode was "cathartic in a lot of ways. Very, very hard and emotional." 

Perry's other cast members had similar experiences with the episode. Ringwald, who plays Archie's mom and Fred's ex-wife, said filming the episode was like touching a raw nerve. “I pretty much cried from beginning to end,” she says. “It was like saying goodbye to [Perry] and dealing with the sadness of that," she told the New York Post. 

Skeet Ulrich, who plays Jughead's dad and Fred's friend FP Jones, that it was "literally almost impossible to utter lines." 

“The emotion you try to bury from the four months prior to [Perry’s death] happening until we’re asked to re-examine it in the episode … it’s one of the hardest experiences I’d had [to do] on film," he told the New York Post.

TEGNA's Travis Pittman contributed to this report.