golang 编译器是否使用常量折叠?
does golang compiler use constant folding?
只是想知道 "go" 编译器是否使用任何类型的优化,例如常量折叠。
https://en.wikipedia.org/wiki/Constant_folding
搜索了 google 但找不到我正在寻找的答案。
尝试写一个简单的程序:eg.
package main
import "fmt"
func main() {
fmt.Println(12345*1000)
}
现在将其编译为程序集
go tool compile -S examle.go
现在在结果中找到12345,你就会有答案了。
Constant folding is the process of recognizing and evaluating constant
expressions at compile time rather than computing them at runtime.
The Go Programming Language Specification
Constant expressions may contain only constant operands and are
evaluated at compile time.
import "math/big"
Package big implements arbitrary-precision arithmetic (big numbers).
Go 常量表达式在编译时求值。 Go gc 编译器,用 Go 编写,使用包 big
来评估数字常量表达式。
只是想知道 "go" 编译器是否使用任何类型的优化,例如常量折叠。
https://en.wikipedia.org/wiki/Constant_folding
搜索了 google 但找不到我正在寻找的答案。
尝试写一个简单的程序:eg.
package main
import "fmt"
func main() {
fmt.Println(12345*1000)
}
现在将其编译为程序集
go tool compile -S examle.go
现在在结果中找到12345,你就会有答案了。
Constant folding is the process of recognizing and evaluating constant expressions at compile time rather than computing them at runtime.
The Go Programming Language Specification
Constant expressions may contain only constant operands and are evaluated at compile time.
import "math/big"
Package big implements arbitrary-precision arithmetic (big numbers).
Go 常量表达式在编译时求值。 Go gc 编译器,用 Go 编写,使用包 big
来评估数字常量表达式。