Optimize bounds checks with correct assertion set
authorJoseph Tremoulet <jotrem@microsoft.com>
Mon, 18 Jul 2016 16:56:37 +0000 (12:56 -0400)
committerJoseph Tremoulet <jotrem@microsoft.com>
Tue, 2 Aug 2016 21:21:37 +0000 (17:21 -0400)
commit144fd2211a08f0713fca7201b9270066e3f92a77
tree13864f88daecdf324ab322ce8f944b98c93bd3ee
parent424d1eae1f6cd16fe9534a8b48dfa08526d42066
Optimize bounds checks with correct assertion set

Assertion prop defers removing redundant bounds checks until processing
the parent comma, because the rewrite involves the comma as well.  The
code currently has a bug in that its check for whether the bounds check
is redundant also occurs when processing reaches the comma, which is wrong
because the assertion set may then include assertions generated by the RHS
of the comma (there is code to compensate for the assertion generated by
the bounds check itself, which is the LHS of the comma, but no compensation
for the RHS).

This change moves the analysis of whether bounds checks are redundant to
the proper spot in the processing order, and delays only the rewrite to
the processing of the comma; the redundancy of the bounds check is
communicated via a new opcode-specific flag: GTF_ARR_BOUND_INBND.

Fixes dotnet/coreclr#6318.

Commit migrated from https://github.com/dotnet/coreclr/commit/16c65845eef41548c5653f14fede5a8c5c0be30f
src/coreclr/src/jit/assertionprop.cpp
src/coreclr/src/jit/gentree.h
src/coreclr/tests/src/JIT/Regression/JitBlue/GitHub_6318/GitHub_6318.cs [new file with mode: 0644]
src/coreclr/tests/src/JIT/Regression/JitBlue/GitHub_6318/GitHub_6318.csproj [new file with mode: 0644]
src/coreclr/tests/src/JIT/Regression/JitBlue/GitHub_6318/app.config [new file with mode: 0644]