github.com/go-asm/go@v1.21.1-0.20240213172139-40c5ead50c48/cmd/compile/ssa/rewriteRISCV64.go (about) 1 // Code generated from _gen/RISCV64.rules using 'go generate'; DO NOT EDIT. 2 3 package ssa 4 5 import ( 6 "math" 7 8 "github.com/go-asm/go/cmd/compile/types" 9 ) 10 11 func rewriteValueRISCV64(v *Value) bool { 12 switch v.Op { 13 case OpAbs: 14 v.Op = OpRISCV64FABSD 15 return true 16 case OpAdd16: 17 v.Op = OpRISCV64ADD 18 return true 19 case OpAdd32: 20 v.Op = OpRISCV64ADD 21 return true 22 case OpAdd32F: 23 v.Op = OpRISCV64FADDS 24 return true 25 case OpAdd64: 26 v.Op = OpRISCV64ADD 27 return true 28 case OpAdd64F: 29 v.Op = OpRISCV64FADDD 30 return true 31 case OpAdd8: 32 v.Op = OpRISCV64ADD 33 return true 34 case OpAddPtr: 35 v.Op = OpRISCV64ADD 36 return true 37 case OpAddr: 38 return rewriteValueRISCV64_OpAddr(v) 39 case OpAnd16: 40 v.Op = OpRISCV64AND 41 return true 42 case OpAnd32: 43 v.Op = OpRISCV64AND 44 return true 45 case OpAnd64: 46 v.Op = OpRISCV64AND 47 return true 48 case OpAnd8: 49 v.Op = OpRISCV64AND 50 return true 51 case OpAndB: 52 v.Op = OpRISCV64AND 53 return true 54 case OpAtomicAdd32: 55 v.Op = OpRISCV64LoweredAtomicAdd32 56 return true 57 case OpAtomicAdd64: 58 v.Op = OpRISCV64LoweredAtomicAdd64 59 return true 60 case OpAtomicAnd32: 61 v.Op = OpRISCV64LoweredAtomicAnd32 62 return true 63 case OpAtomicAnd8: 64 return rewriteValueRISCV64_OpAtomicAnd8(v) 65 case OpAtomicCompareAndSwap32: 66 return rewriteValueRISCV64_OpAtomicCompareAndSwap32(v) 67 case OpAtomicCompareAndSwap64: 68 v.Op = OpRISCV64LoweredAtomicCas64 69 return true 70 case OpAtomicExchange32: 71 v.Op = OpRISCV64LoweredAtomicExchange32 72 return true 73 case OpAtomicExchange64: 74 v.Op = OpRISCV64LoweredAtomicExchange64 75 return true 76 case OpAtomicLoad32: 77 v.Op = OpRISCV64LoweredAtomicLoad32 78 return true 79 case OpAtomicLoad64: 80 v.Op = OpRISCV64LoweredAtomicLoad64 81 return true 82 case OpAtomicLoad8: 83 v.Op = OpRISCV64LoweredAtomicLoad8 84 return true 85 case OpAtomicLoadPtr: 86 v.Op = OpRISCV64LoweredAtomicLoad64 87 return true 88 case OpAtomicOr32: 89 v.Op = OpRISCV64LoweredAtomicOr32 90 return true 91 case OpAtomicOr8: 92 return rewriteValueRISCV64_OpAtomicOr8(v) 93 case OpAtomicStore32: 94 v.Op = OpRISCV64LoweredAtomicStore32 95 return true 96 case OpAtomicStore64: 97 v.Op = OpRISCV64LoweredAtomicStore64 98 return true 99 case OpAtomicStore8: 100 v.Op = OpRISCV64LoweredAtomicStore8 101 return true 102 case OpAtomicStorePtrNoWB: 103 v.Op = OpRISCV64LoweredAtomicStore64 104 return true 105 case OpAvg64u: 106 return rewriteValueRISCV64_OpAvg64u(v) 107 case OpClosureCall: 108 v.Op = OpRISCV64CALLclosure 109 return true 110 case OpCom16: 111 v.Op = OpRISCV64NOT 112 return true 113 case OpCom32: 114 v.Op = OpRISCV64NOT 115 return true 116 case OpCom64: 117 v.Op = OpRISCV64NOT 118 return true 119 case OpCom8: 120 v.Op = OpRISCV64NOT 121 return true 122 case OpConst16: 123 return rewriteValueRISCV64_OpConst16(v) 124 case OpConst32: 125 return rewriteValueRISCV64_OpConst32(v) 126 case OpConst32F: 127 return rewriteValueRISCV64_OpConst32F(v) 128 case OpConst64: 129 return rewriteValueRISCV64_OpConst64(v) 130 case OpConst64F: 131 return rewriteValueRISCV64_OpConst64F(v) 132 case OpConst8: 133 return rewriteValueRISCV64_OpConst8(v) 134 case OpConstBool: 135 return rewriteValueRISCV64_OpConstBool(v) 136 case OpConstNil: 137 return rewriteValueRISCV64_OpConstNil(v) 138 case OpCopysign: 139 v.Op = OpRISCV64FSGNJD 140 return true 141 case OpCvt32Fto32: 142 v.Op = OpRISCV64FCVTWS 143 return true 144 case OpCvt32Fto64: 145 v.Op = OpRISCV64FCVTLS 146 return true 147 case OpCvt32Fto64F: 148 v.Op = OpRISCV64FCVTDS 149 return true 150 case OpCvt32to32F: 151 v.Op = OpRISCV64FCVTSW 152 return true 153 case OpCvt32to64F: 154 v.Op = OpRISCV64FCVTDW 155 return true 156 case OpCvt64Fto32: 157 v.Op = OpRISCV64FCVTWD 158 return true 159 case OpCvt64Fto32F: 160 v.Op = OpRISCV64FCVTSD 161 return true 162 case OpCvt64Fto64: 163 v.Op = OpRISCV64FCVTLD 164 return true 165 case OpCvt64to32F: 166 v.Op = OpRISCV64FCVTSL 167 return true 168 case OpCvt64to64F: 169 v.Op = OpRISCV64FCVTDL 170 return true 171 case OpCvtBoolToUint8: 172 v.Op = OpCopy 173 return true 174 case OpDiv16: 175 return rewriteValueRISCV64_OpDiv16(v) 176 case OpDiv16u: 177 return rewriteValueRISCV64_OpDiv16u(v) 178 case OpDiv32: 179 return rewriteValueRISCV64_OpDiv32(v) 180 case OpDiv32F: 181 v.Op = OpRISCV64FDIVS 182 return true 183 case OpDiv32u: 184 v.Op = OpRISCV64DIVUW 185 return true 186 case OpDiv64: 187 return rewriteValueRISCV64_OpDiv64(v) 188 case OpDiv64F: 189 v.Op = OpRISCV64FDIVD 190 return true 191 case OpDiv64u: 192 v.Op = OpRISCV64DIVU 193 return true 194 case OpDiv8: 195 return rewriteValueRISCV64_OpDiv8(v) 196 case OpDiv8u: 197 return rewriteValueRISCV64_OpDiv8u(v) 198 case OpEq16: 199 return rewriteValueRISCV64_OpEq16(v) 200 case OpEq32: 201 return rewriteValueRISCV64_OpEq32(v) 202 case OpEq32F: 203 v.Op = OpRISCV64FEQS 204 return true 205 case OpEq64: 206 return rewriteValueRISCV64_OpEq64(v) 207 case OpEq64F: 208 v.Op = OpRISCV64FEQD 209 return true 210 case OpEq8: 211 return rewriteValueRISCV64_OpEq8(v) 212 case OpEqB: 213 return rewriteValueRISCV64_OpEqB(v) 214 case OpEqPtr: 215 return rewriteValueRISCV64_OpEqPtr(v) 216 case OpFMA: 217 v.Op = OpRISCV64FMADDD 218 return true 219 case OpGetCallerPC: 220 v.Op = OpRISCV64LoweredGetCallerPC 221 return true 222 case OpGetCallerSP: 223 v.Op = OpRISCV64LoweredGetCallerSP 224 return true 225 case OpGetClosurePtr: 226 v.Op = OpRISCV64LoweredGetClosurePtr 227 return true 228 case OpHmul32: 229 return rewriteValueRISCV64_OpHmul32(v) 230 case OpHmul32u: 231 return rewriteValueRISCV64_OpHmul32u(v) 232 case OpHmul64: 233 v.Op = OpRISCV64MULH 234 return true 235 case OpHmul64u: 236 v.Op = OpRISCV64MULHU 237 return true 238 case OpInterCall: 239 v.Op = OpRISCV64CALLinter 240 return true 241 case OpIsInBounds: 242 v.Op = OpLess64U 243 return true 244 case OpIsNonNil: 245 v.Op = OpRISCV64SNEZ 246 return true 247 case OpIsSliceInBounds: 248 v.Op = OpLeq64U 249 return true 250 case OpLeq16: 251 return rewriteValueRISCV64_OpLeq16(v) 252 case OpLeq16U: 253 return rewriteValueRISCV64_OpLeq16U(v) 254 case OpLeq32: 255 return rewriteValueRISCV64_OpLeq32(v) 256 case OpLeq32F: 257 v.Op = OpRISCV64FLES 258 return true 259 case OpLeq32U: 260 return rewriteValueRISCV64_OpLeq32U(v) 261 case OpLeq64: 262 return rewriteValueRISCV64_OpLeq64(v) 263 case OpLeq64F: 264 v.Op = OpRISCV64FLED 265 return true 266 case OpLeq64U: 267 return rewriteValueRISCV64_OpLeq64U(v) 268 case OpLeq8: 269 return rewriteValueRISCV64_OpLeq8(v) 270 case OpLeq8U: 271 return rewriteValueRISCV64_OpLeq8U(v) 272 case OpLess16: 273 return rewriteValueRISCV64_OpLess16(v) 274 case OpLess16U: 275 return rewriteValueRISCV64_OpLess16U(v) 276 case OpLess32: 277 return rewriteValueRISCV64_OpLess32(v) 278 case OpLess32F: 279 v.Op = OpRISCV64FLTS 280 return true 281 case OpLess32U: 282 return rewriteValueRISCV64_OpLess32U(v) 283 case OpLess64: 284 v.Op = OpRISCV64SLT 285 return true 286 case OpLess64F: 287 v.Op = OpRISCV64FLTD 288 return true 289 case OpLess64U: 290 v.Op = OpRISCV64SLTU 291 return true 292 case OpLess8: 293 return rewriteValueRISCV64_OpLess8(v) 294 case OpLess8U: 295 return rewriteValueRISCV64_OpLess8U(v) 296 case OpLoad: 297 return rewriteValueRISCV64_OpLoad(v) 298 case OpLocalAddr: 299 return rewriteValueRISCV64_OpLocalAddr(v) 300 case OpLsh16x16: 301 return rewriteValueRISCV64_OpLsh16x16(v) 302 case OpLsh16x32: 303 return rewriteValueRISCV64_OpLsh16x32(v) 304 case OpLsh16x64: 305 return rewriteValueRISCV64_OpLsh16x64(v) 306 case OpLsh16x8: 307 return rewriteValueRISCV64_OpLsh16x8(v) 308 case OpLsh32x16: 309 return rewriteValueRISCV64_OpLsh32x16(v) 310 case OpLsh32x32: 311 return rewriteValueRISCV64_OpLsh32x32(v) 312 case OpLsh32x64: 313 return rewriteValueRISCV64_OpLsh32x64(v) 314 case OpLsh32x8: 315 return rewriteValueRISCV64_OpLsh32x8(v) 316 case OpLsh64x16: 317 return rewriteValueRISCV64_OpLsh64x16(v) 318 case OpLsh64x32: 319 return rewriteValueRISCV64_OpLsh64x32(v) 320 case OpLsh64x64: 321 return rewriteValueRISCV64_OpLsh64x64(v) 322 case OpLsh64x8: 323 return rewriteValueRISCV64_OpLsh64x8(v) 324 case OpLsh8x16: 325 return rewriteValueRISCV64_OpLsh8x16(v) 326 case OpLsh8x32: 327 return rewriteValueRISCV64_OpLsh8x32(v) 328 case OpLsh8x64: 329 return rewriteValueRISCV64_OpLsh8x64(v) 330 case OpLsh8x8: 331 return rewriteValueRISCV64_OpLsh8x8(v) 332 case OpMod16: 333 return rewriteValueRISCV64_OpMod16(v) 334 case OpMod16u: 335 return rewriteValueRISCV64_OpMod16u(v) 336 case OpMod32: 337 return rewriteValueRISCV64_OpMod32(v) 338 case OpMod32u: 339 v.Op = OpRISCV64REMUW 340 return true 341 case OpMod64: 342 return rewriteValueRISCV64_OpMod64(v) 343 case OpMod64u: 344 v.Op = OpRISCV64REMU 345 return true 346 case OpMod8: 347 return rewriteValueRISCV64_OpMod8(v) 348 case OpMod8u: 349 return rewriteValueRISCV64_OpMod8u(v) 350 case OpMove: 351 return rewriteValueRISCV64_OpMove(v) 352 case OpMul16: 353 return rewriteValueRISCV64_OpMul16(v) 354 case OpMul32: 355 v.Op = OpRISCV64MULW 356 return true 357 case OpMul32F: 358 v.Op = OpRISCV64FMULS 359 return true 360 case OpMul64: 361 v.Op = OpRISCV64MUL 362 return true 363 case OpMul64F: 364 v.Op = OpRISCV64FMULD 365 return true 366 case OpMul64uhilo: 367 v.Op = OpRISCV64LoweredMuluhilo 368 return true 369 case OpMul64uover: 370 v.Op = OpRISCV64LoweredMuluover 371 return true 372 case OpMul8: 373 return rewriteValueRISCV64_OpMul8(v) 374 case OpNeg16: 375 v.Op = OpRISCV64NEG 376 return true 377 case OpNeg32: 378 v.Op = OpRISCV64NEG 379 return true 380 case OpNeg32F: 381 v.Op = OpRISCV64FNEGS 382 return true 383 case OpNeg64: 384 v.Op = OpRISCV64NEG 385 return true 386 case OpNeg64F: 387 v.Op = OpRISCV64FNEGD 388 return true 389 case OpNeg8: 390 v.Op = OpRISCV64NEG 391 return true 392 case OpNeq16: 393 return rewriteValueRISCV64_OpNeq16(v) 394 case OpNeq32: 395 return rewriteValueRISCV64_OpNeq32(v) 396 case OpNeq32F: 397 v.Op = OpRISCV64FNES 398 return true 399 case OpNeq64: 400 return rewriteValueRISCV64_OpNeq64(v) 401 case OpNeq64F: 402 v.Op = OpRISCV64FNED 403 return true 404 case OpNeq8: 405 return rewriteValueRISCV64_OpNeq8(v) 406 case OpNeqB: 407 return rewriteValueRISCV64_OpNeqB(v) 408 case OpNeqPtr: 409 return rewriteValueRISCV64_OpNeqPtr(v) 410 case OpNilCheck: 411 v.Op = OpRISCV64LoweredNilCheck 412 return true 413 case OpNot: 414 v.Op = OpRISCV64SEQZ 415 return true 416 case OpOffPtr: 417 return rewriteValueRISCV64_OpOffPtr(v) 418 case OpOr16: 419 v.Op = OpRISCV64OR 420 return true 421 case OpOr32: 422 v.Op = OpRISCV64OR 423 return true 424 case OpOr64: 425 v.Op = OpRISCV64OR 426 return true 427 case OpOr8: 428 v.Op = OpRISCV64OR 429 return true 430 case OpOrB: 431 v.Op = OpRISCV64OR 432 return true 433 case OpPanicBounds: 434 return rewriteValueRISCV64_OpPanicBounds(v) 435 case OpPubBarrier: 436 v.Op = OpRISCV64LoweredPubBarrier 437 return true 438 case OpRISCV64ADD: 439 return rewriteValueRISCV64_OpRISCV64ADD(v) 440 case OpRISCV64ADDI: 441 return rewriteValueRISCV64_OpRISCV64ADDI(v) 442 case OpRISCV64AND: 443 return rewriteValueRISCV64_OpRISCV64AND(v) 444 case OpRISCV64ANDI: 445 return rewriteValueRISCV64_OpRISCV64ANDI(v) 446 case OpRISCV64FADDD: 447 return rewriteValueRISCV64_OpRISCV64FADDD(v) 448 case OpRISCV64FADDS: 449 return rewriteValueRISCV64_OpRISCV64FADDS(v) 450 case OpRISCV64FMADDD: 451 return rewriteValueRISCV64_OpRISCV64FMADDD(v) 452 case OpRISCV64FMADDS: 453 return rewriteValueRISCV64_OpRISCV64FMADDS(v) 454 case OpRISCV64FMSUBD: 455 return rewriteValueRISCV64_OpRISCV64FMSUBD(v) 456 case OpRISCV64FMSUBS: 457 return rewriteValueRISCV64_OpRISCV64FMSUBS(v) 458 case OpRISCV64FNMADDD: 459 return rewriteValueRISCV64_OpRISCV64FNMADDD(v) 460 case OpRISCV64FNMADDS: 461 return rewriteValueRISCV64_OpRISCV64FNMADDS(v) 462 case OpRISCV64FNMSUBD: 463 return rewriteValueRISCV64_OpRISCV64FNMSUBD(v) 464 case OpRISCV64FNMSUBS: 465 return rewriteValueRISCV64_OpRISCV64FNMSUBS(v) 466 case OpRISCV64FSUBD: 467 return rewriteValueRISCV64_OpRISCV64FSUBD(v) 468 case OpRISCV64FSUBS: 469 return rewriteValueRISCV64_OpRISCV64FSUBS(v) 470 case OpRISCV64MOVBUload: 471 return rewriteValueRISCV64_OpRISCV64MOVBUload(v) 472 case OpRISCV64MOVBUreg: 473 return rewriteValueRISCV64_OpRISCV64MOVBUreg(v) 474 case OpRISCV64MOVBload: 475 return rewriteValueRISCV64_OpRISCV64MOVBload(v) 476 case OpRISCV64MOVBreg: 477 return rewriteValueRISCV64_OpRISCV64MOVBreg(v) 478 case OpRISCV64MOVBstore: 479 return rewriteValueRISCV64_OpRISCV64MOVBstore(v) 480 case OpRISCV64MOVBstorezero: 481 return rewriteValueRISCV64_OpRISCV64MOVBstorezero(v) 482 case OpRISCV64MOVDload: 483 return rewriteValueRISCV64_OpRISCV64MOVDload(v) 484 case OpRISCV64MOVDnop: 485 return rewriteValueRISCV64_OpRISCV64MOVDnop(v) 486 case OpRISCV64MOVDreg: 487 return rewriteValueRISCV64_OpRISCV64MOVDreg(v) 488 case OpRISCV64MOVDstore: 489 return rewriteValueRISCV64_OpRISCV64MOVDstore(v) 490 case OpRISCV64MOVDstorezero: 491 return rewriteValueRISCV64_OpRISCV64MOVDstorezero(v) 492 case OpRISCV64MOVHUload: 493 return rewriteValueRISCV64_OpRISCV64MOVHUload(v) 494 case OpRISCV64MOVHUreg: 495 return rewriteValueRISCV64_OpRISCV64MOVHUreg(v) 496 case OpRISCV64MOVHload: 497 return rewriteValueRISCV64_OpRISCV64MOVHload(v) 498 case OpRISCV64MOVHreg: 499 return rewriteValueRISCV64_OpRISCV64MOVHreg(v) 500 case OpRISCV64MOVHstore: 501 return rewriteValueRISCV64_OpRISCV64MOVHstore(v) 502 case OpRISCV64MOVHstorezero: 503 return rewriteValueRISCV64_OpRISCV64MOVHstorezero(v) 504 case OpRISCV64MOVWUload: 505 return rewriteValueRISCV64_OpRISCV64MOVWUload(v) 506 case OpRISCV64MOVWUreg: 507 return rewriteValueRISCV64_OpRISCV64MOVWUreg(v) 508 case OpRISCV64MOVWload: 509 return rewriteValueRISCV64_OpRISCV64MOVWload(v) 510 case OpRISCV64MOVWreg: 511 return rewriteValueRISCV64_OpRISCV64MOVWreg(v) 512 case OpRISCV64MOVWstore: 513 return rewriteValueRISCV64_OpRISCV64MOVWstore(v) 514 case OpRISCV64MOVWstorezero: 515 return rewriteValueRISCV64_OpRISCV64MOVWstorezero(v) 516 case OpRISCV64NEG: 517 return rewriteValueRISCV64_OpRISCV64NEG(v) 518 case OpRISCV64NEGW: 519 return rewriteValueRISCV64_OpRISCV64NEGW(v) 520 case OpRISCV64OR: 521 return rewriteValueRISCV64_OpRISCV64OR(v) 522 case OpRISCV64ORI: 523 return rewriteValueRISCV64_OpRISCV64ORI(v) 524 case OpRISCV64SEQZ: 525 return rewriteValueRISCV64_OpRISCV64SEQZ(v) 526 case OpRISCV64SLL: 527 return rewriteValueRISCV64_OpRISCV64SLL(v) 528 case OpRISCV64SLLI: 529 return rewriteValueRISCV64_OpRISCV64SLLI(v) 530 case OpRISCV64SLT: 531 return rewriteValueRISCV64_OpRISCV64SLT(v) 532 case OpRISCV64SLTI: 533 return rewriteValueRISCV64_OpRISCV64SLTI(v) 534 case OpRISCV64SLTIU: 535 return rewriteValueRISCV64_OpRISCV64SLTIU(v) 536 case OpRISCV64SLTU: 537 return rewriteValueRISCV64_OpRISCV64SLTU(v) 538 case OpRISCV64SNEZ: 539 return rewriteValueRISCV64_OpRISCV64SNEZ(v) 540 case OpRISCV64SRA: 541 return rewriteValueRISCV64_OpRISCV64SRA(v) 542 case OpRISCV64SRAI: 543 return rewriteValueRISCV64_OpRISCV64SRAI(v) 544 case OpRISCV64SRAW: 545 return rewriteValueRISCV64_OpRISCV64SRAW(v) 546 case OpRISCV64SRL: 547 return rewriteValueRISCV64_OpRISCV64SRL(v) 548 case OpRISCV64SRLI: 549 return rewriteValueRISCV64_OpRISCV64SRLI(v) 550 case OpRISCV64SRLW: 551 return rewriteValueRISCV64_OpRISCV64SRLW(v) 552 case OpRISCV64SUB: 553 return rewriteValueRISCV64_OpRISCV64SUB(v) 554 case OpRISCV64SUBW: 555 return rewriteValueRISCV64_OpRISCV64SUBW(v) 556 case OpRISCV64XOR: 557 return rewriteValueRISCV64_OpRISCV64XOR(v) 558 case OpRotateLeft16: 559 return rewriteValueRISCV64_OpRotateLeft16(v) 560 case OpRotateLeft32: 561 return rewriteValueRISCV64_OpRotateLeft32(v) 562 case OpRotateLeft64: 563 return rewriteValueRISCV64_OpRotateLeft64(v) 564 case OpRotateLeft8: 565 return rewriteValueRISCV64_OpRotateLeft8(v) 566 case OpRound32F: 567 v.Op = OpRISCV64LoweredRound32F 568 return true 569 case OpRound64F: 570 v.Op = OpRISCV64LoweredRound64F 571 return true 572 case OpRsh16Ux16: 573 return rewriteValueRISCV64_OpRsh16Ux16(v) 574 case OpRsh16Ux32: 575 return rewriteValueRISCV64_OpRsh16Ux32(v) 576 case OpRsh16Ux64: 577 return rewriteValueRISCV64_OpRsh16Ux64(v) 578 case OpRsh16Ux8: 579 return rewriteValueRISCV64_OpRsh16Ux8(v) 580 case OpRsh16x16: 581 return rewriteValueRISCV64_OpRsh16x16(v) 582 case OpRsh16x32: 583 return rewriteValueRISCV64_OpRsh16x32(v) 584 case OpRsh16x64: 585 return rewriteValueRISCV64_OpRsh16x64(v) 586 case OpRsh16x8: 587 return rewriteValueRISCV64_OpRsh16x8(v) 588 case OpRsh32Ux16: 589 return rewriteValueRISCV64_OpRsh32Ux16(v) 590 case OpRsh32Ux32: 591 return rewriteValueRISCV64_OpRsh32Ux32(v) 592 case OpRsh32Ux64: 593 return rewriteValueRISCV64_OpRsh32Ux64(v) 594 case OpRsh32Ux8: 595 return rewriteValueRISCV64_OpRsh32Ux8(v) 596 case OpRsh32x16: 597 return rewriteValueRISCV64_OpRsh32x16(v) 598 case OpRsh32x32: 599 return rewriteValueRISCV64_OpRsh32x32(v) 600 case OpRsh32x64: 601 return rewriteValueRISCV64_OpRsh32x64(v) 602 case OpRsh32x8: 603 return rewriteValueRISCV64_OpRsh32x8(v) 604 case OpRsh64Ux16: 605 return rewriteValueRISCV64_OpRsh64Ux16(v) 606 case OpRsh64Ux32: 607 return rewriteValueRISCV64_OpRsh64Ux32(v) 608 case OpRsh64Ux64: 609 return rewriteValueRISCV64_OpRsh64Ux64(v) 610 case OpRsh64Ux8: 611 return rewriteValueRISCV64_OpRsh64Ux8(v) 612 case OpRsh64x16: 613 return rewriteValueRISCV64_OpRsh64x16(v) 614 case OpRsh64x32: 615 return rewriteValueRISCV64_OpRsh64x32(v) 616 case OpRsh64x64: 617 return rewriteValueRISCV64_OpRsh64x64(v) 618 case OpRsh64x8: 619 return rewriteValueRISCV64_OpRsh64x8(v) 620 case OpRsh8Ux16: 621 return rewriteValueRISCV64_OpRsh8Ux16(v) 622 case OpRsh8Ux32: 623 return rewriteValueRISCV64_OpRsh8Ux32(v) 624 case OpRsh8Ux64: 625 return rewriteValueRISCV64_OpRsh8Ux64(v) 626 case OpRsh8Ux8: 627 return rewriteValueRISCV64_OpRsh8Ux8(v) 628 case OpRsh8x16: 629 return rewriteValueRISCV64_OpRsh8x16(v) 630 case OpRsh8x32: 631 return rewriteValueRISCV64_OpRsh8x32(v) 632 case OpRsh8x64: 633 return rewriteValueRISCV64_OpRsh8x64(v) 634 case OpRsh8x8: 635 return rewriteValueRISCV64_OpRsh8x8(v) 636 case OpSelect0: 637 return rewriteValueRISCV64_OpSelect0(v) 638 case OpSelect1: 639 return rewriteValueRISCV64_OpSelect1(v) 640 case OpSignExt16to32: 641 v.Op = OpRISCV64MOVHreg 642 return true 643 case OpSignExt16to64: 644 v.Op = OpRISCV64MOVHreg 645 return true 646 case OpSignExt32to64: 647 v.Op = OpRISCV64MOVWreg 648 return true 649 case OpSignExt8to16: 650 v.Op = OpRISCV64MOVBreg 651 return true 652 case OpSignExt8to32: 653 v.Op = OpRISCV64MOVBreg 654 return true 655 case OpSignExt8to64: 656 v.Op = OpRISCV64MOVBreg 657 return true 658 case OpSlicemask: 659 return rewriteValueRISCV64_OpSlicemask(v) 660 case OpSqrt: 661 v.Op = OpRISCV64FSQRTD 662 return true 663 case OpSqrt32: 664 v.Op = OpRISCV64FSQRTS 665 return true 666 case OpStaticCall: 667 v.Op = OpRISCV64CALLstatic 668 return true 669 case OpStore: 670 return rewriteValueRISCV64_OpStore(v) 671 case OpSub16: 672 v.Op = OpRISCV64SUB 673 return true 674 case OpSub32: 675 v.Op = OpRISCV64SUB 676 return true 677 case OpSub32F: 678 v.Op = OpRISCV64FSUBS 679 return true 680 case OpSub64: 681 v.Op = OpRISCV64SUB 682 return true 683 case OpSub64F: 684 v.Op = OpRISCV64FSUBD 685 return true 686 case OpSub8: 687 v.Op = OpRISCV64SUB 688 return true 689 case OpSubPtr: 690 v.Op = OpRISCV64SUB 691 return true 692 case OpTailCall: 693 v.Op = OpRISCV64CALLtail 694 return true 695 case OpTrunc16to8: 696 v.Op = OpCopy 697 return true 698 case OpTrunc32to16: 699 v.Op = OpCopy 700 return true 701 case OpTrunc32to8: 702 v.Op = OpCopy 703 return true 704 case OpTrunc64to16: 705 v.Op = OpCopy 706 return true 707 case OpTrunc64to32: 708 v.Op = OpCopy 709 return true 710 case OpTrunc64to8: 711 v.Op = OpCopy 712 return true 713 case OpWB: 714 v.Op = OpRISCV64LoweredWB 715 return true 716 case OpXor16: 717 v.Op = OpRISCV64XOR 718 return true 719 case OpXor32: 720 v.Op = OpRISCV64XOR 721 return true 722 case OpXor64: 723 v.Op = OpRISCV64XOR 724 return true 725 case OpXor8: 726 v.Op = OpRISCV64XOR 727 return true 728 case OpZero: 729 return rewriteValueRISCV64_OpZero(v) 730 case OpZeroExt16to32: 731 v.Op = OpRISCV64MOVHUreg 732 return true 733 case OpZeroExt16to64: 734 v.Op = OpRISCV64MOVHUreg 735 return true 736 case OpZeroExt32to64: 737 v.Op = OpRISCV64MOVWUreg 738 return true 739 case OpZeroExt8to16: 740 v.Op = OpRISCV64MOVBUreg 741 return true 742 case OpZeroExt8to32: 743 v.Op = OpRISCV64MOVBUreg 744 return true 745 case OpZeroExt8to64: 746 v.Op = OpRISCV64MOVBUreg 747 return true 748 } 749 return false 750 } 751 func rewriteValueRISCV64_OpAddr(v *Value) bool { 752 v_0 := v.Args[0] 753 // match: (Addr {sym} base) 754 // result: (MOVaddr {sym} [0] base) 755 for { 756 sym := auxToSym(v.Aux) 757 base := v_0 758 v.reset(OpRISCV64MOVaddr) 759 v.AuxInt = int32ToAuxInt(0) 760 v.Aux = symToAux(sym) 761 v.AddArg(base) 762 return true 763 } 764 } 765 func rewriteValueRISCV64_OpAtomicAnd8(v *Value) bool { 766 v_2 := v.Args[2] 767 v_1 := v.Args[1] 768 v_0 := v.Args[0] 769 b := v.Block 770 typ := &b.Func.Config.Types 771 // match: (AtomicAnd8 ptr val mem) 772 // result: (LoweredAtomicAnd32 (ANDI <typ.Uintptr> [^3] ptr) (NOT <typ.UInt32> (SLL <typ.UInt32> (XORI <typ.UInt32> [0xff] (ZeroExt8to32 val)) (SLLI <typ.UInt64> [3] (ANDI <typ.UInt64> [3] ptr)))) mem) 773 for { 774 ptr := v_0 775 val := v_1 776 mem := v_2 777 v.reset(OpRISCV64LoweredAtomicAnd32) 778 v0 := b.NewValue0(v.Pos, OpRISCV64ANDI, typ.Uintptr) 779 v0.AuxInt = int64ToAuxInt(^3) 780 v0.AddArg(ptr) 781 v1 := b.NewValue0(v.Pos, OpRISCV64NOT, typ.UInt32) 782 v2 := b.NewValue0(v.Pos, OpRISCV64SLL, typ.UInt32) 783 v3 := b.NewValue0(v.Pos, OpRISCV64XORI, typ.UInt32) 784 v3.AuxInt = int64ToAuxInt(0xff) 785 v4 := b.NewValue0(v.Pos, OpZeroExt8to32, typ.UInt32) 786 v4.AddArg(val) 787 v3.AddArg(v4) 788 v5 := b.NewValue0(v.Pos, OpRISCV64SLLI, typ.UInt64) 789 v5.AuxInt = int64ToAuxInt(3) 790 v6 := b.NewValue0(v.Pos, OpRISCV64ANDI, typ.UInt64) 791 v6.AuxInt = int64ToAuxInt(3) 792 v6.AddArg(ptr) 793 v5.AddArg(v6) 794 v2.AddArg2(v3, v5) 795 v1.AddArg(v2) 796 v.AddArg3(v0, v1, mem) 797 return true 798 } 799 } 800 func rewriteValueRISCV64_OpAtomicCompareAndSwap32(v *Value) bool { 801 v_3 := v.Args[3] 802 v_2 := v.Args[2] 803 v_1 := v.Args[1] 804 v_0 := v.Args[0] 805 b := v.Block 806 typ := &b.Func.Config.Types 807 // match: (AtomicCompareAndSwap32 ptr old new mem) 808 // result: (LoweredAtomicCas32 ptr (SignExt32to64 old) new mem) 809 for { 810 ptr := v_0 811 old := v_1 812 new := v_2 813 mem := v_3 814 v.reset(OpRISCV64LoweredAtomicCas32) 815 v0 := b.NewValue0(v.Pos, OpSignExt32to64, typ.Int64) 816 v0.AddArg(old) 817 v.AddArg4(ptr, v0, new, mem) 818 return true 819 } 820 } 821 func rewriteValueRISCV64_OpAtomicOr8(v *Value) bool { 822 v_2 := v.Args[2] 823 v_1 := v.Args[1] 824 v_0 := v.Args[0] 825 b := v.Block 826 typ := &b.Func.Config.Types 827 // match: (AtomicOr8 ptr val mem) 828 // result: (LoweredAtomicOr32 (ANDI <typ.Uintptr> [^3] ptr) (SLL <typ.UInt32> (ZeroExt8to32 val) (SLLI <typ.UInt64> [3] (ANDI <typ.UInt64> [3] ptr))) mem) 829 for { 830 ptr := v_0 831 val := v_1 832 mem := v_2 833 v.reset(OpRISCV64LoweredAtomicOr32) 834 v0 := b.NewValue0(v.Pos, OpRISCV64ANDI, typ.Uintptr) 835 v0.AuxInt = int64ToAuxInt(^3) 836 v0.AddArg(ptr) 837 v1 := b.NewValue0(v.Pos, OpRISCV64SLL, typ.UInt32) 838 v2 := b.NewValue0(v.Pos, OpZeroExt8to32, typ.UInt32) 839 v2.AddArg(val) 840 v3 := b.NewValue0(v.Pos, OpRISCV64SLLI, typ.UInt64) 841 v3.AuxInt = int64ToAuxInt(3) 842 v4 := b.NewValue0(v.Pos, OpRISCV64ANDI, typ.UInt64) 843 v4.AuxInt = int64ToAuxInt(3) 844 v4.AddArg(ptr) 845 v3.AddArg(v4) 846 v1.AddArg2(v2, v3) 847 v.AddArg3(v0, v1, mem) 848 return true 849 } 850 } 851 func rewriteValueRISCV64_OpAvg64u(v *Value) bool { 852 v_1 := v.Args[1] 853 v_0 := v.Args[0] 854 b := v.Block 855 // match: (Avg64u <t> x y) 856 // result: (ADD (ADD <t> (SRLI <t> [1] x) (SRLI <t> [1] y)) (ANDI <t> [1] (AND <t> x y))) 857 for { 858 t := v.Type 859 x := v_0 860 y := v_1 861 v.reset(OpRISCV64ADD) 862 v0 := b.NewValue0(v.Pos, OpRISCV64ADD, t) 863 v1 := b.NewValue0(v.Pos, OpRISCV64SRLI, t) 864 v1.AuxInt = int64ToAuxInt(1) 865 v1.AddArg(x) 866 v2 := b.NewValue0(v.Pos, OpRISCV64SRLI, t) 867 v2.AuxInt = int64ToAuxInt(1) 868 v2.AddArg(y) 869 v0.AddArg2(v1, v2) 870 v3 := b.NewValue0(v.Pos, OpRISCV64ANDI, t) 871 v3.AuxInt = int64ToAuxInt(1) 872 v4 := b.NewValue0(v.Pos, OpRISCV64AND, t) 873 v4.AddArg2(x, y) 874 v3.AddArg(v4) 875 v.AddArg2(v0, v3) 876 return true 877 } 878 } 879 func rewriteValueRISCV64_OpConst16(v *Value) bool { 880 // match: (Const16 [val]) 881 // result: (MOVDconst [int64(val)]) 882 for { 883 val := auxIntToInt16(v.AuxInt) 884 v.reset(OpRISCV64MOVDconst) 885 v.AuxInt = int64ToAuxInt(int64(val)) 886 return true 887 } 888 } 889 func rewriteValueRISCV64_OpConst32(v *Value) bool { 890 // match: (Const32 [val]) 891 // result: (MOVDconst [int64(val)]) 892 for { 893 val := auxIntToInt32(v.AuxInt) 894 v.reset(OpRISCV64MOVDconst) 895 v.AuxInt = int64ToAuxInt(int64(val)) 896 return true 897 } 898 } 899 func rewriteValueRISCV64_OpConst32F(v *Value) bool { 900 b := v.Block 901 typ := &b.Func.Config.Types 902 // match: (Const32F [val]) 903 // result: (FMVSX (MOVDconst [int64(math.Float32bits(val))])) 904 for { 905 val := auxIntToFloat32(v.AuxInt) 906 v.reset(OpRISCV64FMVSX) 907 v0 := b.NewValue0(v.Pos, OpRISCV64MOVDconst, typ.UInt64) 908 v0.AuxInt = int64ToAuxInt(int64(math.Float32bits(val))) 909 v.AddArg(v0) 910 return true 911 } 912 } 913 func rewriteValueRISCV64_OpConst64(v *Value) bool { 914 // match: (Const64 [val]) 915 // result: (MOVDconst [int64(val)]) 916 for { 917 val := auxIntToInt64(v.AuxInt) 918 v.reset(OpRISCV64MOVDconst) 919 v.AuxInt = int64ToAuxInt(int64(val)) 920 return true 921 } 922 } 923 func rewriteValueRISCV64_OpConst64F(v *Value) bool { 924 b := v.Block 925 typ := &b.Func.Config.Types 926 // match: (Const64F [val]) 927 // result: (FMVDX (MOVDconst [int64(math.Float64bits(val))])) 928 for { 929 val := auxIntToFloat64(v.AuxInt) 930 v.reset(OpRISCV64FMVDX) 931 v0 := b.NewValue0(v.Pos, OpRISCV64MOVDconst, typ.UInt64) 932 v0.AuxInt = int64ToAuxInt(int64(math.Float64bits(val))) 933 v.AddArg(v0) 934 return true 935 } 936 } 937 func rewriteValueRISCV64_OpConst8(v *Value) bool { 938 // match: (Const8 [val]) 939 // result: (MOVDconst [int64(val)]) 940 for { 941 val := auxIntToInt8(v.AuxInt) 942 v.reset(OpRISCV64MOVDconst) 943 v.AuxInt = int64ToAuxInt(int64(val)) 944 return true 945 } 946 } 947 func rewriteValueRISCV64_OpConstBool(v *Value) bool { 948 // match: (ConstBool [val]) 949 // result: (MOVDconst [int64(b2i(val))]) 950 for { 951 val := auxIntToBool(v.AuxInt) 952 v.reset(OpRISCV64MOVDconst) 953 v.AuxInt = int64ToAuxInt(int64(b2i(val))) 954 return true 955 } 956 } 957 func rewriteValueRISCV64_OpConstNil(v *Value) bool { 958 // match: (ConstNil) 959 // result: (MOVDconst [0]) 960 for { 961 v.reset(OpRISCV64MOVDconst) 962 v.AuxInt = int64ToAuxInt(0) 963 return true 964 } 965 } 966 func rewriteValueRISCV64_OpDiv16(v *Value) bool { 967 v_1 := v.Args[1] 968 v_0 := v.Args[0] 969 b := v.Block 970 typ := &b.Func.Config.Types 971 // match: (Div16 x y [false]) 972 // result: (DIVW (SignExt16to32 x) (SignExt16to32 y)) 973 for { 974 if auxIntToBool(v.AuxInt) != false { 975 break 976 } 977 x := v_0 978 y := v_1 979 v.reset(OpRISCV64DIVW) 980 v0 := b.NewValue0(v.Pos, OpSignExt16to32, typ.Int32) 981 v0.AddArg(x) 982 v1 := b.NewValue0(v.Pos, OpSignExt16to32, typ.Int32) 983 v1.AddArg(y) 984 v.AddArg2(v0, v1) 985 return true 986 } 987 return false 988 } 989 func rewriteValueRISCV64_OpDiv16u(v *Value) bool { 990 v_1 := v.Args[1] 991 v_0 := v.Args[0] 992 b := v.Block 993 typ := &b.Func.Config.Types 994 // match: (Div16u x y) 995 // result: (DIVUW (ZeroExt16to32 x) (ZeroExt16to32 y)) 996 for { 997 x := v_0 998 y := v_1 999 v.reset(OpRISCV64DIVUW) 1000 v0 := b.NewValue0(v.Pos, OpZeroExt16to32, typ.UInt32) 1001 v0.AddArg(x) 1002 v1 := b.NewValue0(v.Pos, OpZeroExt16to32, typ.UInt32) 1003 v1.AddArg(y) 1004 v.AddArg2(v0, v1) 1005 return true 1006 } 1007 } 1008 func rewriteValueRISCV64_OpDiv32(v *Value) bool { 1009 v_1 := v.Args[1] 1010 v_0 := v.Args[0] 1011 // match: (Div32 x y [false]) 1012 // result: (DIVW x y) 1013 for { 1014 if auxIntToBool(v.AuxInt) != false { 1015 break 1016 } 1017 x := v_0 1018 y := v_1 1019 v.reset(OpRISCV64DIVW) 1020 v.AddArg2(x, y) 1021 return true 1022 } 1023 return false 1024 } 1025 func rewriteValueRISCV64_OpDiv64(v *Value) bool { 1026 v_1 := v.Args[1] 1027 v_0 := v.Args[0] 1028 // match: (Div64 x y [false]) 1029 // result: (DIV x y) 1030 for { 1031 if auxIntToBool(v.AuxInt) != false { 1032 break 1033 } 1034 x := v_0 1035 y := v_1 1036 v.reset(OpRISCV64DIV) 1037 v.AddArg2(x, y) 1038 return true 1039 } 1040 return false 1041 } 1042 func rewriteValueRISCV64_OpDiv8(v *Value) bool { 1043 v_1 := v.Args[1] 1044 v_0 := v.Args[0] 1045 b := v.Block 1046 typ := &b.Func.Config.Types 1047 // match: (Div8 x y) 1048 // result: (DIVW (SignExt8to32 x) (SignExt8to32 y)) 1049 for { 1050 x := v_0 1051 y := v_1 1052 v.reset(OpRISCV64DIVW) 1053 v0 := b.NewValue0(v.Pos, OpSignExt8to32, typ.Int32) 1054 v0.AddArg(x) 1055 v1 := b.NewValue0(v.Pos, OpSignExt8to32, typ.Int32) 1056 v1.AddArg(y) 1057 v.AddArg2(v0, v1) 1058 return true 1059 } 1060 } 1061 func rewriteValueRISCV64_OpDiv8u(v *Value) bool { 1062 v_1 := v.Args[1] 1063 v_0 := v.Args[0] 1064 b := v.Block 1065 typ := &b.Func.Config.Types 1066 // match: (Div8u x y) 1067 // result: (DIVUW (ZeroExt8to32 x) (ZeroExt8to32 y)) 1068 for { 1069 x := v_0 1070 y := v_1 1071 v.reset(OpRISCV64DIVUW) 1072 v0 := b.NewValue0(v.Pos, OpZeroExt8to32, typ.UInt32) 1073 v0.AddArg(x) 1074 v1 := b.NewValue0(v.Pos, OpZeroExt8to32, typ.UInt32) 1075 v1.AddArg(y) 1076 v.AddArg2(v0, v1) 1077 return true 1078 } 1079 } 1080 func rewriteValueRISCV64_OpEq16(v *Value) bool { 1081 v_1 := v.Args[1] 1082 v_0 := v.Args[0] 1083 b := v.Block 1084 typ := &b.Func.Config.Types 1085 // match: (Eq16 x y) 1086 // result: (SEQZ (SUB <x.Type> (ZeroExt16to64 x) (ZeroExt16to64 y))) 1087 for { 1088 x := v_0 1089 y := v_1 1090 v.reset(OpRISCV64SEQZ) 1091 v0 := b.NewValue0(v.Pos, OpRISCV64SUB, x.Type) 1092 v1 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) 1093 v1.AddArg(x) 1094 v2 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) 1095 v2.AddArg(y) 1096 v0.AddArg2(v1, v2) 1097 v.AddArg(v0) 1098 return true 1099 } 1100 } 1101 func rewriteValueRISCV64_OpEq32(v *Value) bool { 1102 v_1 := v.Args[1] 1103 v_0 := v.Args[0] 1104 b := v.Block 1105 typ := &b.Func.Config.Types 1106 // match: (Eq32 x y) 1107 // cond: x.Type.IsSigned() 1108 // result: (SEQZ (SUB <x.Type> (SignExt32to64 x) (SignExt32to64 y))) 1109 for { 1110 for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { 1111 x := v_0 1112 y := v_1 1113 if !(x.Type.IsSigned()) { 1114 continue 1115 } 1116 v.reset(OpRISCV64SEQZ) 1117 v0 := b.NewValue0(v.Pos, OpRISCV64SUB, x.Type) 1118 v1 := b.NewValue0(v.Pos, OpSignExt32to64, typ.Int64) 1119 v1.AddArg(x) 1120 v2 := b.NewValue0(v.Pos, OpSignExt32to64, typ.Int64) 1121 v2.AddArg(y) 1122 v0.AddArg2(v1, v2) 1123 v.AddArg(v0) 1124 return true 1125 } 1126 break 1127 } 1128 // match: (Eq32 x y) 1129 // cond: !x.Type.IsSigned() 1130 // result: (SEQZ (SUB <x.Type> (ZeroExt32to64 x) (ZeroExt32to64 y))) 1131 for { 1132 for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { 1133 x := v_0 1134 y := v_1 1135 if !(!x.Type.IsSigned()) { 1136 continue 1137 } 1138 v.reset(OpRISCV64SEQZ) 1139 v0 := b.NewValue0(v.Pos, OpRISCV64SUB, x.Type) 1140 v1 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) 1141 v1.AddArg(x) 1142 v2 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) 1143 v2.AddArg(y) 1144 v0.AddArg2(v1, v2) 1145 v.AddArg(v0) 1146 return true 1147 } 1148 break 1149 } 1150 return false 1151 } 1152 func rewriteValueRISCV64_OpEq64(v *Value) bool { 1153 v_1 := v.Args[1] 1154 v_0 := v.Args[0] 1155 b := v.Block 1156 // match: (Eq64 x y) 1157 // result: (SEQZ (SUB <x.Type> x y)) 1158 for { 1159 x := v_0 1160 y := v_1 1161 v.reset(OpRISCV64SEQZ) 1162 v0 := b.NewValue0(v.Pos, OpRISCV64SUB, x.Type) 1163 v0.AddArg2(x, y) 1164 v.AddArg(v0) 1165 return true 1166 } 1167 } 1168 func rewriteValueRISCV64_OpEq8(v *Value) bool { 1169 v_1 := v.Args[1] 1170 v_0 := v.Args[0] 1171 b := v.Block 1172 typ := &b.Func.Config.Types 1173 // match: (Eq8 x y) 1174 // result: (SEQZ (SUB <x.Type> (ZeroExt8to64 x) (ZeroExt8to64 y))) 1175 for { 1176 x := v_0 1177 y := v_1 1178 v.reset(OpRISCV64SEQZ) 1179 v0 := b.NewValue0(v.Pos, OpRISCV64SUB, x.Type) 1180 v1 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) 1181 v1.AddArg(x) 1182 v2 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) 1183 v2.AddArg(y) 1184 v0.AddArg2(v1, v2) 1185 v.AddArg(v0) 1186 return true 1187 } 1188 } 1189 func rewriteValueRISCV64_OpEqB(v *Value) bool { 1190 v_1 := v.Args[1] 1191 v_0 := v.Args[0] 1192 b := v.Block 1193 typ := &b.Func.Config.Types 1194 // match: (EqB x y) 1195 // result: (SEQZ (SUB <typ.Bool> x y)) 1196 for { 1197 x := v_0 1198 y := v_1 1199 v.reset(OpRISCV64SEQZ) 1200 v0 := b.NewValue0(v.Pos, OpRISCV64SUB, typ.Bool) 1201 v0.AddArg2(x, y) 1202 v.AddArg(v0) 1203 return true 1204 } 1205 } 1206 func rewriteValueRISCV64_OpEqPtr(v *Value) bool { 1207 v_1 := v.Args[1] 1208 v_0 := v.Args[0] 1209 b := v.Block 1210 typ := &b.Func.Config.Types 1211 // match: (EqPtr x y) 1212 // result: (SEQZ (SUB <typ.Uintptr> x y)) 1213 for { 1214 x := v_0 1215 y := v_1 1216 v.reset(OpRISCV64SEQZ) 1217 v0 := b.NewValue0(v.Pos, OpRISCV64SUB, typ.Uintptr) 1218 v0.AddArg2(x, y) 1219 v.AddArg(v0) 1220 return true 1221 } 1222 } 1223 func rewriteValueRISCV64_OpHmul32(v *Value) bool { 1224 v_1 := v.Args[1] 1225 v_0 := v.Args[0] 1226 b := v.Block 1227 typ := &b.Func.Config.Types 1228 // match: (Hmul32 x y) 1229 // result: (SRAI [32] (MUL (SignExt32to64 x) (SignExt32to64 y))) 1230 for { 1231 x := v_0 1232 y := v_1 1233 v.reset(OpRISCV64SRAI) 1234 v.AuxInt = int64ToAuxInt(32) 1235 v0 := b.NewValue0(v.Pos, OpRISCV64MUL, typ.Int64) 1236 v1 := b.NewValue0(v.Pos, OpSignExt32to64, typ.Int64) 1237 v1.AddArg(x) 1238 v2 := b.NewValue0(v.Pos, OpSignExt32to64, typ.Int64) 1239 v2.AddArg(y) 1240 v0.AddArg2(v1, v2) 1241 v.AddArg(v0) 1242 return true 1243 } 1244 } 1245 func rewriteValueRISCV64_OpHmul32u(v *Value) bool { 1246 v_1 := v.Args[1] 1247 v_0 := v.Args[0] 1248 b := v.Block 1249 typ := &b.Func.Config.Types 1250 // match: (Hmul32u x y) 1251 // result: (SRLI [32] (MUL (ZeroExt32to64 x) (ZeroExt32to64 y))) 1252 for { 1253 x := v_0 1254 y := v_1 1255 v.reset(OpRISCV64SRLI) 1256 v.AuxInt = int64ToAuxInt(32) 1257 v0 := b.NewValue0(v.Pos, OpRISCV64MUL, typ.Int64) 1258 v1 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) 1259 v1.AddArg(x) 1260 v2 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) 1261 v2.AddArg(y) 1262 v0.AddArg2(v1, v2) 1263 v.AddArg(v0) 1264 return true 1265 } 1266 } 1267 func rewriteValueRISCV64_OpLeq16(v *Value) bool { 1268 v_1 := v.Args[1] 1269 v_0 := v.Args[0] 1270 b := v.Block 1271 typ := &b.Func.Config.Types 1272 // match: (Leq16 x y) 1273 // result: (Not (Less16 y x)) 1274 for { 1275 x := v_0 1276 y := v_1 1277 v.reset(OpNot) 1278 v0 := b.NewValue0(v.Pos, OpLess16, typ.Bool) 1279 v0.AddArg2(y, x) 1280 v.AddArg(v0) 1281 return true 1282 } 1283 } 1284 func rewriteValueRISCV64_OpLeq16U(v *Value) bool { 1285 v_1 := v.Args[1] 1286 v_0 := v.Args[0] 1287 b := v.Block 1288 typ := &b.Func.Config.Types 1289 // match: (Leq16U x y) 1290 // result: (Not (Less16U y x)) 1291 for { 1292 x := v_0 1293 y := v_1 1294 v.reset(OpNot) 1295 v0 := b.NewValue0(v.Pos, OpLess16U, typ.Bool) 1296 v0.AddArg2(y, x) 1297 v.AddArg(v0) 1298 return true 1299 } 1300 } 1301 func rewriteValueRISCV64_OpLeq32(v *Value) bool { 1302 v_1 := v.Args[1] 1303 v_0 := v.Args[0] 1304 b := v.Block 1305 typ := &b.Func.Config.Types 1306 // match: (Leq32 x y) 1307 // result: (Not (Less32 y x)) 1308 for { 1309 x := v_0 1310 y := v_1 1311 v.reset(OpNot) 1312 v0 := b.NewValue0(v.Pos, OpLess32, typ.Bool) 1313 v0.AddArg2(y, x) 1314 v.AddArg(v0) 1315 return true 1316 } 1317 } 1318 func rewriteValueRISCV64_OpLeq32U(v *Value) bool { 1319 v_1 := v.Args[1] 1320 v_0 := v.Args[0] 1321 b := v.Block 1322 typ := &b.Func.Config.Types 1323 // match: (Leq32U x y) 1324 // result: (Not (Less32U y x)) 1325 for { 1326 x := v_0 1327 y := v_1 1328 v.reset(OpNot) 1329 v0 := b.NewValue0(v.Pos, OpLess32U, typ.Bool) 1330 v0.AddArg2(y, x) 1331 v.AddArg(v0) 1332 return true 1333 } 1334 } 1335 func rewriteValueRISCV64_OpLeq64(v *Value) bool { 1336 v_1 := v.Args[1] 1337 v_0 := v.Args[0] 1338 b := v.Block 1339 typ := &b.Func.Config.Types 1340 // match: (Leq64 x y) 1341 // result: (Not (Less64 y x)) 1342 for { 1343 x := v_0 1344 y := v_1 1345 v.reset(OpNot) 1346 v0 := b.NewValue0(v.Pos, OpLess64, typ.Bool) 1347 v0.AddArg2(y, x) 1348 v.AddArg(v0) 1349 return true 1350 } 1351 } 1352 func rewriteValueRISCV64_OpLeq64U(v *Value) bool { 1353 v_1 := v.Args[1] 1354 v_0 := v.Args[0] 1355 b := v.Block 1356 typ := &b.Func.Config.Types 1357 // match: (Leq64U x y) 1358 // result: (Not (Less64U y x)) 1359 for { 1360 x := v_0 1361 y := v_1 1362 v.reset(OpNot) 1363 v0 := b.NewValue0(v.Pos, OpLess64U, typ.Bool) 1364 v0.AddArg2(y, x) 1365 v.AddArg(v0) 1366 return true 1367 } 1368 } 1369 func rewriteValueRISCV64_OpLeq8(v *Value) bool { 1370 v_1 := v.Args[1] 1371 v_0 := v.Args[0] 1372 b := v.Block 1373 typ := &b.Func.Config.Types 1374 // match: (Leq8 x y) 1375 // result: (Not (Less8 y x)) 1376 for { 1377 x := v_0 1378 y := v_1 1379 v.reset(OpNot) 1380 v0 := b.NewValue0(v.Pos, OpLess8, typ.Bool) 1381 v0.AddArg2(y, x) 1382 v.AddArg(v0) 1383 return true 1384 } 1385 } 1386 func rewriteValueRISCV64_OpLeq8U(v *Value) bool { 1387 v_1 := v.Args[1] 1388 v_0 := v.Args[0] 1389 b := v.Block 1390 typ := &b.Func.Config.Types 1391 // match: (Leq8U x y) 1392 // result: (Not (Less8U y x)) 1393 for { 1394 x := v_0 1395 y := v_1 1396 v.reset(OpNot) 1397 v0 := b.NewValue0(v.Pos, OpLess8U, typ.Bool) 1398 v0.AddArg2(y, x) 1399 v.AddArg(v0) 1400 return true 1401 } 1402 } 1403 func rewriteValueRISCV64_OpLess16(v *Value) bool { 1404 v_1 := v.Args[1] 1405 v_0 := v.Args[0] 1406 b := v.Block 1407 typ := &b.Func.Config.Types 1408 // match: (Less16 x y) 1409 // result: (SLT (SignExt16to64 x) (SignExt16to64 y)) 1410 for { 1411 x := v_0 1412 y := v_1 1413 v.reset(OpRISCV64SLT) 1414 v0 := b.NewValue0(v.Pos, OpSignExt16to64, typ.Int64) 1415 v0.AddArg(x) 1416 v1 := b.NewValue0(v.Pos, OpSignExt16to64, typ.Int64) 1417 v1.AddArg(y) 1418 v.AddArg2(v0, v1) 1419 return true 1420 } 1421 } 1422 func rewriteValueRISCV64_OpLess16U(v *Value) bool { 1423 v_1 := v.Args[1] 1424 v_0 := v.Args[0] 1425 b := v.Block 1426 typ := &b.Func.Config.Types 1427 // match: (Less16U x y) 1428 // result: (SLTU (ZeroExt16to64 x) (ZeroExt16to64 y)) 1429 for { 1430 x := v_0 1431 y := v_1 1432 v.reset(OpRISCV64SLTU) 1433 v0 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) 1434 v0.AddArg(x) 1435 v1 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) 1436 v1.AddArg(y) 1437 v.AddArg2(v0, v1) 1438 return true 1439 } 1440 } 1441 func rewriteValueRISCV64_OpLess32(v *Value) bool { 1442 v_1 := v.Args[1] 1443 v_0 := v.Args[0] 1444 b := v.Block 1445 typ := &b.Func.Config.Types 1446 // match: (Less32 x y) 1447 // result: (SLT (SignExt32to64 x) (SignExt32to64 y)) 1448 for { 1449 x := v_0 1450 y := v_1 1451 v.reset(OpRISCV64SLT) 1452 v0 := b.NewValue0(v.Pos, OpSignExt32to64, typ.Int64) 1453 v0.AddArg(x) 1454 v1 := b.NewValue0(v.Pos, OpSignExt32to64, typ.Int64) 1455 v1.AddArg(y) 1456 v.AddArg2(v0, v1) 1457 return true 1458 } 1459 } 1460 func rewriteValueRISCV64_OpLess32U(v *Value) bool { 1461 v_1 := v.Args[1] 1462 v_0 := v.Args[0] 1463 b := v.Block 1464 typ := &b.Func.Config.Types 1465 // match: (Less32U x y) 1466 // result: (SLTU (ZeroExt32to64 x) (ZeroExt32to64 y)) 1467 for { 1468 x := v_0 1469 y := v_1 1470 v.reset(OpRISCV64SLTU) 1471 v0 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) 1472 v0.AddArg(x) 1473 v1 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) 1474 v1.AddArg(y) 1475 v.AddArg2(v0, v1) 1476 return true 1477 } 1478 } 1479 func rewriteValueRISCV64_OpLess8(v *Value) bool { 1480 v_1 := v.Args[1] 1481 v_0 := v.Args[0] 1482 b := v.Block 1483 typ := &b.Func.Config.Types 1484 // match: (Less8 x y) 1485 // result: (SLT (SignExt8to64 x) (SignExt8to64 y)) 1486 for { 1487 x := v_0 1488 y := v_1 1489 v.reset(OpRISCV64SLT) 1490 v0 := b.NewValue0(v.Pos, OpSignExt8to64, typ.Int64) 1491 v0.AddArg(x) 1492 v1 := b.NewValue0(v.Pos, OpSignExt8to64, typ.Int64) 1493 v1.AddArg(y) 1494 v.AddArg2(v0, v1) 1495 return true 1496 } 1497 } 1498 func rewriteValueRISCV64_OpLess8U(v *Value) bool { 1499 v_1 := v.Args[1] 1500 v_0 := v.Args[0] 1501 b := v.Block 1502 typ := &b.Func.Config.Types 1503 // match: (Less8U x y) 1504 // result: (SLTU (ZeroExt8to64 x) (ZeroExt8to64 y)) 1505 for { 1506 x := v_0 1507 y := v_1 1508 v.reset(OpRISCV64SLTU) 1509 v0 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) 1510 v0.AddArg(x) 1511 v1 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) 1512 v1.AddArg(y) 1513 v.AddArg2(v0, v1) 1514 return true 1515 } 1516 } 1517 func rewriteValueRISCV64_OpLoad(v *Value) bool { 1518 v_1 := v.Args[1] 1519 v_0 := v.Args[0] 1520 // match: (Load <t> ptr mem) 1521 // cond: t.IsBoolean() 1522 // result: (MOVBUload ptr mem) 1523 for { 1524 t := v.Type 1525 ptr := v_0 1526 mem := v_1 1527 if !(t.IsBoolean()) { 1528 break 1529 } 1530 v.reset(OpRISCV64MOVBUload) 1531 v.AddArg2(ptr, mem) 1532 return true 1533 } 1534 // match: (Load <t> ptr mem) 1535 // cond: ( is8BitInt(t) && t.IsSigned()) 1536 // result: (MOVBload ptr mem) 1537 for { 1538 t := v.Type 1539 ptr := v_0 1540 mem := v_1 1541 if !(is8BitInt(t) && t.IsSigned()) { 1542 break 1543 } 1544 v.reset(OpRISCV64MOVBload) 1545 v.AddArg2(ptr, mem) 1546 return true 1547 } 1548 // match: (Load <t> ptr mem) 1549 // cond: ( is8BitInt(t) && !t.IsSigned()) 1550 // result: (MOVBUload ptr mem) 1551 for { 1552 t := v.Type 1553 ptr := v_0 1554 mem := v_1 1555 if !(is8BitInt(t) && !t.IsSigned()) { 1556 break 1557 } 1558 v.reset(OpRISCV64MOVBUload) 1559 v.AddArg2(ptr, mem) 1560 return true 1561 } 1562 // match: (Load <t> ptr mem) 1563 // cond: (is16BitInt(t) && t.IsSigned()) 1564 // result: (MOVHload ptr mem) 1565 for { 1566 t := v.Type 1567 ptr := v_0 1568 mem := v_1 1569 if !(is16BitInt(t) && t.IsSigned()) { 1570 break 1571 } 1572 v.reset(OpRISCV64MOVHload) 1573 v.AddArg2(ptr, mem) 1574 return true 1575 } 1576 // match: (Load <t> ptr mem) 1577 // cond: (is16BitInt(t) && !t.IsSigned()) 1578 // result: (MOVHUload ptr mem) 1579 for { 1580 t := v.Type 1581 ptr := v_0 1582 mem := v_1 1583 if !(is16BitInt(t) && !t.IsSigned()) { 1584 break 1585 } 1586 v.reset(OpRISCV64MOVHUload) 1587 v.AddArg2(ptr, mem) 1588 return true 1589 } 1590 // match: (Load <t> ptr mem) 1591 // cond: (is32BitInt(t) && t.IsSigned()) 1592 // result: (MOVWload ptr mem) 1593 for { 1594 t := v.Type 1595 ptr := v_0 1596 mem := v_1 1597 if !(is32BitInt(t) && t.IsSigned()) { 1598 break 1599 } 1600 v.reset(OpRISCV64MOVWload) 1601 v.AddArg2(ptr, mem) 1602 return true 1603 } 1604 // match: (Load <t> ptr mem) 1605 // cond: (is32BitInt(t) && !t.IsSigned()) 1606 // result: (MOVWUload ptr mem) 1607 for { 1608 t := v.Type 1609 ptr := v_0 1610 mem := v_1 1611 if !(is32BitInt(t) && !t.IsSigned()) { 1612 break 1613 } 1614 v.reset(OpRISCV64MOVWUload) 1615 v.AddArg2(ptr, mem) 1616 return true 1617 } 1618 // match: (Load <t> ptr mem) 1619 // cond: (is64BitInt(t) || isPtr(t)) 1620 // result: (MOVDload ptr mem) 1621 for { 1622 t := v.Type 1623 ptr := v_0 1624 mem := v_1 1625 if !(is64BitInt(t) || isPtr(t)) { 1626 break 1627 } 1628 v.reset(OpRISCV64MOVDload) 1629 v.AddArg2(ptr, mem) 1630 return true 1631 } 1632 // match: (Load <t> ptr mem) 1633 // cond: is32BitFloat(t) 1634 // result: (FMOVWload ptr mem) 1635 for { 1636 t := v.Type 1637 ptr := v_0 1638 mem := v_1 1639 if !(is32BitFloat(t)) { 1640 break 1641 } 1642 v.reset(OpRISCV64FMOVWload) 1643 v.AddArg2(ptr, mem) 1644 return true 1645 } 1646 // match: (Load <t> ptr mem) 1647 // cond: is64BitFloat(t) 1648 // result: (FMOVDload ptr mem) 1649 for { 1650 t := v.Type 1651 ptr := v_0 1652 mem := v_1 1653 if !(is64BitFloat(t)) { 1654 break 1655 } 1656 v.reset(OpRISCV64FMOVDload) 1657 v.AddArg2(ptr, mem) 1658 return true 1659 } 1660 return false 1661 } 1662 func rewriteValueRISCV64_OpLocalAddr(v *Value) bool { 1663 v_1 := v.Args[1] 1664 v_0 := v.Args[0] 1665 b := v.Block 1666 typ := &b.Func.Config.Types 1667 // match: (LocalAddr <t> {sym} base mem) 1668 // cond: t.Elem().HasPointers() 1669 // result: (MOVaddr {sym} (SPanchored base mem)) 1670 for { 1671 t := v.Type 1672 sym := auxToSym(v.Aux) 1673 base := v_0 1674 mem := v_1 1675 if !(t.Elem().HasPointers()) { 1676 break 1677 } 1678 v.reset(OpRISCV64MOVaddr) 1679 v.Aux = symToAux(sym) 1680 v0 := b.NewValue0(v.Pos, OpSPanchored, typ.Uintptr) 1681 v0.AddArg2(base, mem) 1682 v.AddArg(v0) 1683 return true 1684 } 1685 // match: (LocalAddr <t> {sym} base _) 1686 // cond: !t.Elem().HasPointers() 1687 // result: (MOVaddr {sym} base) 1688 for { 1689 t := v.Type 1690 sym := auxToSym(v.Aux) 1691 base := v_0 1692 if !(!t.Elem().HasPointers()) { 1693 break 1694 } 1695 v.reset(OpRISCV64MOVaddr) 1696 v.Aux = symToAux(sym) 1697 v.AddArg(base) 1698 return true 1699 } 1700 return false 1701 } 1702 func rewriteValueRISCV64_OpLsh16x16(v *Value) bool { 1703 v_1 := v.Args[1] 1704 v_0 := v.Args[0] 1705 b := v.Block 1706 typ := &b.Func.Config.Types 1707 // match: (Lsh16x16 <t> x y) 1708 // cond: !shiftIsBounded(v) 1709 // result: (AND (SLL <t> x y) (Neg16 <t> (SLTIU <t> [64] (ZeroExt16to64 y)))) 1710 for { 1711 t := v.Type 1712 x := v_0 1713 y := v_1 1714 if !(!shiftIsBounded(v)) { 1715 break 1716 } 1717 v.reset(OpRISCV64AND) 1718 v0 := b.NewValue0(v.Pos, OpRISCV64SLL, t) 1719 v0.AddArg2(x, y) 1720 v1 := b.NewValue0(v.Pos, OpNeg16, t) 1721 v2 := b.NewValue0(v.Pos, OpRISCV64SLTIU, t) 1722 v2.AuxInt = int64ToAuxInt(64) 1723 v3 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) 1724 v3.AddArg(y) 1725 v2.AddArg(v3) 1726 v1.AddArg(v2) 1727 v.AddArg2(v0, v1) 1728 return true 1729 } 1730 // match: (Lsh16x16 x y) 1731 // cond: shiftIsBounded(v) 1732 // result: (SLL x y) 1733 for { 1734 x := v_0 1735 y := v_1 1736 if !(shiftIsBounded(v)) { 1737 break 1738 } 1739 v.reset(OpRISCV64SLL) 1740 v.AddArg2(x, y) 1741 return true 1742 } 1743 return false 1744 } 1745 func rewriteValueRISCV64_OpLsh16x32(v *Value) bool { 1746 v_1 := v.Args[1] 1747 v_0 := v.Args[0] 1748 b := v.Block 1749 typ := &b.Func.Config.Types 1750 // match: (Lsh16x32 <t> x y) 1751 // cond: !shiftIsBounded(v) 1752 // result: (AND (SLL <t> x y) (Neg16 <t> (SLTIU <t> [64] (ZeroExt32to64 y)))) 1753 for { 1754 t := v.Type 1755 x := v_0 1756 y := v_1 1757 if !(!shiftIsBounded(v)) { 1758 break 1759 } 1760 v.reset(OpRISCV64AND) 1761 v0 := b.NewValue0(v.Pos, OpRISCV64SLL, t) 1762 v0.AddArg2(x, y) 1763 v1 := b.NewValue0(v.Pos, OpNeg16, t) 1764 v2 := b.NewValue0(v.Pos, OpRISCV64SLTIU, t) 1765 v2.AuxInt = int64ToAuxInt(64) 1766 v3 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) 1767 v3.AddArg(y) 1768 v2.AddArg(v3) 1769 v1.AddArg(v2) 1770 v.AddArg2(v0, v1) 1771 return true 1772 } 1773 // match: (Lsh16x32 x y) 1774 // cond: shiftIsBounded(v) 1775 // result: (SLL x y) 1776 for { 1777 x := v_0 1778 y := v_1 1779 if !(shiftIsBounded(v)) { 1780 break 1781 } 1782 v.reset(OpRISCV64SLL) 1783 v.AddArg2(x, y) 1784 return true 1785 } 1786 return false 1787 } 1788 func rewriteValueRISCV64_OpLsh16x64(v *Value) bool { 1789 v_1 := v.Args[1] 1790 v_0 := v.Args[0] 1791 b := v.Block 1792 // match: (Lsh16x64 <t> x y) 1793 // cond: !shiftIsBounded(v) 1794 // result: (AND (SLL <t> x y) (Neg16 <t> (SLTIU <t> [64] y))) 1795 for { 1796 t := v.Type 1797 x := v_0 1798 y := v_1 1799 if !(!shiftIsBounded(v)) { 1800 break 1801 } 1802 v.reset(OpRISCV64AND) 1803 v0 := b.NewValue0(v.Pos, OpRISCV64SLL, t) 1804 v0.AddArg2(x, y) 1805 v1 := b.NewValue0(v.Pos, OpNeg16, t) 1806 v2 := b.NewValue0(v.Pos, OpRISCV64SLTIU, t) 1807 v2.AuxInt = int64ToAuxInt(64) 1808 v2.AddArg(y) 1809 v1.AddArg(v2) 1810 v.AddArg2(v0, v1) 1811 return true 1812 } 1813 // match: (Lsh16x64 x y) 1814 // cond: shiftIsBounded(v) 1815 // result: (SLL x y) 1816 for { 1817 x := v_0 1818 y := v_1 1819 if !(shiftIsBounded(v)) { 1820 break 1821 } 1822 v.reset(OpRISCV64SLL) 1823 v.AddArg2(x, y) 1824 return true 1825 } 1826 return false 1827 } 1828 func rewriteValueRISCV64_OpLsh16x8(v *Value) bool { 1829 v_1 := v.Args[1] 1830 v_0 := v.Args[0] 1831 b := v.Block 1832 typ := &b.Func.Config.Types 1833 // match: (Lsh16x8 <t> x y) 1834 // cond: !shiftIsBounded(v) 1835 // result: (AND (SLL <t> x y) (Neg16 <t> (SLTIU <t> [64] (ZeroExt8to64 y)))) 1836 for { 1837 t := v.Type 1838 x := v_0 1839 y := v_1 1840 if !(!shiftIsBounded(v)) { 1841 break 1842 } 1843 v.reset(OpRISCV64AND) 1844 v0 := b.NewValue0(v.Pos, OpRISCV64SLL, t) 1845 v0.AddArg2(x, y) 1846 v1 := b.NewValue0(v.Pos, OpNeg16, t) 1847 v2 := b.NewValue0(v.Pos, OpRISCV64SLTIU, t) 1848 v2.AuxInt = int64ToAuxInt(64) 1849 v3 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) 1850 v3.AddArg(y) 1851 v2.AddArg(v3) 1852 v1.AddArg(v2) 1853 v.AddArg2(v0, v1) 1854 return true 1855 } 1856 // match: (Lsh16x8 x y) 1857 // cond: shiftIsBounded(v) 1858 // result: (SLL x y) 1859 for { 1860 x := v_0 1861 y := v_1 1862 if !(shiftIsBounded(v)) { 1863 break 1864 } 1865 v.reset(OpRISCV64SLL) 1866 v.AddArg2(x, y) 1867 return true 1868 } 1869 return false 1870 } 1871 func rewriteValueRISCV64_OpLsh32x16(v *Value) bool { 1872 v_1 := v.Args[1] 1873 v_0 := v.Args[0] 1874 b := v.Block 1875 typ := &b.Func.Config.Types 1876 // match: (Lsh32x16 <t> x y) 1877 // cond: !shiftIsBounded(v) 1878 // result: (AND (SLL <t> x y) (Neg32 <t> (SLTIU <t> [64] (ZeroExt16to64 y)))) 1879 for { 1880 t := v.Type 1881 x := v_0 1882 y := v_1 1883 if !(!shiftIsBounded(v)) { 1884 break 1885 } 1886 v.reset(OpRISCV64AND) 1887 v0 := b.NewValue0(v.Pos, OpRISCV64SLL, t) 1888 v0.AddArg2(x, y) 1889 v1 := b.NewValue0(v.Pos, OpNeg32, t) 1890 v2 := b.NewValue0(v.Pos, OpRISCV64SLTIU, t) 1891 v2.AuxInt = int64ToAuxInt(64) 1892 v3 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) 1893 v3.AddArg(y) 1894 v2.AddArg(v3) 1895 v1.AddArg(v2) 1896 v.AddArg2(v0, v1) 1897 return true 1898 } 1899 // match: (Lsh32x16 x y) 1900 // cond: shiftIsBounded(v) 1901 // result: (SLL x y) 1902 for { 1903 x := v_0 1904 y := v_1 1905 if !(shiftIsBounded(v)) { 1906 break 1907 } 1908 v.reset(OpRISCV64SLL) 1909 v.AddArg2(x, y) 1910 return true 1911 } 1912 return false 1913 } 1914 func rewriteValueRISCV64_OpLsh32x32(v *Value) bool { 1915 v_1 := v.Args[1] 1916 v_0 := v.Args[0] 1917 b := v.Block 1918 typ := &b.Func.Config.Types 1919 // match: (Lsh32x32 <t> x y) 1920 // cond: !shiftIsBounded(v) 1921 // result: (AND (SLL <t> x y) (Neg32 <t> (SLTIU <t> [64] (ZeroExt32to64 y)))) 1922 for { 1923 t := v.Type 1924 x := v_0 1925 y := v_1 1926 if !(!shiftIsBounded(v)) { 1927 break 1928 } 1929 v.reset(OpRISCV64AND) 1930 v0 := b.NewValue0(v.Pos, OpRISCV64SLL, t) 1931 v0.AddArg2(x, y) 1932 v1 := b.NewValue0(v.Pos, OpNeg32, t) 1933 v2 := b.NewValue0(v.Pos, OpRISCV64SLTIU, t) 1934 v2.AuxInt = int64ToAuxInt(64) 1935 v3 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) 1936 v3.AddArg(y) 1937 v2.AddArg(v3) 1938 v1.AddArg(v2) 1939 v.AddArg2(v0, v1) 1940 return true 1941 } 1942 // match: (Lsh32x32 x y) 1943 // cond: shiftIsBounded(v) 1944 // result: (SLL x y) 1945 for { 1946 x := v_0 1947 y := v_1 1948 if !(shiftIsBounded(v)) { 1949 break 1950 } 1951 v.reset(OpRISCV64SLL) 1952 v.AddArg2(x, y) 1953 return true 1954 } 1955 return false 1956 } 1957 func rewriteValueRISCV64_OpLsh32x64(v *Value) bool { 1958 v_1 := v.Args[1] 1959 v_0 := v.Args[0] 1960 b := v.Block 1961 // match: (Lsh32x64 <t> x y) 1962 // cond: !shiftIsBounded(v) 1963 // result: (AND (SLL <t> x y) (Neg32 <t> (SLTIU <t> [64] y))) 1964 for { 1965 t := v.Type 1966 x := v_0 1967 y := v_1 1968 if !(!shiftIsBounded(v)) { 1969 break 1970 } 1971 v.reset(OpRISCV64AND) 1972 v0 := b.NewValue0(v.Pos, OpRISCV64SLL, t) 1973 v0.AddArg2(x, y) 1974 v1 := b.NewValue0(v.Pos, OpNeg32, t) 1975 v2 := b.NewValue0(v.Pos, OpRISCV64SLTIU, t) 1976 v2.AuxInt = int64ToAuxInt(64) 1977 v2.AddArg(y) 1978 v1.AddArg(v2) 1979 v.AddArg2(v0, v1) 1980 return true 1981 } 1982 // match: (Lsh32x64 x y) 1983 // cond: shiftIsBounded(v) 1984 // result: (SLL x y) 1985 for { 1986 x := v_0 1987 y := v_1 1988 if !(shiftIsBounded(v)) { 1989 break 1990 } 1991 v.reset(OpRISCV64SLL) 1992 v.AddArg2(x, y) 1993 return true 1994 } 1995 return false 1996 } 1997 func rewriteValueRISCV64_OpLsh32x8(v *Value) bool { 1998 v_1 := v.Args[1] 1999 v_0 := v.Args[0] 2000 b := v.Block 2001 typ := &b.Func.Config.Types 2002 // match: (Lsh32x8 <t> x y) 2003 // cond: !shiftIsBounded(v) 2004 // result: (AND (SLL <t> x y) (Neg32 <t> (SLTIU <t> [64] (ZeroExt8to64 y)))) 2005 for { 2006 t := v.Type 2007 x := v_0 2008 y := v_1 2009 if !(!shiftIsBounded(v)) { 2010 break 2011 } 2012 v.reset(OpRISCV64AND) 2013 v0 := b.NewValue0(v.Pos, OpRISCV64SLL, t) 2014 v0.AddArg2(x, y) 2015 v1 := b.NewValue0(v.Pos, OpNeg32, t) 2016 v2 := b.NewValue0(v.Pos, OpRISCV64SLTIU, t) 2017 v2.AuxInt = int64ToAuxInt(64) 2018 v3 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) 2019 v3.AddArg(y) 2020 v2.AddArg(v3) 2021 v1.AddArg(v2) 2022 v.AddArg2(v0, v1) 2023 return true 2024 } 2025 // match: (Lsh32x8 x y) 2026 // cond: shiftIsBounded(v) 2027 // result: (SLL x y) 2028 for { 2029 x := v_0 2030 y := v_1 2031 if !(shiftIsBounded(v)) { 2032 break 2033 } 2034 v.reset(OpRISCV64SLL) 2035 v.AddArg2(x, y) 2036 return true 2037 } 2038 return false 2039 } 2040 func rewriteValueRISCV64_OpLsh64x16(v *Value) bool { 2041 v_1 := v.Args[1] 2042 v_0 := v.Args[0] 2043 b := v.Block 2044 typ := &b.Func.Config.Types 2045 // match: (Lsh64x16 <t> x y) 2046 // cond: !shiftIsBounded(v) 2047 // result: (AND (SLL <t> x y) (Neg64 <t> (SLTIU <t> [64] (ZeroExt16to64 y)))) 2048 for { 2049 t := v.Type 2050 x := v_0 2051 y := v_1 2052 if !(!shiftIsBounded(v)) { 2053 break 2054 } 2055 v.reset(OpRISCV64AND) 2056 v0 := b.NewValue0(v.Pos, OpRISCV64SLL, t) 2057 v0.AddArg2(x, y) 2058 v1 := b.NewValue0(v.Pos, OpNeg64, t) 2059 v2 := b.NewValue0(v.Pos, OpRISCV64SLTIU, t) 2060 v2.AuxInt = int64ToAuxInt(64) 2061 v3 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) 2062 v3.AddArg(y) 2063 v2.AddArg(v3) 2064 v1.AddArg(v2) 2065 v.AddArg2(v0, v1) 2066 return true 2067 } 2068 // match: (Lsh64x16 x y) 2069 // cond: shiftIsBounded(v) 2070 // result: (SLL x y) 2071 for { 2072 x := v_0 2073 y := v_1 2074 if !(shiftIsBounded(v)) { 2075 break 2076 } 2077 v.reset(OpRISCV64SLL) 2078 v.AddArg2(x, y) 2079 return true 2080 } 2081 return false 2082 } 2083 func rewriteValueRISCV64_OpLsh64x32(v *Value) bool { 2084 v_1 := v.Args[1] 2085 v_0 := v.Args[0] 2086 b := v.Block 2087 typ := &b.Func.Config.Types 2088 // match: (Lsh64x32 <t> x y) 2089 // cond: !shiftIsBounded(v) 2090 // result: (AND (SLL <t> x y) (Neg64 <t> (SLTIU <t> [64] (ZeroExt32to64 y)))) 2091 for { 2092 t := v.Type 2093 x := v_0 2094 y := v_1 2095 if !(!shiftIsBounded(v)) { 2096 break 2097 } 2098 v.reset(OpRISCV64AND) 2099 v0 := b.NewValue0(v.Pos, OpRISCV64SLL, t) 2100 v0.AddArg2(x, y) 2101 v1 := b.NewValue0(v.Pos, OpNeg64, t) 2102 v2 := b.NewValue0(v.Pos, OpRISCV64SLTIU, t) 2103 v2.AuxInt = int64ToAuxInt(64) 2104 v3 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) 2105 v3.AddArg(y) 2106 v2.AddArg(v3) 2107 v1.AddArg(v2) 2108 v.AddArg2(v0, v1) 2109 return true 2110 } 2111 // match: (Lsh64x32 x y) 2112 // cond: shiftIsBounded(v) 2113 // result: (SLL x y) 2114 for { 2115 x := v_0 2116 y := v_1 2117 if !(shiftIsBounded(v)) { 2118 break 2119 } 2120 v.reset(OpRISCV64SLL) 2121 v.AddArg2(x, y) 2122 return true 2123 } 2124 return false 2125 } 2126 func rewriteValueRISCV64_OpLsh64x64(v *Value) bool { 2127 v_1 := v.Args[1] 2128 v_0 := v.Args[0] 2129 b := v.Block 2130 // match: (Lsh64x64 <t> x y) 2131 // cond: !shiftIsBounded(v) 2132 // result: (AND (SLL <t> x y) (Neg64 <t> (SLTIU <t> [64] y))) 2133 for { 2134 t := v.Type 2135 x := v_0 2136 y := v_1 2137 if !(!shiftIsBounded(v)) { 2138 break 2139 } 2140 v.reset(OpRISCV64AND) 2141 v0 := b.NewValue0(v.Pos, OpRISCV64SLL, t) 2142 v0.AddArg2(x, y) 2143 v1 := b.NewValue0(v.Pos, OpNeg64, t) 2144 v2 := b.NewValue0(v.Pos, OpRISCV64SLTIU, t) 2145 v2.AuxInt = int64ToAuxInt(64) 2146 v2.AddArg(y) 2147 v1.AddArg(v2) 2148 v.AddArg2(v0, v1) 2149 return true 2150 } 2151 // match: (Lsh64x64 x y) 2152 // cond: shiftIsBounded(v) 2153 // result: (SLL x y) 2154 for { 2155 x := v_0 2156 y := v_1 2157 if !(shiftIsBounded(v)) { 2158 break 2159 } 2160 v.reset(OpRISCV64SLL) 2161 v.AddArg2(x, y) 2162 return true 2163 } 2164 return false 2165 } 2166 func rewriteValueRISCV64_OpLsh64x8(v *Value) bool { 2167 v_1 := v.Args[1] 2168 v_0 := v.Args[0] 2169 b := v.Block 2170 typ := &b.Func.Config.Types 2171 // match: (Lsh64x8 <t> x y) 2172 // cond: !shiftIsBounded(v) 2173 // result: (AND (SLL <t> x y) (Neg64 <t> (SLTIU <t> [64] (ZeroExt8to64 y)))) 2174 for { 2175 t := v.Type 2176 x := v_0 2177 y := v_1 2178 if !(!shiftIsBounded(v)) { 2179 break 2180 } 2181 v.reset(OpRISCV64AND) 2182 v0 := b.NewValue0(v.Pos, OpRISCV64SLL, t) 2183 v0.AddArg2(x, y) 2184 v1 := b.NewValue0(v.Pos, OpNeg64, t) 2185 v2 := b.NewValue0(v.Pos, OpRISCV64SLTIU, t) 2186 v2.AuxInt = int64ToAuxInt(64) 2187 v3 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) 2188 v3.AddArg(y) 2189 v2.AddArg(v3) 2190 v1.AddArg(v2) 2191 v.AddArg2(v0, v1) 2192 return true 2193 } 2194 // match: (Lsh64x8 x y) 2195 // cond: shiftIsBounded(v) 2196 // result: (SLL x y) 2197 for { 2198 x := v_0 2199 y := v_1 2200 if !(shiftIsBounded(v)) { 2201 break 2202 } 2203 v.reset(OpRISCV64SLL) 2204 v.AddArg2(x, y) 2205 return true 2206 } 2207 return false 2208 } 2209 func rewriteValueRISCV64_OpLsh8x16(v *Value) bool { 2210 v_1 := v.Args[1] 2211 v_0 := v.Args[0] 2212 b := v.Block 2213 typ := &b.Func.Config.Types 2214 // match: (Lsh8x16 <t> x y) 2215 // cond: !shiftIsBounded(v) 2216 // result: (AND (SLL <t> x y) (Neg8 <t> (SLTIU <t> [64] (ZeroExt16to64 y)))) 2217 for { 2218 t := v.Type 2219 x := v_0 2220 y := v_1 2221 if !(!shiftIsBounded(v)) { 2222 break 2223 } 2224 v.reset(OpRISCV64AND) 2225 v0 := b.NewValue0(v.Pos, OpRISCV64SLL, t) 2226 v0.AddArg2(x, y) 2227 v1 := b.NewValue0(v.Pos, OpNeg8, t) 2228 v2 := b.NewValue0(v.Pos, OpRISCV64SLTIU, t) 2229 v2.AuxInt = int64ToAuxInt(64) 2230 v3 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) 2231 v3.AddArg(y) 2232 v2.AddArg(v3) 2233 v1.AddArg(v2) 2234 v.AddArg2(v0, v1) 2235 return true 2236 } 2237 // match: (Lsh8x16 x y) 2238 // cond: shiftIsBounded(v) 2239 // result: (SLL x y) 2240 for { 2241 x := v_0 2242 y := v_1 2243 if !(shiftIsBounded(v)) { 2244 break 2245 } 2246 v.reset(OpRISCV64SLL) 2247 v.AddArg2(x, y) 2248 return true 2249 } 2250 return false 2251 } 2252 func rewriteValueRISCV64_OpLsh8x32(v *Value) bool { 2253 v_1 := v.Args[1] 2254 v_0 := v.Args[0] 2255 b := v.Block 2256 typ := &b.Func.Config.Types 2257 // match: (Lsh8x32 <t> x y) 2258 // cond: !shiftIsBounded(v) 2259 // result: (AND (SLL <t> x y) (Neg8 <t> (SLTIU <t> [64] (ZeroExt32to64 y)))) 2260 for { 2261 t := v.Type 2262 x := v_0 2263 y := v_1 2264 if !(!shiftIsBounded(v)) { 2265 break 2266 } 2267 v.reset(OpRISCV64AND) 2268 v0 := b.NewValue0(v.Pos, OpRISCV64SLL, t) 2269 v0.AddArg2(x, y) 2270 v1 := b.NewValue0(v.Pos, OpNeg8, t) 2271 v2 := b.NewValue0(v.Pos, OpRISCV64SLTIU, t) 2272 v2.AuxInt = int64ToAuxInt(64) 2273 v3 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) 2274 v3.AddArg(y) 2275 v2.AddArg(v3) 2276 v1.AddArg(v2) 2277 v.AddArg2(v0, v1) 2278 return true 2279 } 2280 // match: (Lsh8x32 x y) 2281 // cond: shiftIsBounded(v) 2282 // result: (SLL x y) 2283 for { 2284 x := v_0 2285 y := v_1 2286 if !(shiftIsBounded(v)) { 2287 break 2288 } 2289 v.reset(OpRISCV64SLL) 2290 v.AddArg2(x, y) 2291 return true 2292 } 2293 return false 2294 } 2295 func rewriteValueRISCV64_OpLsh8x64(v *Value) bool { 2296 v_1 := v.Args[1] 2297 v_0 := v.Args[0] 2298 b := v.Block 2299 // match: (Lsh8x64 <t> x y) 2300 // cond: !shiftIsBounded(v) 2301 // result: (AND (SLL <t> x y) (Neg8 <t> (SLTIU <t> [64] y))) 2302 for { 2303 t := v.Type 2304 x := v_0 2305 y := v_1 2306 if !(!shiftIsBounded(v)) { 2307 break 2308 } 2309 v.reset(OpRISCV64AND) 2310 v0 := b.NewValue0(v.Pos, OpRISCV64SLL, t) 2311 v0.AddArg2(x, y) 2312 v1 := b.NewValue0(v.Pos, OpNeg8, t) 2313 v2 := b.NewValue0(v.Pos, OpRISCV64SLTIU, t) 2314 v2.AuxInt = int64ToAuxInt(64) 2315 v2.AddArg(y) 2316 v1.AddArg(v2) 2317 v.AddArg2(v0, v1) 2318 return true 2319 } 2320 // match: (Lsh8x64 x y) 2321 // cond: shiftIsBounded(v) 2322 // result: (SLL x y) 2323 for { 2324 x := v_0 2325 y := v_1 2326 if !(shiftIsBounded(v)) { 2327 break 2328 } 2329 v.reset(OpRISCV64SLL) 2330 v.AddArg2(x, y) 2331 return true 2332 } 2333 return false 2334 } 2335 func rewriteValueRISCV64_OpLsh8x8(v *Value) bool { 2336 v_1 := v.Args[1] 2337 v_0 := v.Args[0] 2338 b := v.Block 2339 typ := &b.Func.Config.Types 2340 // match: (Lsh8x8 <t> x y) 2341 // cond: !shiftIsBounded(v) 2342 // result: (AND (SLL <t> x y) (Neg8 <t> (SLTIU <t> [64] (ZeroExt8to64 y)))) 2343 for { 2344 t := v.Type 2345 x := v_0 2346 y := v_1 2347 if !(!shiftIsBounded(v)) { 2348 break 2349 } 2350 v.reset(OpRISCV64AND) 2351 v0 := b.NewValue0(v.Pos, OpRISCV64SLL, t) 2352 v0.AddArg2(x, y) 2353 v1 := b.NewValue0(v.Pos, OpNeg8, t) 2354 v2 := b.NewValue0(v.Pos, OpRISCV64SLTIU, t) 2355 v2.AuxInt = int64ToAuxInt(64) 2356 v3 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) 2357 v3.AddArg(y) 2358 v2.AddArg(v3) 2359 v1.AddArg(v2) 2360 v.AddArg2(v0, v1) 2361 return true 2362 } 2363 // match: (Lsh8x8 x y) 2364 // cond: shiftIsBounded(v) 2365 // result: (SLL x y) 2366 for { 2367 x := v_0 2368 y := v_1 2369 if !(shiftIsBounded(v)) { 2370 break 2371 } 2372 v.reset(OpRISCV64SLL) 2373 v.AddArg2(x, y) 2374 return true 2375 } 2376 return false 2377 } 2378 func rewriteValueRISCV64_OpMod16(v *Value) bool { 2379 v_1 := v.Args[1] 2380 v_0 := v.Args[0] 2381 b := v.Block 2382 typ := &b.Func.Config.Types 2383 // match: (Mod16 x y [false]) 2384 // result: (REMW (SignExt16to32 x) (SignExt16to32 y)) 2385 for { 2386 if auxIntToBool(v.AuxInt) != false { 2387 break 2388 } 2389 x := v_0 2390 y := v_1 2391 v.reset(OpRISCV64REMW) 2392 v0 := b.NewValue0(v.Pos, OpSignExt16to32, typ.Int32) 2393 v0.AddArg(x) 2394 v1 := b.NewValue0(v.Pos, OpSignExt16to32, typ.Int32) 2395 v1.AddArg(y) 2396 v.AddArg2(v0, v1) 2397 return true 2398 } 2399 return false 2400 } 2401 func rewriteValueRISCV64_OpMod16u(v *Value) bool { 2402 v_1 := v.Args[1] 2403 v_0 := v.Args[0] 2404 b := v.Block 2405 typ := &b.Func.Config.Types 2406 // match: (Mod16u x y) 2407 // result: (REMUW (ZeroExt16to32 x) (ZeroExt16to32 y)) 2408 for { 2409 x := v_0 2410 y := v_1 2411 v.reset(OpRISCV64REMUW) 2412 v0 := b.NewValue0(v.Pos, OpZeroExt16to32, typ.UInt32) 2413 v0.AddArg(x) 2414 v1 := b.NewValue0(v.Pos, OpZeroExt16to32, typ.UInt32) 2415 v1.AddArg(y) 2416 v.AddArg2(v0, v1) 2417 return true 2418 } 2419 } 2420 func rewriteValueRISCV64_OpMod32(v *Value) bool { 2421 v_1 := v.Args[1] 2422 v_0 := v.Args[0] 2423 // match: (Mod32 x y [false]) 2424 // result: (REMW x y) 2425 for { 2426 if auxIntToBool(v.AuxInt) != false { 2427 break 2428 } 2429 x := v_0 2430 y := v_1 2431 v.reset(OpRISCV64REMW) 2432 v.AddArg2(x, y) 2433 return true 2434 } 2435 return false 2436 } 2437 func rewriteValueRISCV64_OpMod64(v *Value) bool { 2438 v_1 := v.Args[1] 2439 v_0 := v.Args[0] 2440 // match: (Mod64 x y [false]) 2441 // result: (REM x y) 2442 for { 2443 if auxIntToBool(v.AuxInt) != false { 2444 break 2445 } 2446 x := v_0 2447 y := v_1 2448 v.reset(OpRISCV64REM) 2449 v.AddArg2(x, y) 2450 return true 2451 } 2452 return false 2453 } 2454 func rewriteValueRISCV64_OpMod8(v *Value) bool { 2455 v_1 := v.Args[1] 2456 v_0 := v.Args[0] 2457 b := v.Block 2458 typ := &b.Func.Config.Types 2459 // match: (Mod8 x y) 2460 // result: (REMW (SignExt8to32 x) (SignExt8to32 y)) 2461 for { 2462 x := v_0 2463 y := v_1 2464 v.reset(OpRISCV64REMW) 2465 v0 := b.NewValue0(v.Pos, OpSignExt8to32, typ.Int32) 2466 v0.AddArg(x) 2467 v1 := b.NewValue0(v.Pos, OpSignExt8to32, typ.Int32) 2468 v1.AddArg(y) 2469 v.AddArg2(v0, v1) 2470 return true 2471 } 2472 } 2473 func rewriteValueRISCV64_OpMod8u(v *Value) bool { 2474 v_1 := v.Args[1] 2475 v_0 := v.Args[0] 2476 b := v.Block 2477 typ := &b.Func.Config.Types 2478 // match: (Mod8u x y) 2479 // result: (REMUW (ZeroExt8to32 x) (ZeroExt8to32 y)) 2480 for { 2481 x := v_0 2482 y := v_1 2483 v.reset(OpRISCV64REMUW) 2484 v0 := b.NewValue0(v.Pos, OpZeroExt8to32, typ.UInt32) 2485 v0.AddArg(x) 2486 v1 := b.NewValue0(v.Pos, OpZeroExt8to32, typ.UInt32) 2487 v1.AddArg(y) 2488 v.AddArg2(v0, v1) 2489 return true 2490 } 2491 } 2492 func rewriteValueRISCV64_OpMove(v *Value) bool { 2493 v_2 := v.Args[2] 2494 v_1 := v.Args[1] 2495 v_0 := v.Args[0] 2496 b := v.Block 2497 config := b.Func.Config 2498 typ := &b.Func.Config.Types 2499 // match: (Move [0] _ _ mem) 2500 // result: mem 2501 for { 2502 if auxIntToInt64(v.AuxInt) != 0 { 2503 break 2504 } 2505 mem := v_2 2506 v.copyOf(mem) 2507 return true 2508 } 2509 // match: (Move [1] dst src mem) 2510 // result: (MOVBstore dst (MOVBload src mem) mem) 2511 for { 2512 if auxIntToInt64(v.AuxInt) != 1 { 2513 break 2514 } 2515 dst := v_0 2516 src := v_1 2517 mem := v_2 2518 v.reset(OpRISCV64MOVBstore) 2519 v0 := b.NewValue0(v.Pos, OpRISCV64MOVBload, typ.Int8) 2520 v0.AddArg2(src, mem) 2521 v.AddArg3(dst, v0, mem) 2522 return true 2523 } 2524 // match: (Move [2] {t} dst src mem) 2525 // cond: t.Alignment()%2 == 0 2526 // result: (MOVHstore dst (MOVHload src mem) mem) 2527 for { 2528 if auxIntToInt64(v.AuxInt) != 2 { 2529 break 2530 } 2531 t := auxToType(v.Aux) 2532 dst := v_0 2533 src := v_1 2534 mem := v_2 2535 if !(t.Alignment()%2 == 0) { 2536 break 2537 } 2538 v.reset(OpRISCV64MOVHstore) 2539 v0 := b.NewValue0(v.Pos, OpRISCV64MOVHload, typ.Int16) 2540 v0.AddArg2(src, mem) 2541 v.AddArg3(dst, v0, mem) 2542 return true 2543 } 2544 // match: (Move [2] dst src mem) 2545 // result: (MOVBstore [1] dst (MOVBload [1] src mem) (MOVBstore dst (MOVBload src mem) mem)) 2546 for { 2547 if auxIntToInt64(v.AuxInt) != 2 { 2548 break 2549 } 2550 dst := v_0 2551 src := v_1 2552 mem := v_2 2553 v.reset(OpRISCV64MOVBstore) 2554 v.AuxInt = int32ToAuxInt(1) 2555 v0 := b.NewValue0(v.Pos, OpRISCV64MOVBload, typ.Int8) 2556 v0.AuxInt = int32ToAuxInt(1) 2557 v0.AddArg2(src, mem) 2558 v1 := b.NewValue0(v.Pos, OpRISCV64MOVBstore, types.TypeMem) 2559 v2 := b.NewValue0(v.Pos, OpRISCV64MOVBload, typ.Int8) 2560 v2.AddArg2(src, mem) 2561 v1.AddArg3(dst, v2, mem) 2562 v.AddArg3(dst, v0, v1) 2563 return true 2564 } 2565 // match: (Move [4] {t} dst src mem) 2566 // cond: t.Alignment()%4 == 0 2567 // result: (MOVWstore dst (MOVWload src mem) mem) 2568 for { 2569 if auxIntToInt64(v.AuxInt) != 4 { 2570 break 2571 } 2572 t := auxToType(v.Aux) 2573 dst := v_0 2574 src := v_1 2575 mem := v_2 2576 if !(t.Alignment()%4 == 0) { 2577 break 2578 } 2579 v.reset(OpRISCV64MOVWstore) 2580 v0 := b.NewValue0(v.Pos, OpRISCV64MOVWload, typ.Int32) 2581 v0.AddArg2(src, mem) 2582 v.AddArg3(dst, v0, mem) 2583 return true 2584 } 2585 // match: (Move [4] {t} dst src mem) 2586 // cond: t.Alignment()%2 == 0 2587 // result: (MOVHstore [2] dst (MOVHload [2] src mem) (MOVHstore dst (MOVHload src mem) mem)) 2588 for { 2589 if auxIntToInt64(v.AuxInt) != 4 { 2590 break 2591 } 2592 t := auxToType(v.Aux) 2593 dst := v_0 2594 src := v_1 2595 mem := v_2 2596 if !(t.Alignment()%2 == 0) { 2597 break 2598 } 2599 v.reset(OpRISCV64MOVHstore) 2600 v.AuxInt = int32ToAuxInt(2) 2601 v0 := b.NewValue0(v.Pos, OpRISCV64MOVHload, typ.Int16) 2602 v0.AuxInt = int32ToAuxInt(2) 2603 v0.AddArg2(src, mem) 2604 v1 := b.NewValue0(v.Pos, OpRISCV64MOVHstore, types.TypeMem) 2605 v2 := b.NewValue0(v.Pos, OpRISCV64MOVHload, typ.Int16) 2606 v2.AddArg2(src, mem) 2607 v1.AddArg3(dst, v2, mem) 2608 v.AddArg3(dst, v0, v1) 2609 return true 2610 } 2611 // match: (Move [4] dst src mem) 2612 // result: (MOVBstore [3] dst (MOVBload [3] src mem) (MOVBstore [2] dst (MOVBload [2] src mem) (MOVBstore [1] dst (MOVBload [1] src mem) (MOVBstore dst (MOVBload src mem) mem)))) 2613 for { 2614 if auxIntToInt64(v.AuxInt) != 4 { 2615 break 2616 } 2617 dst := v_0 2618 src := v_1 2619 mem := v_2 2620 v.reset(OpRISCV64MOVBstore) 2621 v.AuxInt = int32ToAuxInt(3) 2622 v0 := b.NewValue0(v.Pos, OpRISCV64MOVBload, typ.Int8) 2623 v0.AuxInt = int32ToAuxInt(3) 2624 v0.AddArg2(src, mem) 2625 v1 := b.NewValue0(v.Pos, OpRISCV64MOVBstore, types.TypeMem) 2626 v1.AuxInt = int32ToAuxInt(2) 2627 v2 := b.NewValue0(v.Pos, OpRISCV64MOVBload, typ.Int8) 2628 v2.AuxInt = int32ToAuxInt(2) 2629 v2.AddArg2(src, mem) 2630 v3 := b.NewValue0(v.Pos, OpRISCV64MOVBstore, types.TypeMem) 2631 v3.AuxInt = int32ToAuxInt(1) 2632 v4 := b.NewValue0(v.Pos, OpRISCV64MOVBload, typ.Int8) 2633 v4.AuxInt = int32ToAuxInt(1) 2634 v4.AddArg2(src, mem) 2635 v5 := b.NewValue0(v.Pos, OpRISCV64MOVBstore, types.TypeMem) 2636 v6 := b.NewValue0(v.Pos, OpRISCV64MOVBload, typ.Int8) 2637 v6.AddArg2(src, mem) 2638 v5.AddArg3(dst, v6, mem) 2639 v3.AddArg3(dst, v4, v5) 2640 v1.AddArg3(dst, v2, v3) 2641 v.AddArg3(dst, v0, v1) 2642 return true 2643 } 2644 // match: (Move [8] {t} dst src mem) 2645 // cond: t.Alignment()%8 == 0 2646 // result: (MOVDstore dst (MOVDload src mem) mem) 2647 for { 2648 if auxIntToInt64(v.AuxInt) != 8 { 2649 break 2650 } 2651 t := auxToType(v.Aux) 2652 dst := v_0 2653 src := v_1 2654 mem := v_2 2655 if !(t.Alignment()%8 == 0) { 2656 break 2657 } 2658 v.reset(OpRISCV64MOVDstore) 2659 v0 := b.NewValue0(v.Pos, OpRISCV64MOVDload, typ.Int64) 2660 v0.AddArg2(src, mem) 2661 v.AddArg3(dst, v0, mem) 2662 return true 2663 } 2664 // match: (Move [8] {t} dst src mem) 2665 // cond: t.Alignment()%4 == 0 2666 // result: (MOVWstore [4] dst (MOVWload [4] src mem) (MOVWstore dst (MOVWload src mem) mem)) 2667 for { 2668 if auxIntToInt64(v.AuxInt) != 8 { 2669 break 2670 } 2671 t := auxToType(v.Aux) 2672 dst := v_0 2673 src := v_1 2674 mem := v_2 2675 if !(t.Alignment()%4 == 0) { 2676 break 2677 } 2678 v.reset(OpRISCV64MOVWstore) 2679 v.AuxInt = int32ToAuxInt(4) 2680 v0 := b.NewValue0(v.Pos, OpRISCV64MOVWload, typ.Int32) 2681 v0.AuxInt = int32ToAuxInt(4) 2682 v0.AddArg2(src, mem) 2683 v1 := b.NewValue0(v.Pos, OpRISCV64MOVWstore, types.TypeMem) 2684 v2 := b.NewValue0(v.Pos, OpRISCV64MOVWload, typ.Int32) 2685 v2.AddArg2(src, mem) 2686 v1.AddArg3(dst, v2, mem) 2687 v.AddArg3(dst, v0, v1) 2688 return true 2689 } 2690 // match: (Move [8] {t} dst src mem) 2691 // cond: t.Alignment()%2 == 0 2692 // result: (MOVHstore [6] dst (MOVHload [6] src mem) (MOVHstore [4] dst (MOVHload [4] src mem) (MOVHstore [2] dst (MOVHload [2] src mem) (MOVHstore dst (MOVHload src mem) mem)))) 2693 for { 2694 if auxIntToInt64(v.AuxInt) != 8 { 2695 break 2696 } 2697 t := auxToType(v.Aux) 2698 dst := v_0 2699 src := v_1 2700 mem := v_2 2701 if !(t.Alignment()%2 == 0) { 2702 break 2703 } 2704 v.reset(OpRISCV64MOVHstore) 2705 v.AuxInt = int32ToAuxInt(6) 2706 v0 := b.NewValue0(v.Pos, OpRISCV64MOVHload, typ.Int16) 2707 v0.AuxInt = int32ToAuxInt(6) 2708 v0.AddArg2(src, mem) 2709 v1 := b.NewValue0(v.Pos, OpRISCV64MOVHstore, types.TypeMem) 2710 v1.AuxInt = int32ToAuxInt(4) 2711 v2 := b.NewValue0(v.Pos, OpRISCV64MOVHload, typ.Int16) 2712 v2.AuxInt = int32ToAuxInt(4) 2713 v2.AddArg2(src, mem) 2714 v3 := b.NewValue0(v.Pos, OpRISCV64MOVHstore, types.TypeMem) 2715 v3.AuxInt = int32ToAuxInt(2) 2716 v4 := b.NewValue0(v.Pos, OpRISCV64MOVHload, typ.Int16) 2717 v4.AuxInt = int32ToAuxInt(2) 2718 v4.AddArg2(src, mem) 2719 v5 := b.NewValue0(v.Pos, OpRISCV64MOVHstore, types.TypeMem) 2720 v6 := b.NewValue0(v.Pos, OpRISCV64MOVHload, typ.Int16) 2721 v6.AddArg2(src, mem) 2722 v5.AddArg3(dst, v6, mem) 2723 v3.AddArg3(dst, v4, v5) 2724 v1.AddArg3(dst, v2, v3) 2725 v.AddArg3(dst, v0, v1) 2726 return true 2727 } 2728 // match: (Move [3] dst src mem) 2729 // result: (MOVBstore [2] dst (MOVBload [2] src mem) (MOVBstore [1] dst (MOVBload [1] src mem) (MOVBstore dst (MOVBload src mem) mem))) 2730 for { 2731 if auxIntToInt64(v.AuxInt) != 3 { 2732 break 2733 } 2734 dst := v_0 2735 src := v_1 2736 mem := v_2 2737 v.reset(OpRISCV64MOVBstore) 2738 v.AuxInt = int32ToAuxInt(2) 2739 v0 := b.NewValue0(v.Pos, OpRISCV64MOVBload, typ.Int8) 2740 v0.AuxInt = int32ToAuxInt(2) 2741 v0.AddArg2(src, mem) 2742 v1 := b.NewValue0(v.Pos, OpRISCV64MOVBstore, types.TypeMem) 2743 v1.AuxInt = int32ToAuxInt(1) 2744 v2 := b.NewValue0(v.Pos, OpRISCV64MOVBload, typ.Int8) 2745 v2.AuxInt = int32ToAuxInt(1) 2746 v2.AddArg2(src, mem) 2747 v3 := b.NewValue0(v.Pos, OpRISCV64MOVBstore, types.TypeMem) 2748 v4 := b.NewValue0(v.Pos, OpRISCV64MOVBload, typ.Int8) 2749 v4.AddArg2(src, mem) 2750 v3.AddArg3(dst, v4, mem) 2751 v1.AddArg3(dst, v2, v3) 2752 v.AddArg3(dst, v0, v1) 2753 return true 2754 } 2755 // match: (Move [6] {t} dst src mem) 2756 // cond: t.Alignment()%2 == 0 2757 // result: (MOVHstore [4] dst (MOVHload [4] src mem) (MOVHstore [2] dst (MOVHload [2] src mem) (MOVHstore dst (MOVHload src mem) mem))) 2758 for { 2759 if auxIntToInt64(v.AuxInt) != 6 { 2760 break 2761 } 2762 t := auxToType(v.Aux) 2763 dst := v_0 2764 src := v_1 2765 mem := v_2 2766 if !(t.Alignment()%2 == 0) { 2767 break 2768 } 2769 v.reset(OpRISCV64MOVHstore) 2770 v.AuxInt = int32ToAuxInt(4) 2771 v0 := b.NewValue0(v.Pos, OpRISCV64MOVHload, typ.Int16) 2772 v0.AuxInt = int32ToAuxInt(4) 2773 v0.AddArg2(src, mem) 2774 v1 := b.NewValue0(v.Pos, OpRISCV64MOVHstore, types.TypeMem) 2775 v1.AuxInt = int32ToAuxInt(2) 2776 v2 := b.NewValue0(v.Pos, OpRISCV64MOVHload, typ.Int16) 2777 v2.AuxInt = int32ToAuxInt(2) 2778 v2.AddArg2(src, mem) 2779 v3 := b.NewValue0(v.Pos, OpRISCV64MOVHstore, types.TypeMem) 2780 v4 := b.NewValue0(v.Pos, OpRISCV64MOVHload, typ.Int16) 2781 v4.AddArg2(src, mem) 2782 v3.AddArg3(dst, v4, mem) 2783 v1.AddArg3(dst, v2, v3) 2784 v.AddArg3(dst, v0, v1) 2785 return true 2786 } 2787 // match: (Move [12] {t} dst src mem) 2788 // cond: t.Alignment()%4 == 0 2789 // result: (MOVWstore [8] dst (MOVWload [8] src mem) (MOVWstore [4] dst (MOVWload [4] src mem) (MOVWstore dst (MOVWload src mem) mem))) 2790 for { 2791 if auxIntToInt64(v.AuxInt) != 12 { 2792 break 2793 } 2794 t := auxToType(v.Aux) 2795 dst := v_0 2796 src := v_1 2797 mem := v_2 2798 if !(t.Alignment()%4 == 0) { 2799 break 2800 } 2801 v.reset(OpRISCV64MOVWstore) 2802 v.AuxInt = int32ToAuxInt(8) 2803 v0 := b.NewValue0(v.Pos, OpRISCV64MOVWload, typ.Int32) 2804 v0.AuxInt = int32ToAuxInt(8) 2805 v0.AddArg2(src, mem) 2806 v1 := b.NewValue0(v.Pos, OpRISCV64MOVWstore, types.TypeMem) 2807 v1.AuxInt = int32ToAuxInt(4) 2808 v2 := b.NewValue0(v.Pos, OpRISCV64MOVWload, typ.Int32) 2809 v2.AuxInt = int32ToAuxInt(4) 2810 v2.AddArg2(src, mem) 2811 v3 := b.NewValue0(v.Pos, OpRISCV64MOVWstore, types.TypeMem) 2812 v4 := b.NewValue0(v.Pos, OpRISCV64MOVWload, typ.Int32) 2813 v4.AddArg2(src, mem) 2814 v3.AddArg3(dst, v4, mem) 2815 v1.AddArg3(dst, v2, v3) 2816 v.AddArg3(dst, v0, v1) 2817 return true 2818 } 2819 // match: (Move [16] {t} dst src mem) 2820 // cond: t.Alignment()%8 == 0 2821 // result: (MOVDstore [8] dst (MOVDload [8] src mem) (MOVDstore dst (MOVDload src mem) mem)) 2822 for { 2823 if auxIntToInt64(v.AuxInt) != 16 { 2824 break 2825 } 2826 t := auxToType(v.Aux) 2827 dst := v_0 2828 src := v_1 2829 mem := v_2 2830 if !(t.Alignment()%8 == 0) { 2831 break 2832 } 2833 v.reset(OpRISCV64MOVDstore) 2834 v.AuxInt = int32ToAuxInt(8) 2835 v0 := b.NewValue0(v.Pos, OpRISCV64MOVDload, typ.Int64) 2836 v0.AuxInt = int32ToAuxInt(8) 2837 v0.AddArg2(src, mem) 2838 v1 := b.NewValue0(v.Pos, OpRISCV64MOVDstore, types.TypeMem) 2839 v2 := b.NewValue0(v.Pos, OpRISCV64MOVDload, typ.Int64) 2840 v2.AddArg2(src, mem) 2841 v1.AddArg3(dst, v2, mem) 2842 v.AddArg3(dst, v0, v1) 2843 return true 2844 } 2845 // match: (Move [24] {t} dst src mem) 2846 // cond: t.Alignment()%8 == 0 2847 // result: (MOVDstore [16] dst (MOVDload [16] src mem) (MOVDstore [8] dst (MOVDload [8] src mem) (MOVDstore dst (MOVDload src mem) mem))) 2848 for { 2849 if auxIntToInt64(v.AuxInt) != 24 { 2850 break 2851 } 2852 t := auxToType(v.Aux) 2853 dst := v_0 2854 src := v_1 2855 mem := v_2 2856 if !(t.Alignment()%8 == 0) { 2857 break 2858 } 2859 v.reset(OpRISCV64MOVDstore) 2860 v.AuxInt = int32ToAuxInt(16) 2861 v0 := b.NewValue0(v.Pos, OpRISCV64MOVDload, typ.Int64) 2862 v0.AuxInt = int32ToAuxInt(16) 2863 v0.AddArg2(src, mem) 2864 v1 := b.NewValue0(v.Pos, OpRISCV64MOVDstore, types.TypeMem) 2865 v1.AuxInt = int32ToAuxInt(8) 2866 v2 := b.NewValue0(v.Pos, OpRISCV64MOVDload, typ.Int64) 2867 v2.AuxInt = int32ToAuxInt(8) 2868 v2.AddArg2(src, mem) 2869 v3 := b.NewValue0(v.Pos, OpRISCV64MOVDstore, types.TypeMem) 2870 v4 := b.NewValue0(v.Pos, OpRISCV64MOVDload, typ.Int64) 2871 v4.AddArg2(src, mem) 2872 v3.AddArg3(dst, v4, mem) 2873 v1.AddArg3(dst, v2, v3) 2874 v.AddArg3(dst, v0, v1) 2875 return true 2876 } 2877 // match: (Move [32] {t} dst src mem) 2878 // cond: t.Alignment()%8 == 0 2879 // result: (MOVDstore [24] dst (MOVDload [24] src mem) (MOVDstore [16] dst (MOVDload [16] src mem) (MOVDstore [8] dst (MOVDload [8] src mem) (MOVDstore dst (MOVDload src mem) mem)))) 2880 for { 2881 if auxIntToInt64(v.AuxInt) != 32 { 2882 break 2883 } 2884 t := auxToType(v.Aux) 2885 dst := v_0 2886 src := v_1 2887 mem := v_2 2888 if !(t.Alignment()%8 == 0) { 2889 break 2890 } 2891 v.reset(OpRISCV64MOVDstore) 2892 v.AuxInt = int32ToAuxInt(24) 2893 v0 := b.NewValue0(v.Pos, OpRISCV64MOVDload, typ.Int64) 2894 v0.AuxInt = int32ToAuxInt(24) 2895 v0.AddArg2(src, mem) 2896 v1 := b.NewValue0(v.Pos, OpRISCV64MOVDstore, types.TypeMem) 2897 v1.AuxInt = int32ToAuxInt(16) 2898 v2 := b.NewValue0(v.Pos, OpRISCV64MOVDload, typ.Int64) 2899 v2.AuxInt = int32ToAuxInt(16) 2900 v2.AddArg2(src, mem) 2901 v3 := b.NewValue0(v.Pos, OpRISCV64MOVDstore, types.TypeMem) 2902 v3.AuxInt = int32ToAuxInt(8) 2903 v4 := b.NewValue0(v.Pos, OpRISCV64MOVDload, typ.Int64) 2904 v4.AuxInt = int32ToAuxInt(8) 2905 v4.AddArg2(src, mem) 2906 v5 := b.NewValue0(v.Pos, OpRISCV64MOVDstore, types.TypeMem) 2907 v6 := b.NewValue0(v.Pos, OpRISCV64MOVDload, typ.Int64) 2908 v6.AddArg2(src, mem) 2909 v5.AddArg3(dst, v6, mem) 2910 v3.AddArg3(dst, v4, v5) 2911 v1.AddArg3(dst, v2, v3) 2912 v.AddArg3(dst, v0, v1) 2913 return true 2914 } 2915 // match: (Move [s] {t} dst src mem) 2916 // cond: s%8 == 0 && s <= 8*128 && t.Alignment()%8 == 0 && !config.noDuffDevice && logLargeCopy(v, s) 2917 // result: (DUFFCOPY [16 * (128 - s/8)] dst src mem) 2918 for { 2919 s := auxIntToInt64(v.AuxInt) 2920 t := auxToType(v.Aux) 2921 dst := v_0 2922 src := v_1 2923 mem := v_2 2924 if !(s%8 == 0 && s <= 8*128 && t.Alignment()%8 == 0 && !config.noDuffDevice && logLargeCopy(v, s)) { 2925 break 2926 } 2927 v.reset(OpRISCV64DUFFCOPY) 2928 v.AuxInt = int64ToAuxInt(16 * (128 - s/8)) 2929 v.AddArg3(dst, src, mem) 2930 return true 2931 } 2932 // match: (Move [s] {t} dst src mem) 2933 // cond: (s <= 16 || logLargeCopy(v, s)) 2934 // result: (LoweredMove [t.Alignment()] dst src (ADDI <src.Type> [s-moveSize(t.Alignment(), config)] src) mem) 2935 for { 2936 s := auxIntToInt64(v.AuxInt) 2937 t := auxToType(v.Aux) 2938 dst := v_0 2939 src := v_1 2940 mem := v_2 2941 if !(s <= 16 || logLargeCopy(v, s)) { 2942 break 2943 } 2944 v.reset(OpRISCV64LoweredMove) 2945 v.AuxInt = int64ToAuxInt(t.Alignment()) 2946 v0 := b.NewValue0(v.Pos, OpRISCV64ADDI, src.Type) 2947 v0.AuxInt = int64ToAuxInt(s - moveSize(t.Alignment(), config)) 2948 v0.AddArg(src) 2949 v.AddArg4(dst, src, v0, mem) 2950 return true 2951 } 2952 return false 2953 } 2954 func rewriteValueRISCV64_OpMul16(v *Value) bool { 2955 v_1 := v.Args[1] 2956 v_0 := v.Args[0] 2957 b := v.Block 2958 typ := &b.Func.Config.Types 2959 // match: (Mul16 x y) 2960 // result: (MULW (SignExt16to32 x) (SignExt16to32 y)) 2961 for { 2962 x := v_0 2963 y := v_1 2964 v.reset(OpRISCV64MULW) 2965 v0 := b.NewValue0(v.Pos, OpSignExt16to32, typ.Int32) 2966 v0.AddArg(x) 2967 v1 := b.NewValue0(v.Pos, OpSignExt16to32, typ.Int32) 2968 v1.AddArg(y) 2969 v.AddArg2(v0, v1) 2970 return true 2971 } 2972 } 2973 func rewriteValueRISCV64_OpMul8(v *Value) bool { 2974 v_1 := v.Args[1] 2975 v_0 := v.Args[0] 2976 b := v.Block 2977 typ := &b.Func.Config.Types 2978 // match: (Mul8 x y) 2979 // result: (MULW (SignExt8to32 x) (SignExt8to32 y)) 2980 for { 2981 x := v_0 2982 y := v_1 2983 v.reset(OpRISCV64MULW) 2984 v0 := b.NewValue0(v.Pos, OpSignExt8to32, typ.Int32) 2985 v0.AddArg(x) 2986 v1 := b.NewValue0(v.Pos, OpSignExt8to32, typ.Int32) 2987 v1.AddArg(y) 2988 v.AddArg2(v0, v1) 2989 return true 2990 } 2991 } 2992 func rewriteValueRISCV64_OpNeq16(v *Value) bool { 2993 v_1 := v.Args[1] 2994 v_0 := v.Args[0] 2995 b := v.Block 2996 typ := &b.Func.Config.Types 2997 // match: (Neq16 x y) 2998 // result: (Not (Eq16 x y)) 2999 for { 3000 x := v_0 3001 y := v_1 3002 v.reset(OpNot) 3003 v0 := b.NewValue0(v.Pos, OpEq16, typ.Bool) 3004 v0.AddArg2(x, y) 3005 v.AddArg(v0) 3006 return true 3007 } 3008 } 3009 func rewriteValueRISCV64_OpNeq32(v *Value) bool { 3010 v_1 := v.Args[1] 3011 v_0 := v.Args[0] 3012 b := v.Block 3013 typ := &b.Func.Config.Types 3014 // match: (Neq32 x y) 3015 // result: (Not (Eq32 x y)) 3016 for { 3017 x := v_0 3018 y := v_1 3019 v.reset(OpNot) 3020 v0 := b.NewValue0(v.Pos, OpEq32, typ.Bool) 3021 v0.AddArg2(x, y) 3022 v.AddArg(v0) 3023 return true 3024 } 3025 } 3026 func rewriteValueRISCV64_OpNeq64(v *Value) bool { 3027 v_1 := v.Args[1] 3028 v_0 := v.Args[0] 3029 b := v.Block 3030 typ := &b.Func.Config.Types 3031 // match: (Neq64 x y) 3032 // result: (Not (Eq64 x y)) 3033 for { 3034 x := v_0 3035 y := v_1 3036 v.reset(OpNot) 3037 v0 := b.NewValue0(v.Pos, OpEq64, typ.Bool) 3038 v0.AddArg2(x, y) 3039 v.AddArg(v0) 3040 return true 3041 } 3042 } 3043 func rewriteValueRISCV64_OpNeq8(v *Value) bool { 3044 v_1 := v.Args[1] 3045 v_0 := v.Args[0] 3046 b := v.Block 3047 typ := &b.Func.Config.Types 3048 // match: (Neq8 x y) 3049 // result: (Not (Eq8 x y)) 3050 for { 3051 x := v_0 3052 y := v_1 3053 v.reset(OpNot) 3054 v0 := b.NewValue0(v.Pos, OpEq8, typ.Bool) 3055 v0.AddArg2(x, y) 3056 v.AddArg(v0) 3057 return true 3058 } 3059 } 3060 func rewriteValueRISCV64_OpNeqB(v *Value) bool { 3061 v_1 := v.Args[1] 3062 v_0 := v.Args[0] 3063 b := v.Block 3064 typ := &b.Func.Config.Types 3065 // match: (NeqB x y) 3066 // result: (SNEZ (SUB <typ.Bool> x y)) 3067 for { 3068 x := v_0 3069 y := v_1 3070 v.reset(OpRISCV64SNEZ) 3071 v0 := b.NewValue0(v.Pos, OpRISCV64SUB, typ.Bool) 3072 v0.AddArg2(x, y) 3073 v.AddArg(v0) 3074 return true 3075 } 3076 } 3077 func rewriteValueRISCV64_OpNeqPtr(v *Value) bool { 3078 v_1 := v.Args[1] 3079 v_0 := v.Args[0] 3080 b := v.Block 3081 typ := &b.Func.Config.Types 3082 // match: (NeqPtr x y) 3083 // result: (Not (EqPtr x y)) 3084 for { 3085 x := v_0 3086 y := v_1 3087 v.reset(OpNot) 3088 v0 := b.NewValue0(v.Pos, OpEqPtr, typ.Bool) 3089 v0.AddArg2(x, y) 3090 v.AddArg(v0) 3091 return true 3092 } 3093 } 3094 func rewriteValueRISCV64_OpOffPtr(v *Value) bool { 3095 v_0 := v.Args[0] 3096 b := v.Block 3097 typ := &b.Func.Config.Types 3098 // match: (OffPtr [off] ptr:(SP)) 3099 // cond: is32Bit(off) 3100 // result: (MOVaddr [int32(off)] ptr) 3101 for { 3102 off := auxIntToInt64(v.AuxInt) 3103 ptr := v_0 3104 if ptr.Op != OpSP || !(is32Bit(off)) { 3105 break 3106 } 3107 v.reset(OpRISCV64MOVaddr) 3108 v.AuxInt = int32ToAuxInt(int32(off)) 3109 v.AddArg(ptr) 3110 return true 3111 } 3112 // match: (OffPtr [off] ptr) 3113 // cond: is32Bit(off) 3114 // result: (ADDI [off] ptr) 3115 for { 3116 off := auxIntToInt64(v.AuxInt) 3117 ptr := v_0 3118 if !(is32Bit(off)) { 3119 break 3120 } 3121 v.reset(OpRISCV64ADDI) 3122 v.AuxInt = int64ToAuxInt(off) 3123 v.AddArg(ptr) 3124 return true 3125 } 3126 // match: (OffPtr [off] ptr) 3127 // result: (ADD (MOVDconst [off]) ptr) 3128 for { 3129 off := auxIntToInt64(v.AuxInt) 3130 ptr := v_0 3131 v.reset(OpRISCV64ADD) 3132 v0 := b.NewValue0(v.Pos, OpRISCV64MOVDconst, typ.UInt64) 3133 v0.AuxInt = int64ToAuxInt(off) 3134 v.AddArg2(v0, ptr) 3135 return true 3136 } 3137 } 3138 func rewriteValueRISCV64_OpPanicBounds(v *Value) bool { 3139 v_2 := v.Args[2] 3140 v_1 := v.Args[1] 3141 v_0 := v.Args[0] 3142 // match: (PanicBounds [kind] x y mem) 3143 // cond: boundsABI(kind) == 0 3144 // result: (LoweredPanicBoundsA [kind] x y mem) 3145 for { 3146 kind := auxIntToInt64(v.AuxInt) 3147 x := v_0 3148 y := v_1 3149 mem := v_2 3150 if !(boundsABI(kind) == 0) { 3151 break 3152 } 3153 v.reset(OpRISCV64LoweredPanicBoundsA) 3154 v.AuxInt = int64ToAuxInt(kind) 3155 v.AddArg3(x, y, mem) 3156 return true 3157 } 3158 // match: (PanicBounds [kind] x y mem) 3159 // cond: boundsABI(kind) == 1 3160 // result: (LoweredPanicBoundsB [kind] x y mem) 3161 for { 3162 kind := auxIntToInt64(v.AuxInt) 3163 x := v_0 3164 y := v_1 3165 mem := v_2 3166 if !(boundsABI(kind) == 1) { 3167 break 3168 } 3169 v.reset(OpRISCV64LoweredPanicBoundsB) 3170 v.AuxInt = int64ToAuxInt(kind) 3171 v.AddArg3(x, y, mem) 3172 return true 3173 } 3174 // match: (PanicBounds [kind] x y mem) 3175 // cond: boundsABI(kind) == 2 3176 // result: (LoweredPanicBoundsC [kind] x y mem) 3177 for { 3178 kind := auxIntToInt64(v.AuxInt) 3179 x := v_0 3180 y := v_1 3181 mem := v_2 3182 if !(boundsABI(kind) == 2) { 3183 break 3184 } 3185 v.reset(OpRISCV64LoweredPanicBoundsC) 3186 v.AuxInt = int64ToAuxInt(kind) 3187 v.AddArg3(x, y, mem) 3188 return true 3189 } 3190 return false 3191 } 3192 func rewriteValueRISCV64_OpRISCV64ADD(v *Value) bool { 3193 v_1 := v.Args[1] 3194 v_0 := v.Args[0] 3195 // match: (ADD (MOVDconst <t> [val]) x) 3196 // cond: is32Bit(val) && !t.IsPtr() 3197 // result: (ADDI [val] x) 3198 for { 3199 for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { 3200 if v_0.Op != OpRISCV64MOVDconst { 3201 continue 3202 } 3203 t := v_0.Type 3204 val := auxIntToInt64(v_0.AuxInt) 3205 x := v_1 3206 if !(is32Bit(val) && !t.IsPtr()) { 3207 continue 3208 } 3209 v.reset(OpRISCV64ADDI) 3210 v.AuxInt = int64ToAuxInt(val) 3211 v.AddArg(x) 3212 return true 3213 } 3214 break 3215 } 3216 return false 3217 } 3218 func rewriteValueRISCV64_OpRISCV64ADDI(v *Value) bool { 3219 v_0 := v.Args[0] 3220 // match: (ADDI [c] (MOVaddr [d] {s} x)) 3221 // cond: is32Bit(c+int64(d)) 3222 // result: (MOVaddr [int32(c)+d] {s} x) 3223 for { 3224 c := auxIntToInt64(v.AuxInt) 3225 if v_0.Op != OpRISCV64MOVaddr { 3226 break 3227 } 3228 d := auxIntToInt32(v_0.AuxInt) 3229 s := auxToSym(v_0.Aux) 3230 x := v_0.Args[0] 3231 if !(is32Bit(c + int64(d))) { 3232 break 3233 } 3234 v.reset(OpRISCV64MOVaddr) 3235 v.AuxInt = int32ToAuxInt(int32(c) + d) 3236 v.Aux = symToAux(s) 3237 v.AddArg(x) 3238 return true 3239 } 3240 // match: (ADDI [0] x) 3241 // result: x 3242 for { 3243 if auxIntToInt64(v.AuxInt) != 0 { 3244 break 3245 } 3246 x := v_0 3247 v.copyOf(x) 3248 return true 3249 } 3250 // match: (ADDI [x] (MOVDconst [y])) 3251 // cond: is32Bit(x + y) 3252 // result: (MOVDconst [x + y]) 3253 for { 3254 x := auxIntToInt64(v.AuxInt) 3255 if v_0.Op != OpRISCV64MOVDconst { 3256 break 3257 } 3258 y := auxIntToInt64(v_0.AuxInt) 3259 if !(is32Bit(x + y)) { 3260 break 3261 } 3262 v.reset(OpRISCV64MOVDconst) 3263 v.AuxInt = int64ToAuxInt(x + y) 3264 return true 3265 } 3266 // match: (ADDI [x] (ADDI [y] z)) 3267 // cond: is32Bit(x + y) 3268 // result: (ADDI [x + y] z) 3269 for { 3270 x := auxIntToInt64(v.AuxInt) 3271 if v_0.Op != OpRISCV64ADDI { 3272 break 3273 } 3274 y := auxIntToInt64(v_0.AuxInt) 3275 z := v_0.Args[0] 3276 if !(is32Bit(x + y)) { 3277 break 3278 } 3279 v.reset(OpRISCV64ADDI) 3280 v.AuxInt = int64ToAuxInt(x + y) 3281 v.AddArg(z) 3282 return true 3283 } 3284 return false 3285 } 3286 func rewriteValueRISCV64_OpRISCV64AND(v *Value) bool { 3287 v_1 := v.Args[1] 3288 v_0 := v.Args[0] 3289 // match: (AND (MOVDconst [val]) x) 3290 // cond: is32Bit(val) 3291 // result: (ANDI [val] x) 3292 for { 3293 for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { 3294 if v_0.Op != OpRISCV64MOVDconst { 3295 continue 3296 } 3297 val := auxIntToInt64(v_0.AuxInt) 3298 x := v_1 3299 if !(is32Bit(val)) { 3300 continue 3301 } 3302 v.reset(OpRISCV64ANDI) 3303 v.AuxInt = int64ToAuxInt(val) 3304 v.AddArg(x) 3305 return true 3306 } 3307 break 3308 } 3309 return false 3310 } 3311 func rewriteValueRISCV64_OpRISCV64ANDI(v *Value) bool { 3312 v_0 := v.Args[0] 3313 // match: (ANDI [0] x) 3314 // result: (MOVDconst [0]) 3315 for { 3316 if auxIntToInt64(v.AuxInt) != 0 { 3317 break 3318 } 3319 v.reset(OpRISCV64MOVDconst) 3320 v.AuxInt = int64ToAuxInt(0) 3321 return true 3322 } 3323 // match: (ANDI [-1] x) 3324 // result: x 3325 for { 3326 if auxIntToInt64(v.AuxInt) != -1 { 3327 break 3328 } 3329 x := v_0 3330 v.copyOf(x) 3331 return true 3332 } 3333 // match: (ANDI [x] (MOVDconst [y])) 3334 // result: (MOVDconst [x & y]) 3335 for { 3336 x := auxIntToInt64(v.AuxInt) 3337 if v_0.Op != OpRISCV64MOVDconst { 3338 break 3339 } 3340 y := auxIntToInt64(v_0.AuxInt) 3341 v.reset(OpRISCV64MOVDconst) 3342 v.AuxInt = int64ToAuxInt(x & y) 3343 return true 3344 } 3345 // match: (ANDI [x] (ANDI [y] z)) 3346 // result: (ANDI [x & y] z) 3347 for { 3348 x := auxIntToInt64(v.AuxInt) 3349 if v_0.Op != OpRISCV64ANDI { 3350 break 3351 } 3352 y := auxIntToInt64(v_0.AuxInt) 3353 z := v_0.Args[0] 3354 v.reset(OpRISCV64ANDI) 3355 v.AuxInt = int64ToAuxInt(x & y) 3356 v.AddArg(z) 3357 return true 3358 } 3359 return false 3360 } 3361 func rewriteValueRISCV64_OpRISCV64FADDD(v *Value) bool { 3362 v_1 := v.Args[1] 3363 v_0 := v.Args[0] 3364 // match: (FADDD a (FMULD x y)) 3365 // cond: a.Block.Func.useFMA(v) 3366 // result: (FMADDD x y a) 3367 for { 3368 for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { 3369 a := v_0 3370 if v_1.Op != OpRISCV64FMULD { 3371 continue 3372 } 3373 y := v_1.Args[1] 3374 x := v_1.Args[0] 3375 if !(a.Block.Func.useFMA(v)) { 3376 continue 3377 } 3378 v.reset(OpRISCV64FMADDD) 3379 v.AddArg3(x, y, a) 3380 return true 3381 } 3382 break 3383 } 3384 return false 3385 } 3386 func rewriteValueRISCV64_OpRISCV64FADDS(v *Value) bool { 3387 v_1 := v.Args[1] 3388 v_0 := v.Args[0] 3389 // match: (FADDS a (FMULS x y)) 3390 // cond: a.Block.Func.useFMA(v) 3391 // result: (FMADDS x y a) 3392 for { 3393 for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { 3394 a := v_0 3395 if v_1.Op != OpRISCV64FMULS { 3396 continue 3397 } 3398 y := v_1.Args[1] 3399 x := v_1.Args[0] 3400 if !(a.Block.Func.useFMA(v)) { 3401 continue 3402 } 3403 v.reset(OpRISCV64FMADDS) 3404 v.AddArg3(x, y, a) 3405 return true 3406 } 3407 break 3408 } 3409 return false 3410 } 3411 func rewriteValueRISCV64_OpRISCV64FMADDD(v *Value) bool { 3412 v_2 := v.Args[2] 3413 v_1 := v.Args[1] 3414 v_0 := v.Args[0] 3415 // match: (FMADDD neg:(FNEGD x) y z) 3416 // cond: neg.Uses == 1 3417 // result: (FNMSUBD x y z) 3418 for { 3419 for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { 3420 neg := v_0 3421 if neg.Op != OpRISCV64FNEGD { 3422 continue 3423 } 3424 x := neg.Args[0] 3425 y := v_1 3426 z := v_2 3427 if !(neg.Uses == 1) { 3428 continue 3429 } 3430 v.reset(OpRISCV64FNMSUBD) 3431 v.AddArg3(x, y, z) 3432 return true 3433 } 3434 break 3435 } 3436 // match: (FMADDD x y neg:(FNEGD z)) 3437 // cond: neg.Uses == 1 3438 // result: (FMSUBD x y z) 3439 for { 3440 x := v_0 3441 y := v_1 3442 neg := v_2 3443 if neg.Op != OpRISCV64FNEGD { 3444 break 3445 } 3446 z := neg.Args[0] 3447 if !(neg.Uses == 1) { 3448 break 3449 } 3450 v.reset(OpRISCV64FMSUBD) 3451 v.AddArg3(x, y, z) 3452 return true 3453 } 3454 return false 3455 } 3456 func rewriteValueRISCV64_OpRISCV64FMADDS(v *Value) bool { 3457 v_2 := v.Args[2] 3458 v_1 := v.Args[1] 3459 v_0 := v.Args[0] 3460 // match: (FMADDS neg:(FNEGS x) y z) 3461 // cond: neg.Uses == 1 3462 // result: (FNMSUBS x y z) 3463 for { 3464 for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { 3465 neg := v_0 3466 if neg.Op != OpRISCV64FNEGS { 3467 continue 3468 } 3469 x := neg.Args[0] 3470 y := v_1 3471 z := v_2 3472 if !(neg.Uses == 1) { 3473 continue 3474 } 3475 v.reset(OpRISCV64FNMSUBS) 3476 v.AddArg3(x, y, z) 3477 return true 3478 } 3479 break 3480 } 3481 // match: (FMADDS x y neg:(FNEGS z)) 3482 // cond: neg.Uses == 1 3483 // result: (FMSUBS x y z) 3484 for { 3485 x := v_0 3486 y := v_1 3487 neg := v_2 3488 if neg.Op != OpRISCV64FNEGS { 3489 break 3490 } 3491 z := neg.Args[0] 3492 if !(neg.Uses == 1) { 3493 break 3494 } 3495 v.reset(OpRISCV64FMSUBS) 3496 v.AddArg3(x, y, z) 3497 return true 3498 } 3499 return false 3500 } 3501 func rewriteValueRISCV64_OpRISCV64FMSUBD(v *Value) bool { 3502 v_2 := v.Args[2] 3503 v_1 := v.Args[1] 3504 v_0 := v.Args[0] 3505 // match: (FMSUBD neg:(FNEGD x) y z) 3506 // cond: neg.Uses == 1 3507 // result: (FNMADDD x y z) 3508 for { 3509 for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { 3510 neg := v_0 3511 if neg.Op != OpRISCV64FNEGD { 3512 continue 3513 } 3514 x := neg.Args[0] 3515 y := v_1 3516 z := v_2 3517 if !(neg.Uses == 1) { 3518 continue 3519 } 3520 v.reset(OpRISCV64FNMADDD) 3521 v.AddArg3(x, y, z) 3522 return true 3523 } 3524 break 3525 } 3526 // match: (FMSUBD x y neg:(FNEGD z)) 3527 // cond: neg.Uses == 1 3528 // result: (FMADDD x y z) 3529 for { 3530 x := v_0 3531 y := v_1 3532 neg := v_2 3533 if neg.Op != OpRISCV64FNEGD { 3534 break 3535 } 3536 z := neg.Args[0] 3537 if !(neg.Uses == 1) { 3538 break 3539 } 3540 v.reset(OpRISCV64FMADDD) 3541 v.AddArg3(x, y, z) 3542 return true 3543 } 3544 return false 3545 } 3546 func rewriteValueRISCV64_OpRISCV64FMSUBS(v *Value) bool { 3547 v_2 := v.Args[2] 3548 v_1 := v.Args[1] 3549 v_0 := v.Args[0] 3550 // match: (FMSUBS neg:(FNEGS x) y z) 3551 // cond: neg.Uses == 1 3552 // result: (FNMADDS x y z) 3553 for { 3554 for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { 3555 neg := v_0 3556 if neg.Op != OpRISCV64FNEGS { 3557 continue 3558 } 3559 x := neg.Args[0] 3560 y := v_1 3561 z := v_2 3562 if !(neg.Uses == 1) { 3563 continue 3564 } 3565 v.reset(OpRISCV64FNMADDS) 3566 v.AddArg3(x, y, z) 3567 return true 3568 } 3569 break 3570 } 3571 // match: (FMSUBS x y neg:(FNEGS z)) 3572 // cond: neg.Uses == 1 3573 // result: (FMADDS x y z) 3574 for { 3575 x := v_0 3576 y := v_1 3577 neg := v_2 3578 if neg.Op != OpRISCV64FNEGS { 3579 break 3580 } 3581 z := neg.Args[0] 3582 if !(neg.Uses == 1) { 3583 break 3584 } 3585 v.reset(OpRISCV64FMADDS) 3586 v.AddArg3(x, y, z) 3587 return true 3588 } 3589 return false 3590 } 3591 func rewriteValueRISCV64_OpRISCV64FNMADDD(v *Value) bool { 3592 v_2 := v.Args[2] 3593 v_1 := v.Args[1] 3594 v_0 := v.Args[0] 3595 // match: (FNMADDD neg:(FNEGD x) y z) 3596 // cond: neg.Uses == 1 3597 // result: (FMSUBD x y z) 3598 for { 3599 for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { 3600 neg := v_0 3601 if neg.Op != OpRISCV64FNEGD { 3602 continue 3603 } 3604 x := neg.Args[0] 3605 y := v_1 3606 z := v_2 3607 if !(neg.Uses == 1) { 3608 continue 3609 } 3610 v.reset(OpRISCV64FMSUBD) 3611 v.AddArg3(x, y, z) 3612 return true 3613 } 3614 break 3615 } 3616 // match: (FNMADDD x y neg:(FNEGD z)) 3617 // cond: neg.Uses == 1 3618 // result: (FNMSUBD x y z) 3619 for { 3620 x := v_0 3621 y := v_1 3622 neg := v_2 3623 if neg.Op != OpRISCV64FNEGD { 3624 break 3625 } 3626 z := neg.Args[0] 3627 if !(neg.Uses == 1) { 3628 break 3629 } 3630 v.reset(OpRISCV64FNMSUBD) 3631 v.AddArg3(x, y, z) 3632 return true 3633 } 3634 return false 3635 } 3636 func rewriteValueRISCV64_OpRISCV64FNMADDS(v *Value) bool { 3637 v_2 := v.Args[2] 3638 v_1 := v.Args[1] 3639 v_0 := v.Args[0] 3640 // match: (FNMADDS neg:(FNEGS x) y z) 3641 // cond: neg.Uses == 1 3642 // result: (FMSUBS x y z) 3643 for { 3644 for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { 3645 neg := v_0 3646 if neg.Op != OpRISCV64FNEGS { 3647 continue 3648 } 3649 x := neg.Args[0] 3650 y := v_1 3651 z := v_2 3652 if !(neg.Uses == 1) { 3653 continue 3654 } 3655 v.reset(OpRISCV64FMSUBS) 3656 v.AddArg3(x, y, z) 3657 return true 3658 } 3659 break 3660 } 3661 // match: (FNMADDS x y neg:(FNEGS z)) 3662 // cond: neg.Uses == 1 3663 // result: (FNMSUBS x y z) 3664 for { 3665 x := v_0 3666 y := v_1 3667 neg := v_2 3668 if neg.Op != OpRISCV64FNEGS { 3669 break 3670 } 3671 z := neg.Args[0] 3672 if !(neg.Uses == 1) { 3673 break 3674 } 3675 v.reset(OpRISCV64FNMSUBS) 3676 v.AddArg3(x, y, z) 3677 return true 3678 } 3679 return false 3680 } 3681 func rewriteValueRISCV64_OpRISCV64FNMSUBD(v *Value) bool { 3682 v_2 := v.Args[2] 3683 v_1 := v.Args[1] 3684 v_0 := v.Args[0] 3685 // match: (FNMSUBD neg:(FNEGD x) y z) 3686 // cond: neg.Uses == 1 3687 // result: (FMADDD x y z) 3688 for { 3689 for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { 3690 neg := v_0 3691 if neg.Op != OpRISCV64FNEGD { 3692 continue 3693 } 3694 x := neg.Args[0] 3695 y := v_1 3696 z := v_2 3697 if !(neg.Uses == 1) { 3698 continue 3699 } 3700 v.reset(OpRISCV64FMADDD) 3701 v.AddArg3(x, y, z) 3702 return true 3703 } 3704 break 3705 } 3706 // match: (FNMSUBD x y neg:(FNEGD z)) 3707 // cond: neg.Uses == 1 3708 // result: (FNMADDD x y z) 3709 for { 3710 x := v_0 3711 y := v_1 3712 neg := v_2 3713 if neg.Op != OpRISCV64FNEGD { 3714 break 3715 } 3716 z := neg.Args[0] 3717 if !(neg.Uses == 1) { 3718 break 3719 } 3720 v.reset(OpRISCV64FNMADDD) 3721 v.AddArg3(x, y, z) 3722 return true 3723 } 3724 return false 3725 } 3726 func rewriteValueRISCV64_OpRISCV64FNMSUBS(v *Value) bool { 3727 v_2 := v.Args[2] 3728 v_1 := v.Args[1] 3729 v_0 := v.Args[0] 3730 // match: (FNMSUBS neg:(FNEGS x) y z) 3731 // cond: neg.Uses == 1 3732 // result: (FMADDS x y z) 3733 for { 3734 for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { 3735 neg := v_0 3736 if neg.Op != OpRISCV64FNEGS { 3737 continue 3738 } 3739 x := neg.Args[0] 3740 y := v_1 3741 z := v_2 3742 if !(neg.Uses == 1) { 3743 continue 3744 } 3745 v.reset(OpRISCV64FMADDS) 3746 v.AddArg3(x, y, z) 3747 return true 3748 } 3749 break 3750 } 3751 // match: (FNMSUBS x y neg:(FNEGS z)) 3752 // cond: neg.Uses == 1 3753 // result: (FNMADDS x y z) 3754 for { 3755 x := v_0 3756 y := v_1 3757 neg := v_2 3758 if neg.Op != OpRISCV64FNEGS { 3759 break 3760 } 3761 z := neg.Args[0] 3762 if !(neg.Uses == 1) { 3763 break 3764 } 3765 v.reset(OpRISCV64FNMADDS) 3766 v.AddArg3(x, y, z) 3767 return true 3768 } 3769 return false 3770 } 3771 func rewriteValueRISCV64_OpRISCV64FSUBD(v *Value) bool { 3772 v_1 := v.Args[1] 3773 v_0 := v.Args[0] 3774 // match: (FSUBD a (FMULD x y)) 3775 // cond: a.Block.Func.useFMA(v) 3776 // result: (FNMSUBD x y a) 3777 for { 3778 a := v_0 3779 if v_1.Op != OpRISCV64FMULD { 3780 break 3781 } 3782 y := v_1.Args[1] 3783 x := v_1.Args[0] 3784 if !(a.Block.Func.useFMA(v)) { 3785 break 3786 } 3787 v.reset(OpRISCV64FNMSUBD) 3788 v.AddArg3(x, y, a) 3789 return true 3790 } 3791 // match: (FSUBD (FMULD x y) a) 3792 // cond: a.Block.Func.useFMA(v) 3793 // result: (FMSUBD x y a) 3794 for { 3795 if v_0.Op != OpRISCV64FMULD { 3796 break 3797 } 3798 y := v_0.Args[1] 3799 x := v_0.Args[0] 3800 a := v_1 3801 if !(a.Block.Func.useFMA(v)) { 3802 break 3803 } 3804 v.reset(OpRISCV64FMSUBD) 3805 v.AddArg3(x, y, a) 3806 return true 3807 } 3808 return false 3809 } 3810 func rewriteValueRISCV64_OpRISCV64FSUBS(v *Value) bool { 3811 v_1 := v.Args[1] 3812 v_0 := v.Args[0] 3813 // match: (FSUBS a (FMULS x y)) 3814 // cond: a.Block.Func.useFMA(v) 3815 // result: (FNMSUBS x y a) 3816 for { 3817 a := v_0 3818 if v_1.Op != OpRISCV64FMULS { 3819 break 3820 } 3821 y := v_1.Args[1] 3822 x := v_1.Args[0] 3823 if !(a.Block.Func.useFMA(v)) { 3824 break 3825 } 3826 v.reset(OpRISCV64FNMSUBS) 3827 v.AddArg3(x, y, a) 3828 return true 3829 } 3830 // match: (FSUBS (FMULS x y) a) 3831 // cond: a.Block.Func.useFMA(v) 3832 // result: (FMSUBS x y a) 3833 for { 3834 if v_0.Op != OpRISCV64FMULS { 3835 break 3836 } 3837 y := v_0.Args[1] 3838 x := v_0.Args[0] 3839 a := v_1 3840 if !(a.Block.Func.useFMA(v)) { 3841 break 3842 } 3843 v.reset(OpRISCV64FMSUBS) 3844 v.AddArg3(x, y, a) 3845 return true 3846 } 3847 return false 3848 } 3849 func rewriteValueRISCV64_OpRISCV64MOVBUload(v *Value) bool { 3850 v_1 := v.Args[1] 3851 v_0 := v.Args[0] 3852 // match: (MOVBUload [off1] {sym1} (MOVaddr [off2] {sym2} base) mem) 3853 // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) 3854 // result: (MOVBUload [off1+off2] {mergeSym(sym1,sym2)} base mem) 3855 for { 3856 off1 := auxIntToInt32(v.AuxInt) 3857 sym1 := auxToSym(v.Aux) 3858 if v_0.Op != OpRISCV64MOVaddr { 3859 break 3860 } 3861 off2 := auxIntToInt32(v_0.AuxInt) 3862 sym2 := auxToSym(v_0.Aux) 3863 base := v_0.Args[0] 3864 mem := v_1 3865 if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2)) { 3866 break 3867 } 3868 v.reset(OpRISCV64MOVBUload) 3869 v.AuxInt = int32ToAuxInt(off1 + off2) 3870 v.Aux = symToAux(mergeSym(sym1, sym2)) 3871 v.AddArg2(base, mem) 3872 return true 3873 } 3874 // match: (MOVBUload [off1] {sym} (ADDI [off2] base) mem) 3875 // cond: is32Bit(int64(off1)+off2) 3876 // result: (MOVBUload [off1+int32(off2)] {sym} base mem) 3877 for { 3878 off1 := auxIntToInt32(v.AuxInt) 3879 sym := auxToSym(v.Aux) 3880 if v_0.Op != OpRISCV64ADDI { 3881 break 3882 } 3883 off2 := auxIntToInt64(v_0.AuxInt) 3884 base := v_0.Args[0] 3885 mem := v_1 3886 if !(is32Bit(int64(off1) + off2)) { 3887 break 3888 } 3889 v.reset(OpRISCV64MOVBUload) 3890 v.AuxInt = int32ToAuxInt(off1 + int32(off2)) 3891 v.Aux = symToAux(sym) 3892 v.AddArg2(base, mem) 3893 return true 3894 } 3895 return false 3896 } 3897 func rewriteValueRISCV64_OpRISCV64MOVBUreg(v *Value) bool { 3898 v_0 := v.Args[0] 3899 b := v.Block 3900 // match: (MOVBUreg x:(FLES _ _)) 3901 // result: x 3902 for { 3903 x := v_0 3904 if x.Op != OpRISCV64FLES { 3905 break 3906 } 3907 v.copyOf(x) 3908 return true 3909 } 3910 // match: (MOVBUreg x:(FLTS _ _)) 3911 // result: x 3912 for { 3913 x := v_0 3914 if x.Op != OpRISCV64FLTS { 3915 break 3916 } 3917 v.copyOf(x) 3918 return true 3919 } 3920 // match: (MOVBUreg x:(FEQS _ _)) 3921 // result: x 3922 for { 3923 x := v_0 3924 if x.Op != OpRISCV64FEQS { 3925 break 3926 } 3927 v.copyOf(x) 3928 return true 3929 } 3930 // match: (MOVBUreg x:(FNES _ _)) 3931 // result: x 3932 for { 3933 x := v_0 3934 if x.Op != OpRISCV64FNES { 3935 break 3936 } 3937 v.copyOf(x) 3938 return true 3939 } 3940 // match: (MOVBUreg x:(FLED _ _)) 3941 // result: x 3942 for { 3943 x := v_0 3944 if x.Op != OpRISCV64FLED { 3945 break 3946 } 3947 v.copyOf(x) 3948 return true 3949 } 3950 // match: (MOVBUreg x:(FLTD _ _)) 3951 // result: x 3952 for { 3953 x := v_0 3954 if x.Op != OpRISCV64FLTD { 3955 break 3956 } 3957 v.copyOf(x) 3958 return true 3959 } 3960 // match: (MOVBUreg x:(FEQD _ _)) 3961 // result: x 3962 for { 3963 x := v_0 3964 if x.Op != OpRISCV64FEQD { 3965 break 3966 } 3967 v.copyOf(x) 3968 return true 3969 } 3970 // match: (MOVBUreg x:(FNED _ _)) 3971 // result: x 3972 for { 3973 x := v_0 3974 if x.Op != OpRISCV64FNED { 3975 break 3976 } 3977 v.copyOf(x) 3978 return true 3979 } 3980 // match: (MOVBUreg x:(SEQZ _)) 3981 // result: x 3982 for { 3983 x := v_0 3984 if x.Op != OpRISCV64SEQZ { 3985 break 3986 } 3987 v.copyOf(x) 3988 return true 3989 } 3990 // match: (MOVBUreg x:(SNEZ _)) 3991 // result: x 3992 for { 3993 x := v_0 3994 if x.Op != OpRISCV64SNEZ { 3995 break 3996 } 3997 v.copyOf(x) 3998 return true 3999 } 4000 // match: (MOVBUreg x:(SLT _ _)) 4001 // result: x 4002 for { 4003 x := v_0 4004 if x.Op != OpRISCV64SLT { 4005 break 4006 } 4007 v.copyOf(x) 4008 return true 4009 } 4010 // match: (MOVBUreg x:(SLTU _ _)) 4011 // result: x 4012 for { 4013 x := v_0 4014 if x.Op != OpRISCV64SLTU { 4015 break 4016 } 4017 v.copyOf(x) 4018 return true 4019 } 4020 // match: (MOVBUreg x:(ANDI [c] y)) 4021 // cond: c >= 0 && int64(uint8(c)) == c 4022 // result: x 4023 for { 4024 x := v_0 4025 if x.Op != OpRISCV64ANDI { 4026 break 4027 } 4028 c := auxIntToInt64(x.AuxInt) 4029 if !(c >= 0 && int64(uint8(c)) == c) { 4030 break 4031 } 4032 v.copyOf(x) 4033 return true 4034 } 4035 // match: (MOVBUreg (ANDI [c] x)) 4036 // cond: c < 0 4037 // result: (ANDI [int64(uint8(c))] x) 4038 for { 4039 if v_0.Op != OpRISCV64ANDI { 4040 break 4041 } 4042 c := auxIntToInt64(v_0.AuxInt) 4043 x := v_0.Args[0] 4044 if !(c < 0) { 4045 break 4046 } 4047 v.reset(OpRISCV64ANDI) 4048 v.AuxInt = int64ToAuxInt(int64(uint8(c))) 4049 v.AddArg(x) 4050 return true 4051 } 4052 // match: (MOVBUreg (MOVDconst [c])) 4053 // result: (MOVDconst [int64(uint8(c))]) 4054 for { 4055 if v_0.Op != OpRISCV64MOVDconst { 4056 break 4057 } 4058 c := auxIntToInt64(v_0.AuxInt) 4059 v.reset(OpRISCV64MOVDconst) 4060 v.AuxInt = int64ToAuxInt(int64(uint8(c))) 4061 return true 4062 } 4063 // match: (MOVBUreg x:(MOVBUload _ _)) 4064 // result: (MOVDreg x) 4065 for { 4066 x := v_0 4067 if x.Op != OpRISCV64MOVBUload { 4068 break 4069 } 4070 v.reset(OpRISCV64MOVDreg) 4071 v.AddArg(x) 4072 return true 4073 } 4074 // match: (MOVBUreg x:(Select0 (LoweredAtomicLoad8 _ _))) 4075 // result: (MOVDreg x) 4076 for { 4077 x := v_0 4078 if x.Op != OpSelect0 { 4079 break 4080 } 4081 x_0 := x.Args[0] 4082 if x_0.Op != OpRISCV64LoweredAtomicLoad8 { 4083 break 4084 } 4085 v.reset(OpRISCV64MOVDreg) 4086 v.AddArg(x) 4087 return true 4088 } 4089 // match: (MOVBUreg x:(Select0 (LoweredAtomicCas32 _ _ _ _))) 4090 // result: (MOVDreg x) 4091 for { 4092 x := v_0 4093 if x.Op != OpSelect0 { 4094 break 4095 } 4096 x_0 := x.Args[0] 4097 if x_0.Op != OpRISCV64LoweredAtomicCas32 { 4098 break 4099 } 4100 v.reset(OpRISCV64MOVDreg) 4101 v.AddArg(x) 4102 return true 4103 } 4104 // match: (MOVBUreg x:(Select0 (LoweredAtomicCas64 _ _ _ _))) 4105 // result: (MOVDreg x) 4106 for { 4107 x := v_0 4108 if x.Op != OpSelect0 { 4109 break 4110 } 4111 x_0 := x.Args[0] 4112 if x_0.Op != OpRISCV64LoweredAtomicCas64 { 4113 break 4114 } 4115 v.reset(OpRISCV64MOVDreg) 4116 v.AddArg(x) 4117 return true 4118 } 4119 // match: (MOVBUreg x:(MOVBUreg _)) 4120 // result: (MOVDreg x) 4121 for { 4122 x := v_0 4123 if x.Op != OpRISCV64MOVBUreg { 4124 break 4125 } 4126 v.reset(OpRISCV64MOVDreg) 4127 v.AddArg(x) 4128 return true 4129 } 4130 // match: (MOVBUreg <t> x:(MOVBload [off] {sym} ptr mem)) 4131 // cond: x.Uses == 1 && clobber(x) 4132 // result: @x.Block (MOVBUload <t> [off] {sym} ptr mem) 4133 for { 4134 t := v.Type 4135 x := v_0 4136 if x.Op != OpRISCV64MOVBload { 4137 break 4138 } 4139 off := auxIntToInt32(x.AuxInt) 4140 sym := auxToSym(x.Aux) 4141 mem := x.Args[1] 4142 ptr := x.Args[0] 4143 if !(x.Uses == 1 && clobber(x)) { 4144 break 4145 } 4146 b = x.Block 4147 v0 := b.NewValue0(x.Pos, OpRISCV64MOVBUload, t) 4148 v.copyOf(v0) 4149 v0.AuxInt = int32ToAuxInt(off) 4150 v0.Aux = symToAux(sym) 4151 v0.AddArg2(ptr, mem) 4152 return true 4153 } 4154 return false 4155 } 4156 func rewriteValueRISCV64_OpRISCV64MOVBload(v *Value) bool { 4157 v_1 := v.Args[1] 4158 v_0 := v.Args[0] 4159 // match: (MOVBload [off1] {sym1} (MOVaddr [off2] {sym2} base) mem) 4160 // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) 4161 // result: (MOVBload [off1+off2] {mergeSym(sym1,sym2)} base mem) 4162 for { 4163 off1 := auxIntToInt32(v.AuxInt) 4164 sym1 := auxToSym(v.Aux) 4165 if v_0.Op != OpRISCV64MOVaddr { 4166 break 4167 } 4168 off2 := auxIntToInt32(v_0.AuxInt) 4169 sym2 := auxToSym(v_0.Aux) 4170 base := v_0.Args[0] 4171 mem := v_1 4172 if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2)) { 4173 break 4174 } 4175 v.reset(OpRISCV64MOVBload) 4176 v.AuxInt = int32ToAuxInt(off1 + off2) 4177 v.Aux = symToAux(mergeSym(sym1, sym2)) 4178 v.AddArg2(base, mem) 4179 return true 4180 } 4181 // match: (MOVBload [off1] {sym} (ADDI [off2] base) mem) 4182 // cond: is32Bit(int64(off1)+off2) 4183 // result: (MOVBload [off1+int32(off2)] {sym} base mem) 4184 for { 4185 off1 := auxIntToInt32(v.AuxInt) 4186 sym := auxToSym(v.Aux) 4187 if v_0.Op != OpRISCV64ADDI { 4188 break 4189 } 4190 off2 := auxIntToInt64(v_0.AuxInt) 4191 base := v_0.Args[0] 4192 mem := v_1 4193 if !(is32Bit(int64(off1) + off2)) { 4194 break 4195 } 4196 v.reset(OpRISCV64MOVBload) 4197 v.AuxInt = int32ToAuxInt(off1 + int32(off2)) 4198 v.Aux = symToAux(sym) 4199 v.AddArg2(base, mem) 4200 return true 4201 } 4202 return false 4203 } 4204 func rewriteValueRISCV64_OpRISCV64MOVBreg(v *Value) bool { 4205 v_0 := v.Args[0] 4206 b := v.Block 4207 // match: (MOVBreg x:(ANDI [c] y)) 4208 // cond: c >= 0 && int64(int8(c)) == c 4209 // result: x 4210 for { 4211 x := v_0 4212 if x.Op != OpRISCV64ANDI { 4213 break 4214 } 4215 c := auxIntToInt64(x.AuxInt) 4216 if !(c >= 0 && int64(int8(c)) == c) { 4217 break 4218 } 4219 v.copyOf(x) 4220 return true 4221 } 4222 // match: (MOVBreg (MOVDconst [c])) 4223 // result: (MOVDconst [int64(int8(c))]) 4224 for { 4225 if v_0.Op != OpRISCV64MOVDconst { 4226 break 4227 } 4228 c := auxIntToInt64(v_0.AuxInt) 4229 v.reset(OpRISCV64MOVDconst) 4230 v.AuxInt = int64ToAuxInt(int64(int8(c))) 4231 return true 4232 } 4233 // match: (MOVBreg x:(MOVBload _ _)) 4234 // result: (MOVDreg x) 4235 for { 4236 x := v_0 4237 if x.Op != OpRISCV64MOVBload { 4238 break 4239 } 4240 v.reset(OpRISCV64MOVDreg) 4241 v.AddArg(x) 4242 return true 4243 } 4244 // match: (MOVBreg x:(MOVBreg _)) 4245 // result: (MOVDreg x) 4246 for { 4247 x := v_0 4248 if x.Op != OpRISCV64MOVBreg { 4249 break 4250 } 4251 v.reset(OpRISCV64MOVDreg) 4252 v.AddArg(x) 4253 return true 4254 } 4255 // match: (MOVBreg <t> x:(MOVBUload [off] {sym} ptr mem)) 4256 // cond: x.Uses == 1 && clobber(x) 4257 // result: @x.Block (MOVBload <t> [off] {sym} ptr mem) 4258 for { 4259 t := v.Type 4260 x := v_0 4261 if x.Op != OpRISCV64MOVBUload { 4262 break 4263 } 4264 off := auxIntToInt32(x.AuxInt) 4265 sym := auxToSym(x.Aux) 4266 mem := x.Args[1] 4267 ptr := x.Args[0] 4268 if !(x.Uses == 1 && clobber(x)) { 4269 break 4270 } 4271 b = x.Block 4272 v0 := b.NewValue0(x.Pos, OpRISCV64MOVBload, t) 4273 v.copyOf(v0) 4274 v0.AuxInt = int32ToAuxInt(off) 4275 v0.Aux = symToAux(sym) 4276 v0.AddArg2(ptr, mem) 4277 return true 4278 } 4279 return false 4280 } 4281 func rewriteValueRISCV64_OpRISCV64MOVBstore(v *Value) bool { 4282 v_2 := v.Args[2] 4283 v_1 := v.Args[1] 4284 v_0 := v.Args[0] 4285 // match: (MOVBstore [off1] {sym1} (MOVaddr [off2] {sym2} base) val mem) 4286 // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) 4287 // result: (MOVBstore [off1+off2] {mergeSym(sym1,sym2)} base val mem) 4288 for { 4289 off1 := auxIntToInt32(v.AuxInt) 4290 sym1 := auxToSym(v.Aux) 4291 if v_0.Op != OpRISCV64MOVaddr { 4292 break 4293 } 4294 off2 := auxIntToInt32(v_0.AuxInt) 4295 sym2 := auxToSym(v_0.Aux) 4296 base := v_0.Args[0] 4297 val := v_1 4298 mem := v_2 4299 if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2)) { 4300 break 4301 } 4302 v.reset(OpRISCV64MOVBstore) 4303 v.AuxInt = int32ToAuxInt(off1 + off2) 4304 v.Aux = symToAux(mergeSym(sym1, sym2)) 4305 v.AddArg3(base, val, mem) 4306 return true 4307 } 4308 // match: (MOVBstore [off1] {sym} (ADDI [off2] base) val mem) 4309 // cond: is32Bit(int64(off1)+off2) 4310 // result: (MOVBstore [off1+int32(off2)] {sym} base val mem) 4311 for { 4312 off1 := auxIntToInt32(v.AuxInt) 4313 sym := auxToSym(v.Aux) 4314 if v_0.Op != OpRISCV64ADDI { 4315 break 4316 } 4317 off2 := auxIntToInt64(v_0.AuxInt) 4318 base := v_0.Args[0] 4319 val := v_1 4320 mem := v_2 4321 if !(is32Bit(int64(off1) + off2)) { 4322 break 4323 } 4324 v.reset(OpRISCV64MOVBstore) 4325 v.AuxInt = int32ToAuxInt(off1 + int32(off2)) 4326 v.Aux = symToAux(sym) 4327 v.AddArg3(base, val, mem) 4328 return true 4329 } 4330 // match: (MOVBstore [off] {sym} ptr (MOVDconst [0]) mem) 4331 // result: (MOVBstorezero [off] {sym} ptr mem) 4332 for { 4333 off := auxIntToInt32(v.AuxInt) 4334 sym := auxToSym(v.Aux) 4335 ptr := v_0 4336 if v_1.Op != OpRISCV64MOVDconst || auxIntToInt64(v_1.AuxInt) != 0 { 4337 break 4338 } 4339 mem := v_2 4340 v.reset(OpRISCV64MOVBstorezero) 4341 v.AuxInt = int32ToAuxInt(off) 4342 v.Aux = symToAux(sym) 4343 v.AddArg2(ptr, mem) 4344 return true 4345 } 4346 // match: (MOVBstore [off] {sym} ptr (MOVBreg x) mem) 4347 // result: (MOVBstore [off] {sym} ptr x mem) 4348 for { 4349 off := auxIntToInt32(v.AuxInt) 4350 sym := auxToSym(v.Aux) 4351 ptr := v_0 4352 if v_1.Op != OpRISCV64MOVBreg { 4353 break 4354 } 4355 x := v_1.Args[0] 4356 mem := v_2 4357 v.reset(OpRISCV64MOVBstore) 4358 v.AuxInt = int32ToAuxInt(off) 4359 v.Aux = symToAux(sym) 4360 v.AddArg3(ptr, x, mem) 4361 return true 4362 } 4363 // match: (MOVBstore [off] {sym} ptr (MOVHreg x) mem) 4364 // result: (MOVBstore [off] {sym} ptr x mem) 4365 for { 4366 off := auxIntToInt32(v.AuxInt) 4367 sym := auxToSym(v.Aux) 4368 ptr := v_0 4369 if v_1.Op != OpRISCV64MOVHreg { 4370 break 4371 } 4372 x := v_1.Args[0] 4373 mem := v_2 4374 v.reset(OpRISCV64MOVBstore) 4375 v.AuxInt = int32ToAuxInt(off) 4376 v.Aux = symToAux(sym) 4377 v.AddArg3(ptr, x, mem) 4378 return true 4379 } 4380 // match: (MOVBstore [off] {sym} ptr (MOVWreg x) mem) 4381 // result: (MOVBstore [off] {sym} ptr x mem) 4382 for { 4383 off := auxIntToInt32(v.AuxInt) 4384 sym := auxToSym(v.Aux) 4385 ptr := v_0 4386 if v_1.Op != OpRISCV64MOVWreg { 4387 break 4388 } 4389 x := v_1.Args[0] 4390 mem := v_2 4391 v.reset(OpRISCV64MOVBstore) 4392 v.AuxInt = int32ToAuxInt(off) 4393 v.Aux = symToAux(sym) 4394 v.AddArg3(ptr, x, mem) 4395 return true 4396 } 4397 // match: (MOVBstore [off] {sym} ptr (MOVBUreg x) mem) 4398 // result: (MOVBstore [off] {sym} ptr x mem) 4399 for { 4400 off := auxIntToInt32(v.AuxInt) 4401 sym := auxToSym(v.Aux) 4402 ptr := v_0 4403 if v_1.Op != OpRISCV64MOVBUreg { 4404 break 4405 } 4406 x := v_1.Args[0] 4407 mem := v_2 4408 v.reset(OpRISCV64MOVBstore) 4409 v.AuxInt = int32ToAuxInt(off) 4410 v.Aux = symToAux(sym) 4411 v.AddArg3(ptr, x, mem) 4412 return true 4413 } 4414 // match: (MOVBstore [off] {sym} ptr (MOVHUreg x) mem) 4415 // result: (MOVBstore [off] {sym} ptr x mem) 4416 for { 4417 off := auxIntToInt32(v.AuxInt) 4418 sym := auxToSym(v.Aux) 4419 ptr := v_0 4420 if v_1.Op != OpRISCV64MOVHUreg { 4421 break 4422 } 4423 x := v_1.Args[0] 4424 mem := v_2 4425 v.reset(OpRISCV64MOVBstore) 4426 v.AuxInt = int32ToAuxInt(off) 4427 v.Aux = symToAux(sym) 4428 v.AddArg3(ptr, x, mem) 4429 return true 4430 } 4431 // match: (MOVBstore [off] {sym} ptr (MOVWUreg x) mem) 4432 // result: (MOVBstore [off] {sym} ptr x mem) 4433 for { 4434 off := auxIntToInt32(v.AuxInt) 4435 sym := auxToSym(v.Aux) 4436 ptr := v_0 4437 if v_1.Op != OpRISCV64MOVWUreg { 4438 break 4439 } 4440 x := v_1.Args[0] 4441 mem := v_2 4442 v.reset(OpRISCV64MOVBstore) 4443 v.AuxInt = int32ToAuxInt(off) 4444 v.Aux = symToAux(sym) 4445 v.AddArg3(ptr, x, mem) 4446 return true 4447 } 4448 return false 4449 } 4450 func rewriteValueRISCV64_OpRISCV64MOVBstorezero(v *Value) bool { 4451 v_1 := v.Args[1] 4452 v_0 := v.Args[0] 4453 // match: (MOVBstorezero [off1] {sym1} (MOVaddr [off2] {sym2} ptr) mem) 4454 // cond: canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2)) 4455 // result: (MOVBstorezero [off1+off2] {mergeSym(sym1,sym2)} ptr mem) 4456 for { 4457 off1 := auxIntToInt32(v.AuxInt) 4458 sym1 := auxToSym(v.Aux) 4459 if v_0.Op != OpRISCV64MOVaddr { 4460 break 4461 } 4462 off2 := auxIntToInt32(v_0.AuxInt) 4463 sym2 := auxToSym(v_0.Aux) 4464 ptr := v_0.Args[0] 4465 mem := v_1 4466 if !(canMergeSym(sym1, sym2) && is32Bit(int64(off1)+int64(off2))) { 4467 break 4468 } 4469 v.reset(OpRISCV64MOVBstorezero) 4470 v.AuxInt = int32ToAuxInt(off1 + off2) 4471 v.Aux = symToAux(mergeSym(sym1, sym2)) 4472 v.AddArg2(ptr, mem) 4473 return true 4474 } 4475 // match: (MOVBstorezero [off1] {sym} (ADDI [off2] ptr) mem) 4476 // cond: is32Bit(int64(off1)+off2) 4477 // result: (MOVBstorezero [off1+int32(off2)] {sym} ptr mem) 4478 for { 4479 off1 := auxIntToInt32(v.AuxInt) 4480 sym := auxToSym(v.Aux) 4481 if v_0.Op != OpRISCV64ADDI { 4482 break 4483 } 4484 off2 := auxIntToInt64(v_0.AuxInt) 4485 ptr := v_0.Args[0] 4486 mem := v_1 4487 if !(is32Bit(int64(off1) + off2)) { 4488 break 4489 } 4490 v.reset(OpRISCV64MOVBstorezero) 4491 v.AuxInt = int32ToAuxInt(off1 + int32(off2)) 4492 v.Aux = symToAux(sym) 4493 v.AddArg2(ptr, mem) 4494 return true 4495 } 4496 return false 4497 } 4498 func rewriteValueRISCV64_OpRISCV64MOVDload(v *Value) bool { 4499 v_1 := v.Args[1] 4500 v_0 := v.Args[0] 4501 // match: (MOVDload [off1] {sym1} (MOVaddr [off2] {sym2} base) mem) 4502 // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) 4503 // result: (MOVDload [off1+off2] {mergeSym(sym1,sym2)} base mem) 4504 for { 4505 off1 := auxIntToInt32(v.AuxInt) 4506 sym1 := auxToSym(v.Aux) 4507 if v_0.Op != OpRISCV64MOVaddr { 4508 break 4509 } 4510 off2 := auxIntToInt32(v_0.AuxInt) 4511 sym2 := auxToSym(v_0.Aux) 4512 base := v_0.Args[0] 4513 mem := v_1 4514 if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2)) { 4515 break 4516 } 4517 v.reset(OpRISCV64MOVDload) 4518 v.AuxInt = int32ToAuxInt(off1 + off2) 4519 v.Aux = symToAux(mergeSym(sym1, sym2)) 4520 v.AddArg2(base, mem) 4521 return true 4522 } 4523 // match: (MOVDload [off1] {sym} (ADDI [off2] base) mem) 4524 // cond: is32Bit(int64(off1)+off2) 4525 // result: (MOVDload [off1+int32(off2)] {sym} base mem) 4526 for { 4527 off1 := auxIntToInt32(v.AuxInt) 4528 sym := auxToSym(v.Aux) 4529 if v_0.Op != OpRISCV64ADDI { 4530 break 4531 } 4532 off2 := auxIntToInt64(v_0.AuxInt) 4533 base := v_0.Args[0] 4534 mem := v_1 4535 if !(is32Bit(int64(off1) + off2)) { 4536 break 4537 } 4538 v.reset(OpRISCV64MOVDload) 4539 v.AuxInt = int32ToAuxInt(off1 + int32(off2)) 4540 v.Aux = symToAux(sym) 4541 v.AddArg2(base, mem) 4542 return true 4543 } 4544 return false 4545 } 4546 func rewriteValueRISCV64_OpRISCV64MOVDnop(v *Value) bool { 4547 v_0 := v.Args[0] 4548 // match: (MOVDnop (MOVDconst [c])) 4549 // result: (MOVDconst [c]) 4550 for { 4551 if v_0.Op != OpRISCV64MOVDconst { 4552 break 4553 } 4554 c := auxIntToInt64(v_0.AuxInt) 4555 v.reset(OpRISCV64MOVDconst) 4556 v.AuxInt = int64ToAuxInt(c) 4557 return true 4558 } 4559 return false 4560 } 4561 func rewriteValueRISCV64_OpRISCV64MOVDreg(v *Value) bool { 4562 v_0 := v.Args[0] 4563 // match: (MOVDreg x) 4564 // cond: x.Uses == 1 4565 // result: (MOVDnop x) 4566 for { 4567 x := v_0 4568 if !(x.Uses == 1) { 4569 break 4570 } 4571 v.reset(OpRISCV64MOVDnop) 4572 v.AddArg(x) 4573 return true 4574 } 4575 return false 4576 } 4577 func rewriteValueRISCV64_OpRISCV64MOVDstore(v *Value) bool { 4578 v_2 := v.Args[2] 4579 v_1 := v.Args[1] 4580 v_0 := v.Args[0] 4581 // match: (MOVDstore [off1] {sym1} (MOVaddr [off2] {sym2} base) val mem) 4582 // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) 4583 // result: (MOVDstore [off1+off2] {mergeSym(sym1,sym2)} base val mem) 4584 for { 4585 off1 := auxIntToInt32(v.AuxInt) 4586 sym1 := auxToSym(v.Aux) 4587 if v_0.Op != OpRISCV64MOVaddr { 4588 break 4589 } 4590 off2 := auxIntToInt32(v_0.AuxInt) 4591 sym2 := auxToSym(v_0.Aux) 4592 base := v_0.Args[0] 4593 val := v_1 4594 mem := v_2 4595 if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2)) { 4596 break 4597 } 4598 v.reset(OpRISCV64MOVDstore) 4599 v.AuxInt = int32ToAuxInt(off1 + off2) 4600 v.Aux = symToAux(mergeSym(sym1, sym2)) 4601 v.AddArg3(base, val, mem) 4602 return true 4603 } 4604 // match: (MOVDstore [off1] {sym} (ADDI [off2] base) val mem) 4605 // cond: is32Bit(int64(off1)+off2) 4606 // result: (MOVDstore [off1+int32(off2)] {sym} base val mem) 4607 for { 4608 off1 := auxIntToInt32(v.AuxInt) 4609 sym := auxToSym(v.Aux) 4610 if v_0.Op != OpRISCV64ADDI { 4611 break 4612 } 4613 off2 := auxIntToInt64(v_0.AuxInt) 4614 base := v_0.Args[0] 4615 val := v_1 4616 mem := v_2 4617 if !(is32Bit(int64(off1) + off2)) { 4618 break 4619 } 4620 v.reset(OpRISCV64MOVDstore) 4621 v.AuxInt = int32ToAuxInt(off1 + int32(off2)) 4622 v.Aux = symToAux(sym) 4623 v.AddArg3(base, val, mem) 4624 return true 4625 } 4626 // match: (MOVDstore [off] {sym} ptr (MOVDconst [0]) mem) 4627 // result: (MOVDstorezero [off] {sym} ptr mem) 4628 for { 4629 off := auxIntToInt32(v.AuxInt) 4630 sym := auxToSym(v.Aux) 4631 ptr := v_0 4632 if v_1.Op != OpRISCV64MOVDconst || auxIntToInt64(v_1.AuxInt) != 0 { 4633 break 4634 } 4635 mem := v_2 4636 v.reset(OpRISCV64MOVDstorezero) 4637 v.AuxInt = int32ToAuxInt(off) 4638 v.Aux = symToAux(sym) 4639 v.AddArg2(ptr, mem) 4640 return true 4641 } 4642 return false 4643 } 4644 func rewriteValueRISCV64_OpRISCV64MOVDstorezero(v *Value) bool { 4645 v_1 := v.Args[1] 4646 v_0 := v.Args[0] 4647 // match: (MOVDstorezero [off1] {sym1} (MOVaddr [off2] {sym2} ptr) mem) 4648 // cond: canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2)) 4649 // result: (MOVDstorezero [off1+off2] {mergeSym(sym1,sym2)} ptr mem) 4650 for { 4651 off1 := auxIntToInt32(v.AuxInt) 4652 sym1 := auxToSym(v.Aux) 4653 if v_0.Op != OpRISCV64MOVaddr { 4654 break 4655 } 4656 off2 := auxIntToInt32(v_0.AuxInt) 4657 sym2 := auxToSym(v_0.Aux) 4658 ptr := v_0.Args[0] 4659 mem := v_1 4660 if !(canMergeSym(sym1, sym2) && is32Bit(int64(off1)+int64(off2))) { 4661 break 4662 } 4663 v.reset(OpRISCV64MOVDstorezero) 4664 v.AuxInt = int32ToAuxInt(off1 + off2) 4665 v.Aux = symToAux(mergeSym(sym1, sym2)) 4666 v.AddArg2(ptr, mem) 4667 return true 4668 } 4669 // match: (MOVDstorezero [off1] {sym} (ADDI [off2] ptr) mem) 4670 // cond: is32Bit(int64(off1)+off2) 4671 // result: (MOVDstorezero [off1+int32(off2)] {sym} ptr mem) 4672 for { 4673 off1 := auxIntToInt32(v.AuxInt) 4674 sym := auxToSym(v.Aux) 4675 if v_0.Op != OpRISCV64ADDI { 4676 break 4677 } 4678 off2 := auxIntToInt64(v_0.AuxInt) 4679 ptr := v_0.Args[0] 4680 mem := v_1 4681 if !(is32Bit(int64(off1) + off2)) { 4682 break 4683 } 4684 v.reset(OpRISCV64MOVDstorezero) 4685 v.AuxInt = int32ToAuxInt(off1 + int32(off2)) 4686 v.Aux = symToAux(sym) 4687 v.AddArg2(ptr, mem) 4688 return true 4689 } 4690 return false 4691 } 4692 func rewriteValueRISCV64_OpRISCV64MOVHUload(v *Value) bool { 4693 v_1 := v.Args[1] 4694 v_0 := v.Args[0] 4695 // match: (MOVHUload [off1] {sym1} (MOVaddr [off2] {sym2} base) mem) 4696 // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) 4697 // result: (MOVHUload [off1+off2] {mergeSym(sym1,sym2)} base mem) 4698 for { 4699 off1 := auxIntToInt32(v.AuxInt) 4700 sym1 := auxToSym(v.Aux) 4701 if v_0.Op != OpRISCV64MOVaddr { 4702 break 4703 } 4704 off2 := auxIntToInt32(v_0.AuxInt) 4705 sym2 := auxToSym(v_0.Aux) 4706 base := v_0.Args[0] 4707 mem := v_1 4708 if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2)) { 4709 break 4710 } 4711 v.reset(OpRISCV64MOVHUload) 4712 v.AuxInt = int32ToAuxInt(off1 + off2) 4713 v.Aux = symToAux(mergeSym(sym1, sym2)) 4714 v.AddArg2(base, mem) 4715 return true 4716 } 4717 // match: (MOVHUload [off1] {sym} (ADDI [off2] base) mem) 4718 // cond: is32Bit(int64(off1)+off2) 4719 // result: (MOVHUload [off1+int32(off2)] {sym} base mem) 4720 for { 4721 off1 := auxIntToInt32(v.AuxInt) 4722 sym := auxToSym(v.Aux) 4723 if v_0.Op != OpRISCV64ADDI { 4724 break 4725 } 4726 off2 := auxIntToInt64(v_0.AuxInt) 4727 base := v_0.Args[0] 4728 mem := v_1 4729 if !(is32Bit(int64(off1) + off2)) { 4730 break 4731 } 4732 v.reset(OpRISCV64MOVHUload) 4733 v.AuxInt = int32ToAuxInt(off1 + int32(off2)) 4734 v.Aux = symToAux(sym) 4735 v.AddArg2(base, mem) 4736 return true 4737 } 4738 return false 4739 } 4740 func rewriteValueRISCV64_OpRISCV64MOVHUreg(v *Value) bool { 4741 v_0 := v.Args[0] 4742 b := v.Block 4743 // match: (MOVHUreg x:(ANDI [c] y)) 4744 // cond: c >= 0 && int64(uint16(c)) == c 4745 // result: x 4746 for { 4747 x := v_0 4748 if x.Op != OpRISCV64ANDI { 4749 break 4750 } 4751 c := auxIntToInt64(x.AuxInt) 4752 if !(c >= 0 && int64(uint16(c)) == c) { 4753 break 4754 } 4755 v.copyOf(x) 4756 return true 4757 } 4758 // match: (MOVHUreg (ANDI [c] x)) 4759 // cond: c < 0 4760 // result: (ANDI [int64(uint16(c))] x) 4761 for { 4762 if v_0.Op != OpRISCV64ANDI { 4763 break 4764 } 4765 c := auxIntToInt64(v_0.AuxInt) 4766 x := v_0.Args[0] 4767 if !(c < 0) { 4768 break 4769 } 4770 v.reset(OpRISCV64ANDI) 4771 v.AuxInt = int64ToAuxInt(int64(uint16(c))) 4772 v.AddArg(x) 4773 return true 4774 } 4775 // match: (MOVHUreg (MOVDconst [c])) 4776 // result: (MOVDconst [int64(uint16(c))]) 4777 for { 4778 if v_0.Op != OpRISCV64MOVDconst { 4779 break 4780 } 4781 c := auxIntToInt64(v_0.AuxInt) 4782 v.reset(OpRISCV64MOVDconst) 4783 v.AuxInt = int64ToAuxInt(int64(uint16(c))) 4784 return true 4785 } 4786 // match: (MOVHUreg x:(MOVBUload _ _)) 4787 // result: (MOVDreg x) 4788 for { 4789 x := v_0 4790 if x.Op != OpRISCV64MOVBUload { 4791 break 4792 } 4793 v.reset(OpRISCV64MOVDreg) 4794 v.AddArg(x) 4795 return true 4796 } 4797 // match: (MOVHUreg x:(MOVHUload _ _)) 4798 // result: (MOVDreg x) 4799 for { 4800 x := v_0 4801 if x.Op != OpRISCV64MOVHUload { 4802 break 4803 } 4804 v.reset(OpRISCV64MOVDreg) 4805 v.AddArg(x) 4806 return true 4807 } 4808 // match: (MOVHUreg x:(MOVBUreg _)) 4809 // result: (MOVDreg x) 4810 for { 4811 x := v_0 4812 if x.Op != OpRISCV64MOVBUreg { 4813 break 4814 } 4815 v.reset(OpRISCV64MOVDreg) 4816 v.AddArg(x) 4817 return true 4818 } 4819 // match: (MOVHUreg x:(MOVHUreg _)) 4820 // result: (MOVDreg x) 4821 for { 4822 x := v_0 4823 if x.Op != OpRISCV64MOVHUreg { 4824 break 4825 } 4826 v.reset(OpRISCV64MOVDreg) 4827 v.AddArg(x) 4828 return true 4829 } 4830 // match: (MOVHUreg <t> x:(MOVHload [off] {sym} ptr mem)) 4831 // cond: x.Uses == 1 && clobber(x) 4832 // result: @x.Block (MOVHUload <t> [off] {sym} ptr mem) 4833 for { 4834 t := v.Type 4835 x := v_0 4836 if x.Op != OpRISCV64MOVHload { 4837 break 4838 } 4839 off := auxIntToInt32(x.AuxInt) 4840 sym := auxToSym(x.Aux) 4841 mem := x.Args[1] 4842 ptr := x.Args[0] 4843 if !(x.Uses == 1 && clobber(x)) { 4844 break 4845 } 4846 b = x.Block 4847 v0 := b.NewValue0(x.Pos, OpRISCV64MOVHUload, t) 4848 v.copyOf(v0) 4849 v0.AuxInt = int32ToAuxInt(off) 4850 v0.Aux = symToAux(sym) 4851 v0.AddArg2(ptr, mem) 4852 return true 4853 } 4854 return false 4855 } 4856 func rewriteValueRISCV64_OpRISCV64MOVHload(v *Value) bool { 4857 v_1 := v.Args[1] 4858 v_0 := v.Args[0] 4859 // match: (MOVHload [off1] {sym1} (MOVaddr [off2] {sym2} base) mem) 4860 // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) 4861 // result: (MOVHload [off1+off2] {mergeSym(sym1,sym2)} base mem) 4862 for { 4863 off1 := auxIntToInt32(v.AuxInt) 4864 sym1 := auxToSym(v.Aux) 4865 if v_0.Op != OpRISCV64MOVaddr { 4866 break 4867 } 4868 off2 := auxIntToInt32(v_0.AuxInt) 4869 sym2 := auxToSym(v_0.Aux) 4870 base := v_0.Args[0] 4871 mem := v_1 4872 if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2)) { 4873 break 4874 } 4875 v.reset(OpRISCV64MOVHload) 4876 v.AuxInt = int32ToAuxInt(off1 + off2) 4877 v.Aux = symToAux(mergeSym(sym1, sym2)) 4878 v.AddArg2(base, mem) 4879 return true 4880 } 4881 // match: (MOVHload [off1] {sym} (ADDI [off2] base) mem) 4882 // cond: is32Bit(int64(off1)+off2) 4883 // result: (MOVHload [off1+int32(off2)] {sym} base mem) 4884 for { 4885 off1 := auxIntToInt32(v.AuxInt) 4886 sym := auxToSym(v.Aux) 4887 if v_0.Op != OpRISCV64ADDI { 4888 break 4889 } 4890 off2 := auxIntToInt64(v_0.AuxInt) 4891 base := v_0.Args[0] 4892 mem := v_1 4893 if !(is32Bit(int64(off1) + off2)) { 4894 break 4895 } 4896 v.reset(OpRISCV64MOVHload) 4897 v.AuxInt = int32ToAuxInt(off1 + int32(off2)) 4898 v.Aux = symToAux(sym) 4899 v.AddArg2(base, mem) 4900 return true 4901 } 4902 return false 4903 } 4904 func rewriteValueRISCV64_OpRISCV64MOVHreg(v *Value) bool { 4905 v_0 := v.Args[0] 4906 b := v.Block 4907 // match: (MOVHreg x:(ANDI [c] y)) 4908 // cond: c >= 0 && int64(int16(c)) == c 4909 // result: x 4910 for { 4911 x := v_0 4912 if x.Op != OpRISCV64ANDI { 4913 break 4914 } 4915 c := auxIntToInt64(x.AuxInt) 4916 if !(c >= 0 && int64(int16(c)) == c) { 4917 break 4918 } 4919 v.copyOf(x) 4920 return true 4921 } 4922 // match: (MOVHreg (MOVDconst [c])) 4923 // result: (MOVDconst [int64(int16(c))]) 4924 for { 4925 if v_0.Op != OpRISCV64MOVDconst { 4926 break 4927 } 4928 c := auxIntToInt64(v_0.AuxInt) 4929 v.reset(OpRISCV64MOVDconst) 4930 v.AuxInt = int64ToAuxInt(int64(int16(c))) 4931 return true 4932 } 4933 // match: (MOVHreg x:(MOVBload _ _)) 4934 // result: (MOVDreg x) 4935 for { 4936 x := v_0 4937 if x.Op != OpRISCV64MOVBload { 4938 break 4939 } 4940 v.reset(OpRISCV64MOVDreg) 4941 v.AddArg(x) 4942 return true 4943 } 4944 // match: (MOVHreg x:(MOVBUload _ _)) 4945 // result: (MOVDreg x) 4946 for { 4947 x := v_0 4948 if x.Op != OpRISCV64MOVBUload { 4949 break 4950 } 4951 v.reset(OpRISCV64MOVDreg) 4952 v.AddArg(x) 4953 return true 4954 } 4955 // match: (MOVHreg x:(MOVHload _ _)) 4956 // result: (MOVDreg x) 4957 for { 4958 x := v_0 4959 if x.Op != OpRISCV64MOVHload { 4960 break 4961 } 4962 v.reset(OpRISCV64MOVDreg) 4963 v.AddArg(x) 4964 return true 4965 } 4966 // match: (MOVHreg x:(MOVBreg _)) 4967 // result: (MOVDreg x) 4968 for { 4969 x := v_0 4970 if x.Op != OpRISCV64MOVBreg { 4971 break 4972 } 4973 v.reset(OpRISCV64MOVDreg) 4974 v.AddArg(x) 4975 return true 4976 } 4977 // match: (MOVHreg x:(MOVBUreg _)) 4978 // result: (MOVDreg x) 4979 for { 4980 x := v_0 4981 if x.Op != OpRISCV64MOVBUreg { 4982 break 4983 } 4984 v.reset(OpRISCV64MOVDreg) 4985 v.AddArg(x) 4986 return true 4987 } 4988 // match: (MOVHreg x:(MOVHreg _)) 4989 // result: (MOVDreg x) 4990 for { 4991 x := v_0 4992 if x.Op != OpRISCV64MOVHreg { 4993 break 4994 } 4995 v.reset(OpRISCV64MOVDreg) 4996 v.AddArg(x) 4997 return true 4998 } 4999 // match: (MOVHreg <t> x:(MOVHUload [off] {sym} ptr mem)) 5000 // cond: x.Uses == 1 && clobber(x) 5001 // result: @x.Block (MOVHload <t> [off] {sym} ptr mem) 5002 for { 5003 t := v.Type 5004 x := v_0 5005 if x.Op != OpRISCV64MOVHUload { 5006 break 5007 } 5008 off := auxIntToInt32(x.AuxInt) 5009 sym := auxToSym(x.Aux) 5010 mem := x.Args[1] 5011 ptr := x.Args[0] 5012 if !(x.Uses == 1 && clobber(x)) { 5013 break 5014 } 5015 b = x.Block 5016 v0 := b.NewValue0(x.Pos, OpRISCV64MOVHload, t) 5017 v.copyOf(v0) 5018 v0.AuxInt = int32ToAuxInt(off) 5019 v0.Aux = symToAux(sym) 5020 v0.AddArg2(ptr, mem) 5021 return true 5022 } 5023 return false 5024 } 5025 func rewriteValueRISCV64_OpRISCV64MOVHstore(v *Value) bool { 5026 v_2 := v.Args[2] 5027 v_1 := v.Args[1] 5028 v_0 := v.Args[0] 5029 // match: (MOVHstore [off1] {sym1} (MOVaddr [off2] {sym2} base) val mem) 5030 // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) 5031 // result: (MOVHstore [off1+off2] {mergeSym(sym1,sym2)} base val mem) 5032 for { 5033 off1 := auxIntToInt32(v.AuxInt) 5034 sym1 := auxToSym(v.Aux) 5035 if v_0.Op != OpRISCV64MOVaddr { 5036 break 5037 } 5038 off2 := auxIntToInt32(v_0.AuxInt) 5039 sym2 := auxToSym(v_0.Aux) 5040 base := v_0.Args[0] 5041 val := v_1 5042 mem := v_2 5043 if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2)) { 5044 break 5045 } 5046 v.reset(OpRISCV64MOVHstore) 5047 v.AuxInt = int32ToAuxInt(off1 + off2) 5048 v.Aux = symToAux(mergeSym(sym1, sym2)) 5049 v.AddArg3(base, val, mem) 5050 return true 5051 } 5052 // match: (MOVHstore [off1] {sym} (ADDI [off2] base) val mem) 5053 // cond: is32Bit(int64(off1)+off2) 5054 // result: (MOVHstore [off1+int32(off2)] {sym} base val mem) 5055 for { 5056 off1 := auxIntToInt32(v.AuxInt) 5057 sym := auxToSym(v.Aux) 5058 if v_0.Op != OpRISCV64ADDI { 5059 break 5060 } 5061 off2 := auxIntToInt64(v_0.AuxInt) 5062 base := v_0.Args[0] 5063 val := v_1 5064 mem := v_2 5065 if !(is32Bit(int64(off1) + off2)) { 5066 break 5067 } 5068 v.reset(OpRISCV64MOVHstore) 5069 v.AuxInt = int32ToAuxInt(off1 + int32(off2)) 5070 v.Aux = symToAux(sym) 5071 v.AddArg3(base, val, mem) 5072 return true 5073 } 5074 // match: (MOVHstore [off] {sym} ptr (MOVDconst [0]) mem) 5075 // result: (MOVHstorezero [off] {sym} ptr mem) 5076 for { 5077 off := auxIntToInt32(v.AuxInt) 5078 sym := auxToSym(v.Aux) 5079 ptr := v_0 5080 if v_1.Op != OpRISCV64MOVDconst || auxIntToInt64(v_1.AuxInt) != 0 { 5081 break 5082 } 5083 mem := v_2 5084 v.reset(OpRISCV64MOVHstorezero) 5085 v.AuxInt = int32ToAuxInt(off) 5086 v.Aux = symToAux(sym) 5087 v.AddArg2(ptr, mem) 5088 return true 5089 } 5090 // match: (MOVHstore [off] {sym} ptr (MOVHreg x) mem) 5091 // result: (MOVHstore [off] {sym} ptr x mem) 5092 for { 5093 off := auxIntToInt32(v.AuxInt) 5094 sym := auxToSym(v.Aux) 5095 ptr := v_0 5096 if v_1.Op != OpRISCV64MOVHreg { 5097 break 5098 } 5099 x := v_1.Args[0] 5100 mem := v_2 5101 v.reset(OpRISCV64MOVHstore) 5102 v.AuxInt = int32ToAuxInt(off) 5103 v.Aux = symToAux(sym) 5104 v.AddArg3(ptr, x, mem) 5105 return true 5106 } 5107 // match: (MOVHstore [off] {sym} ptr (MOVWreg x) mem) 5108 // result: (MOVHstore [off] {sym} ptr x mem) 5109 for { 5110 off := auxIntToInt32(v.AuxInt) 5111 sym := auxToSym(v.Aux) 5112 ptr := v_0 5113 if v_1.Op != OpRISCV64MOVWreg { 5114 break 5115 } 5116 x := v_1.Args[0] 5117 mem := v_2 5118 v.reset(OpRISCV64MOVHstore) 5119 v.AuxInt = int32ToAuxInt(off) 5120 v.Aux = symToAux(sym) 5121 v.AddArg3(ptr, x, mem) 5122 return true 5123 } 5124 // match: (MOVHstore [off] {sym} ptr (MOVHUreg x) mem) 5125 // result: (MOVHstore [off] {sym} ptr x mem) 5126 for { 5127 off := auxIntToInt32(v.AuxInt) 5128 sym := auxToSym(v.Aux) 5129 ptr := v_0 5130 if v_1.Op != OpRISCV64MOVHUreg { 5131 break 5132 } 5133 x := v_1.Args[0] 5134 mem := v_2 5135 v.reset(OpRISCV64MOVHstore) 5136 v.AuxInt = int32ToAuxInt(off) 5137 v.Aux = symToAux(sym) 5138 v.AddArg3(ptr, x, mem) 5139 return true 5140 } 5141 // match: (MOVHstore [off] {sym} ptr (MOVWUreg x) mem) 5142 // result: (MOVHstore [off] {sym} ptr x mem) 5143 for { 5144 off := auxIntToInt32(v.AuxInt) 5145 sym := auxToSym(v.Aux) 5146 ptr := v_0 5147 if v_1.Op != OpRISCV64MOVWUreg { 5148 break 5149 } 5150 x := v_1.Args[0] 5151 mem := v_2 5152 v.reset(OpRISCV64MOVHstore) 5153 v.AuxInt = int32ToAuxInt(off) 5154 v.Aux = symToAux(sym) 5155 v.AddArg3(ptr, x, mem) 5156 return true 5157 } 5158 return false 5159 } 5160 func rewriteValueRISCV64_OpRISCV64MOVHstorezero(v *Value) bool { 5161 v_1 := v.Args[1] 5162 v_0 := v.Args[0] 5163 // match: (MOVHstorezero [off1] {sym1} (MOVaddr [off2] {sym2} ptr) mem) 5164 // cond: canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2)) 5165 // result: (MOVHstorezero [off1+off2] {mergeSym(sym1,sym2)} ptr mem) 5166 for { 5167 off1 := auxIntToInt32(v.AuxInt) 5168 sym1 := auxToSym(v.Aux) 5169 if v_0.Op != OpRISCV64MOVaddr { 5170 break 5171 } 5172 off2 := auxIntToInt32(v_0.AuxInt) 5173 sym2 := auxToSym(v_0.Aux) 5174 ptr := v_0.Args[0] 5175 mem := v_1 5176 if !(canMergeSym(sym1, sym2) && is32Bit(int64(off1)+int64(off2))) { 5177 break 5178 } 5179 v.reset(OpRISCV64MOVHstorezero) 5180 v.AuxInt = int32ToAuxInt(off1 + off2) 5181 v.Aux = symToAux(mergeSym(sym1, sym2)) 5182 v.AddArg2(ptr, mem) 5183 return true 5184 } 5185 // match: (MOVHstorezero [off1] {sym} (ADDI [off2] ptr) mem) 5186 // cond: is32Bit(int64(off1)+off2) 5187 // result: (MOVHstorezero [off1+int32(off2)] {sym} ptr mem) 5188 for { 5189 off1 := auxIntToInt32(v.AuxInt) 5190 sym := auxToSym(v.Aux) 5191 if v_0.Op != OpRISCV64ADDI { 5192 break 5193 } 5194 off2 := auxIntToInt64(v_0.AuxInt) 5195 ptr := v_0.Args[0] 5196 mem := v_1 5197 if !(is32Bit(int64(off1) + off2)) { 5198 break 5199 } 5200 v.reset(OpRISCV64MOVHstorezero) 5201 v.AuxInt = int32ToAuxInt(off1 + int32(off2)) 5202 v.Aux = symToAux(sym) 5203 v.AddArg2(ptr, mem) 5204 return true 5205 } 5206 return false 5207 } 5208 func rewriteValueRISCV64_OpRISCV64MOVWUload(v *Value) bool { 5209 v_1 := v.Args[1] 5210 v_0 := v.Args[0] 5211 // match: (MOVWUload [off1] {sym1} (MOVaddr [off2] {sym2} base) mem) 5212 // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) 5213 // result: (MOVWUload [off1+off2] {mergeSym(sym1,sym2)} base mem) 5214 for { 5215 off1 := auxIntToInt32(v.AuxInt) 5216 sym1 := auxToSym(v.Aux) 5217 if v_0.Op != OpRISCV64MOVaddr { 5218 break 5219 } 5220 off2 := auxIntToInt32(v_0.AuxInt) 5221 sym2 := auxToSym(v_0.Aux) 5222 base := v_0.Args[0] 5223 mem := v_1 5224 if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2)) { 5225 break 5226 } 5227 v.reset(OpRISCV64MOVWUload) 5228 v.AuxInt = int32ToAuxInt(off1 + off2) 5229 v.Aux = symToAux(mergeSym(sym1, sym2)) 5230 v.AddArg2(base, mem) 5231 return true 5232 } 5233 // match: (MOVWUload [off1] {sym} (ADDI [off2] base) mem) 5234 // cond: is32Bit(int64(off1)+off2) 5235 // result: (MOVWUload [off1+int32(off2)] {sym} base mem) 5236 for { 5237 off1 := auxIntToInt32(v.AuxInt) 5238 sym := auxToSym(v.Aux) 5239 if v_0.Op != OpRISCV64ADDI { 5240 break 5241 } 5242 off2 := auxIntToInt64(v_0.AuxInt) 5243 base := v_0.Args[0] 5244 mem := v_1 5245 if !(is32Bit(int64(off1) + off2)) { 5246 break 5247 } 5248 v.reset(OpRISCV64MOVWUload) 5249 v.AuxInt = int32ToAuxInt(off1 + int32(off2)) 5250 v.Aux = symToAux(sym) 5251 v.AddArg2(base, mem) 5252 return true 5253 } 5254 return false 5255 } 5256 func rewriteValueRISCV64_OpRISCV64MOVWUreg(v *Value) bool { 5257 v_0 := v.Args[0] 5258 b := v.Block 5259 typ := &b.Func.Config.Types 5260 // match: (MOVWUreg x:(ANDI [c] y)) 5261 // cond: c >= 0 && int64(uint32(c)) == c 5262 // result: x 5263 for { 5264 x := v_0 5265 if x.Op != OpRISCV64ANDI { 5266 break 5267 } 5268 c := auxIntToInt64(x.AuxInt) 5269 if !(c >= 0 && int64(uint32(c)) == c) { 5270 break 5271 } 5272 v.copyOf(x) 5273 return true 5274 } 5275 // match: (MOVWUreg (ANDI [c] x)) 5276 // cond: c < 0 5277 // result: (AND (MOVDconst [int64(uint32(c))]) x) 5278 for { 5279 if v_0.Op != OpRISCV64ANDI { 5280 break 5281 } 5282 c := auxIntToInt64(v_0.AuxInt) 5283 x := v_0.Args[0] 5284 if !(c < 0) { 5285 break 5286 } 5287 v.reset(OpRISCV64AND) 5288 v0 := b.NewValue0(v.Pos, OpRISCV64MOVDconst, typ.UInt64) 5289 v0.AuxInt = int64ToAuxInt(int64(uint32(c))) 5290 v.AddArg2(v0, x) 5291 return true 5292 } 5293 // match: (MOVWUreg (MOVDconst [c])) 5294 // result: (MOVDconst [int64(uint32(c))]) 5295 for { 5296 if v_0.Op != OpRISCV64MOVDconst { 5297 break 5298 } 5299 c := auxIntToInt64(v_0.AuxInt) 5300 v.reset(OpRISCV64MOVDconst) 5301 v.AuxInt = int64ToAuxInt(int64(uint32(c))) 5302 return true 5303 } 5304 // match: (MOVWUreg x:(MOVBUload _ _)) 5305 // result: (MOVDreg x) 5306 for { 5307 x := v_0 5308 if x.Op != OpRISCV64MOVBUload { 5309 break 5310 } 5311 v.reset(OpRISCV64MOVDreg) 5312 v.AddArg(x) 5313 return true 5314 } 5315 // match: (MOVWUreg x:(MOVHUload _ _)) 5316 // result: (MOVDreg x) 5317 for { 5318 x := v_0 5319 if x.Op != OpRISCV64MOVHUload { 5320 break 5321 } 5322 v.reset(OpRISCV64MOVDreg) 5323 v.AddArg(x) 5324 return true 5325 } 5326 // match: (MOVWUreg x:(MOVWUload _ _)) 5327 // result: (MOVDreg x) 5328 for { 5329 x := v_0 5330 if x.Op != OpRISCV64MOVWUload { 5331 break 5332 } 5333 v.reset(OpRISCV64MOVDreg) 5334 v.AddArg(x) 5335 return true 5336 } 5337 // match: (MOVWUreg x:(MOVBUreg _)) 5338 // result: (MOVDreg x) 5339 for { 5340 x := v_0 5341 if x.Op != OpRISCV64MOVBUreg { 5342 break 5343 } 5344 v.reset(OpRISCV64MOVDreg) 5345 v.AddArg(x) 5346 return true 5347 } 5348 // match: (MOVWUreg x:(MOVHUreg _)) 5349 // result: (MOVDreg x) 5350 for { 5351 x := v_0 5352 if x.Op != OpRISCV64MOVHUreg { 5353 break 5354 } 5355 v.reset(OpRISCV64MOVDreg) 5356 v.AddArg(x) 5357 return true 5358 } 5359 // match: (MOVWUreg x:(MOVWUreg _)) 5360 // result: (MOVDreg x) 5361 for { 5362 x := v_0 5363 if x.Op != OpRISCV64MOVWUreg { 5364 break 5365 } 5366 v.reset(OpRISCV64MOVDreg) 5367 v.AddArg(x) 5368 return true 5369 } 5370 // match: (MOVWUreg <t> x:(MOVWload [off] {sym} ptr mem)) 5371 // cond: x.Uses == 1 && clobber(x) 5372 // result: @x.Block (MOVWUload <t> [off] {sym} ptr mem) 5373 for { 5374 t := v.Type 5375 x := v_0 5376 if x.Op != OpRISCV64MOVWload { 5377 break 5378 } 5379 off := auxIntToInt32(x.AuxInt) 5380 sym := auxToSym(x.Aux) 5381 mem := x.Args[1] 5382 ptr := x.Args[0] 5383 if !(x.Uses == 1 && clobber(x)) { 5384 break 5385 } 5386 b = x.Block 5387 v0 := b.NewValue0(x.Pos, OpRISCV64MOVWUload, t) 5388 v.copyOf(v0) 5389 v0.AuxInt = int32ToAuxInt(off) 5390 v0.Aux = symToAux(sym) 5391 v0.AddArg2(ptr, mem) 5392 return true 5393 } 5394 return false 5395 } 5396 func rewriteValueRISCV64_OpRISCV64MOVWload(v *Value) bool { 5397 v_1 := v.Args[1] 5398 v_0 := v.Args[0] 5399 // match: (MOVWload [off1] {sym1} (MOVaddr [off2] {sym2} base) mem) 5400 // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) 5401 // result: (MOVWload [off1+off2] {mergeSym(sym1,sym2)} base mem) 5402 for { 5403 off1 := auxIntToInt32(v.AuxInt) 5404 sym1 := auxToSym(v.Aux) 5405 if v_0.Op != OpRISCV64MOVaddr { 5406 break 5407 } 5408 off2 := auxIntToInt32(v_0.AuxInt) 5409 sym2 := auxToSym(v_0.Aux) 5410 base := v_0.Args[0] 5411 mem := v_1 5412 if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2)) { 5413 break 5414 } 5415 v.reset(OpRISCV64MOVWload) 5416 v.AuxInt = int32ToAuxInt(off1 + off2) 5417 v.Aux = symToAux(mergeSym(sym1, sym2)) 5418 v.AddArg2(base, mem) 5419 return true 5420 } 5421 // match: (MOVWload [off1] {sym} (ADDI [off2] base) mem) 5422 // cond: is32Bit(int64(off1)+off2) 5423 // result: (MOVWload [off1+int32(off2)] {sym} base mem) 5424 for { 5425 off1 := auxIntToInt32(v.AuxInt) 5426 sym := auxToSym(v.Aux) 5427 if v_0.Op != OpRISCV64ADDI { 5428 break 5429 } 5430 off2 := auxIntToInt64(v_0.AuxInt) 5431 base := v_0.Args[0] 5432 mem := v_1 5433 if !(is32Bit(int64(off1) + off2)) { 5434 break 5435 } 5436 v.reset(OpRISCV64MOVWload) 5437 v.AuxInt = int32ToAuxInt(off1 + int32(off2)) 5438 v.Aux = symToAux(sym) 5439 v.AddArg2(base, mem) 5440 return true 5441 } 5442 return false 5443 } 5444 func rewriteValueRISCV64_OpRISCV64MOVWreg(v *Value) bool { 5445 v_0 := v.Args[0] 5446 b := v.Block 5447 // match: (MOVWreg x:(ANDI [c] y)) 5448 // cond: c >= 0 && int64(int32(c)) == c 5449 // result: x 5450 for { 5451 x := v_0 5452 if x.Op != OpRISCV64ANDI { 5453 break 5454 } 5455 c := auxIntToInt64(x.AuxInt) 5456 if !(c >= 0 && int64(int32(c)) == c) { 5457 break 5458 } 5459 v.copyOf(x) 5460 return true 5461 } 5462 // match: (MOVWreg (MOVDconst [c])) 5463 // result: (MOVDconst [int64(int32(c))]) 5464 for { 5465 if v_0.Op != OpRISCV64MOVDconst { 5466 break 5467 } 5468 c := auxIntToInt64(v_0.AuxInt) 5469 v.reset(OpRISCV64MOVDconst) 5470 v.AuxInt = int64ToAuxInt(int64(int32(c))) 5471 return true 5472 } 5473 // match: (MOVWreg x:(MOVBload _ _)) 5474 // result: (MOVDreg x) 5475 for { 5476 x := v_0 5477 if x.Op != OpRISCV64MOVBload { 5478 break 5479 } 5480 v.reset(OpRISCV64MOVDreg) 5481 v.AddArg(x) 5482 return true 5483 } 5484 // match: (MOVWreg x:(MOVBUload _ _)) 5485 // result: (MOVDreg x) 5486 for { 5487 x := v_0 5488 if x.Op != OpRISCV64MOVBUload { 5489 break 5490 } 5491 v.reset(OpRISCV64MOVDreg) 5492 v.AddArg(x) 5493 return true 5494 } 5495 // match: (MOVWreg x:(MOVHload _ _)) 5496 // result: (MOVDreg x) 5497 for { 5498 x := v_0 5499 if x.Op != OpRISCV64MOVHload { 5500 break 5501 } 5502 v.reset(OpRISCV64MOVDreg) 5503 v.AddArg(x) 5504 return true 5505 } 5506 // match: (MOVWreg x:(MOVHUload _ _)) 5507 // result: (MOVDreg x) 5508 for { 5509 x := v_0 5510 if x.Op != OpRISCV64MOVHUload { 5511 break 5512 } 5513 v.reset(OpRISCV64MOVDreg) 5514 v.AddArg(x) 5515 return true 5516 } 5517 // match: (MOVWreg x:(MOVWload _ _)) 5518 // result: (MOVDreg x) 5519 for { 5520 x := v_0 5521 if x.Op != OpRISCV64MOVWload { 5522 break 5523 } 5524 v.reset(OpRISCV64MOVDreg) 5525 v.AddArg(x) 5526 return true 5527 } 5528 // match: (MOVWreg x:(ADDIW _)) 5529 // result: (MOVDreg x) 5530 for { 5531 x := v_0 5532 if x.Op != OpRISCV64ADDIW { 5533 break 5534 } 5535 v.reset(OpRISCV64MOVDreg) 5536 v.AddArg(x) 5537 return true 5538 } 5539 // match: (MOVWreg x:(SUBW _ _)) 5540 // result: (MOVDreg x) 5541 for { 5542 x := v_0 5543 if x.Op != OpRISCV64SUBW { 5544 break 5545 } 5546 v.reset(OpRISCV64MOVDreg) 5547 v.AddArg(x) 5548 return true 5549 } 5550 // match: (MOVWreg x:(NEGW _)) 5551 // result: (MOVDreg x) 5552 for { 5553 x := v_0 5554 if x.Op != OpRISCV64NEGW { 5555 break 5556 } 5557 v.reset(OpRISCV64MOVDreg) 5558 v.AddArg(x) 5559 return true 5560 } 5561 // match: (MOVWreg x:(MULW _ _)) 5562 // result: (MOVDreg x) 5563 for { 5564 x := v_0 5565 if x.Op != OpRISCV64MULW { 5566 break 5567 } 5568 v.reset(OpRISCV64MOVDreg) 5569 v.AddArg(x) 5570 return true 5571 } 5572 // match: (MOVWreg x:(DIVW _ _)) 5573 // result: (MOVDreg x) 5574 for { 5575 x := v_0 5576 if x.Op != OpRISCV64DIVW { 5577 break 5578 } 5579 v.reset(OpRISCV64MOVDreg) 5580 v.AddArg(x) 5581 return true 5582 } 5583 // match: (MOVWreg x:(DIVUW _ _)) 5584 // result: (MOVDreg x) 5585 for { 5586 x := v_0 5587 if x.Op != OpRISCV64DIVUW { 5588 break 5589 } 5590 v.reset(OpRISCV64MOVDreg) 5591 v.AddArg(x) 5592 return true 5593 } 5594 // match: (MOVWreg x:(REMW _ _)) 5595 // result: (MOVDreg x) 5596 for { 5597 x := v_0 5598 if x.Op != OpRISCV64REMW { 5599 break 5600 } 5601 v.reset(OpRISCV64MOVDreg) 5602 v.AddArg(x) 5603 return true 5604 } 5605 // match: (MOVWreg x:(REMUW _ _)) 5606 // result: (MOVDreg x) 5607 for { 5608 x := v_0 5609 if x.Op != OpRISCV64REMUW { 5610 break 5611 } 5612 v.reset(OpRISCV64MOVDreg) 5613 v.AddArg(x) 5614 return true 5615 } 5616 // match: (MOVWreg x:(MOVBreg _)) 5617 // result: (MOVDreg x) 5618 for { 5619 x := v_0 5620 if x.Op != OpRISCV64MOVBreg { 5621 break 5622 } 5623 v.reset(OpRISCV64MOVDreg) 5624 v.AddArg(x) 5625 return true 5626 } 5627 // match: (MOVWreg x:(MOVBUreg _)) 5628 // result: (MOVDreg x) 5629 for { 5630 x := v_0 5631 if x.Op != OpRISCV64MOVBUreg { 5632 break 5633 } 5634 v.reset(OpRISCV64MOVDreg) 5635 v.AddArg(x) 5636 return true 5637 } 5638 // match: (MOVWreg x:(MOVHreg _)) 5639 // result: (MOVDreg x) 5640 for { 5641 x := v_0 5642 if x.Op != OpRISCV64MOVHreg { 5643 break 5644 } 5645 v.reset(OpRISCV64MOVDreg) 5646 v.AddArg(x) 5647 return true 5648 } 5649 // match: (MOVWreg x:(MOVWreg _)) 5650 // result: (MOVDreg x) 5651 for { 5652 x := v_0 5653 if x.Op != OpRISCV64MOVWreg { 5654 break 5655 } 5656 v.reset(OpRISCV64MOVDreg) 5657 v.AddArg(x) 5658 return true 5659 } 5660 // match: (MOVWreg <t> x:(MOVWUload [off] {sym} ptr mem)) 5661 // cond: x.Uses == 1 && clobber(x) 5662 // result: @x.Block (MOVWload <t> [off] {sym} ptr mem) 5663 for { 5664 t := v.Type 5665 x := v_0 5666 if x.Op != OpRISCV64MOVWUload { 5667 break 5668 } 5669 off := auxIntToInt32(x.AuxInt) 5670 sym := auxToSym(x.Aux) 5671 mem := x.Args[1] 5672 ptr := x.Args[0] 5673 if !(x.Uses == 1 && clobber(x)) { 5674 break 5675 } 5676 b = x.Block 5677 v0 := b.NewValue0(x.Pos, OpRISCV64MOVWload, t) 5678 v.copyOf(v0) 5679 v0.AuxInt = int32ToAuxInt(off) 5680 v0.Aux = symToAux(sym) 5681 v0.AddArg2(ptr, mem) 5682 return true 5683 } 5684 return false 5685 } 5686 func rewriteValueRISCV64_OpRISCV64MOVWstore(v *Value) bool { 5687 v_2 := v.Args[2] 5688 v_1 := v.Args[1] 5689 v_0 := v.Args[0] 5690 // match: (MOVWstore [off1] {sym1} (MOVaddr [off2] {sym2} base) val mem) 5691 // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) 5692 // result: (MOVWstore [off1+off2] {mergeSym(sym1,sym2)} base val mem) 5693 for { 5694 off1 := auxIntToInt32(v.AuxInt) 5695 sym1 := auxToSym(v.Aux) 5696 if v_0.Op != OpRISCV64MOVaddr { 5697 break 5698 } 5699 off2 := auxIntToInt32(v_0.AuxInt) 5700 sym2 := auxToSym(v_0.Aux) 5701 base := v_0.Args[0] 5702 val := v_1 5703 mem := v_2 5704 if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2)) { 5705 break 5706 } 5707 v.reset(OpRISCV64MOVWstore) 5708 v.AuxInt = int32ToAuxInt(off1 + off2) 5709 v.Aux = symToAux(mergeSym(sym1, sym2)) 5710 v.AddArg3(base, val, mem) 5711 return true 5712 } 5713 // match: (MOVWstore [off1] {sym} (ADDI [off2] base) val mem) 5714 // cond: is32Bit(int64(off1)+off2) 5715 // result: (MOVWstore [off1+int32(off2)] {sym} base val mem) 5716 for { 5717 off1 := auxIntToInt32(v.AuxInt) 5718 sym := auxToSym(v.Aux) 5719 if v_0.Op != OpRISCV64ADDI { 5720 break 5721 } 5722 off2 := auxIntToInt64(v_0.AuxInt) 5723 base := v_0.Args[0] 5724 val := v_1 5725 mem := v_2 5726 if !(is32Bit(int64(off1) + off2)) { 5727 break 5728 } 5729 v.reset(OpRISCV64MOVWstore) 5730 v.AuxInt = int32ToAuxInt(off1 + int32(off2)) 5731 v.Aux = symToAux(sym) 5732 v.AddArg3(base, val, mem) 5733 return true 5734 } 5735 // match: (MOVWstore [off] {sym} ptr (MOVDconst [0]) mem) 5736 // result: (MOVWstorezero [off] {sym} ptr mem) 5737 for { 5738 off := auxIntToInt32(v.AuxInt) 5739 sym := auxToSym(v.Aux) 5740 ptr := v_0 5741 if v_1.Op != OpRISCV64MOVDconst || auxIntToInt64(v_1.AuxInt) != 0 { 5742 break 5743 } 5744 mem := v_2 5745 v.reset(OpRISCV64MOVWstorezero) 5746 v.AuxInt = int32ToAuxInt(off) 5747 v.Aux = symToAux(sym) 5748 v.AddArg2(ptr, mem) 5749 return true 5750 } 5751 // match: (MOVWstore [off] {sym} ptr (MOVWreg x) mem) 5752 // result: (MOVWstore [off] {sym} ptr x mem) 5753 for { 5754 off := auxIntToInt32(v.AuxInt) 5755 sym := auxToSym(v.Aux) 5756 ptr := v_0 5757 if v_1.Op != OpRISCV64MOVWreg { 5758 break 5759 } 5760 x := v_1.Args[0] 5761 mem := v_2 5762 v.reset(OpRISCV64MOVWstore) 5763 v.AuxInt = int32ToAuxInt(off) 5764 v.Aux = symToAux(sym) 5765 v.AddArg3(ptr, x, mem) 5766 return true 5767 } 5768 // match: (MOVWstore [off] {sym} ptr (MOVWUreg x) mem) 5769 // result: (MOVWstore [off] {sym} ptr x mem) 5770 for { 5771 off := auxIntToInt32(v.AuxInt) 5772 sym := auxToSym(v.Aux) 5773 ptr := v_0 5774 if v_1.Op != OpRISCV64MOVWUreg { 5775 break 5776 } 5777 x := v_1.Args[0] 5778 mem := v_2 5779 v.reset(OpRISCV64MOVWstore) 5780 v.AuxInt = int32ToAuxInt(off) 5781 v.Aux = symToAux(sym) 5782 v.AddArg3(ptr, x, mem) 5783 return true 5784 } 5785 return false 5786 } 5787 func rewriteValueRISCV64_OpRISCV64MOVWstorezero(v *Value) bool { 5788 v_1 := v.Args[1] 5789 v_0 := v.Args[0] 5790 // match: (MOVWstorezero [off1] {sym1} (MOVaddr [off2] {sym2} ptr) mem) 5791 // cond: canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2)) 5792 // result: (MOVWstorezero [off1+off2] {mergeSym(sym1,sym2)} ptr mem) 5793 for { 5794 off1 := auxIntToInt32(v.AuxInt) 5795 sym1 := auxToSym(v.Aux) 5796 if v_0.Op != OpRISCV64MOVaddr { 5797 break 5798 } 5799 off2 := auxIntToInt32(v_0.AuxInt) 5800 sym2 := auxToSym(v_0.Aux) 5801 ptr := v_0.Args[0] 5802 mem := v_1 5803 if !(canMergeSym(sym1, sym2) && is32Bit(int64(off1)+int64(off2))) { 5804 break 5805 } 5806 v.reset(OpRISCV64MOVWstorezero) 5807 v.AuxInt = int32ToAuxInt(off1 + off2) 5808 v.Aux = symToAux(mergeSym(sym1, sym2)) 5809 v.AddArg2(ptr, mem) 5810 return true 5811 } 5812 // match: (MOVWstorezero [off1] {sym} (ADDI [off2] ptr) mem) 5813 // cond: is32Bit(int64(off1)+off2) 5814 // result: (MOVWstorezero [off1+int32(off2)] {sym} ptr mem) 5815 for { 5816 off1 := auxIntToInt32(v.AuxInt) 5817 sym := auxToSym(v.Aux) 5818 if v_0.Op != OpRISCV64ADDI { 5819 break 5820 } 5821 off2 := auxIntToInt64(v_0.AuxInt) 5822 ptr := v_0.Args[0] 5823 mem := v_1 5824 if !(is32Bit(int64(off1) + off2)) { 5825 break 5826 } 5827 v.reset(OpRISCV64MOVWstorezero) 5828 v.AuxInt = int32ToAuxInt(off1 + int32(off2)) 5829 v.Aux = symToAux(sym) 5830 v.AddArg2(ptr, mem) 5831 return true 5832 } 5833 return false 5834 } 5835 func rewriteValueRISCV64_OpRISCV64NEG(v *Value) bool { 5836 v_0 := v.Args[0] 5837 b := v.Block 5838 // match: (NEG (SUB x y)) 5839 // result: (SUB y x) 5840 for { 5841 if v_0.Op != OpRISCV64SUB { 5842 break 5843 } 5844 y := v_0.Args[1] 5845 x := v_0.Args[0] 5846 v.reset(OpRISCV64SUB) 5847 v.AddArg2(y, x) 5848 return true 5849 } 5850 // match: (NEG <t> s:(ADDI [val] (SUB x y))) 5851 // cond: s.Uses == 1 && is32Bit(-val) 5852 // result: (ADDI [-val] (SUB <t> y x)) 5853 for { 5854 t := v.Type 5855 s := v_0 5856 if s.Op != OpRISCV64ADDI { 5857 break 5858 } 5859 val := auxIntToInt64(s.AuxInt) 5860 s_0 := s.Args[0] 5861 if s_0.Op != OpRISCV64SUB { 5862 break 5863 } 5864 y := s_0.Args[1] 5865 x := s_0.Args[0] 5866 if !(s.Uses == 1 && is32Bit(-val)) { 5867 break 5868 } 5869 v.reset(OpRISCV64ADDI) 5870 v.AuxInt = int64ToAuxInt(-val) 5871 v0 := b.NewValue0(v.Pos, OpRISCV64SUB, t) 5872 v0.AddArg2(y, x) 5873 v.AddArg(v0) 5874 return true 5875 } 5876 // match: (NEG (NEG x)) 5877 // result: x 5878 for { 5879 if v_0.Op != OpRISCV64NEG { 5880 break 5881 } 5882 x := v_0.Args[0] 5883 v.copyOf(x) 5884 return true 5885 } 5886 // match: (NEG (MOVDconst [x])) 5887 // result: (MOVDconst [-x]) 5888 for { 5889 if v_0.Op != OpRISCV64MOVDconst { 5890 break 5891 } 5892 x := auxIntToInt64(v_0.AuxInt) 5893 v.reset(OpRISCV64MOVDconst) 5894 v.AuxInt = int64ToAuxInt(-x) 5895 return true 5896 } 5897 return false 5898 } 5899 func rewriteValueRISCV64_OpRISCV64NEGW(v *Value) bool { 5900 v_0 := v.Args[0] 5901 // match: (NEGW (MOVDconst [x])) 5902 // result: (MOVDconst [int64(int32(-x))]) 5903 for { 5904 if v_0.Op != OpRISCV64MOVDconst { 5905 break 5906 } 5907 x := auxIntToInt64(v_0.AuxInt) 5908 v.reset(OpRISCV64MOVDconst) 5909 v.AuxInt = int64ToAuxInt(int64(int32(-x))) 5910 return true 5911 } 5912 return false 5913 } 5914 func rewriteValueRISCV64_OpRISCV64OR(v *Value) bool { 5915 v_1 := v.Args[1] 5916 v_0 := v.Args[0] 5917 // match: (OR (MOVDconst [val]) x) 5918 // cond: is32Bit(val) 5919 // result: (ORI [val] x) 5920 for { 5921 for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { 5922 if v_0.Op != OpRISCV64MOVDconst { 5923 continue 5924 } 5925 val := auxIntToInt64(v_0.AuxInt) 5926 x := v_1 5927 if !(is32Bit(val)) { 5928 continue 5929 } 5930 v.reset(OpRISCV64ORI) 5931 v.AuxInt = int64ToAuxInt(val) 5932 v.AddArg(x) 5933 return true 5934 } 5935 break 5936 } 5937 return false 5938 } 5939 func rewriteValueRISCV64_OpRISCV64ORI(v *Value) bool { 5940 v_0 := v.Args[0] 5941 // match: (ORI [0] x) 5942 // result: x 5943 for { 5944 if auxIntToInt64(v.AuxInt) != 0 { 5945 break 5946 } 5947 x := v_0 5948 v.copyOf(x) 5949 return true 5950 } 5951 // match: (ORI [-1] x) 5952 // result: (MOVDconst [-1]) 5953 for { 5954 if auxIntToInt64(v.AuxInt) != -1 { 5955 break 5956 } 5957 v.reset(OpRISCV64MOVDconst) 5958 v.AuxInt = int64ToAuxInt(-1) 5959 return true 5960 } 5961 // match: (ORI [x] (MOVDconst [y])) 5962 // result: (MOVDconst [x | y]) 5963 for { 5964 x := auxIntToInt64(v.AuxInt) 5965 if v_0.Op != OpRISCV64MOVDconst { 5966 break 5967 } 5968 y := auxIntToInt64(v_0.AuxInt) 5969 v.reset(OpRISCV64MOVDconst) 5970 v.AuxInt = int64ToAuxInt(x | y) 5971 return true 5972 } 5973 // match: (ORI [x] (ORI [y] z)) 5974 // result: (ORI [x | y] z) 5975 for { 5976 x := auxIntToInt64(v.AuxInt) 5977 if v_0.Op != OpRISCV64ORI { 5978 break 5979 } 5980 y := auxIntToInt64(v_0.AuxInt) 5981 z := v_0.Args[0] 5982 v.reset(OpRISCV64ORI) 5983 v.AuxInt = int64ToAuxInt(x | y) 5984 v.AddArg(z) 5985 return true 5986 } 5987 return false 5988 } 5989 func rewriteValueRISCV64_OpRISCV64SEQZ(v *Value) bool { 5990 v_0 := v.Args[0] 5991 // match: (SEQZ (NEG x)) 5992 // result: (SEQZ x) 5993 for { 5994 if v_0.Op != OpRISCV64NEG { 5995 break 5996 } 5997 x := v_0.Args[0] 5998 v.reset(OpRISCV64SEQZ) 5999 v.AddArg(x) 6000 return true 6001 } 6002 // match: (SEQZ (SEQZ x)) 6003 // result: (SNEZ x) 6004 for { 6005 if v_0.Op != OpRISCV64SEQZ { 6006 break 6007 } 6008 x := v_0.Args[0] 6009 v.reset(OpRISCV64SNEZ) 6010 v.AddArg(x) 6011 return true 6012 } 6013 // match: (SEQZ (SNEZ x)) 6014 // result: (SEQZ x) 6015 for { 6016 if v_0.Op != OpRISCV64SNEZ { 6017 break 6018 } 6019 x := v_0.Args[0] 6020 v.reset(OpRISCV64SEQZ) 6021 v.AddArg(x) 6022 return true 6023 } 6024 return false 6025 } 6026 func rewriteValueRISCV64_OpRISCV64SLL(v *Value) bool { 6027 v_1 := v.Args[1] 6028 v_0 := v.Args[0] 6029 // match: (SLL x (MOVDconst [val])) 6030 // result: (SLLI [int64(val&63)] x) 6031 for { 6032 x := v_0 6033 if v_1.Op != OpRISCV64MOVDconst { 6034 break 6035 } 6036 val := auxIntToInt64(v_1.AuxInt) 6037 v.reset(OpRISCV64SLLI) 6038 v.AuxInt = int64ToAuxInt(int64(val & 63)) 6039 v.AddArg(x) 6040 return true 6041 } 6042 return false 6043 } 6044 func rewriteValueRISCV64_OpRISCV64SLLI(v *Value) bool { 6045 v_0 := v.Args[0] 6046 // match: (SLLI [x] (MOVDconst [y])) 6047 // cond: is32Bit(y << uint32(x)) 6048 // result: (MOVDconst [y << uint32(x)]) 6049 for { 6050 x := auxIntToInt64(v.AuxInt) 6051 if v_0.Op != OpRISCV64MOVDconst { 6052 break 6053 } 6054 y := auxIntToInt64(v_0.AuxInt) 6055 if !(is32Bit(y << uint32(x))) { 6056 break 6057 } 6058 v.reset(OpRISCV64MOVDconst) 6059 v.AuxInt = int64ToAuxInt(y << uint32(x)) 6060 return true 6061 } 6062 return false 6063 } 6064 func rewriteValueRISCV64_OpRISCV64SLT(v *Value) bool { 6065 v_1 := v.Args[1] 6066 v_0 := v.Args[0] 6067 // match: (SLT x (MOVDconst [val])) 6068 // cond: val >= -2048 && val <= 2047 6069 // result: (SLTI [val] x) 6070 for { 6071 x := v_0 6072 if v_1.Op != OpRISCV64MOVDconst { 6073 break 6074 } 6075 val := auxIntToInt64(v_1.AuxInt) 6076 if !(val >= -2048 && val <= 2047) { 6077 break 6078 } 6079 v.reset(OpRISCV64SLTI) 6080 v.AuxInt = int64ToAuxInt(val) 6081 v.AddArg(x) 6082 return true 6083 } 6084 // match: (SLT x x) 6085 // result: (MOVDconst [0]) 6086 for { 6087 x := v_0 6088 if x != v_1 { 6089 break 6090 } 6091 v.reset(OpRISCV64MOVDconst) 6092 v.AuxInt = int64ToAuxInt(0) 6093 return true 6094 } 6095 return false 6096 } 6097 func rewriteValueRISCV64_OpRISCV64SLTI(v *Value) bool { 6098 v_0 := v.Args[0] 6099 // match: (SLTI [x] (MOVDconst [y])) 6100 // result: (MOVDconst [b2i(int64(y) < int64(x))]) 6101 for { 6102 x := auxIntToInt64(v.AuxInt) 6103 if v_0.Op != OpRISCV64MOVDconst { 6104 break 6105 } 6106 y := auxIntToInt64(v_0.AuxInt) 6107 v.reset(OpRISCV64MOVDconst) 6108 v.AuxInt = int64ToAuxInt(b2i(int64(y) < int64(x))) 6109 return true 6110 } 6111 // match: (SLTI [x] (ANDI [y] _)) 6112 // cond: y >= 0 && int64(y) < int64(x) 6113 // result: (MOVDconst [1]) 6114 for { 6115 x := auxIntToInt64(v.AuxInt) 6116 if v_0.Op != OpRISCV64ANDI { 6117 break 6118 } 6119 y := auxIntToInt64(v_0.AuxInt) 6120 if !(y >= 0 && int64(y) < int64(x)) { 6121 break 6122 } 6123 v.reset(OpRISCV64MOVDconst) 6124 v.AuxInt = int64ToAuxInt(1) 6125 return true 6126 } 6127 // match: (SLTI [x] (ORI [y] _)) 6128 // cond: y >= 0 && int64(y) >= int64(x) 6129 // result: (MOVDconst [0]) 6130 for { 6131 x := auxIntToInt64(v.AuxInt) 6132 if v_0.Op != OpRISCV64ORI { 6133 break 6134 } 6135 y := auxIntToInt64(v_0.AuxInt) 6136 if !(y >= 0 && int64(y) >= int64(x)) { 6137 break 6138 } 6139 v.reset(OpRISCV64MOVDconst) 6140 v.AuxInt = int64ToAuxInt(0) 6141 return true 6142 } 6143 return false 6144 } 6145 func rewriteValueRISCV64_OpRISCV64SLTIU(v *Value) bool { 6146 v_0 := v.Args[0] 6147 // match: (SLTIU [x] (MOVDconst [y])) 6148 // result: (MOVDconst [b2i(uint64(y) < uint64(x))]) 6149 for { 6150 x := auxIntToInt64(v.AuxInt) 6151 if v_0.Op != OpRISCV64MOVDconst { 6152 break 6153 } 6154 y := auxIntToInt64(v_0.AuxInt) 6155 v.reset(OpRISCV64MOVDconst) 6156 v.AuxInt = int64ToAuxInt(b2i(uint64(y) < uint64(x))) 6157 return true 6158 } 6159 // match: (SLTIU [x] (ANDI [y] _)) 6160 // cond: y >= 0 && uint64(y) < uint64(x) 6161 // result: (MOVDconst [1]) 6162 for { 6163 x := auxIntToInt64(v.AuxInt) 6164 if v_0.Op != OpRISCV64ANDI { 6165 break 6166 } 6167 y := auxIntToInt64(v_0.AuxInt) 6168 if !(y >= 0 && uint64(y) < uint64(x)) { 6169 break 6170 } 6171 v.reset(OpRISCV64MOVDconst) 6172 v.AuxInt = int64ToAuxInt(1) 6173 return true 6174 } 6175 // match: (SLTIU [x] (ORI [y] _)) 6176 // cond: y >= 0 && uint64(y) >= uint64(x) 6177 // result: (MOVDconst [0]) 6178 for { 6179 x := auxIntToInt64(v.AuxInt) 6180 if v_0.Op != OpRISCV64ORI { 6181 break 6182 } 6183 y := auxIntToInt64(v_0.AuxInt) 6184 if !(y >= 0 && uint64(y) >= uint64(x)) { 6185 break 6186 } 6187 v.reset(OpRISCV64MOVDconst) 6188 v.AuxInt = int64ToAuxInt(0) 6189 return true 6190 } 6191 return false 6192 } 6193 func rewriteValueRISCV64_OpRISCV64SLTU(v *Value) bool { 6194 v_1 := v.Args[1] 6195 v_0 := v.Args[0] 6196 // match: (SLTU x (MOVDconst [val])) 6197 // cond: val >= -2048 && val <= 2047 6198 // result: (SLTIU [val] x) 6199 for { 6200 x := v_0 6201 if v_1.Op != OpRISCV64MOVDconst { 6202 break 6203 } 6204 val := auxIntToInt64(v_1.AuxInt) 6205 if !(val >= -2048 && val <= 2047) { 6206 break 6207 } 6208 v.reset(OpRISCV64SLTIU) 6209 v.AuxInt = int64ToAuxInt(val) 6210 v.AddArg(x) 6211 return true 6212 } 6213 // match: (SLTU x x) 6214 // result: (MOVDconst [0]) 6215 for { 6216 x := v_0 6217 if x != v_1 { 6218 break 6219 } 6220 v.reset(OpRISCV64MOVDconst) 6221 v.AuxInt = int64ToAuxInt(0) 6222 return true 6223 } 6224 return false 6225 } 6226 func rewriteValueRISCV64_OpRISCV64SNEZ(v *Value) bool { 6227 v_0 := v.Args[0] 6228 // match: (SNEZ (NEG x)) 6229 // result: (SNEZ x) 6230 for { 6231 if v_0.Op != OpRISCV64NEG { 6232 break 6233 } 6234 x := v_0.Args[0] 6235 v.reset(OpRISCV64SNEZ) 6236 v.AddArg(x) 6237 return true 6238 } 6239 // match: (SNEZ (SEQZ x)) 6240 // result: (SEQZ x) 6241 for { 6242 if v_0.Op != OpRISCV64SEQZ { 6243 break 6244 } 6245 x := v_0.Args[0] 6246 v.reset(OpRISCV64SEQZ) 6247 v.AddArg(x) 6248 return true 6249 } 6250 // match: (SNEZ (SNEZ x)) 6251 // result: (SNEZ x) 6252 for { 6253 if v_0.Op != OpRISCV64SNEZ { 6254 break 6255 } 6256 x := v_0.Args[0] 6257 v.reset(OpRISCV64SNEZ) 6258 v.AddArg(x) 6259 return true 6260 } 6261 return false 6262 } 6263 func rewriteValueRISCV64_OpRISCV64SRA(v *Value) bool { 6264 v_1 := v.Args[1] 6265 v_0 := v.Args[0] 6266 // match: (SRA x (MOVDconst [val])) 6267 // result: (SRAI [int64(val&63)] x) 6268 for { 6269 x := v_0 6270 if v_1.Op != OpRISCV64MOVDconst { 6271 break 6272 } 6273 val := auxIntToInt64(v_1.AuxInt) 6274 v.reset(OpRISCV64SRAI) 6275 v.AuxInt = int64ToAuxInt(int64(val & 63)) 6276 v.AddArg(x) 6277 return true 6278 } 6279 return false 6280 } 6281 func rewriteValueRISCV64_OpRISCV64SRAI(v *Value) bool { 6282 v_0 := v.Args[0] 6283 b := v.Block 6284 // match: (SRAI <t> [x] (MOVWreg y)) 6285 // cond: x >= 0 && x <= 31 6286 // result: (SRAIW <t> [int64(x)] y) 6287 for { 6288 t := v.Type 6289 x := auxIntToInt64(v.AuxInt) 6290 if v_0.Op != OpRISCV64MOVWreg { 6291 break 6292 } 6293 y := v_0.Args[0] 6294 if !(x >= 0 && x <= 31) { 6295 break 6296 } 6297 v.reset(OpRISCV64SRAIW) 6298 v.Type = t 6299 v.AuxInt = int64ToAuxInt(int64(x)) 6300 v.AddArg(y) 6301 return true 6302 } 6303 // match: (SRAI <t> [x] (MOVBreg y)) 6304 // cond: x >= 8 6305 // result: (SRAI [63] (SLLI <t> [56] y)) 6306 for { 6307 t := v.Type 6308 x := auxIntToInt64(v.AuxInt) 6309 if v_0.Op != OpRISCV64MOVBreg { 6310 break 6311 } 6312 y := v_0.Args[0] 6313 if !(x >= 8) { 6314 break 6315 } 6316 v.reset(OpRISCV64SRAI) 6317 v.AuxInt = int64ToAuxInt(63) 6318 v0 := b.NewValue0(v.Pos, OpRISCV64SLLI, t) 6319 v0.AuxInt = int64ToAuxInt(56) 6320 v0.AddArg(y) 6321 v.AddArg(v0) 6322 return true 6323 } 6324 // match: (SRAI <t> [x] (MOVHreg y)) 6325 // cond: x >= 16 6326 // result: (SRAI [63] (SLLI <t> [48] y)) 6327 for { 6328 t := v.Type 6329 x := auxIntToInt64(v.AuxInt) 6330 if v_0.Op != OpRISCV64MOVHreg { 6331 break 6332 } 6333 y := v_0.Args[0] 6334 if !(x >= 16) { 6335 break 6336 } 6337 v.reset(OpRISCV64SRAI) 6338 v.AuxInt = int64ToAuxInt(63) 6339 v0 := b.NewValue0(v.Pos, OpRISCV64SLLI, t) 6340 v0.AuxInt = int64ToAuxInt(48) 6341 v0.AddArg(y) 6342 v.AddArg(v0) 6343 return true 6344 } 6345 // match: (SRAI <t> [x] (MOVWreg y)) 6346 // cond: x >= 32 6347 // result: (SRAIW [31] y) 6348 for { 6349 x := auxIntToInt64(v.AuxInt) 6350 if v_0.Op != OpRISCV64MOVWreg { 6351 break 6352 } 6353 y := v_0.Args[0] 6354 if !(x >= 32) { 6355 break 6356 } 6357 v.reset(OpRISCV64SRAIW) 6358 v.AuxInt = int64ToAuxInt(31) 6359 v.AddArg(y) 6360 return true 6361 } 6362 // match: (SRAI [x] (MOVDconst [y])) 6363 // result: (MOVDconst [int64(y) >> uint32(x)]) 6364 for { 6365 x := auxIntToInt64(v.AuxInt) 6366 if v_0.Op != OpRISCV64MOVDconst { 6367 break 6368 } 6369 y := auxIntToInt64(v_0.AuxInt) 6370 v.reset(OpRISCV64MOVDconst) 6371 v.AuxInt = int64ToAuxInt(int64(y) >> uint32(x)) 6372 return true 6373 } 6374 return false 6375 } 6376 func rewriteValueRISCV64_OpRISCV64SRAW(v *Value) bool { 6377 v_1 := v.Args[1] 6378 v_0 := v.Args[0] 6379 // match: (SRAW x (MOVDconst [val])) 6380 // result: (SRAIW [int64(val&31)] x) 6381 for { 6382 x := v_0 6383 if v_1.Op != OpRISCV64MOVDconst { 6384 break 6385 } 6386 val := auxIntToInt64(v_1.AuxInt) 6387 v.reset(OpRISCV64SRAIW) 6388 v.AuxInt = int64ToAuxInt(int64(val & 31)) 6389 v.AddArg(x) 6390 return true 6391 } 6392 return false 6393 } 6394 func rewriteValueRISCV64_OpRISCV64SRL(v *Value) bool { 6395 v_1 := v.Args[1] 6396 v_0 := v.Args[0] 6397 // match: (SRL x (MOVDconst [val])) 6398 // result: (SRLI [int64(val&63)] x) 6399 for { 6400 x := v_0 6401 if v_1.Op != OpRISCV64MOVDconst { 6402 break 6403 } 6404 val := auxIntToInt64(v_1.AuxInt) 6405 v.reset(OpRISCV64SRLI) 6406 v.AuxInt = int64ToAuxInt(int64(val & 63)) 6407 v.AddArg(x) 6408 return true 6409 } 6410 return false 6411 } 6412 func rewriteValueRISCV64_OpRISCV64SRLI(v *Value) bool { 6413 v_0 := v.Args[0] 6414 // match: (SRLI <t> [x] (MOVWUreg y)) 6415 // cond: x >= 0 && x <= 31 6416 // result: (SRLIW <t> [int64(x)] y) 6417 for { 6418 t := v.Type 6419 x := auxIntToInt64(v.AuxInt) 6420 if v_0.Op != OpRISCV64MOVWUreg { 6421 break 6422 } 6423 y := v_0.Args[0] 6424 if !(x >= 0 && x <= 31) { 6425 break 6426 } 6427 v.reset(OpRISCV64SRLIW) 6428 v.Type = t 6429 v.AuxInt = int64ToAuxInt(int64(x)) 6430 v.AddArg(y) 6431 return true 6432 } 6433 // match: (SRLI <t> [x] (MOVBUreg y)) 6434 // cond: x >= 8 6435 // result: (MOVDconst <t> [0]) 6436 for { 6437 t := v.Type 6438 x := auxIntToInt64(v.AuxInt) 6439 if v_0.Op != OpRISCV64MOVBUreg { 6440 break 6441 } 6442 if !(x >= 8) { 6443 break 6444 } 6445 v.reset(OpRISCV64MOVDconst) 6446 v.Type = t 6447 v.AuxInt = int64ToAuxInt(0) 6448 return true 6449 } 6450 // match: (SRLI <t> [x] (MOVHUreg y)) 6451 // cond: x >= 16 6452 // result: (MOVDconst <t> [0]) 6453 for { 6454 t := v.Type 6455 x := auxIntToInt64(v.AuxInt) 6456 if v_0.Op != OpRISCV64MOVHUreg { 6457 break 6458 } 6459 if !(x >= 16) { 6460 break 6461 } 6462 v.reset(OpRISCV64MOVDconst) 6463 v.Type = t 6464 v.AuxInt = int64ToAuxInt(0) 6465 return true 6466 } 6467 // match: (SRLI <t> [x] (MOVWUreg y)) 6468 // cond: x >= 32 6469 // result: (MOVDconst <t> [0]) 6470 for { 6471 t := v.Type 6472 x := auxIntToInt64(v.AuxInt) 6473 if v_0.Op != OpRISCV64MOVWUreg { 6474 break 6475 } 6476 if !(x >= 32) { 6477 break 6478 } 6479 v.reset(OpRISCV64MOVDconst) 6480 v.Type = t 6481 v.AuxInt = int64ToAuxInt(0) 6482 return true 6483 } 6484 // match: (SRLI [x] (MOVDconst [y])) 6485 // result: (MOVDconst [int64(uint64(y) >> uint32(x))]) 6486 for { 6487 x := auxIntToInt64(v.AuxInt) 6488 if v_0.Op != OpRISCV64MOVDconst { 6489 break 6490 } 6491 y := auxIntToInt64(v_0.AuxInt) 6492 v.reset(OpRISCV64MOVDconst) 6493 v.AuxInt = int64ToAuxInt(int64(uint64(y) >> uint32(x))) 6494 return true 6495 } 6496 return false 6497 } 6498 func rewriteValueRISCV64_OpRISCV64SRLW(v *Value) bool { 6499 v_1 := v.Args[1] 6500 v_0 := v.Args[0] 6501 // match: (SRLW x (MOVDconst [val])) 6502 // result: (SRLIW [int64(val&31)] x) 6503 for { 6504 x := v_0 6505 if v_1.Op != OpRISCV64MOVDconst { 6506 break 6507 } 6508 val := auxIntToInt64(v_1.AuxInt) 6509 v.reset(OpRISCV64SRLIW) 6510 v.AuxInt = int64ToAuxInt(int64(val & 31)) 6511 v.AddArg(x) 6512 return true 6513 } 6514 return false 6515 } 6516 func rewriteValueRISCV64_OpRISCV64SUB(v *Value) bool { 6517 v_1 := v.Args[1] 6518 v_0 := v.Args[0] 6519 b := v.Block 6520 // match: (SUB x (MOVDconst [val])) 6521 // cond: is32Bit(-val) 6522 // result: (ADDI [-val] x) 6523 for { 6524 x := v_0 6525 if v_1.Op != OpRISCV64MOVDconst { 6526 break 6527 } 6528 val := auxIntToInt64(v_1.AuxInt) 6529 if !(is32Bit(-val)) { 6530 break 6531 } 6532 v.reset(OpRISCV64ADDI) 6533 v.AuxInt = int64ToAuxInt(-val) 6534 v.AddArg(x) 6535 return true 6536 } 6537 // match: (SUB <t> (MOVDconst [val]) y) 6538 // cond: is32Bit(-val) 6539 // result: (NEG (ADDI <t> [-val] y)) 6540 for { 6541 t := v.Type 6542 if v_0.Op != OpRISCV64MOVDconst { 6543 break 6544 } 6545 val := auxIntToInt64(v_0.AuxInt) 6546 y := v_1 6547 if !(is32Bit(-val)) { 6548 break 6549 } 6550 v.reset(OpRISCV64NEG) 6551 v0 := b.NewValue0(v.Pos, OpRISCV64ADDI, t) 6552 v0.AuxInt = int64ToAuxInt(-val) 6553 v0.AddArg(y) 6554 v.AddArg(v0) 6555 return true 6556 } 6557 // match: (SUB x (MOVDconst [0])) 6558 // result: x 6559 for { 6560 x := v_0 6561 if v_1.Op != OpRISCV64MOVDconst || auxIntToInt64(v_1.AuxInt) != 0 { 6562 break 6563 } 6564 v.copyOf(x) 6565 return true 6566 } 6567 // match: (SUB (MOVDconst [0]) x) 6568 // result: (NEG x) 6569 for { 6570 if v_0.Op != OpRISCV64MOVDconst || auxIntToInt64(v_0.AuxInt) != 0 { 6571 break 6572 } 6573 x := v_1 6574 v.reset(OpRISCV64NEG) 6575 v.AddArg(x) 6576 return true 6577 } 6578 return false 6579 } 6580 func rewriteValueRISCV64_OpRISCV64SUBW(v *Value) bool { 6581 v_1 := v.Args[1] 6582 v_0 := v.Args[0] 6583 // match: (SUBW x (MOVDconst [0])) 6584 // result: (ADDIW [0] x) 6585 for { 6586 x := v_0 6587 if v_1.Op != OpRISCV64MOVDconst || auxIntToInt64(v_1.AuxInt) != 0 { 6588 break 6589 } 6590 v.reset(OpRISCV64ADDIW) 6591 v.AuxInt = int64ToAuxInt(0) 6592 v.AddArg(x) 6593 return true 6594 } 6595 // match: (SUBW (MOVDconst [0]) x) 6596 // result: (NEGW x) 6597 for { 6598 if v_0.Op != OpRISCV64MOVDconst || auxIntToInt64(v_0.AuxInt) != 0 { 6599 break 6600 } 6601 x := v_1 6602 v.reset(OpRISCV64NEGW) 6603 v.AddArg(x) 6604 return true 6605 } 6606 return false 6607 } 6608 func rewriteValueRISCV64_OpRISCV64XOR(v *Value) bool { 6609 v_1 := v.Args[1] 6610 v_0 := v.Args[0] 6611 // match: (XOR (MOVDconst [val]) x) 6612 // cond: is32Bit(val) 6613 // result: (XORI [val] x) 6614 for { 6615 for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { 6616 if v_0.Op != OpRISCV64MOVDconst { 6617 continue 6618 } 6619 val := auxIntToInt64(v_0.AuxInt) 6620 x := v_1 6621 if !(is32Bit(val)) { 6622 continue 6623 } 6624 v.reset(OpRISCV64XORI) 6625 v.AuxInt = int64ToAuxInt(val) 6626 v.AddArg(x) 6627 return true 6628 } 6629 break 6630 } 6631 return false 6632 } 6633 func rewriteValueRISCV64_OpRotateLeft16(v *Value) bool { 6634 v_1 := v.Args[1] 6635 v_0 := v.Args[0] 6636 b := v.Block 6637 typ := &b.Func.Config.Types 6638 // match: (RotateLeft16 <t> x (MOVDconst [c])) 6639 // result: (Or16 (Lsh16x64 <t> x (MOVDconst [c&15])) (Rsh16Ux64 <t> x (MOVDconst [-c&15]))) 6640 for { 6641 t := v.Type 6642 x := v_0 6643 if v_1.Op != OpRISCV64MOVDconst { 6644 break 6645 } 6646 c := auxIntToInt64(v_1.AuxInt) 6647 v.reset(OpOr16) 6648 v0 := b.NewValue0(v.Pos, OpLsh16x64, t) 6649 v1 := b.NewValue0(v.Pos, OpRISCV64MOVDconst, typ.UInt64) 6650 v1.AuxInt = int64ToAuxInt(c & 15) 6651 v0.AddArg2(x, v1) 6652 v2 := b.NewValue0(v.Pos, OpRsh16Ux64, t) 6653 v3 := b.NewValue0(v.Pos, OpRISCV64MOVDconst, typ.UInt64) 6654 v3.AuxInt = int64ToAuxInt(-c & 15) 6655 v2.AddArg2(x, v3) 6656 v.AddArg2(v0, v2) 6657 return true 6658 } 6659 return false 6660 } 6661 func rewriteValueRISCV64_OpRotateLeft32(v *Value) bool { 6662 v_1 := v.Args[1] 6663 v_0 := v.Args[0] 6664 b := v.Block 6665 typ := &b.Func.Config.Types 6666 // match: (RotateLeft32 <t> x (MOVDconst [c])) 6667 // result: (Or32 (Lsh32x64 <t> x (MOVDconst [c&31])) (Rsh32Ux64 <t> x (MOVDconst [-c&31]))) 6668 for { 6669 t := v.Type 6670 x := v_0 6671 if v_1.Op != OpRISCV64MOVDconst { 6672 break 6673 } 6674 c := auxIntToInt64(v_1.AuxInt) 6675 v.reset(OpOr32) 6676 v0 := b.NewValue0(v.Pos, OpLsh32x64, t) 6677 v1 := b.NewValue0(v.Pos, OpRISCV64MOVDconst, typ.UInt64) 6678 v1.AuxInt = int64ToAuxInt(c & 31) 6679 v0.AddArg2(x, v1) 6680 v2 := b.NewValue0(v.Pos, OpRsh32Ux64, t) 6681 v3 := b.NewValue0(v.Pos, OpRISCV64MOVDconst, typ.UInt64) 6682 v3.AuxInt = int64ToAuxInt(-c & 31) 6683 v2.AddArg2(x, v3) 6684 v.AddArg2(v0, v2) 6685 return true 6686 } 6687 return false 6688 } 6689 func rewriteValueRISCV64_OpRotateLeft64(v *Value) bool { 6690 v_1 := v.Args[1] 6691 v_0 := v.Args[0] 6692 b := v.Block 6693 typ := &b.Func.Config.Types 6694 // match: (RotateLeft64 <t> x (MOVDconst [c])) 6695 // result: (Or64 (Lsh64x64 <t> x (MOVDconst [c&63])) (Rsh64Ux64 <t> x (MOVDconst [-c&63]))) 6696 for { 6697 t := v.Type 6698 x := v_0 6699 if v_1.Op != OpRISCV64MOVDconst { 6700 break 6701 } 6702 c := auxIntToInt64(v_1.AuxInt) 6703 v.reset(OpOr64) 6704 v0 := b.NewValue0(v.Pos, OpLsh64x64, t) 6705 v1 := b.NewValue0(v.Pos, OpRISCV64MOVDconst, typ.UInt64) 6706 v1.AuxInt = int64ToAuxInt(c & 63) 6707 v0.AddArg2(x, v1) 6708 v2 := b.NewValue0(v.Pos, OpRsh64Ux64, t) 6709 v3 := b.NewValue0(v.Pos, OpRISCV64MOVDconst, typ.UInt64) 6710 v3.AuxInt = int64ToAuxInt(-c & 63) 6711 v2.AddArg2(x, v3) 6712 v.AddArg2(v0, v2) 6713 return true 6714 } 6715 return false 6716 } 6717 func rewriteValueRISCV64_OpRotateLeft8(v *Value) bool { 6718 v_1 := v.Args[1] 6719 v_0 := v.Args[0] 6720 b := v.Block 6721 typ := &b.Func.Config.Types 6722 // match: (RotateLeft8 <t> x (MOVDconst [c])) 6723 // result: (Or8 (Lsh8x64 <t> x (MOVDconst [c&7])) (Rsh8Ux64 <t> x (MOVDconst [-c&7]))) 6724 for { 6725 t := v.Type 6726 x := v_0 6727 if v_1.Op != OpRISCV64MOVDconst { 6728 break 6729 } 6730 c := auxIntToInt64(v_1.AuxInt) 6731 v.reset(OpOr8) 6732 v0 := b.NewValue0(v.Pos, OpLsh8x64, t) 6733 v1 := b.NewValue0(v.Pos, OpRISCV64MOVDconst, typ.UInt64) 6734 v1.AuxInt = int64ToAuxInt(c & 7) 6735 v0.AddArg2(x, v1) 6736 v2 := b.NewValue0(v.Pos, OpRsh8Ux64, t) 6737 v3 := b.NewValue0(v.Pos, OpRISCV64MOVDconst, typ.UInt64) 6738 v3.AuxInt = int64ToAuxInt(-c & 7) 6739 v2.AddArg2(x, v3) 6740 v.AddArg2(v0, v2) 6741 return true 6742 } 6743 return false 6744 } 6745 func rewriteValueRISCV64_OpRsh16Ux16(v *Value) bool { 6746 v_1 := v.Args[1] 6747 v_0 := v.Args[0] 6748 b := v.Block 6749 typ := &b.Func.Config.Types 6750 // match: (Rsh16Ux16 <t> x y) 6751 // cond: !shiftIsBounded(v) 6752 // result: (AND (SRL <t> (ZeroExt16to64 x) y) (Neg16 <t> (SLTIU <t> [64] (ZeroExt16to64 y)))) 6753 for { 6754 t := v.Type 6755 x := v_0 6756 y := v_1 6757 if !(!shiftIsBounded(v)) { 6758 break 6759 } 6760 v.reset(OpRISCV64AND) 6761 v0 := b.NewValue0(v.Pos, OpRISCV64SRL, t) 6762 v1 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) 6763 v1.AddArg(x) 6764 v0.AddArg2(v1, y) 6765 v2 := b.NewValue0(v.Pos, OpNeg16, t) 6766 v3 := b.NewValue0(v.Pos, OpRISCV64SLTIU, t) 6767 v3.AuxInt = int64ToAuxInt(64) 6768 v4 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) 6769 v4.AddArg(y) 6770 v3.AddArg(v4) 6771 v2.AddArg(v3) 6772 v.AddArg2(v0, v2) 6773 return true 6774 } 6775 // match: (Rsh16Ux16 x y) 6776 // cond: shiftIsBounded(v) 6777 // result: (SRL (ZeroExt16to64 x) y) 6778 for { 6779 x := v_0 6780 y := v_1 6781 if !(shiftIsBounded(v)) { 6782 break 6783 } 6784 v.reset(OpRISCV64SRL) 6785 v0 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) 6786 v0.AddArg(x) 6787 v.AddArg2(v0, y) 6788 return true 6789 } 6790 return false 6791 } 6792 func rewriteValueRISCV64_OpRsh16Ux32(v *Value) bool { 6793 v_1 := v.Args[1] 6794 v_0 := v.Args[0] 6795 b := v.Block 6796 typ := &b.Func.Config.Types 6797 // match: (Rsh16Ux32 <t> x y) 6798 // cond: !shiftIsBounded(v) 6799 // result: (AND (SRL <t> (ZeroExt16to64 x) y) (Neg16 <t> (SLTIU <t> [64] (ZeroExt32to64 y)))) 6800 for { 6801 t := v.Type 6802 x := v_0 6803 y := v_1 6804 if !(!shiftIsBounded(v)) { 6805 break 6806 } 6807 v.reset(OpRISCV64AND) 6808 v0 := b.NewValue0(v.Pos, OpRISCV64SRL, t) 6809 v1 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) 6810 v1.AddArg(x) 6811 v0.AddArg2(v1, y) 6812 v2 := b.NewValue0(v.Pos, OpNeg16, t) 6813 v3 := b.NewValue0(v.Pos, OpRISCV64SLTIU, t) 6814 v3.AuxInt = int64ToAuxInt(64) 6815 v4 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) 6816 v4.AddArg(y) 6817 v3.AddArg(v4) 6818 v2.AddArg(v3) 6819 v.AddArg2(v0, v2) 6820 return true 6821 } 6822 // match: (Rsh16Ux32 x y) 6823 // cond: shiftIsBounded(v) 6824 // result: (SRL (ZeroExt16to64 x) y) 6825 for { 6826 x := v_0 6827 y := v_1 6828 if !(shiftIsBounded(v)) { 6829 break 6830 } 6831 v.reset(OpRISCV64SRL) 6832 v0 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) 6833 v0.AddArg(x) 6834 v.AddArg2(v0, y) 6835 return true 6836 } 6837 return false 6838 } 6839 func rewriteValueRISCV64_OpRsh16Ux64(v *Value) bool { 6840 v_1 := v.Args[1] 6841 v_0 := v.Args[0] 6842 b := v.Block 6843 typ := &b.Func.Config.Types 6844 // match: (Rsh16Ux64 <t> x y) 6845 // cond: !shiftIsBounded(v) 6846 // result: (AND (SRL <t> (ZeroExt16to64 x) y) (Neg16 <t> (SLTIU <t> [64] y))) 6847 for { 6848 t := v.Type 6849 x := v_0 6850 y := v_1 6851 if !(!shiftIsBounded(v)) { 6852 break 6853 } 6854 v.reset(OpRISCV64AND) 6855 v0 := b.NewValue0(v.Pos, OpRISCV64SRL, t) 6856 v1 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) 6857 v1.AddArg(x) 6858 v0.AddArg2(v1, y) 6859 v2 := b.NewValue0(v.Pos, OpNeg16, t) 6860 v3 := b.NewValue0(v.Pos, OpRISCV64SLTIU, t) 6861 v3.AuxInt = int64ToAuxInt(64) 6862 v3.AddArg(y) 6863 v2.AddArg(v3) 6864 v.AddArg2(v0, v2) 6865 return true 6866 } 6867 // match: (Rsh16Ux64 x y) 6868 // cond: shiftIsBounded(v) 6869 // result: (SRL (ZeroExt16to64 x) y) 6870 for { 6871 x := v_0 6872 y := v_1 6873 if !(shiftIsBounded(v)) { 6874 break 6875 } 6876 v.reset(OpRISCV64SRL) 6877 v0 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) 6878 v0.AddArg(x) 6879 v.AddArg2(v0, y) 6880 return true 6881 } 6882 return false 6883 } 6884 func rewriteValueRISCV64_OpRsh16Ux8(v *Value) bool { 6885 v_1 := v.Args[1] 6886 v_0 := v.Args[0] 6887 b := v.Block 6888 typ := &b.Func.Config.Types 6889 // match: (Rsh16Ux8 <t> x y) 6890 // cond: !shiftIsBounded(v) 6891 // result: (AND (SRL <t> (ZeroExt16to64 x) y) (Neg16 <t> (SLTIU <t> [64] (ZeroExt8to64 y)))) 6892 for { 6893 t := v.Type 6894 x := v_0 6895 y := v_1 6896 if !(!shiftIsBounded(v)) { 6897 break 6898 } 6899 v.reset(OpRISCV64AND) 6900 v0 := b.NewValue0(v.Pos, OpRISCV64SRL, t) 6901 v1 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) 6902 v1.AddArg(x) 6903 v0.AddArg2(v1, y) 6904 v2 := b.NewValue0(v.Pos, OpNeg16, t) 6905 v3 := b.NewValue0(v.Pos, OpRISCV64SLTIU, t) 6906 v3.AuxInt = int64ToAuxInt(64) 6907 v4 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) 6908 v4.AddArg(y) 6909 v3.AddArg(v4) 6910 v2.AddArg(v3) 6911 v.AddArg2(v0, v2) 6912 return true 6913 } 6914 // match: (Rsh16Ux8 x y) 6915 // cond: shiftIsBounded(v) 6916 // result: (SRL (ZeroExt16to64 x) y) 6917 for { 6918 x := v_0 6919 y := v_1 6920 if !(shiftIsBounded(v)) { 6921 break 6922 } 6923 v.reset(OpRISCV64SRL) 6924 v0 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) 6925 v0.AddArg(x) 6926 v.AddArg2(v0, y) 6927 return true 6928 } 6929 return false 6930 } 6931 func rewriteValueRISCV64_OpRsh16x16(v *Value) bool { 6932 v_1 := v.Args[1] 6933 v_0 := v.Args[0] 6934 b := v.Block 6935 typ := &b.Func.Config.Types 6936 // match: (Rsh16x16 <t> x y) 6937 // cond: !shiftIsBounded(v) 6938 // result: (SRA <t> (SignExt16to64 x) (OR <y.Type> y (ADDI <y.Type> [-1] (SLTIU <y.Type> [64] (ZeroExt16to64 y))))) 6939 for { 6940 t := v.Type 6941 x := v_0 6942 y := v_1 6943 if !(!shiftIsBounded(v)) { 6944 break 6945 } 6946 v.reset(OpRISCV64SRA) 6947 v.Type = t 6948 v0 := b.NewValue0(v.Pos, OpSignExt16to64, typ.Int64) 6949 v0.AddArg(x) 6950 v1 := b.NewValue0(v.Pos, OpRISCV64OR, y.Type) 6951 v2 := b.NewValue0(v.Pos, OpRISCV64ADDI, y.Type) 6952 v2.AuxInt = int64ToAuxInt(-1) 6953 v3 := b.NewValue0(v.Pos, OpRISCV64SLTIU, y.Type) 6954 v3.AuxInt = int64ToAuxInt(64) 6955 v4 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) 6956 v4.AddArg(y) 6957 v3.AddArg(v4) 6958 v2.AddArg(v3) 6959 v1.AddArg2(y, v2) 6960 v.AddArg2(v0, v1) 6961 return true 6962 } 6963 // match: (Rsh16x16 x y) 6964 // cond: shiftIsBounded(v) 6965 // result: (SRA (SignExt16to64 x) y) 6966 for { 6967 x := v_0 6968 y := v_1 6969 if !(shiftIsBounded(v)) { 6970 break 6971 } 6972 v.reset(OpRISCV64SRA) 6973 v0 := b.NewValue0(v.Pos, OpSignExt16to64, typ.Int64) 6974 v0.AddArg(x) 6975 v.AddArg2(v0, y) 6976 return true 6977 } 6978 return false 6979 } 6980 func rewriteValueRISCV64_OpRsh16x32(v *Value) bool { 6981 v_1 := v.Args[1] 6982 v_0 := v.Args[0] 6983 b := v.Block 6984 typ := &b.Func.Config.Types 6985 // match: (Rsh16x32 <t> x y) 6986 // cond: !shiftIsBounded(v) 6987 // result: (SRA <t> (SignExt16to64 x) (OR <y.Type> y (ADDI <y.Type> [-1] (SLTIU <y.Type> [64] (ZeroExt32to64 y))))) 6988 for { 6989 t := v.Type 6990 x := v_0 6991 y := v_1 6992 if !(!shiftIsBounded(v)) { 6993 break 6994 } 6995 v.reset(OpRISCV64SRA) 6996 v.Type = t 6997 v0 := b.NewValue0(v.Pos, OpSignExt16to64, typ.Int64) 6998 v0.AddArg(x) 6999 v1 := b.NewValue0(v.Pos, OpRISCV64OR, y.Type) 7000 v2 := b.NewValue0(v.Pos, OpRISCV64ADDI, y.Type) 7001 v2.AuxInt = int64ToAuxInt(-1) 7002 v3 := b.NewValue0(v.Pos, OpRISCV64SLTIU, y.Type) 7003 v3.AuxInt = int64ToAuxInt(64) 7004 v4 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) 7005 v4.AddArg(y) 7006 v3.AddArg(v4) 7007 v2.AddArg(v3) 7008 v1.AddArg2(y, v2) 7009 v.AddArg2(v0, v1) 7010 return true 7011 } 7012 // match: (Rsh16x32 x y) 7013 // cond: shiftIsBounded(v) 7014 // result: (SRA (SignExt16to64 x) y) 7015 for { 7016 x := v_0 7017 y := v_1 7018 if !(shiftIsBounded(v)) { 7019 break 7020 } 7021 v.reset(OpRISCV64SRA) 7022 v0 := b.NewValue0(v.Pos, OpSignExt16to64, typ.Int64) 7023 v0.AddArg(x) 7024 v.AddArg2(v0, y) 7025 return true 7026 } 7027 return false 7028 } 7029 func rewriteValueRISCV64_OpRsh16x64(v *Value) bool { 7030 v_1 := v.Args[1] 7031 v_0 := v.Args[0] 7032 b := v.Block 7033 typ := &b.Func.Config.Types 7034 // match: (Rsh16x64 <t> x y) 7035 // cond: !shiftIsBounded(v) 7036 // result: (SRA <t> (SignExt16to64 x) (OR <y.Type> y (ADDI <y.Type> [-1] (SLTIU <y.Type> [64] y)))) 7037 for { 7038 t := v.Type 7039 x := v_0 7040 y := v_1 7041 if !(!shiftIsBounded(v)) { 7042 break 7043 } 7044 v.reset(OpRISCV64SRA) 7045 v.Type = t 7046 v0 := b.NewValue0(v.Pos, OpSignExt16to64, typ.Int64) 7047 v0.AddArg(x) 7048 v1 := b.NewValue0(v.Pos, OpRISCV64OR, y.Type) 7049 v2 := b.NewValue0(v.Pos, OpRISCV64ADDI, y.Type) 7050 v2.AuxInt = int64ToAuxInt(-1) 7051 v3 := b.NewValue0(v.Pos, OpRISCV64SLTIU, y.Type) 7052 v3.AuxInt = int64ToAuxInt(64) 7053 v3.AddArg(y) 7054 v2.AddArg(v3) 7055 v1.AddArg2(y, v2) 7056 v.AddArg2(v0, v1) 7057 return true 7058 } 7059 // match: (Rsh16x64 x y) 7060 // cond: shiftIsBounded(v) 7061 // result: (SRA (SignExt16to64 x) y) 7062 for { 7063 x := v_0 7064 y := v_1 7065 if !(shiftIsBounded(v)) { 7066 break 7067 } 7068 v.reset(OpRISCV64SRA) 7069 v0 := b.NewValue0(v.Pos, OpSignExt16to64, typ.Int64) 7070 v0.AddArg(x) 7071 v.AddArg2(v0, y) 7072 return true 7073 } 7074 return false 7075 } 7076 func rewriteValueRISCV64_OpRsh16x8(v *Value) bool { 7077 v_1 := v.Args[1] 7078 v_0 := v.Args[0] 7079 b := v.Block 7080 typ := &b.Func.Config.Types 7081 // match: (Rsh16x8 <t> x y) 7082 // cond: !shiftIsBounded(v) 7083 // result: (SRA <t> (SignExt16to64 x) (OR <y.Type> y (ADDI <y.Type> [-1] (SLTIU <y.Type> [64] (ZeroExt8to64 y))))) 7084 for { 7085 t := v.Type 7086 x := v_0 7087 y := v_1 7088 if !(!shiftIsBounded(v)) { 7089 break 7090 } 7091 v.reset(OpRISCV64SRA) 7092 v.Type = t 7093 v0 := b.NewValue0(v.Pos, OpSignExt16to64, typ.Int64) 7094 v0.AddArg(x) 7095 v1 := b.NewValue0(v.Pos, OpRISCV64OR, y.Type) 7096 v2 := b.NewValue0(v.Pos, OpRISCV64ADDI, y.Type) 7097 v2.AuxInt = int64ToAuxInt(-1) 7098 v3 := b.NewValue0(v.Pos, OpRISCV64SLTIU, y.Type) 7099 v3.AuxInt = int64ToAuxInt(64) 7100 v4 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) 7101 v4.AddArg(y) 7102 v3.AddArg(v4) 7103 v2.AddArg(v3) 7104 v1.AddArg2(y, v2) 7105 v.AddArg2(v0, v1) 7106 return true 7107 } 7108 // match: (Rsh16x8 x y) 7109 // cond: shiftIsBounded(v) 7110 // result: (SRA (SignExt16to64 x) y) 7111 for { 7112 x := v_0 7113 y := v_1 7114 if !(shiftIsBounded(v)) { 7115 break 7116 } 7117 v.reset(OpRISCV64SRA) 7118 v0 := b.NewValue0(v.Pos, OpSignExt16to64, typ.Int64) 7119 v0.AddArg(x) 7120 v.AddArg2(v0, y) 7121 return true 7122 } 7123 return false 7124 } 7125 func rewriteValueRISCV64_OpRsh32Ux16(v *Value) bool { 7126 v_1 := v.Args[1] 7127 v_0 := v.Args[0] 7128 b := v.Block 7129 typ := &b.Func.Config.Types 7130 // match: (Rsh32Ux16 <t> x y) 7131 // cond: !shiftIsBounded(v) 7132 // result: (AND (SRLW <t> x y) (Neg32 <t> (SLTIU <t> [32] (ZeroExt16to64 y)))) 7133 for { 7134 t := v.Type 7135 x := v_0 7136 y := v_1 7137 if !(!shiftIsBounded(v)) { 7138 break 7139 } 7140 v.reset(OpRISCV64AND) 7141 v0 := b.NewValue0(v.Pos, OpRISCV64SRLW, t) 7142 v0.AddArg2(x, y) 7143 v1 := b.NewValue0(v.Pos, OpNeg32, t) 7144 v2 := b.NewValue0(v.Pos, OpRISCV64SLTIU, t) 7145 v2.AuxInt = int64ToAuxInt(32) 7146 v3 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) 7147 v3.AddArg(y) 7148 v2.AddArg(v3) 7149 v1.AddArg(v2) 7150 v.AddArg2(v0, v1) 7151 return true 7152 } 7153 // match: (Rsh32Ux16 x y) 7154 // cond: shiftIsBounded(v) 7155 // result: (SRLW x y) 7156 for { 7157 x := v_0 7158 y := v_1 7159 if !(shiftIsBounded(v)) { 7160 break 7161 } 7162 v.reset(OpRISCV64SRLW) 7163 v.AddArg2(x, y) 7164 return true 7165 } 7166 return false 7167 } 7168 func rewriteValueRISCV64_OpRsh32Ux32(v *Value) bool { 7169 v_1 := v.Args[1] 7170 v_0 := v.Args[0] 7171 b := v.Block 7172 typ := &b.Func.Config.Types 7173 // match: (Rsh32Ux32 <t> x y) 7174 // cond: !shiftIsBounded(v) 7175 // result: (AND (SRLW <t> x y) (Neg32 <t> (SLTIU <t> [32] (ZeroExt32to64 y)))) 7176 for { 7177 t := v.Type 7178 x := v_0 7179 y := v_1 7180 if !(!shiftIsBounded(v)) { 7181 break 7182 } 7183 v.reset(OpRISCV64AND) 7184 v0 := b.NewValue0(v.Pos, OpRISCV64SRLW, t) 7185 v0.AddArg2(x, y) 7186 v1 := b.NewValue0(v.Pos, OpNeg32, t) 7187 v2 := b.NewValue0(v.Pos, OpRISCV64SLTIU, t) 7188 v2.AuxInt = int64ToAuxInt(32) 7189 v3 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) 7190 v3.AddArg(y) 7191 v2.AddArg(v3) 7192 v1.AddArg(v2) 7193 v.AddArg2(v0, v1) 7194 return true 7195 } 7196 // match: (Rsh32Ux32 x y) 7197 // cond: shiftIsBounded(v) 7198 // result: (SRLW x y) 7199 for { 7200 x := v_0 7201 y := v_1 7202 if !(shiftIsBounded(v)) { 7203 break 7204 } 7205 v.reset(OpRISCV64SRLW) 7206 v.AddArg2(x, y) 7207 return true 7208 } 7209 return false 7210 } 7211 func rewriteValueRISCV64_OpRsh32Ux64(v *Value) bool { 7212 v_1 := v.Args[1] 7213 v_0 := v.Args[0] 7214 b := v.Block 7215 // match: (Rsh32Ux64 <t> x y) 7216 // cond: !shiftIsBounded(v) 7217 // result: (AND (SRLW <t> x y) (Neg32 <t> (SLTIU <t> [32] y))) 7218 for { 7219 t := v.Type 7220 x := v_0 7221 y := v_1 7222 if !(!shiftIsBounded(v)) { 7223 break 7224 } 7225 v.reset(OpRISCV64AND) 7226 v0 := b.NewValue0(v.Pos, OpRISCV64SRLW, t) 7227 v0.AddArg2(x, y) 7228 v1 := b.NewValue0(v.Pos, OpNeg32, t) 7229 v2 := b.NewValue0(v.Pos, OpRISCV64SLTIU, t) 7230 v2.AuxInt = int64ToAuxInt(32) 7231 v2.AddArg(y) 7232 v1.AddArg(v2) 7233 v.AddArg2(v0, v1) 7234 return true 7235 } 7236 // match: (Rsh32Ux64 x y) 7237 // cond: shiftIsBounded(v) 7238 // result: (SRLW x y) 7239 for { 7240 x := v_0 7241 y := v_1 7242 if !(shiftIsBounded(v)) { 7243 break 7244 } 7245 v.reset(OpRISCV64SRLW) 7246 v.AddArg2(x, y) 7247 return true 7248 } 7249 return false 7250 } 7251 func rewriteValueRISCV64_OpRsh32Ux8(v *Value) bool { 7252 v_1 := v.Args[1] 7253 v_0 := v.Args[0] 7254 b := v.Block 7255 typ := &b.Func.Config.Types 7256 // match: (Rsh32Ux8 <t> x y) 7257 // cond: !shiftIsBounded(v) 7258 // result: (AND (SRLW <t> x y) (Neg32 <t> (SLTIU <t> [32] (ZeroExt8to64 y)))) 7259 for { 7260 t := v.Type 7261 x := v_0 7262 y := v_1 7263 if !(!shiftIsBounded(v)) { 7264 break 7265 } 7266 v.reset(OpRISCV64AND) 7267 v0 := b.NewValue0(v.Pos, OpRISCV64SRLW, t) 7268 v0.AddArg2(x, y) 7269 v1 := b.NewValue0(v.Pos, OpNeg32, t) 7270 v2 := b.NewValue0(v.Pos, OpRISCV64SLTIU, t) 7271 v2.AuxInt = int64ToAuxInt(32) 7272 v3 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) 7273 v3.AddArg(y) 7274 v2.AddArg(v3) 7275 v1.AddArg(v2) 7276 v.AddArg2(v0, v1) 7277 return true 7278 } 7279 // match: (Rsh32Ux8 x y) 7280 // cond: shiftIsBounded(v) 7281 // result: (SRLW x y) 7282 for { 7283 x := v_0 7284 y := v_1 7285 if !(shiftIsBounded(v)) { 7286 break 7287 } 7288 v.reset(OpRISCV64SRLW) 7289 v.AddArg2(x, y) 7290 return true 7291 } 7292 return false 7293 } 7294 func rewriteValueRISCV64_OpRsh32x16(v *Value) bool { 7295 v_1 := v.Args[1] 7296 v_0 := v.Args[0] 7297 b := v.Block 7298 typ := &b.Func.Config.Types 7299 // match: (Rsh32x16 <t> x y) 7300 // cond: !shiftIsBounded(v) 7301 // result: (SRAW <t> x (OR <y.Type> y (ADDI <y.Type> [-1] (SLTIU <y.Type> [32] (ZeroExt16to64 y))))) 7302 for { 7303 t := v.Type 7304 x := v_0 7305 y := v_1 7306 if !(!shiftIsBounded(v)) { 7307 break 7308 } 7309 v.reset(OpRISCV64SRAW) 7310 v.Type = t 7311 v0 := b.NewValue0(v.Pos, OpRISCV64OR, y.Type) 7312 v1 := b.NewValue0(v.Pos, OpRISCV64ADDI, y.Type) 7313 v1.AuxInt = int64ToAuxInt(-1) 7314 v2 := b.NewValue0(v.Pos, OpRISCV64SLTIU, y.Type) 7315 v2.AuxInt = int64ToAuxInt(32) 7316 v3 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) 7317 v3.AddArg(y) 7318 v2.AddArg(v3) 7319 v1.AddArg(v2) 7320 v0.AddArg2(y, v1) 7321 v.AddArg2(x, v0) 7322 return true 7323 } 7324 // match: (Rsh32x16 x y) 7325 // cond: shiftIsBounded(v) 7326 // result: (SRAW x y) 7327 for { 7328 x := v_0 7329 y := v_1 7330 if !(shiftIsBounded(v)) { 7331 break 7332 } 7333 v.reset(OpRISCV64SRAW) 7334 v.AddArg2(x, y) 7335 return true 7336 } 7337 return false 7338 } 7339 func rewriteValueRISCV64_OpRsh32x32(v *Value) bool { 7340 v_1 := v.Args[1] 7341 v_0 := v.Args[0] 7342 b := v.Block 7343 typ := &b.Func.Config.Types 7344 // match: (Rsh32x32 <t> x y) 7345 // cond: !shiftIsBounded(v) 7346 // result: (SRAW <t> x (OR <y.Type> y (ADDI <y.Type> [-1] (SLTIU <y.Type> [32] (ZeroExt32to64 y))))) 7347 for { 7348 t := v.Type 7349 x := v_0 7350 y := v_1 7351 if !(!shiftIsBounded(v)) { 7352 break 7353 } 7354 v.reset(OpRISCV64SRAW) 7355 v.Type = t 7356 v0 := b.NewValue0(v.Pos, OpRISCV64OR, y.Type) 7357 v1 := b.NewValue0(v.Pos, OpRISCV64ADDI, y.Type) 7358 v1.AuxInt = int64ToAuxInt(-1) 7359 v2 := b.NewValue0(v.Pos, OpRISCV64SLTIU, y.Type) 7360 v2.AuxInt = int64ToAuxInt(32) 7361 v3 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) 7362 v3.AddArg(y) 7363 v2.AddArg(v3) 7364 v1.AddArg(v2) 7365 v0.AddArg2(y, v1) 7366 v.AddArg2(x, v0) 7367 return true 7368 } 7369 // match: (Rsh32x32 x y) 7370 // cond: shiftIsBounded(v) 7371 // result: (SRAW x y) 7372 for { 7373 x := v_0 7374 y := v_1 7375 if !(shiftIsBounded(v)) { 7376 break 7377 } 7378 v.reset(OpRISCV64SRAW) 7379 v.AddArg2(x, y) 7380 return true 7381 } 7382 return false 7383 } 7384 func rewriteValueRISCV64_OpRsh32x64(v *Value) bool { 7385 v_1 := v.Args[1] 7386 v_0 := v.Args[0] 7387 b := v.Block 7388 // match: (Rsh32x64 <t> x y) 7389 // cond: !shiftIsBounded(v) 7390 // result: (SRAW <t> x (OR <y.Type> y (ADDI <y.Type> [-1] (SLTIU <y.Type> [32] y)))) 7391 for { 7392 t := v.Type 7393 x := v_0 7394 y := v_1 7395 if !(!shiftIsBounded(v)) { 7396 break 7397 } 7398 v.reset(OpRISCV64SRAW) 7399 v.Type = t 7400 v0 := b.NewValue0(v.Pos, OpRISCV64OR, y.Type) 7401 v1 := b.NewValue0(v.Pos, OpRISCV64ADDI, y.Type) 7402 v1.AuxInt = int64ToAuxInt(-1) 7403 v2 := b.NewValue0(v.Pos, OpRISCV64SLTIU, y.Type) 7404 v2.AuxInt = int64ToAuxInt(32) 7405 v2.AddArg(y) 7406 v1.AddArg(v2) 7407 v0.AddArg2(y, v1) 7408 v.AddArg2(x, v0) 7409 return true 7410 } 7411 // match: (Rsh32x64 x y) 7412 // cond: shiftIsBounded(v) 7413 // result: (SRAW x y) 7414 for { 7415 x := v_0 7416 y := v_1 7417 if !(shiftIsBounded(v)) { 7418 break 7419 } 7420 v.reset(OpRISCV64SRAW) 7421 v.AddArg2(x, y) 7422 return true 7423 } 7424 return false 7425 } 7426 func rewriteValueRISCV64_OpRsh32x8(v *Value) bool { 7427 v_1 := v.Args[1] 7428 v_0 := v.Args[0] 7429 b := v.Block 7430 typ := &b.Func.Config.Types 7431 // match: (Rsh32x8 <t> x y) 7432 // cond: !shiftIsBounded(v) 7433 // result: (SRAW <t> x (OR <y.Type> y (ADDI <y.Type> [-1] (SLTIU <y.Type> [32] (ZeroExt8to64 y))))) 7434 for { 7435 t := v.Type 7436 x := v_0 7437 y := v_1 7438 if !(!shiftIsBounded(v)) { 7439 break 7440 } 7441 v.reset(OpRISCV64SRAW) 7442 v.Type = t 7443 v0 := b.NewValue0(v.Pos, OpRISCV64OR, y.Type) 7444 v1 := b.NewValue0(v.Pos, OpRISCV64ADDI, y.Type) 7445 v1.AuxInt = int64ToAuxInt(-1) 7446 v2 := b.NewValue0(v.Pos, OpRISCV64SLTIU, y.Type) 7447 v2.AuxInt = int64ToAuxInt(32) 7448 v3 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) 7449 v3.AddArg(y) 7450 v2.AddArg(v3) 7451 v1.AddArg(v2) 7452 v0.AddArg2(y, v1) 7453 v.AddArg2(x, v0) 7454 return true 7455 } 7456 // match: (Rsh32x8 x y) 7457 // cond: shiftIsBounded(v) 7458 // result: (SRAW x y) 7459 for { 7460 x := v_0 7461 y := v_1 7462 if !(shiftIsBounded(v)) { 7463 break 7464 } 7465 v.reset(OpRISCV64SRAW) 7466 v.AddArg2(x, y) 7467 return true 7468 } 7469 return false 7470 } 7471 func rewriteValueRISCV64_OpRsh64Ux16(v *Value) bool { 7472 v_1 := v.Args[1] 7473 v_0 := v.Args[0] 7474 b := v.Block 7475 typ := &b.Func.Config.Types 7476 // match: (Rsh64Ux16 <t> x y) 7477 // cond: !shiftIsBounded(v) 7478 // result: (AND (SRL <t> x y) (Neg64 <t> (SLTIU <t> [64] (ZeroExt16to64 y)))) 7479 for { 7480 t := v.Type 7481 x := v_0 7482 y := v_1 7483 if !(!shiftIsBounded(v)) { 7484 break 7485 } 7486 v.reset(OpRISCV64AND) 7487 v0 := b.NewValue0(v.Pos, OpRISCV64SRL, t) 7488 v0.AddArg2(x, y) 7489 v1 := b.NewValue0(v.Pos, OpNeg64, t) 7490 v2 := b.NewValue0(v.Pos, OpRISCV64SLTIU, t) 7491 v2.AuxInt = int64ToAuxInt(64) 7492 v3 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) 7493 v3.AddArg(y) 7494 v2.AddArg(v3) 7495 v1.AddArg(v2) 7496 v.AddArg2(v0, v1) 7497 return true 7498 } 7499 // match: (Rsh64Ux16 x y) 7500 // cond: shiftIsBounded(v) 7501 // result: (SRL x y) 7502 for { 7503 x := v_0 7504 y := v_1 7505 if !(shiftIsBounded(v)) { 7506 break 7507 } 7508 v.reset(OpRISCV64SRL) 7509 v.AddArg2(x, y) 7510 return true 7511 } 7512 return false 7513 } 7514 func rewriteValueRISCV64_OpRsh64Ux32(v *Value) bool { 7515 v_1 := v.Args[1] 7516 v_0 := v.Args[0] 7517 b := v.Block 7518 typ := &b.Func.Config.Types 7519 // match: (Rsh64Ux32 <t> x y) 7520 // cond: !shiftIsBounded(v) 7521 // result: (AND (SRL <t> x y) (Neg64 <t> (SLTIU <t> [64] (ZeroExt32to64 y)))) 7522 for { 7523 t := v.Type 7524 x := v_0 7525 y := v_1 7526 if !(!shiftIsBounded(v)) { 7527 break 7528 } 7529 v.reset(OpRISCV64AND) 7530 v0 := b.NewValue0(v.Pos, OpRISCV64SRL, t) 7531 v0.AddArg2(x, y) 7532 v1 := b.NewValue0(v.Pos, OpNeg64, t) 7533 v2 := b.NewValue0(v.Pos, OpRISCV64SLTIU, t) 7534 v2.AuxInt = int64ToAuxInt(64) 7535 v3 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) 7536 v3.AddArg(y) 7537 v2.AddArg(v3) 7538 v1.AddArg(v2) 7539 v.AddArg2(v0, v1) 7540 return true 7541 } 7542 // match: (Rsh64Ux32 x y) 7543 // cond: shiftIsBounded(v) 7544 // result: (SRL x y) 7545 for { 7546 x := v_0 7547 y := v_1 7548 if !(shiftIsBounded(v)) { 7549 break 7550 } 7551 v.reset(OpRISCV64SRL) 7552 v.AddArg2(x, y) 7553 return true 7554 } 7555 return false 7556 } 7557 func rewriteValueRISCV64_OpRsh64Ux64(v *Value) bool { 7558 v_1 := v.Args[1] 7559 v_0 := v.Args[0] 7560 b := v.Block 7561 // match: (Rsh64Ux64 <t> x y) 7562 // cond: !shiftIsBounded(v) 7563 // result: (AND (SRL <t> x y) (Neg64 <t> (SLTIU <t> [64] y))) 7564 for { 7565 t := v.Type 7566 x := v_0 7567 y := v_1 7568 if !(!shiftIsBounded(v)) { 7569 break 7570 } 7571 v.reset(OpRISCV64AND) 7572 v0 := b.NewValue0(v.Pos, OpRISCV64SRL, t) 7573 v0.AddArg2(x, y) 7574 v1 := b.NewValue0(v.Pos, OpNeg64, t) 7575 v2 := b.NewValue0(v.Pos, OpRISCV64SLTIU, t) 7576 v2.AuxInt = int64ToAuxInt(64) 7577 v2.AddArg(y) 7578 v1.AddArg(v2) 7579 v.AddArg2(v0, v1) 7580 return true 7581 } 7582 // match: (Rsh64Ux64 x y) 7583 // cond: shiftIsBounded(v) 7584 // result: (SRL x y) 7585 for { 7586 x := v_0 7587 y := v_1 7588 if !(shiftIsBounded(v)) { 7589 break 7590 } 7591 v.reset(OpRISCV64SRL) 7592 v.AddArg2(x, y) 7593 return true 7594 } 7595 return false 7596 } 7597 func rewriteValueRISCV64_OpRsh64Ux8(v *Value) bool { 7598 v_1 := v.Args[1] 7599 v_0 := v.Args[0] 7600 b := v.Block 7601 typ := &b.Func.Config.Types 7602 // match: (Rsh64Ux8 <t> x y) 7603 // cond: !shiftIsBounded(v) 7604 // result: (AND (SRL <t> x y) (Neg64 <t> (SLTIU <t> [64] (ZeroExt8to64 y)))) 7605 for { 7606 t := v.Type 7607 x := v_0 7608 y := v_1 7609 if !(!shiftIsBounded(v)) { 7610 break 7611 } 7612 v.reset(OpRISCV64AND) 7613 v0 := b.NewValue0(v.Pos, OpRISCV64SRL, t) 7614 v0.AddArg2(x, y) 7615 v1 := b.NewValue0(v.Pos, OpNeg64, t) 7616 v2 := b.NewValue0(v.Pos, OpRISCV64SLTIU, t) 7617 v2.AuxInt = int64ToAuxInt(64) 7618 v3 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) 7619 v3.AddArg(y) 7620 v2.AddArg(v3) 7621 v1.AddArg(v2) 7622 v.AddArg2(v0, v1) 7623 return true 7624 } 7625 // match: (Rsh64Ux8 x y) 7626 // cond: shiftIsBounded(v) 7627 // result: (SRL x y) 7628 for { 7629 x := v_0 7630 y := v_1 7631 if !(shiftIsBounded(v)) { 7632 break 7633 } 7634 v.reset(OpRISCV64SRL) 7635 v.AddArg2(x, y) 7636 return true 7637 } 7638 return false 7639 } 7640 func rewriteValueRISCV64_OpRsh64x16(v *Value) bool { 7641 v_1 := v.Args[1] 7642 v_0 := v.Args[0] 7643 b := v.Block 7644 typ := &b.Func.Config.Types 7645 // match: (Rsh64x16 <t> x y) 7646 // cond: !shiftIsBounded(v) 7647 // result: (SRA <t> x (OR <y.Type> y (ADDI <y.Type> [-1] (SLTIU <y.Type> [64] (ZeroExt16to64 y))))) 7648 for { 7649 t := v.Type 7650 x := v_0 7651 y := v_1 7652 if !(!shiftIsBounded(v)) { 7653 break 7654 } 7655 v.reset(OpRISCV64SRA) 7656 v.Type = t 7657 v0 := b.NewValue0(v.Pos, OpRISCV64OR, y.Type) 7658 v1 := b.NewValue0(v.Pos, OpRISCV64ADDI, y.Type) 7659 v1.AuxInt = int64ToAuxInt(-1) 7660 v2 := b.NewValue0(v.Pos, OpRISCV64SLTIU, y.Type) 7661 v2.AuxInt = int64ToAuxInt(64) 7662 v3 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) 7663 v3.AddArg(y) 7664 v2.AddArg(v3) 7665 v1.AddArg(v2) 7666 v0.AddArg2(y, v1) 7667 v.AddArg2(x, v0) 7668 return true 7669 } 7670 // match: (Rsh64x16 x y) 7671 // cond: shiftIsBounded(v) 7672 // result: (SRA x y) 7673 for { 7674 x := v_0 7675 y := v_1 7676 if !(shiftIsBounded(v)) { 7677 break 7678 } 7679 v.reset(OpRISCV64SRA) 7680 v.AddArg2(x, y) 7681 return true 7682 } 7683 return false 7684 } 7685 func rewriteValueRISCV64_OpRsh64x32(v *Value) bool { 7686 v_1 := v.Args[1] 7687 v_0 := v.Args[0] 7688 b := v.Block 7689 typ := &b.Func.Config.Types 7690 // match: (Rsh64x32 <t> x y) 7691 // cond: !shiftIsBounded(v) 7692 // result: (SRA <t> x (OR <y.Type> y (ADDI <y.Type> [-1] (SLTIU <y.Type> [64] (ZeroExt32to64 y))))) 7693 for { 7694 t := v.Type 7695 x := v_0 7696 y := v_1 7697 if !(!shiftIsBounded(v)) { 7698 break 7699 } 7700 v.reset(OpRISCV64SRA) 7701 v.Type = t 7702 v0 := b.NewValue0(v.Pos, OpRISCV64OR, y.Type) 7703 v1 := b.NewValue0(v.Pos, OpRISCV64ADDI, y.Type) 7704 v1.AuxInt = int64ToAuxInt(-1) 7705 v2 := b.NewValue0(v.Pos, OpRISCV64SLTIU, y.Type) 7706 v2.AuxInt = int64ToAuxInt(64) 7707 v3 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) 7708 v3.AddArg(y) 7709 v2.AddArg(v3) 7710 v1.AddArg(v2) 7711 v0.AddArg2(y, v1) 7712 v.AddArg2(x, v0) 7713 return true 7714 } 7715 // match: (Rsh64x32 x y) 7716 // cond: shiftIsBounded(v) 7717 // result: (SRA x y) 7718 for { 7719 x := v_0 7720 y := v_1 7721 if !(shiftIsBounded(v)) { 7722 break 7723 } 7724 v.reset(OpRISCV64SRA) 7725 v.AddArg2(x, y) 7726 return true 7727 } 7728 return false 7729 } 7730 func rewriteValueRISCV64_OpRsh64x64(v *Value) bool { 7731 v_1 := v.Args[1] 7732 v_0 := v.Args[0] 7733 b := v.Block 7734 // match: (Rsh64x64 <t> x y) 7735 // cond: !shiftIsBounded(v) 7736 // result: (SRA <t> x (OR <y.Type> y (ADDI <y.Type> [-1] (SLTIU <y.Type> [64] y)))) 7737 for { 7738 t := v.Type 7739 x := v_0 7740 y := v_1 7741 if !(!shiftIsBounded(v)) { 7742 break 7743 } 7744 v.reset(OpRISCV64SRA) 7745 v.Type = t 7746 v0 := b.NewValue0(v.Pos, OpRISCV64OR, y.Type) 7747 v1 := b.NewValue0(v.Pos, OpRISCV64ADDI, y.Type) 7748 v1.AuxInt = int64ToAuxInt(-1) 7749 v2 := b.NewValue0(v.Pos, OpRISCV64SLTIU, y.Type) 7750 v2.AuxInt = int64ToAuxInt(64) 7751 v2.AddArg(y) 7752 v1.AddArg(v2) 7753 v0.AddArg2(y, v1) 7754 v.AddArg2(x, v0) 7755 return true 7756 } 7757 // match: (Rsh64x64 x y) 7758 // cond: shiftIsBounded(v) 7759 // result: (SRA x y) 7760 for { 7761 x := v_0 7762 y := v_1 7763 if !(shiftIsBounded(v)) { 7764 break 7765 } 7766 v.reset(OpRISCV64SRA) 7767 v.AddArg2(x, y) 7768 return true 7769 } 7770 return false 7771 } 7772 func rewriteValueRISCV64_OpRsh64x8(v *Value) bool { 7773 v_1 := v.Args[1] 7774 v_0 := v.Args[0] 7775 b := v.Block 7776 typ := &b.Func.Config.Types 7777 // match: (Rsh64x8 <t> x y) 7778 // cond: !shiftIsBounded(v) 7779 // result: (SRA <t> x (OR <y.Type> y (ADDI <y.Type> [-1] (SLTIU <y.Type> [64] (ZeroExt8to64 y))))) 7780 for { 7781 t := v.Type 7782 x := v_0 7783 y := v_1 7784 if !(!shiftIsBounded(v)) { 7785 break 7786 } 7787 v.reset(OpRISCV64SRA) 7788 v.Type = t 7789 v0 := b.NewValue0(v.Pos, OpRISCV64OR, y.Type) 7790 v1 := b.NewValue0(v.Pos, OpRISCV64ADDI, y.Type) 7791 v1.AuxInt = int64ToAuxInt(-1) 7792 v2 := b.NewValue0(v.Pos, OpRISCV64SLTIU, y.Type) 7793 v2.AuxInt = int64ToAuxInt(64) 7794 v3 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) 7795 v3.AddArg(y) 7796 v2.AddArg(v3) 7797 v1.AddArg(v2) 7798 v0.AddArg2(y, v1) 7799 v.AddArg2(x, v0) 7800 return true 7801 } 7802 // match: (Rsh64x8 x y) 7803 // cond: shiftIsBounded(v) 7804 // result: (SRA x y) 7805 for { 7806 x := v_0 7807 y := v_1 7808 if !(shiftIsBounded(v)) { 7809 break 7810 } 7811 v.reset(OpRISCV64SRA) 7812 v.AddArg2(x, y) 7813 return true 7814 } 7815 return false 7816 } 7817 func rewriteValueRISCV64_OpRsh8Ux16(v *Value) bool { 7818 v_1 := v.Args[1] 7819 v_0 := v.Args[0] 7820 b := v.Block 7821 typ := &b.Func.Config.Types 7822 // match: (Rsh8Ux16 <t> x y) 7823 // cond: !shiftIsBounded(v) 7824 // result: (AND (SRL <t> (ZeroExt8to64 x) y) (Neg8 <t> (SLTIU <t> [64] (ZeroExt16to64 y)))) 7825 for { 7826 t := v.Type 7827 x := v_0 7828 y := v_1 7829 if !(!shiftIsBounded(v)) { 7830 break 7831 } 7832 v.reset(OpRISCV64AND) 7833 v0 := b.NewValue0(v.Pos, OpRISCV64SRL, t) 7834 v1 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) 7835 v1.AddArg(x) 7836 v0.AddArg2(v1, y) 7837 v2 := b.NewValue0(v.Pos, OpNeg8, t) 7838 v3 := b.NewValue0(v.Pos, OpRISCV64SLTIU, t) 7839 v3.AuxInt = int64ToAuxInt(64) 7840 v4 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) 7841 v4.AddArg(y) 7842 v3.AddArg(v4) 7843 v2.AddArg(v3) 7844 v.AddArg2(v0, v2) 7845 return true 7846 } 7847 // match: (Rsh8Ux16 x y) 7848 // cond: shiftIsBounded(v) 7849 // result: (SRL (ZeroExt8to64 x) y) 7850 for { 7851 x := v_0 7852 y := v_1 7853 if !(shiftIsBounded(v)) { 7854 break 7855 } 7856 v.reset(OpRISCV64SRL) 7857 v0 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) 7858 v0.AddArg(x) 7859 v.AddArg2(v0, y) 7860 return true 7861 } 7862 return false 7863 } 7864 func rewriteValueRISCV64_OpRsh8Ux32(v *Value) bool { 7865 v_1 := v.Args[1] 7866 v_0 := v.Args[0] 7867 b := v.Block 7868 typ := &b.Func.Config.Types 7869 // match: (Rsh8Ux32 <t> x y) 7870 // cond: !shiftIsBounded(v) 7871 // result: (AND (SRL <t> (ZeroExt8to64 x) y) (Neg8 <t> (SLTIU <t> [64] (ZeroExt32to64 y)))) 7872 for { 7873 t := v.Type 7874 x := v_0 7875 y := v_1 7876 if !(!shiftIsBounded(v)) { 7877 break 7878 } 7879 v.reset(OpRISCV64AND) 7880 v0 := b.NewValue0(v.Pos, OpRISCV64SRL, t) 7881 v1 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) 7882 v1.AddArg(x) 7883 v0.AddArg2(v1, y) 7884 v2 := b.NewValue0(v.Pos, OpNeg8, t) 7885 v3 := b.NewValue0(v.Pos, OpRISCV64SLTIU, t) 7886 v3.AuxInt = int64ToAuxInt(64) 7887 v4 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) 7888 v4.AddArg(y) 7889 v3.AddArg(v4) 7890 v2.AddArg(v3) 7891 v.AddArg2(v0, v2) 7892 return true 7893 } 7894 // match: (Rsh8Ux32 x y) 7895 // cond: shiftIsBounded(v) 7896 // result: (SRL (ZeroExt8to64 x) y) 7897 for { 7898 x := v_0 7899 y := v_1 7900 if !(shiftIsBounded(v)) { 7901 break 7902 } 7903 v.reset(OpRISCV64SRL) 7904 v0 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) 7905 v0.AddArg(x) 7906 v.AddArg2(v0, y) 7907 return true 7908 } 7909 return false 7910 } 7911 func rewriteValueRISCV64_OpRsh8Ux64(v *Value) bool { 7912 v_1 := v.Args[1] 7913 v_0 := v.Args[0] 7914 b := v.Block 7915 typ := &b.Func.Config.Types 7916 // match: (Rsh8Ux64 <t> x y) 7917 // cond: !shiftIsBounded(v) 7918 // result: (AND (SRL <t> (ZeroExt8to64 x) y) (Neg8 <t> (SLTIU <t> [64] y))) 7919 for { 7920 t := v.Type 7921 x := v_0 7922 y := v_1 7923 if !(!shiftIsBounded(v)) { 7924 break 7925 } 7926 v.reset(OpRISCV64AND) 7927 v0 := b.NewValue0(v.Pos, OpRISCV64SRL, t) 7928 v1 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) 7929 v1.AddArg(x) 7930 v0.AddArg2(v1, y) 7931 v2 := b.NewValue0(v.Pos, OpNeg8, t) 7932 v3 := b.NewValue0(v.Pos, OpRISCV64SLTIU, t) 7933 v3.AuxInt = int64ToAuxInt(64) 7934 v3.AddArg(y) 7935 v2.AddArg(v3) 7936 v.AddArg2(v0, v2) 7937 return true 7938 } 7939 // match: (Rsh8Ux64 x y) 7940 // cond: shiftIsBounded(v) 7941 // result: (SRL (ZeroExt8to64 x) y) 7942 for { 7943 x := v_0 7944 y := v_1 7945 if !(shiftIsBounded(v)) { 7946 break 7947 } 7948 v.reset(OpRISCV64SRL) 7949 v0 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) 7950 v0.AddArg(x) 7951 v.AddArg2(v0, y) 7952 return true 7953 } 7954 return false 7955 } 7956 func rewriteValueRISCV64_OpRsh8Ux8(v *Value) bool { 7957 v_1 := v.Args[1] 7958 v_0 := v.Args[0] 7959 b := v.Block 7960 typ := &b.Func.Config.Types 7961 // match: (Rsh8Ux8 <t> x y) 7962 // cond: !shiftIsBounded(v) 7963 // result: (AND (SRL <t> (ZeroExt8to64 x) y) (Neg8 <t> (SLTIU <t> [64] (ZeroExt8to64 y)))) 7964 for { 7965 t := v.Type 7966 x := v_0 7967 y := v_1 7968 if !(!shiftIsBounded(v)) { 7969 break 7970 } 7971 v.reset(OpRISCV64AND) 7972 v0 := b.NewValue0(v.Pos, OpRISCV64SRL, t) 7973 v1 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) 7974 v1.AddArg(x) 7975 v0.AddArg2(v1, y) 7976 v2 := b.NewValue0(v.Pos, OpNeg8, t) 7977 v3 := b.NewValue0(v.Pos, OpRISCV64SLTIU, t) 7978 v3.AuxInt = int64ToAuxInt(64) 7979 v4 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) 7980 v4.AddArg(y) 7981 v3.AddArg(v4) 7982 v2.AddArg(v3) 7983 v.AddArg2(v0, v2) 7984 return true 7985 } 7986 // match: (Rsh8Ux8 x y) 7987 // cond: shiftIsBounded(v) 7988 // result: (SRL (ZeroExt8to64 x) y) 7989 for { 7990 x := v_0 7991 y := v_1 7992 if !(shiftIsBounded(v)) { 7993 break 7994 } 7995 v.reset(OpRISCV64SRL) 7996 v0 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) 7997 v0.AddArg(x) 7998 v.AddArg2(v0, y) 7999 return true 8000 } 8001 return false 8002 } 8003 func rewriteValueRISCV64_OpRsh8x16(v *Value) bool { 8004 v_1 := v.Args[1] 8005 v_0 := v.Args[0] 8006 b := v.Block 8007 typ := &b.Func.Config.Types 8008 // match: (Rsh8x16 <t> x y) 8009 // cond: !shiftIsBounded(v) 8010 // result: (SRA <t> (SignExt8to64 x) (OR <y.Type> y (ADDI <y.Type> [-1] (SLTIU <y.Type> [64] (ZeroExt16to64 y))))) 8011 for { 8012 t := v.Type 8013 x := v_0 8014 y := v_1 8015 if !(!shiftIsBounded(v)) { 8016 break 8017 } 8018 v.reset(OpRISCV64SRA) 8019 v.Type = t 8020 v0 := b.NewValue0(v.Pos, OpSignExt8to64, typ.Int64) 8021 v0.AddArg(x) 8022 v1 := b.NewValue0(v.Pos, OpRISCV64OR, y.Type) 8023 v2 := b.NewValue0(v.Pos, OpRISCV64ADDI, y.Type) 8024 v2.AuxInt = int64ToAuxInt(-1) 8025 v3 := b.NewValue0(v.Pos, OpRISCV64SLTIU, y.Type) 8026 v3.AuxInt = int64ToAuxInt(64) 8027 v4 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) 8028 v4.AddArg(y) 8029 v3.AddArg(v4) 8030 v2.AddArg(v3) 8031 v1.AddArg2(y, v2) 8032 v.AddArg2(v0, v1) 8033 return true 8034 } 8035 // match: (Rsh8x16 x y) 8036 // cond: shiftIsBounded(v) 8037 // result: (SRA (SignExt8to64 x) y) 8038 for { 8039 x := v_0 8040 y := v_1 8041 if !(shiftIsBounded(v)) { 8042 break 8043 } 8044 v.reset(OpRISCV64SRA) 8045 v0 := b.NewValue0(v.Pos, OpSignExt8to64, typ.Int64) 8046 v0.AddArg(x) 8047 v.AddArg2(v0, y) 8048 return true 8049 } 8050 return false 8051 } 8052 func rewriteValueRISCV64_OpRsh8x32(v *Value) bool { 8053 v_1 := v.Args[1] 8054 v_0 := v.Args[0] 8055 b := v.Block 8056 typ := &b.Func.Config.Types 8057 // match: (Rsh8x32 <t> x y) 8058 // cond: !shiftIsBounded(v) 8059 // result: (SRA <t> (SignExt8to64 x) (OR <y.Type> y (ADDI <y.Type> [-1] (SLTIU <y.Type> [64] (ZeroExt32to64 y))))) 8060 for { 8061 t := v.Type 8062 x := v_0 8063 y := v_1 8064 if !(!shiftIsBounded(v)) { 8065 break 8066 } 8067 v.reset(OpRISCV64SRA) 8068 v.Type = t 8069 v0 := b.NewValue0(v.Pos, OpSignExt8to64, typ.Int64) 8070 v0.AddArg(x) 8071 v1 := b.NewValue0(v.Pos, OpRISCV64OR, y.Type) 8072 v2 := b.NewValue0(v.Pos, OpRISCV64ADDI, y.Type) 8073 v2.AuxInt = int64ToAuxInt(-1) 8074 v3 := b.NewValue0(v.Pos, OpRISCV64SLTIU, y.Type) 8075 v3.AuxInt = int64ToAuxInt(64) 8076 v4 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) 8077 v4.AddArg(y) 8078 v3.AddArg(v4) 8079 v2.AddArg(v3) 8080 v1.AddArg2(y, v2) 8081 v.AddArg2(v0, v1) 8082 return true 8083 } 8084 // match: (Rsh8x32 x y) 8085 // cond: shiftIsBounded(v) 8086 // result: (SRA (SignExt8to64 x) y) 8087 for { 8088 x := v_0 8089 y := v_1 8090 if !(shiftIsBounded(v)) { 8091 break 8092 } 8093 v.reset(OpRISCV64SRA) 8094 v0 := b.NewValue0(v.Pos, OpSignExt8to64, typ.Int64) 8095 v0.AddArg(x) 8096 v.AddArg2(v0, y) 8097 return true 8098 } 8099 return false 8100 } 8101 func rewriteValueRISCV64_OpRsh8x64(v *Value) bool { 8102 v_1 := v.Args[1] 8103 v_0 := v.Args[0] 8104 b := v.Block 8105 typ := &b.Func.Config.Types 8106 // match: (Rsh8x64 <t> x y) 8107 // cond: !shiftIsBounded(v) 8108 // result: (SRA <t> (SignExt8to64 x) (OR <y.Type> y (ADDI <y.Type> [-1] (SLTIU <y.Type> [64] y)))) 8109 for { 8110 t := v.Type 8111 x := v_0 8112 y := v_1 8113 if !(!shiftIsBounded(v)) { 8114 break 8115 } 8116 v.reset(OpRISCV64SRA) 8117 v.Type = t 8118 v0 := b.NewValue0(v.Pos, OpSignExt8to64, typ.Int64) 8119 v0.AddArg(x) 8120 v1 := b.NewValue0(v.Pos, OpRISCV64OR, y.Type) 8121 v2 := b.NewValue0(v.Pos, OpRISCV64ADDI, y.Type) 8122 v2.AuxInt = int64ToAuxInt(-1) 8123 v3 := b.NewValue0(v.Pos, OpRISCV64SLTIU, y.Type) 8124 v3.AuxInt = int64ToAuxInt(64) 8125 v3.AddArg(y) 8126 v2.AddArg(v3) 8127 v1.AddArg2(y, v2) 8128 v.AddArg2(v0, v1) 8129 return true 8130 } 8131 // match: (Rsh8x64 x y) 8132 // cond: shiftIsBounded(v) 8133 // result: (SRA (SignExt8to64 x) y) 8134 for { 8135 x := v_0 8136 y := v_1 8137 if !(shiftIsBounded(v)) { 8138 break 8139 } 8140 v.reset(OpRISCV64SRA) 8141 v0 := b.NewValue0(v.Pos, OpSignExt8to64, typ.Int64) 8142 v0.AddArg(x) 8143 v.AddArg2(v0, y) 8144 return true 8145 } 8146 return false 8147 } 8148 func rewriteValueRISCV64_OpRsh8x8(v *Value) bool { 8149 v_1 := v.Args[1] 8150 v_0 := v.Args[0] 8151 b := v.Block 8152 typ := &b.Func.Config.Types 8153 // match: (Rsh8x8 <t> x y) 8154 // cond: !shiftIsBounded(v) 8155 // result: (SRA <t> (SignExt8to64 x) (OR <y.Type> y (ADDI <y.Type> [-1] (SLTIU <y.Type> [64] (ZeroExt8to64 y))))) 8156 for { 8157 t := v.Type 8158 x := v_0 8159 y := v_1 8160 if !(!shiftIsBounded(v)) { 8161 break 8162 } 8163 v.reset(OpRISCV64SRA) 8164 v.Type = t 8165 v0 := b.NewValue0(v.Pos, OpSignExt8to64, typ.Int64) 8166 v0.AddArg(x) 8167 v1 := b.NewValue0(v.Pos, OpRISCV64OR, y.Type) 8168 v2 := b.NewValue0(v.Pos, OpRISCV64ADDI, y.Type) 8169 v2.AuxInt = int64ToAuxInt(-1) 8170 v3 := b.NewValue0(v.Pos, OpRISCV64SLTIU, y.Type) 8171 v3.AuxInt = int64ToAuxInt(64) 8172 v4 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) 8173 v4.AddArg(y) 8174 v3.AddArg(v4) 8175 v2.AddArg(v3) 8176 v1.AddArg2(y, v2) 8177 v.AddArg2(v0, v1) 8178 return true 8179 } 8180 // match: (Rsh8x8 x y) 8181 // cond: shiftIsBounded(v) 8182 // result: (SRA (SignExt8to64 x) y) 8183 for { 8184 x := v_0 8185 y := v_1 8186 if !(shiftIsBounded(v)) { 8187 break 8188 } 8189 v.reset(OpRISCV64SRA) 8190 v0 := b.NewValue0(v.Pos, OpSignExt8to64, typ.Int64) 8191 v0.AddArg(x) 8192 v.AddArg2(v0, y) 8193 return true 8194 } 8195 return false 8196 } 8197 func rewriteValueRISCV64_OpSelect0(v *Value) bool { 8198 v_0 := v.Args[0] 8199 b := v.Block 8200 typ := &b.Func.Config.Types 8201 // match: (Select0 (Add64carry x y c)) 8202 // result: (ADD (ADD <typ.UInt64> x y) c) 8203 for { 8204 if v_0.Op != OpAdd64carry { 8205 break 8206 } 8207 c := v_0.Args[2] 8208 x := v_0.Args[0] 8209 y := v_0.Args[1] 8210 v.reset(OpRISCV64ADD) 8211 v0 := b.NewValue0(v.Pos, OpRISCV64ADD, typ.UInt64) 8212 v0.AddArg2(x, y) 8213 v.AddArg2(v0, c) 8214 return true 8215 } 8216 // match: (Select0 (Sub64borrow x y c)) 8217 // result: (SUB (SUB <typ.UInt64> x y) c) 8218 for { 8219 if v_0.Op != OpSub64borrow { 8220 break 8221 } 8222 c := v_0.Args[2] 8223 x := v_0.Args[0] 8224 y := v_0.Args[1] 8225 v.reset(OpRISCV64SUB) 8226 v0 := b.NewValue0(v.Pos, OpRISCV64SUB, typ.UInt64) 8227 v0.AddArg2(x, y) 8228 v.AddArg2(v0, c) 8229 return true 8230 } 8231 // match: (Select0 m:(LoweredMuluhilo x y)) 8232 // cond: m.Uses == 1 8233 // result: (MULHU x y) 8234 for { 8235 m := v_0 8236 if m.Op != OpRISCV64LoweredMuluhilo { 8237 break 8238 } 8239 y := m.Args[1] 8240 x := m.Args[0] 8241 if !(m.Uses == 1) { 8242 break 8243 } 8244 v.reset(OpRISCV64MULHU) 8245 v.AddArg2(x, y) 8246 return true 8247 } 8248 return false 8249 } 8250 func rewriteValueRISCV64_OpSelect1(v *Value) bool { 8251 v_0 := v.Args[0] 8252 b := v.Block 8253 typ := &b.Func.Config.Types 8254 // match: (Select1 (Add64carry x y c)) 8255 // result: (OR (SLTU <typ.UInt64> s:(ADD <typ.UInt64> x y) x) (SLTU <typ.UInt64> (ADD <typ.UInt64> s c) s)) 8256 for { 8257 if v_0.Op != OpAdd64carry { 8258 break 8259 } 8260 c := v_0.Args[2] 8261 x := v_0.Args[0] 8262 y := v_0.Args[1] 8263 v.reset(OpRISCV64OR) 8264 v0 := b.NewValue0(v.Pos, OpRISCV64SLTU, typ.UInt64) 8265 s := b.NewValue0(v.Pos, OpRISCV64ADD, typ.UInt64) 8266 s.AddArg2(x, y) 8267 v0.AddArg2(s, x) 8268 v2 := b.NewValue0(v.Pos, OpRISCV64SLTU, typ.UInt64) 8269 v3 := b.NewValue0(v.Pos, OpRISCV64ADD, typ.UInt64) 8270 v3.AddArg2(s, c) 8271 v2.AddArg2(v3, s) 8272 v.AddArg2(v0, v2) 8273 return true 8274 } 8275 // match: (Select1 (Sub64borrow x y c)) 8276 // result: (OR (SLTU <typ.UInt64> x s:(SUB <typ.UInt64> x y)) (SLTU <typ.UInt64> s (SUB <typ.UInt64> s c))) 8277 for { 8278 if v_0.Op != OpSub64borrow { 8279 break 8280 } 8281 c := v_0.Args[2] 8282 x := v_0.Args[0] 8283 y := v_0.Args[1] 8284 v.reset(OpRISCV64OR) 8285 v0 := b.NewValue0(v.Pos, OpRISCV64SLTU, typ.UInt64) 8286 s := b.NewValue0(v.Pos, OpRISCV64SUB, typ.UInt64) 8287 s.AddArg2(x, y) 8288 v0.AddArg2(x, s) 8289 v2 := b.NewValue0(v.Pos, OpRISCV64SLTU, typ.UInt64) 8290 v3 := b.NewValue0(v.Pos, OpRISCV64SUB, typ.UInt64) 8291 v3.AddArg2(s, c) 8292 v2.AddArg2(s, v3) 8293 v.AddArg2(v0, v2) 8294 return true 8295 } 8296 // match: (Select1 m:(LoweredMuluhilo x y)) 8297 // cond: m.Uses == 1 8298 // result: (MUL x y) 8299 for { 8300 m := v_0 8301 if m.Op != OpRISCV64LoweredMuluhilo { 8302 break 8303 } 8304 y := m.Args[1] 8305 x := m.Args[0] 8306 if !(m.Uses == 1) { 8307 break 8308 } 8309 v.reset(OpRISCV64MUL) 8310 v.AddArg2(x, y) 8311 return true 8312 } 8313 return false 8314 } 8315 func rewriteValueRISCV64_OpSlicemask(v *Value) bool { 8316 v_0 := v.Args[0] 8317 b := v.Block 8318 // match: (Slicemask <t> x) 8319 // result: (SRAI [63] (NEG <t> x)) 8320 for { 8321 t := v.Type 8322 x := v_0 8323 v.reset(OpRISCV64SRAI) 8324 v.AuxInt = int64ToAuxInt(63) 8325 v0 := b.NewValue0(v.Pos, OpRISCV64NEG, t) 8326 v0.AddArg(x) 8327 v.AddArg(v0) 8328 return true 8329 } 8330 } 8331 func rewriteValueRISCV64_OpStore(v *Value) bool { 8332 v_2 := v.Args[2] 8333 v_1 := v.Args[1] 8334 v_0 := v.Args[0] 8335 // match: (Store {t} ptr val mem) 8336 // cond: t.Size() == 1 8337 // result: (MOVBstore ptr val mem) 8338 for { 8339 t := auxToType(v.Aux) 8340 ptr := v_0 8341 val := v_1 8342 mem := v_2 8343 if !(t.Size() == 1) { 8344 break 8345 } 8346 v.reset(OpRISCV64MOVBstore) 8347 v.AddArg3(ptr, val, mem) 8348 return true 8349 } 8350 // match: (Store {t} ptr val mem) 8351 // cond: t.Size() == 2 8352 // result: (MOVHstore ptr val mem) 8353 for { 8354 t := auxToType(v.Aux) 8355 ptr := v_0 8356 val := v_1 8357 mem := v_2 8358 if !(t.Size() == 2) { 8359 break 8360 } 8361 v.reset(OpRISCV64MOVHstore) 8362 v.AddArg3(ptr, val, mem) 8363 return true 8364 } 8365 // match: (Store {t} ptr val mem) 8366 // cond: t.Size() == 4 && !t.IsFloat() 8367 // result: (MOVWstore ptr val mem) 8368 for { 8369 t := auxToType(v.Aux) 8370 ptr := v_0 8371 val := v_1 8372 mem := v_2 8373 if !(t.Size() == 4 && !t.IsFloat()) { 8374 break 8375 } 8376 v.reset(OpRISCV64MOVWstore) 8377 v.AddArg3(ptr, val, mem) 8378 return true 8379 } 8380 // match: (Store {t} ptr val mem) 8381 // cond: t.Size() == 8 && !t.IsFloat() 8382 // result: (MOVDstore ptr val mem) 8383 for { 8384 t := auxToType(v.Aux) 8385 ptr := v_0 8386 val := v_1 8387 mem := v_2 8388 if !(t.Size() == 8 && !t.IsFloat()) { 8389 break 8390 } 8391 v.reset(OpRISCV64MOVDstore) 8392 v.AddArg3(ptr, val, mem) 8393 return true 8394 } 8395 // match: (Store {t} ptr val mem) 8396 // cond: t.Size() == 4 && t.IsFloat() 8397 // result: (FMOVWstore ptr val mem) 8398 for { 8399 t := auxToType(v.Aux) 8400 ptr := v_0 8401 val := v_1 8402 mem := v_2 8403 if !(t.Size() == 4 && t.IsFloat()) { 8404 break 8405 } 8406 v.reset(OpRISCV64FMOVWstore) 8407 v.AddArg3(ptr, val, mem) 8408 return true 8409 } 8410 // match: (Store {t} ptr val mem) 8411 // cond: t.Size() == 8 && t.IsFloat() 8412 // result: (FMOVDstore ptr val mem) 8413 for { 8414 t := auxToType(v.Aux) 8415 ptr := v_0 8416 val := v_1 8417 mem := v_2 8418 if !(t.Size() == 8 && t.IsFloat()) { 8419 break 8420 } 8421 v.reset(OpRISCV64FMOVDstore) 8422 v.AddArg3(ptr, val, mem) 8423 return true 8424 } 8425 return false 8426 } 8427 func rewriteValueRISCV64_OpZero(v *Value) bool { 8428 v_1 := v.Args[1] 8429 v_0 := v.Args[0] 8430 b := v.Block 8431 config := b.Func.Config 8432 typ := &b.Func.Config.Types 8433 // match: (Zero [0] _ mem) 8434 // result: mem 8435 for { 8436 if auxIntToInt64(v.AuxInt) != 0 { 8437 break 8438 } 8439 mem := v_1 8440 v.copyOf(mem) 8441 return true 8442 } 8443 // match: (Zero [1] ptr mem) 8444 // result: (MOVBstore ptr (MOVDconst [0]) mem) 8445 for { 8446 if auxIntToInt64(v.AuxInt) != 1 { 8447 break 8448 } 8449 ptr := v_0 8450 mem := v_1 8451 v.reset(OpRISCV64MOVBstore) 8452 v0 := b.NewValue0(v.Pos, OpRISCV64MOVDconst, typ.UInt64) 8453 v0.AuxInt = int64ToAuxInt(0) 8454 v.AddArg3(ptr, v0, mem) 8455 return true 8456 } 8457 // match: (Zero [2] {t} ptr mem) 8458 // cond: t.Alignment()%2 == 0 8459 // result: (MOVHstore ptr (MOVDconst [0]) mem) 8460 for { 8461 if auxIntToInt64(v.AuxInt) != 2 { 8462 break 8463 } 8464 t := auxToType(v.Aux) 8465 ptr := v_0 8466 mem := v_1 8467 if !(t.Alignment()%2 == 0) { 8468 break 8469 } 8470 v.reset(OpRISCV64MOVHstore) 8471 v0 := b.NewValue0(v.Pos, OpRISCV64MOVDconst, typ.UInt64) 8472 v0.AuxInt = int64ToAuxInt(0) 8473 v.AddArg3(ptr, v0, mem) 8474 return true 8475 } 8476 // match: (Zero [2] ptr mem) 8477 // result: (MOVBstore [1] ptr (MOVDconst [0]) (MOVBstore ptr (MOVDconst [0]) mem)) 8478 for { 8479 if auxIntToInt64(v.AuxInt) != 2 { 8480 break 8481 } 8482 ptr := v_0 8483 mem := v_1 8484 v.reset(OpRISCV64MOVBstore) 8485 v.AuxInt = int32ToAuxInt(1) 8486 v0 := b.NewValue0(v.Pos, OpRISCV64MOVDconst, typ.UInt64) 8487 v0.AuxInt = int64ToAuxInt(0) 8488 v1 := b.NewValue0(v.Pos, OpRISCV64MOVBstore, types.TypeMem) 8489 v1.AddArg3(ptr, v0, mem) 8490 v.AddArg3(ptr, v0, v1) 8491 return true 8492 } 8493 // match: (Zero [4] {t} ptr mem) 8494 // cond: t.Alignment()%4 == 0 8495 // result: (MOVWstore ptr (MOVDconst [0]) mem) 8496 for { 8497 if auxIntToInt64(v.AuxInt) != 4 { 8498 break 8499 } 8500 t := auxToType(v.Aux) 8501 ptr := v_0 8502 mem := v_1 8503 if !(t.Alignment()%4 == 0) { 8504 break 8505 } 8506 v.reset(OpRISCV64MOVWstore) 8507 v0 := b.NewValue0(v.Pos, OpRISCV64MOVDconst, typ.UInt64) 8508 v0.AuxInt = int64ToAuxInt(0) 8509 v.AddArg3(ptr, v0, mem) 8510 return true 8511 } 8512 // match: (Zero [4] {t} ptr mem) 8513 // cond: t.Alignment()%2 == 0 8514 // result: (MOVHstore [2] ptr (MOVDconst [0]) (MOVHstore ptr (MOVDconst [0]) mem)) 8515 for { 8516 if auxIntToInt64(v.AuxInt) != 4 { 8517 break 8518 } 8519 t := auxToType(v.Aux) 8520 ptr := v_0 8521 mem := v_1 8522 if !(t.Alignment()%2 == 0) { 8523 break 8524 } 8525 v.reset(OpRISCV64MOVHstore) 8526 v.AuxInt = int32ToAuxInt(2) 8527 v0 := b.NewValue0(v.Pos, OpRISCV64MOVDconst, typ.UInt64) 8528 v0.AuxInt = int64ToAuxInt(0) 8529 v1 := b.NewValue0(v.Pos, OpRISCV64MOVHstore, types.TypeMem) 8530 v1.AddArg3(ptr, v0, mem) 8531 v.AddArg3(ptr, v0, v1) 8532 return true 8533 } 8534 // match: (Zero [4] ptr mem) 8535 // result: (MOVBstore [3] ptr (MOVDconst [0]) (MOVBstore [2] ptr (MOVDconst [0]) (MOVBstore [1] ptr (MOVDconst [0]) (MOVBstore ptr (MOVDconst [0]) mem)))) 8536 for { 8537 if auxIntToInt64(v.AuxInt) != 4 { 8538 break 8539 } 8540 ptr := v_0 8541 mem := v_1 8542 v.reset(OpRISCV64MOVBstore) 8543 v.AuxInt = int32ToAuxInt(3) 8544 v0 := b.NewValue0(v.Pos, OpRISCV64MOVDconst, typ.UInt64) 8545 v0.AuxInt = int64ToAuxInt(0) 8546 v1 := b.NewValue0(v.Pos, OpRISCV64MOVBstore, types.TypeMem) 8547 v1.AuxInt = int32ToAuxInt(2) 8548 v2 := b.NewValue0(v.Pos, OpRISCV64MOVBstore, types.TypeMem) 8549 v2.AuxInt = int32ToAuxInt(1) 8550 v3 := b.NewValue0(v.Pos, OpRISCV64MOVBstore, types.TypeMem) 8551 v3.AddArg3(ptr, v0, mem) 8552 v2.AddArg3(ptr, v0, v3) 8553 v1.AddArg3(ptr, v0, v2) 8554 v.AddArg3(ptr, v0, v1) 8555 return true 8556 } 8557 // match: (Zero [8] {t} ptr mem) 8558 // cond: t.Alignment()%8 == 0 8559 // result: (MOVDstore ptr (MOVDconst [0]) mem) 8560 for { 8561 if auxIntToInt64(v.AuxInt) != 8 { 8562 break 8563 } 8564 t := auxToType(v.Aux) 8565 ptr := v_0 8566 mem := v_1 8567 if !(t.Alignment()%8 == 0) { 8568 break 8569 } 8570 v.reset(OpRISCV64MOVDstore) 8571 v0 := b.NewValue0(v.Pos, OpRISCV64MOVDconst, typ.UInt64) 8572 v0.AuxInt = int64ToAuxInt(0) 8573 v.AddArg3(ptr, v0, mem) 8574 return true 8575 } 8576 // match: (Zero [8] {t} ptr mem) 8577 // cond: t.Alignment()%4 == 0 8578 // result: (MOVWstore [4] ptr (MOVDconst [0]) (MOVWstore ptr (MOVDconst [0]) mem)) 8579 for { 8580 if auxIntToInt64(v.AuxInt) != 8 { 8581 break 8582 } 8583 t := auxToType(v.Aux) 8584 ptr := v_0 8585 mem := v_1 8586 if !(t.Alignment()%4 == 0) { 8587 break 8588 } 8589 v.reset(OpRISCV64MOVWstore) 8590 v.AuxInt = int32ToAuxInt(4) 8591 v0 := b.NewValue0(v.Pos, OpRISCV64MOVDconst, typ.UInt64) 8592 v0.AuxInt = int64ToAuxInt(0) 8593 v1 := b.NewValue0(v.Pos, OpRISCV64MOVWstore, types.TypeMem) 8594 v1.AddArg3(ptr, v0, mem) 8595 v.AddArg3(ptr, v0, v1) 8596 return true 8597 } 8598 // match: (Zero [8] {t} ptr mem) 8599 // cond: t.Alignment()%2 == 0 8600 // result: (MOVHstore [6] ptr (MOVDconst [0]) (MOVHstore [4] ptr (MOVDconst [0]) (MOVHstore [2] ptr (MOVDconst [0]) (MOVHstore ptr (MOVDconst [0]) mem)))) 8601 for { 8602 if auxIntToInt64(v.AuxInt) != 8 { 8603 break 8604 } 8605 t := auxToType(v.Aux) 8606 ptr := v_0 8607 mem := v_1 8608 if !(t.Alignment()%2 == 0) { 8609 break 8610 } 8611 v.reset(OpRISCV64MOVHstore) 8612 v.AuxInt = int32ToAuxInt(6) 8613 v0 := b.NewValue0(v.Pos, OpRISCV64MOVDconst, typ.UInt64) 8614 v0.AuxInt = int64ToAuxInt(0) 8615 v1 := b.NewValue0(v.Pos, OpRISCV64MOVHstore, types.TypeMem) 8616 v1.AuxInt = int32ToAuxInt(4) 8617 v2 := b.NewValue0(v.Pos, OpRISCV64MOVHstore, types.TypeMem) 8618 v2.AuxInt = int32ToAuxInt(2) 8619 v3 := b.NewValue0(v.Pos, OpRISCV64MOVHstore, types.TypeMem) 8620 v3.AddArg3(ptr, v0, mem) 8621 v2.AddArg3(ptr, v0, v3) 8622 v1.AddArg3(ptr, v0, v2) 8623 v.AddArg3(ptr, v0, v1) 8624 return true 8625 } 8626 // match: (Zero [3] ptr mem) 8627 // result: (MOVBstore [2] ptr (MOVDconst [0]) (MOVBstore [1] ptr (MOVDconst [0]) (MOVBstore ptr (MOVDconst [0]) mem))) 8628 for { 8629 if auxIntToInt64(v.AuxInt) != 3 { 8630 break 8631 } 8632 ptr := v_0 8633 mem := v_1 8634 v.reset(OpRISCV64MOVBstore) 8635 v.AuxInt = int32ToAuxInt(2) 8636 v0 := b.NewValue0(v.Pos, OpRISCV64MOVDconst, typ.UInt64) 8637 v0.AuxInt = int64ToAuxInt(0) 8638 v1 := b.NewValue0(v.Pos, OpRISCV64MOVBstore, types.TypeMem) 8639 v1.AuxInt = int32ToAuxInt(1) 8640 v2 := b.NewValue0(v.Pos, OpRISCV64MOVBstore, types.TypeMem) 8641 v2.AddArg3(ptr, v0, mem) 8642 v1.AddArg3(ptr, v0, v2) 8643 v.AddArg3(ptr, v0, v1) 8644 return true 8645 } 8646 // match: (Zero [6] {t} ptr mem) 8647 // cond: t.Alignment()%2 == 0 8648 // result: (MOVHstore [4] ptr (MOVDconst [0]) (MOVHstore [2] ptr (MOVDconst [0]) (MOVHstore ptr (MOVDconst [0]) mem))) 8649 for { 8650 if auxIntToInt64(v.AuxInt) != 6 { 8651 break 8652 } 8653 t := auxToType(v.Aux) 8654 ptr := v_0 8655 mem := v_1 8656 if !(t.Alignment()%2 == 0) { 8657 break 8658 } 8659 v.reset(OpRISCV64MOVHstore) 8660 v.AuxInt = int32ToAuxInt(4) 8661 v0 := b.NewValue0(v.Pos, OpRISCV64MOVDconst, typ.UInt64) 8662 v0.AuxInt = int64ToAuxInt(0) 8663 v1 := b.NewValue0(v.Pos, OpRISCV64MOVHstore, types.TypeMem) 8664 v1.AuxInt = int32ToAuxInt(2) 8665 v2 := b.NewValue0(v.Pos, OpRISCV64MOVHstore, types.TypeMem) 8666 v2.AddArg3(ptr, v0, mem) 8667 v1.AddArg3(ptr, v0, v2) 8668 v.AddArg3(ptr, v0, v1) 8669 return true 8670 } 8671 // match: (Zero [12] {t} ptr mem) 8672 // cond: t.Alignment()%4 == 0 8673 // result: (MOVWstore [8] ptr (MOVDconst [0]) (MOVWstore [4] ptr (MOVDconst [0]) (MOVWstore ptr (MOVDconst [0]) mem))) 8674 for { 8675 if auxIntToInt64(v.AuxInt) != 12 { 8676 break 8677 } 8678 t := auxToType(v.Aux) 8679 ptr := v_0 8680 mem := v_1 8681 if !(t.Alignment()%4 == 0) { 8682 break 8683 } 8684 v.reset(OpRISCV64MOVWstore) 8685 v.AuxInt = int32ToAuxInt(8) 8686 v0 := b.NewValue0(v.Pos, OpRISCV64MOVDconst, typ.UInt64) 8687 v0.AuxInt = int64ToAuxInt(0) 8688 v1 := b.NewValue0(v.Pos, OpRISCV64MOVWstore, types.TypeMem) 8689 v1.AuxInt = int32ToAuxInt(4) 8690 v2 := b.NewValue0(v.Pos, OpRISCV64MOVWstore, types.TypeMem) 8691 v2.AddArg3(ptr, v0, mem) 8692 v1.AddArg3(ptr, v0, v2) 8693 v.AddArg3(ptr, v0, v1) 8694 return true 8695 } 8696 // match: (Zero [16] {t} ptr mem) 8697 // cond: t.Alignment()%8 == 0 8698 // result: (MOVDstore [8] ptr (MOVDconst [0]) (MOVDstore ptr (MOVDconst [0]) mem)) 8699 for { 8700 if auxIntToInt64(v.AuxInt) != 16 { 8701 break 8702 } 8703 t := auxToType(v.Aux) 8704 ptr := v_0 8705 mem := v_1 8706 if !(t.Alignment()%8 == 0) { 8707 break 8708 } 8709 v.reset(OpRISCV64MOVDstore) 8710 v.AuxInt = int32ToAuxInt(8) 8711 v0 := b.NewValue0(v.Pos, OpRISCV64MOVDconst, typ.UInt64) 8712 v0.AuxInt = int64ToAuxInt(0) 8713 v1 := b.NewValue0(v.Pos, OpRISCV64MOVDstore, types.TypeMem) 8714 v1.AddArg3(ptr, v0, mem) 8715 v.AddArg3(ptr, v0, v1) 8716 return true 8717 } 8718 // match: (Zero [24] {t} ptr mem) 8719 // cond: t.Alignment()%8 == 0 8720 // result: (MOVDstore [16] ptr (MOVDconst [0]) (MOVDstore [8] ptr (MOVDconst [0]) (MOVDstore ptr (MOVDconst [0]) mem))) 8721 for { 8722 if auxIntToInt64(v.AuxInt) != 24 { 8723 break 8724 } 8725 t := auxToType(v.Aux) 8726 ptr := v_0 8727 mem := v_1 8728 if !(t.Alignment()%8 == 0) { 8729 break 8730 } 8731 v.reset(OpRISCV64MOVDstore) 8732 v.AuxInt = int32ToAuxInt(16) 8733 v0 := b.NewValue0(v.Pos, OpRISCV64MOVDconst, typ.UInt64) 8734 v0.AuxInt = int64ToAuxInt(0) 8735 v1 := b.NewValue0(v.Pos, OpRISCV64MOVDstore, types.TypeMem) 8736 v1.AuxInt = int32ToAuxInt(8) 8737 v2 := b.NewValue0(v.Pos, OpRISCV64MOVDstore, types.TypeMem) 8738 v2.AddArg3(ptr, v0, mem) 8739 v1.AddArg3(ptr, v0, v2) 8740 v.AddArg3(ptr, v0, v1) 8741 return true 8742 } 8743 // match: (Zero [32] {t} ptr mem) 8744 // cond: t.Alignment()%8 == 0 8745 // result: (MOVDstore [24] ptr (MOVDconst [0]) (MOVDstore [16] ptr (MOVDconst [0]) (MOVDstore [8] ptr (MOVDconst [0]) (MOVDstore ptr (MOVDconst [0]) mem)))) 8746 for { 8747 if auxIntToInt64(v.AuxInt) != 32 { 8748 break 8749 } 8750 t := auxToType(v.Aux) 8751 ptr := v_0 8752 mem := v_1 8753 if !(t.Alignment()%8 == 0) { 8754 break 8755 } 8756 v.reset(OpRISCV64MOVDstore) 8757 v.AuxInt = int32ToAuxInt(24) 8758 v0 := b.NewValue0(v.Pos, OpRISCV64MOVDconst, typ.UInt64) 8759 v0.AuxInt = int64ToAuxInt(0) 8760 v1 := b.NewValue0(v.Pos, OpRISCV64MOVDstore, types.TypeMem) 8761 v1.AuxInt = int32ToAuxInt(16) 8762 v2 := b.NewValue0(v.Pos, OpRISCV64MOVDstore, types.TypeMem) 8763 v2.AuxInt = int32ToAuxInt(8) 8764 v3 := b.NewValue0(v.Pos, OpRISCV64MOVDstore, types.TypeMem) 8765 v3.AddArg3(ptr, v0, mem) 8766 v2.AddArg3(ptr, v0, v3) 8767 v1.AddArg3(ptr, v0, v2) 8768 v.AddArg3(ptr, v0, v1) 8769 return true 8770 } 8771 // match: (Zero [s] {t} ptr mem) 8772 // cond: s%8 == 0 && s <= 8*128 && t.Alignment()%8 == 0 && !config.noDuffDevice 8773 // result: (DUFFZERO [8 * (128 - s/8)] ptr mem) 8774 for { 8775 s := auxIntToInt64(v.AuxInt) 8776 t := auxToType(v.Aux) 8777 ptr := v_0 8778 mem := v_1 8779 if !(s%8 == 0 && s <= 8*128 && t.Alignment()%8 == 0 && !config.noDuffDevice) { 8780 break 8781 } 8782 v.reset(OpRISCV64DUFFZERO) 8783 v.AuxInt = int64ToAuxInt(8 * (128 - s/8)) 8784 v.AddArg2(ptr, mem) 8785 return true 8786 } 8787 // match: (Zero [s] {t} ptr mem) 8788 // result: (LoweredZero [t.Alignment()] ptr (ADD <ptr.Type> ptr (MOVDconst [s-moveSize(t.Alignment(), config)])) mem) 8789 for { 8790 s := auxIntToInt64(v.AuxInt) 8791 t := auxToType(v.Aux) 8792 ptr := v_0 8793 mem := v_1 8794 v.reset(OpRISCV64LoweredZero) 8795 v.AuxInt = int64ToAuxInt(t.Alignment()) 8796 v0 := b.NewValue0(v.Pos, OpRISCV64ADD, ptr.Type) 8797 v1 := b.NewValue0(v.Pos, OpRISCV64MOVDconst, typ.UInt64) 8798 v1.AuxInt = int64ToAuxInt(s - moveSize(t.Alignment(), config)) 8799 v0.AddArg2(ptr, v1) 8800 v.AddArg3(ptr, v0, mem) 8801 return true 8802 } 8803 } 8804 func rewriteBlockRISCV64(b *Block) bool { 8805 typ := &b.Func.Config.Types 8806 switch b.Kind { 8807 case BlockRISCV64BEQ: 8808 // match: (BEQ (MOVDconst [0]) cond yes no) 8809 // result: (BEQZ cond yes no) 8810 for b.Controls[0].Op == OpRISCV64MOVDconst { 8811 v_0 := b.Controls[0] 8812 if auxIntToInt64(v_0.AuxInt) != 0 { 8813 break 8814 } 8815 cond := b.Controls[1] 8816 b.resetWithControl(BlockRISCV64BEQZ, cond) 8817 return true 8818 } 8819 // match: (BEQ cond (MOVDconst [0]) yes no) 8820 // result: (BEQZ cond yes no) 8821 for b.Controls[1].Op == OpRISCV64MOVDconst { 8822 cond := b.Controls[0] 8823 v_1 := b.Controls[1] 8824 if auxIntToInt64(v_1.AuxInt) != 0 { 8825 break 8826 } 8827 b.resetWithControl(BlockRISCV64BEQZ, cond) 8828 return true 8829 } 8830 case BlockRISCV64BEQZ: 8831 // match: (BEQZ (SEQZ x) yes no) 8832 // result: (BNEZ x yes no) 8833 for b.Controls[0].Op == OpRISCV64SEQZ { 8834 v_0 := b.Controls[0] 8835 x := v_0.Args[0] 8836 b.resetWithControl(BlockRISCV64BNEZ, x) 8837 return true 8838 } 8839 // match: (BEQZ (SNEZ x) yes no) 8840 // result: (BEQZ x yes no) 8841 for b.Controls[0].Op == OpRISCV64SNEZ { 8842 v_0 := b.Controls[0] 8843 x := v_0.Args[0] 8844 b.resetWithControl(BlockRISCV64BEQZ, x) 8845 return true 8846 } 8847 // match: (BEQZ (NEG x) yes no) 8848 // result: (BEQZ x yes no) 8849 for b.Controls[0].Op == OpRISCV64NEG { 8850 v_0 := b.Controls[0] 8851 x := v_0.Args[0] 8852 b.resetWithControl(BlockRISCV64BEQZ, x) 8853 return true 8854 } 8855 // match: (BEQZ (FNES <t> x y) yes no) 8856 // result: (BNEZ (FEQS <t> x y) yes no) 8857 for b.Controls[0].Op == OpRISCV64FNES { 8858 v_0 := b.Controls[0] 8859 t := v_0.Type 8860 _ = v_0.Args[1] 8861 v_0_0 := v_0.Args[0] 8862 v_0_1 := v_0.Args[1] 8863 for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { 8864 x := v_0_0 8865 y := v_0_1 8866 v0 := b.NewValue0(v_0.Pos, OpRISCV64FEQS, t) 8867 v0.AddArg2(x, y) 8868 b.resetWithControl(BlockRISCV64BNEZ, v0) 8869 return true 8870 } 8871 } 8872 // match: (BEQZ (FNED <t> x y) yes no) 8873 // result: (BNEZ (FEQD <t> x y) yes no) 8874 for b.Controls[0].Op == OpRISCV64FNED { 8875 v_0 := b.Controls[0] 8876 t := v_0.Type 8877 _ = v_0.Args[1] 8878 v_0_0 := v_0.Args[0] 8879 v_0_1 := v_0.Args[1] 8880 for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { 8881 x := v_0_0 8882 y := v_0_1 8883 v0 := b.NewValue0(v_0.Pos, OpRISCV64FEQD, t) 8884 v0.AddArg2(x, y) 8885 b.resetWithControl(BlockRISCV64BNEZ, v0) 8886 return true 8887 } 8888 } 8889 // match: (BEQZ (SUB x y) yes no) 8890 // result: (BEQ x y yes no) 8891 for b.Controls[0].Op == OpRISCV64SUB { 8892 v_0 := b.Controls[0] 8893 y := v_0.Args[1] 8894 x := v_0.Args[0] 8895 b.resetWithControl2(BlockRISCV64BEQ, x, y) 8896 return true 8897 } 8898 // match: (BEQZ (SLT x y) yes no) 8899 // result: (BGE x y yes no) 8900 for b.Controls[0].Op == OpRISCV64SLT { 8901 v_0 := b.Controls[0] 8902 y := v_0.Args[1] 8903 x := v_0.Args[0] 8904 b.resetWithControl2(BlockRISCV64BGE, x, y) 8905 return true 8906 } 8907 // match: (BEQZ (SLTU x y) yes no) 8908 // result: (BGEU x y yes no) 8909 for b.Controls[0].Op == OpRISCV64SLTU { 8910 v_0 := b.Controls[0] 8911 y := v_0.Args[1] 8912 x := v_0.Args[0] 8913 b.resetWithControl2(BlockRISCV64BGEU, x, y) 8914 return true 8915 } 8916 // match: (BEQZ (SLTI [x] y) yes no) 8917 // result: (BGE y (MOVDconst [x]) yes no) 8918 for b.Controls[0].Op == OpRISCV64SLTI { 8919 v_0 := b.Controls[0] 8920 x := auxIntToInt64(v_0.AuxInt) 8921 y := v_0.Args[0] 8922 v0 := b.NewValue0(b.Pos, OpRISCV64MOVDconst, typ.UInt64) 8923 v0.AuxInt = int64ToAuxInt(x) 8924 b.resetWithControl2(BlockRISCV64BGE, y, v0) 8925 return true 8926 } 8927 // match: (BEQZ (SLTIU [x] y) yes no) 8928 // result: (BGEU y (MOVDconst [x]) yes no) 8929 for b.Controls[0].Op == OpRISCV64SLTIU { 8930 v_0 := b.Controls[0] 8931 x := auxIntToInt64(v_0.AuxInt) 8932 y := v_0.Args[0] 8933 v0 := b.NewValue0(b.Pos, OpRISCV64MOVDconst, typ.UInt64) 8934 v0.AuxInt = int64ToAuxInt(x) 8935 b.resetWithControl2(BlockRISCV64BGEU, y, v0) 8936 return true 8937 } 8938 case BlockRISCV64BGE: 8939 // match: (BGE (MOVDconst [0]) cond yes no) 8940 // result: (BLEZ cond yes no) 8941 for b.Controls[0].Op == OpRISCV64MOVDconst { 8942 v_0 := b.Controls[0] 8943 if auxIntToInt64(v_0.AuxInt) != 0 { 8944 break 8945 } 8946 cond := b.Controls[1] 8947 b.resetWithControl(BlockRISCV64BLEZ, cond) 8948 return true 8949 } 8950 // match: (BGE cond (MOVDconst [0]) yes no) 8951 // result: (BGEZ cond yes no) 8952 for b.Controls[1].Op == OpRISCV64MOVDconst { 8953 cond := b.Controls[0] 8954 v_1 := b.Controls[1] 8955 if auxIntToInt64(v_1.AuxInt) != 0 { 8956 break 8957 } 8958 b.resetWithControl(BlockRISCV64BGEZ, cond) 8959 return true 8960 } 8961 case BlockRISCV64BLT: 8962 // match: (BLT (MOVDconst [0]) cond yes no) 8963 // result: (BGTZ cond yes no) 8964 for b.Controls[0].Op == OpRISCV64MOVDconst { 8965 v_0 := b.Controls[0] 8966 if auxIntToInt64(v_0.AuxInt) != 0 { 8967 break 8968 } 8969 cond := b.Controls[1] 8970 b.resetWithControl(BlockRISCV64BGTZ, cond) 8971 return true 8972 } 8973 // match: (BLT cond (MOVDconst [0]) yes no) 8974 // result: (BLTZ cond yes no) 8975 for b.Controls[1].Op == OpRISCV64MOVDconst { 8976 cond := b.Controls[0] 8977 v_1 := b.Controls[1] 8978 if auxIntToInt64(v_1.AuxInt) != 0 { 8979 break 8980 } 8981 b.resetWithControl(BlockRISCV64BLTZ, cond) 8982 return true 8983 } 8984 case BlockRISCV64BNE: 8985 // match: (BNE (MOVDconst [0]) cond yes no) 8986 // result: (BNEZ cond yes no) 8987 for b.Controls[0].Op == OpRISCV64MOVDconst { 8988 v_0 := b.Controls[0] 8989 if auxIntToInt64(v_0.AuxInt) != 0 { 8990 break 8991 } 8992 cond := b.Controls[1] 8993 b.resetWithControl(BlockRISCV64BNEZ, cond) 8994 return true 8995 } 8996 // match: (BNE cond (MOVDconst [0]) yes no) 8997 // result: (BNEZ cond yes no) 8998 for b.Controls[1].Op == OpRISCV64MOVDconst { 8999 cond := b.Controls[0] 9000 v_1 := b.Controls[1] 9001 if auxIntToInt64(v_1.AuxInt) != 0 { 9002 break 9003 } 9004 b.resetWithControl(BlockRISCV64BNEZ, cond) 9005 return true 9006 } 9007 case BlockRISCV64BNEZ: 9008 // match: (BNEZ (SEQZ x) yes no) 9009 // result: (BEQZ x yes no) 9010 for b.Controls[0].Op == OpRISCV64SEQZ { 9011 v_0 := b.Controls[0] 9012 x := v_0.Args[0] 9013 b.resetWithControl(BlockRISCV64BEQZ, x) 9014 return true 9015 } 9016 // match: (BNEZ (SNEZ x) yes no) 9017 // result: (BNEZ x yes no) 9018 for b.Controls[0].Op == OpRISCV64SNEZ { 9019 v_0 := b.Controls[0] 9020 x := v_0.Args[0] 9021 b.resetWithControl(BlockRISCV64BNEZ, x) 9022 return true 9023 } 9024 // match: (BNEZ (NEG x) yes no) 9025 // result: (BNEZ x yes no) 9026 for b.Controls[0].Op == OpRISCV64NEG { 9027 v_0 := b.Controls[0] 9028 x := v_0.Args[0] 9029 b.resetWithControl(BlockRISCV64BNEZ, x) 9030 return true 9031 } 9032 // match: (BNEZ (FNES <t> x y) yes no) 9033 // result: (BEQZ (FEQS <t> x y) yes no) 9034 for b.Controls[0].Op == OpRISCV64FNES { 9035 v_0 := b.Controls[0] 9036 t := v_0.Type 9037 _ = v_0.Args[1] 9038 v_0_0 := v_0.Args[0] 9039 v_0_1 := v_0.Args[1] 9040 for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { 9041 x := v_0_0 9042 y := v_0_1 9043 v0 := b.NewValue0(v_0.Pos, OpRISCV64FEQS, t) 9044 v0.AddArg2(x, y) 9045 b.resetWithControl(BlockRISCV64BEQZ, v0) 9046 return true 9047 } 9048 } 9049 // match: (BNEZ (FNED <t> x y) yes no) 9050 // result: (BEQZ (FEQD <t> x y) yes no) 9051 for b.Controls[0].Op == OpRISCV64FNED { 9052 v_0 := b.Controls[0] 9053 t := v_0.Type 9054 _ = v_0.Args[1] 9055 v_0_0 := v_0.Args[0] 9056 v_0_1 := v_0.Args[1] 9057 for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { 9058 x := v_0_0 9059 y := v_0_1 9060 v0 := b.NewValue0(v_0.Pos, OpRISCV64FEQD, t) 9061 v0.AddArg2(x, y) 9062 b.resetWithControl(BlockRISCV64BEQZ, v0) 9063 return true 9064 } 9065 } 9066 // match: (BNEZ (SUB x y) yes no) 9067 // result: (BNE x y yes no) 9068 for b.Controls[0].Op == OpRISCV64SUB { 9069 v_0 := b.Controls[0] 9070 y := v_0.Args[1] 9071 x := v_0.Args[0] 9072 b.resetWithControl2(BlockRISCV64BNE, x, y) 9073 return true 9074 } 9075 // match: (BNEZ (SLT x y) yes no) 9076 // result: (BLT x y yes no) 9077 for b.Controls[0].Op == OpRISCV64SLT { 9078 v_0 := b.Controls[0] 9079 y := v_0.Args[1] 9080 x := v_0.Args[0] 9081 b.resetWithControl2(BlockRISCV64BLT, x, y) 9082 return true 9083 } 9084 // match: (BNEZ (SLTU x y) yes no) 9085 // result: (BLTU x y yes no) 9086 for b.Controls[0].Op == OpRISCV64SLTU { 9087 v_0 := b.Controls[0] 9088 y := v_0.Args[1] 9089 x := v_0.Args[0] 9090 b.resetWithControl2(BlockRISCV64BLTU, x, y) 9091 return true 9092 } 9093 // match: (BNEZ (SLTI [x] y) yes no) 9094 // result: (BLT y (MOVDconst [x]) yes no) 9095 for b.Controls[0].Op == OpRISCV64SLTI { 9096 v_0 := b.Controls[0] 9097 x := auxIntToInt64(v_0.AuxInt) 9098 y := v_0.Args[0] 9099 v0 := b.NewValue0(b.Pos, OpRISCV64MOVDconst, typ.UInt64) 9100 v0.AuxInt = int64ToAuxInt(x) 9101 b.resetWithControl2(BlockRISCV64BLT, y, v0) 9102 return true 9103 } 9104 // match: (BNEZ (SLTIU [x] y) yes no) 9105 // result: (BLTU y (MOVDconst [x]) yes no) 9106 for b.Controls[0].Op == OpRISCV64SLTIU { 9107 v_0 := b.Controls[0] 9108 x := auxIntToInt64(v_0.AuxInt) 9109 y := v_0.Args[0] 9110 v0 := b.NewValue0(b.Pos, OpRISCV64MOVDconst, typ.UInt64) 9111 v0.AuxInt = int64ToAuxInt(x) 9112 b.resetWithControl2(BlockRISCV64BLTU, y, v0) 9113 return true 9114 } 9115 case BlockIf: 9116 // match: (If cond yes no) 9117 // result: (BNEZ (MOVBUreg <typ.UInt64> cond) yes no) 9118 for { 9119 cond := b.Controls[0] 9120 v0 := b.NewValue0(cond.Pos, OpRISCV64MOVBUreg, typ.UInt64) 9121 v0.AddArg(cond) 9122 b.resetWithControl(BlockRISCV64BNEZ, v0) 9123 return true 9124 } 9125 } 9126 return false 9127 }