aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2009-11-16 17:40:47 -0800
committerRuss Cox <rsc@golang.org>2009-11-16 17:40:47 -0800
commit1ee83f851dd7b70564c54f60575957ed84a368b7 (patch)
tree31d93c363a673f824456f56ac3efc3b9140450cc
parent44e51fad2865eb560bd71333c5f8b2f60b60e67b (diff)
downloadgo-1ee83f851dd7b70564c54f60575957ed84a368b7.tar.gz
go-1ee83f851dd7b70564c54f60575957ed84a368b7.zip
gc: change "can we const evaluate this" from blacklist to whitelist
R=ken2 https://golang.org/cl/155074
-rw-r--r--src/cmd/gc/const.c36
1 files changed, 30 insertions, 6 deletions
diff --git a/src/cmd/gc/const.c b/src/cmd/gc/const.c
index b11ab1c7f8..cca13b9528 100644
--- a/src/cmd/gc/const.c
+++ b/src/cmd/gc/const.c
@@ -329,14 +329,38 @@ evconst(Node *n)
Val v;
Mpint b;
+ // pick off just the opcodes that can be
+ // constant evaluated.
switch(n->op) {
- case OMAKE:
- case OMAKEMAP:
- case OMAKESLICE:
- case OMAKECHAN:
- case ODCLCONST:
- case OCONVIFACE:
+ default:
return;
+ case OADD:
+ case OADDSTR:
+ case OAND:
+ case OANDAND:
+ case OANDNOT:
+ case OARRAYBYTESTR:
+ case OCOM:
+ case OCONV:
+ case ODIV:
+ case OEQ:
+ case OGE:
+ case OGT:
+ case OLE:
+ case OLSH:
+ case OLT:
+ case OMINUS:
+ case OMOD:
+ case OMUL:
+ case ONE:
+ case ONOT:
+ case OOR:
+ case OOROR:
+ case OPLUS:
+ case ORSH:
+ case OSUB:
+ case OXOR:
+ break;
}
nl = n->left;