If Guan Yu, Sainted Warrior is removed from the graveyard after the ability triggers but before it resolves, it won't get shuffled into your library.

Artwork
Loading artwork…
Guan Yu, Sainted Warrior
Portal Three Kingdoms · #6 · EN
Nonfoil—Foil—
Card rules
Horsemanship (This creature can't be blocked except by creatures with horsemanship.)
When Guan Yu is put into your graveyard from the battlefield, you may shuffle Guan Yu into your library.
3/5
Rare · Illustrated by Qiao Dafu
Format legality
Commander Legal
Duel Legal
Legacy Legal
Oathbreaker Legal
PreDH Legal
Vintage Legal
Alchemy Not Legal
Brawl Not Legal
Competitive Brawl Not Legal
Future Not Legal
Gladiator Not Legal
Historic Not Legal
Modern Not Legal
Old School Not Legal
Pauper Not Legal
Pauper Commander Not Legal
Penny Not Legal
Pioneer Not Legal
Premodern Not Legal
Standard Not Legal
Standard Brawl Not Legal
Timeless Not Legal
Tlr Not Legal
Rulings
Published rulings from the downloaded Scryfall catalog. Source card record · Rules and interactions
Despite the similarities between horsemanship and flying, horsemanship doesn't interact with flying or reach.
If a replacement effect has Guan Yu move to a different zone instead of being put into the graveyard, the ability won't trigger at all.