irgen: fix canAvoid*

Patch by Andrew Wilkins!

canAvoidElementLoad and canAvoidLoad were incorrectly
eliding loads when an index expression is used as an
another array index expression. This led to a panic.

See comments on https://github.com/go-llvm/llgo/issues/175

Test Plan: lit test added

Differential Revision: http://reviews.llvm.org/D6676

llvm-svn: 224420
GitOrigin-RevId: 1f89ffdf4db9fa28463ee70bab08d83eb496a31b
2 files changed