http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54245
--- Comment #3 from William J. Schmidt <wschmidt at gcc dot gnu.org> 2012-08-14 12:34:24 UTC --- I'm putting together a for-now patch that disables the optimization when a widening cast produces the stride. In the long run this can be re-enabled so long as we can retain the original cast and base the new multiply on that value rather than doing it in the smaller type. This is a bit subtle to get right so I plan to defer that work until I have more time to concentrate on it. I.e., there are two problems in this example: we did the multiply in a smaller type and we introduced an extra cast that wasn't necessary if we were smart enough (causing the longer sequence as Jakub noted). The replacement would be ok with a little re-design.