Skip to content

cmd/compile: rulegen results in confusing compiler errors when reserved names are used in rewrite rules #45154

@zhangfannie

Description

@zhangfannie

Recently, I have a problem when I want to rewrite the following go codes with ARM64 REV16 instruction.

// go codes

 func genREV16(c uint64) uint64 {
        b := ((c & 0xff00ff00) >> 8) | ((c & 0x00ff00ff) << 8)
        return b
 }

The above codes can be optimized as two instructions "AND 0xffffffff, c, Rd" and "REV16 Rd". So I added the following rewritten rules to do this optimization.

((ADDshiftLL|ORshiftLL|XORshiftLL) <typ.UInt64> [8] (SRLconst [8] (ANDconst [a] x)) (ANDconst [b] x))
        && (uint64(a) == 0xff00ff00 && uint64(b) == 0x00ff00ff)
        => (REV16 (ANDconst <typ.UInt64> [0xffffffff] x))

But make.bash will report the error: "golong/src/cmd/compile/internal/ssa/rewriteARM64.go:1845: b.NewValue0 undefined (type int64 has no field or method NewValue0)".

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions