Mining and commodities trader Glencore dipped in early deals on Wednesday after the stock went ex-dividend, but losses were quickly erased after a rating upgrade by Investec.The broker said it has lifted the stock from 'hold' to 'add' and raised its target price from 360p to 380p following last month's interim report from the group, at which it unveiled a share buyback worth $1bn.Analyst Marc Elliott said that Glencore management was the fastest of the major resource companies to slash capital profits and firmly outline how it planned to return surplus cash to shareholders.What's more, the company has "substantial scope" to return funds to shareholders in the coming years, Elliot said."Glencore has outperformed peers significantly in recent months and with iron ore pricing looking increasingly weak, we believe the company's greater earnings diversity continues to place it at a distinct advantage within the large-cap mining sector," he said."Back in mid-June, we argued that Glencore offers more varied exposure to commodities with stronger fundamentals and greater scope for upside from commodity rallies. We set this against Rio Tinto ('hold'), where heavy iron ore exposure undermines the value case. Our argument still stands."The stock was up 0.5% at 369.25p by 13:03.BC