From cmd/compile/internal/gc/bv.go:
func (dst bvec) AndNot(src1, src2 bvec) {
for i, x := range src1.b {
dst.b[i] = x &^ src2.b[i]
}
}
This can be very hot code for certain kind of input code. The core loop here contains two bounds checks, on dst.b[i] and src2.b[i]. By construction, though, len(dst.b) == len(src1.b) == len(src2.b).
The compiler should already have enough information to hoist these bounds checks out of the loop. I'd be happy enough to provide explicit hints, though, e.g. like _ = dst.b[len(src1.b)-1] at the top of the function. I'm not too particular about what they look like--I just want it to be possible. It doesn't appear to be right now; at least, I can't figure it out.
cc @brtzsnr @dr2chase
From cmd/compile/internal/gc/bv.go:
This can be very hot code for certain kind of input code. The core loop here contains two bounds checks, on
dst.b[i]andsrc2.b[i]. By construction, though, len(dst.b) == len(src1.b) == len(src2.b).The compiler should already have enough information to hoist these bounds checks out of the loop. I'd be happy enough to provide explicit hints, though, e.g. like
_ = dst.b[len(src1.b)-1]at the top of the function. I'm not too particular about what they look like--I just want it to be possible. It doesn't appear to be right now; at least, I can't figure it out.cc @brtzsnr @dr2chase