]> Cypherpunks.ru repositories - gostls13.git/commit
cmd/compile: simplify less with non-negative number and constant 0 or 1
authorwdvxdr <wdvxdr1123@gmail.com>
Mon, 30 Aug 2021 14:26:54 +0000 (22:26 +0800)
committerCherry Mui <cherryyz@google.com>
Tue, 7 Sep 2021 14:53:41 +0000 (14:53 +0000)
commit21de6bc463e52af01bcbfda478e2cb221e982e41
tree80f022ac084deea5a7f286ec27cc61080014e218
parent6226020c2f713e4545c73d56dc05676b642c9bc7
cmd/compile: simplify less with non-negative number and constant 0 or 1

The most common cases:
len(s) > 0
len(s) < 1

and they can be simplified to:
len(s) != 0
len(s) == 0

Fixes #48054

Change-Id: I16e5b0cffcfab62a4acc2a09977a6cd3543dd000
Reviewed-on: https://go-review.googlesource.com/c/go/+/346050
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
src/cmd/compile/internal/ssa/gen/generic.rules
src/cmd/compile/internal/ssa/rewritegeneric.go
test/codegen/issue48054.go [new file with mode: 0644]