Investing in the stock market is not a good hedge against inflation. If you look at the 1970's, the stock market did not do well, while price inflation was in double digits. An inflationary environment will hurt profits for many companies. Inflation (monetary or price) will not necessarily translate into an increase in the stock market in the short-term, even nominally.
In addition, even if stocks did go up with inflation in the short-term, it is still not a good hedge against inflation. For something to be a good hedge, you want it to overcompensate. A good hedge against inflation would go up at a greater rate than the inflation rate. This is why gold is a good inflation hedge. It will go up in dollar terms faster than the actual inflation rate, during a high inflationary time. A good hedge should help compensate for the losses in other investments in your portfolio.
In the very long-term, stocks actually are somewhat of an inflation hedge. At the very least, stocks will tend to keep up with inflation. In fact, I would argue that the stock market would go up very little, if at all, if there were no monetary inflation.
If the money supply remained constant over a long period of time, why would the broad stock market go up in any significant way? Some individual stocks would go up as others went down, but generally, the overall market would not go up. If it did, where would the money come from? This is a hard concept for most people to grasp because we are so accustomed to living in a world of fiat money and inflation.
So what would be the point of investing in the stock market if it didn't go up? Well, stocks would pay dividends. This is really supposed to be the point of stock investing anyway. In addition, in a free market environment, due to increases in capital, technology, and production, things would actually get cheaper. So even though your stocks might not be going up in nominal terms, the value of your money would be increasing as you could buy more goods and services with it.
The whole stock market system is highly distorted because we don't have a truly free market. Monetary inflation, regulations, and taxes all distort how the stock market functions. It discourages dividends and encourages capital gains. It also makes investing very difficult. This is just another reason that we need a free market in money.