compiler: inline slice bounds checking

This improves code size in all tests by about 1% and up to 5% in some
cases, likely because LLVM can better reason about inline bounds checks.
This commit is contained in:
Ayke van Laethem
2019-03-07 18:17:57 +01:00
committed by Ron Evans
parent 051ad07755
commit bd6a7b69ce
3 changed files with 69 additions and 66 deletions
-3
View File
@@ -1603,7 +1603,6 @@ func (c *Compiler) parseExpr(frame *Frame, expr ssa.Value) (llvm.Value, error) {
}
// Bounds check.
// LLVM optimizes this away in most cases.
c.emitLookupBoundsCheck(frame, buflen, index, expr.Index.Type())
switch expr.X.Type().Underlying().(type) {
@@ -1635,7 +1634,6 @@ func (c *Compiler) parseExpr(frame *Frame, expr ssa.Value) (llvm.Value, error) {
}
// Bounds check.
// LLVM optimizes this away in most cases.
length := c.builder.CreateExtractValue(value, 1, "len")
c.emitLookupBoundsCheck(frame, length, index, expr.Index.Type())
@@ -1883,7 +1881,6 @@ func (c *Compiler) parseExpr(frame *Frame, expr ssa.Value) (llvm.Value, error) {
low,
}
// This check is optimized away in most cases.
c.emitSliceBoundsCheck(frame, llvmLen, low, high, lowType, highType)
if c.targetData.TypeAllocSize(high.Type()) > c.targetData.TypeAllocSize(c.uintptrType) {