mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-14 07:53:40 +00:00
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:
committed by
Ron Evans
parent
051ad07755
commit
bd6a7b69ce
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user