@@ -2971,6 +2971,232 @@ var linuxARM64Tests = []*asmTest{
2971
2971
` ,
2972
2972
pos : []string {"\t CSEL\t " },
2973
2973
},
2974
+ // Check that zero stores are combine into larger stores
2975
+ {
2976
+ fn : `
2977
+ func $(b []byte) {
2978
+ _ = b[1] // early bounds check to guarantee safety of writes below
2979
+ b[0] = 0
2980
+ b[1] = 0
2981
+ }
2982
+ ` ,
2983
+ pos : []string {"MOVH\t ZR" },
2984
+ neg : []string {"MOVB" },
2985
+ },
2986
+ {
2987
+ fn : `
2988
+ func $(b []byte) {
2989
+ _ = b[1] // early bounds check to guarantee safety of writes below
2990
+ b[1] = 0
2991
+ b[0] = 0
2992
+ }
2993
+ ` ,
2994
+ pos : []string {"MOVH\t ZR" },
2995
+ neg : []string {"MOVB" },
2996
+ },
2997
+ {
2998
+ fn : `
2999
+ func $(b []byte) {
3000
+ _ = b[3] // early bounds check to guarantee safety of writes below
3001
+ b[0] = 0
3002
+ b[1] = 0
3003
+ b[2] = 0
3004
+ b[3] = 0
3005
+ }
3006
+ ` ,
3007
+ pos : []string {"MOVW\t ZR" },
3008
+ neg : []string {"MOVB" , "MOVH" },
3009
+ },
3010
+ {
3011
+ fn : `
3012
+ func $(b []byte) {
3013
+ _ = b[3] // early bounds check to guarantee safety of writes below
3014
+ b[2] = 0
3015
+ b[3] = 0
3016
+ b[1] = 0
3017
+ b[0] = 0
3018
+ }
3019
+ ` ,
3020
+ pos : []string {"MOVW\t ZR" },
3021
+ neg : []string {"MOVB" , "MOVH" },
3022
+ },
3023
+ {
3024
+ fn : `
3025
+ func $(h []uint16) {
3026
+ _ = h[1] // early bounds check to guarantee safety of writes below
3027
+ h[0] = 0
3028
+ h[1] = 0
3029
+ }
3030
+ ` ,
3031
+ pos : []string {"MOVW\t ZR" },
3032
+ neg : []string {"MOVB" , "MOVH" },
3033
+ },
3034
+ {
3035
+ fn : `
3036
+ func $(h []uint16) {
3037
+ _ = h[1] // early bounds check to guarantee safety of writes below
3038
+ h[1] = 0
3039
+ h[0] = 0
3040
+ }
3041
+ ` ,
3042
+ pos : []string {"MOVW\t ZR" },
3043
+ neg : []string {"MOVB" , "MOVH" },
3044
+ },
3045
+ {
3046
+ fn : `
3047
+ func $(b []byte) {
3048
+ _ = b[7] // early bounds check to guarantee safety of writes below
3049
+ b[0] = 0
3050
+ b[1] = 0
3051
+ b[2] = 0
3052
+ b[3] = 0
3053
+ b[4] = 0
3054
+ b[5] = 0
3055
+ b[6] = 0
3056
+ b[7] = 0
3057
+ }
3058
+ ` ,
3059
+ pos : []string {"MOVD\t ZR" },
3060
+ neg : []string {"MOVB" , "MOVH" , "MOVW" },
3061
+ },
3062
+ {
3063
+ fn : `
3064
+ func $(h []uint16) {
3065
+ _ = h[3] // early bounds check to guarantee safety of writes below
3066
+ h[0] = 0
3067
+ h[1] = 0
3068
+ h[2] = 0
3069
+ h[3] = 0
3070
+ }
3071
+ ` ,
3072
+ pos : []string {"MOVD\t ZR" },
3073
+ neg : []string {"MOVB" , "MOVH" , "MOVW" },
3074
+ },
3075
+ {
3076
+ fn : `
3077
+ func $(h []uint16) {
3078
+ _ = h[3] // early bounds check to guarantee safety of writes below
3079
+ h[2] = 0
3080
+ h[3] = 0
3081
+ h[1] = 0
3082
+ h[0] = 0
3083
+ }
3084
+ ` ,
3085
+ pos : []string {"MOVD\t ZR" },
3086
+ neg : []string {"MOVB" , "MOVH" , "MOVW" },
3087
+ },
3088
+ {
3089
+ fn : `
3090
+ func $(w []uint32) {
3091
+ _ = w[1] // early bounds check to guarantee safety of writes below
3092
+ w[0] = 0
3093
+ w[1] = 0
3094
+ }
3095
+ ` ,
3096
+ pos : []string {"MOVD\t ZR" },
3097
+ neg : []string {"MOVB" , "MOVH" , "MOVW" },
3098
+ },
3099
+ {
3100
+ fn : `
3101
+ func $(w []uint32) {
3102
+ _ = w[1] // early bounds check to guarantee safety of writes below
3103
+ w[1] = 0
3104
+ w[0] = 0
3105
+ }
3106
+ ` ,
3107
+ pos : []string {"MOVD\t ZR" },
3108
+ neg : []string {"MOVB" , "MOVH" , "MOVW" },
3109
+ },
3110
+ {
3111
+ fn : `
3112
+ func $(b []byte) {
3113
+ _ = b[15] // early bounds check to guarantee safety of writes below
3114
+ b[0] = 0
3115
+ b[1] = 0
3116
+ b[2] = 0
3117
+ b[3] = 0
3118
+ b[4] = 0
3119
+ b[5] = 0
3120
+ b[6] = 0
3121
+ b[7] = 0
3122
+ b[8] = 0
3123
+ b[9] = 0
3124
+ b[10] = 0
3125
+ b[11] = 0
3126
+ b[12] = 0
3127
+ b[13] = 0
3128
+ b[15] = 0
3129
+ b[14] = 0
3130
+ }
3131
+ ` ,
3132
+ pos : []string {"STP" },
3133
+ neg : []string {"MOVB" , "MOVH" , "MOVW" },
3134
+ },
3135
+ {
3136
+ fn : `
3137
+ func $(h []uint16) {
3138
+ _ = h[7] // early bounds check to guarantee safety of writes below
3139
+ h[0] = 0
3140
+ h[1] = 0
3141
+ h[2] = 0
3142
+ h[3] = 0
3143
+ h[4] = 0
3144
+ h[5] = 0
3145
+ h[6] = 0
3146
+ h[7] = 0
3147
+ }
3148
+ ` ,
3149
+ pos : []string {"STP" },
3150
+ neg : []string {"MOVB" , "MOVH" },
3151
+ },
3152
+ {
3153
+ fn : `
3154
+ func $(w []uint32) {
3155
+ _ = w[3] // early bounds check to guarantee safety of writes below
3156
+ w[0] = 0
3157
+ w[1] = 0
3158
+ w[2] = 0
3159
+ w[3] = 0
3160
+ }
3161
+ ` ,
3162
+ pos : []string {"STP" },
3163
+ neg : []string {"MOVB" , "MOVH" },
3164
+ },
3165
+ {
3166
+ fn : `
3167
+ func $(w []uint32) {
3168
+ _ = w[3] // early bounds check to guarantee safety of writes below
3169
+ w[1] = 0
3170
+ w[0] = 0
3171
+ w[3] = 0
3172
+ w[2] = 0
3173
+ }
3174
+ ` ,
3175
+ pos : []string {"STP" },
3176
+ neg : []string {"MOVB" , "MOVH" },
3177
+ },
3178
+ {
3179
+ fn : `
3180
+ func $(d []uint64) {
3181
+ _ = d[1] // early bounds check to guarantee safety of writes below
3182
+ d[0] = 0
3183
+ d[1] = 0
3184
+ }
3185
+ ` ,
3186
+ pos : []string {"STP" },
3187
+ neg : []string {"MOVB" , "MOVH" },
3188
+ },
3189
+ {
3190
+ fn : `
3191
+ func $(d []uint64) {
3192
+ _ = d[1] // early bounds check to guarantee safety of writes below
3193
+ d[1] = 0
3194
+ d[0] = 0
3195
+ }
3196
+ ` ,
3197
+ pos : []string {"STP" },
3198
+ neg : []string {"MOVB" , "MOVH" },
3199
+ },
2974
3200
}
2975
3201
2976
3202
var linuxMIPSTests = []* asmTest {
0 commit comments