fix various codegen bugs on arm64