HP is preparing one of the largest restructurings in its recent history, planning to eliminate thousands of roles as it leans heavily into artificial intelligence to reshape how the company operates.