PPCInstrQPX.td 57.6 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213
//===- PPCInstrQPX.td - The PowerPC QPX Extension --*- tablegen -*-===//
// 
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
// 
//===----------------------------------------------------------------------===//
//
// This file describes the QPX extension to the PowerPC instruction set.
// Reference:
// Book Q: QPX Architecture Definition. IBM (as updated in) 2011.
//
//===----------------------------------------------------------------------===//

def PPCRegQFRCAsmOperand : AsmOperandClass {
  let Name = "RegQFRC"; let PredicateMethod = "isRegNumber";
}
def qfrc : RegisterOperand<QFRC> {
  let ParserMatchClass = PPCRegQFRCAsmOperand;
}
def PPCRegQSRCAsmOperand : AsmOperandClass {
  let Name = "RegQSRC"; let PredicateMethod = "isRegNumber";
}
def qsrc : RegisterOperand<QSRC> {
  let ParserMatchClass = PPCRegQSRCAsmOperand;
}
def PPCRegQBRCAsmOperand : AsmOperandClass {
  let Name = "RegQBRC"; let PredicateMethod = "isRegNumber";
}
def qbrc : RegisterOperand<QBRC> {
  let ParserMatchClass = PPCRegQBRCAsmOperand;
}

//===----------------------------------------------------------------------===//
// Helpers for defining instructions that directly correspond to intrinsics.

// QPXA1_Int - A AForm_1 intrinsic definition.
class QPXA1_Int<bits<6> opcode, bits<5> xo, string opc, Intrinsic IntID>
  : AForm_1<opcode, xo, (outs qfrc:$FRT), (ins qfrc:$FRA, qfrc:$FRB, qfrc:$FRC),
              !strconcat(opc, " $FRT, $FRA, $FRC, $FRB"), IIC_FPFused,
                       [(set v4f64:$FRT, (IntID v4f64:$FRA, v4f64:$FRB, v4f64:$FRC))]>;
// QPXA1s_Int - A AForm_1 intrinsic definition (simple instructions).
class QPXA1s_Int<bits<6> opcode, bits<5> xo, string opc, Intrinsic IntID>
  : AForm_1<opcode, xo, (outs qfrc:$FRT), (ins qfrc:$FRA, qfrc:$FRB, qfrc:$FRC),
              !strconcat(opc, " $FRT, $FRA, $FRC, $FRB"), IIC_VecPerm,
                       [(set v4f64:$FRT, (IntID v4f64:$FRA, v4f64:$FRB, v4f64:$FRC))]>;
// QPXA2_Int - A AForm_2 intrinsic definition.
class QPXA2_Int<bits<6> opcode, bits<5> xo, string opc, Intrinsic IntID>
  : AForm_2<opcode, xo, (outs qfrc:$FRT), (ins qfrc:$FRA, qfrc:$FRB),
              !strconcat(opc, " $FRT, $FRA, $FRB"), IIC_FPGeneral,
                       [(set v4f64:$FRT, (IntID v4f64:$FRA, v4f64:$FRB))]>;
// QPXA3_Int - A AForm_3 intrinsic definition.
class QPXA3_Int<bits<6> opcode, bits<5> xo, string opc, Intrinsic IntID>
  : AForm_3<opcode, xo, (outs qfrc:$FRT), (ins qfrc:$FRA, qfrc:$FRC),
              !strconcat(opc, " $FRT, $FRA, $FRC"), IIC_FPGeneral,
                       [(set v4f64:$FRT, (IntID v4f64:$FRA, v4f64:$FRC))]>;
// QPXA4_Int - A AForm_4a intrinsic definition.
class QPXA4_Int<bits<6> opcode, bits<5> xo, string opc, Intrinsic IntID>
  : AForm_4a<opcode, xo, (outs qfrc:$FRT), (ins qfrc:$FRB),
              !strconcat(opc, " $FRT, $FRB"), IIC_FPGeneral,
                       [(set v4f64:$FRT, (IntID v4f64:$FRB))]>;
// QPXX18_Int - A XForm_18 intrinsic definition.
class QPXX18_Int<bits<6> opcode, bits<10> xo, string opc, Intrinsic IntID>
  : XForm_18<opcode, xo, (outs qfrc:$FRT), (ins qfrc:$FRA, qfrc:$FRB),
              !strconcat(opc, " $FRT, $FRA, $FRB"), IIC_FPCompare,
                       [(set v4f64:$FRT, (IntID v4f64:$FRA, v4f64:$FRB))]>;
// QPXX19_Int - A XForm_19 intrinsic definition.
class QPXX19_Int<bits<6> opcode, bits<10> xo, string opc, Intrinsic IntID>
  : XForm_19<opcode, xo, (outs qfrc:$FRT), (ins qfrc:$FRB),
              !strconcat(opc, " $FRT, $FRB"), IIC_FPGeneral,
                       [(set v4f64:$FRT, (IntID v4f64:$FRB))]>;

//===----------------------------------------------------------------------===//
// Pattern Frags.

def extloadv4f32 : PatFrag<(ops node:$ptr), (extload node:$ptr), [{
  return cast<LoadSDNode>(N)->getMemoryVT() == MVT::v4f32;
}]>;

def truncstorev4f32 : PatFrag<(ops node:$val, node:$ptr),
                            (truncstore node:$val, node:$ptr), [{
  return cast<StoreSDNode>(N)->getMemoryVT() == MVT::v4f32;
}]>;
def pre_truncstv4f32 : PatFrag<(ops node:$val, node:$base, node:$offset),
                               (pre_truncst node:$val,
                                            node:$base, node:$offset), [{
  return cast<StoreSDNode>(N)->getMemoryVT() == MVT::v4f32;
}]>;

def fround_inexact : PatFrag<(ops node:$val), (fpround node:$val), [{
  return cast<ConstantSDNode>(N->getOperand(1))->getZExtValue() == 0;
}]>;

def fround_exact : PatFrag<(ops node:$val), (fpround node:$val), [{
  return cast<ConstantSDNode>(N->getOperand(1))->getZExtValue() == 1;
}]>;

let FastIselShouldIgnore = 1 in // FastIsel should ignore all u12 instrs.
  def u12 : ImmLeaf<i32, [{ return (Imm & 0xFFF) == Imm; }]>;

//===----------------------------------------------------------------------===//
// Instruction Definitions.

def HasQPX : Predicate<"PPCSubTarget->hasQPX()">;
let Predicates = [HasQPX] in {
let DecoderNamespace = "QPX" in {
let hasSideEffects = 0 in { // QPX instructions don't have side effects.
let Uses = [RM] in {
  // Add Instructions
  let isCommutable = 1 in {
    def QVFADD : AForm_2<4, 21,
                        (outs qfrc:$FRT), (ins qfrc:$FRA, qfrc:$FRB),
                        "qvfadd $FRT, $FRA, $FRB", IIC_FPGeneral,
                        [(set v4f64:$FRT, (fadd v4f64:$FRA, v4f64:$FRB))]>;
    let isCodeGenOnly = 1 in
      def QVFADDS : QPXA2_Int<0, 21, "qvfadds", int_ppc_qpx_qvfadds>;
    def QVFADDSs : AForm_2<0, 21,
                          (outs qsrc:$FRT), (ins qsrc:$FRA, qsrc:$FRB),
                          "qvfadds $FRT, $FRA, $FRB", IIC_FPGeneral,
                          [(set v4f32:$FRT, (fadd v4f32:$FRA, v4f32:$FRB))]>;
  }
  def QVFSUB : AForm_2<4, 20,
                      (outs qfrc:$FRT), (ins qfrc:$FRA, qfrc:$FRB),
                      "qvfsub $FRT, $FRA, $FRB", IIC_FPGeneral,
                      [(set v4f64:$FRT, (fsub v4f64:$FRA, v4f64:$FRB))]>;
  let isCodeGenOnly = 1 in
    def QVFSUBS : QPXA2_Int<0, 20, "qvfsubs", int_ppc_qpx_qvfsubs>;
  def QVFSUBSs : AForm_2<0, 20,
                        (outs qsrc:$FRT), (ins qsrc:$FRA, qsrc:$FRB),
                        "qvfsubs $FRT, $FRA, $FRB", IIC_FPGeneral,
                        [(set v4f32:$FRT, (fsub v4f32:$FRA, v4f32:$FRB))]>;

  // Estimate Instructions
  def QVFRE : AForm_4a<4, 24, (outs qfrc:$FRT), (ins qfrc:$FRB),
                       "qvfre $FRT, $FRB", IIC_FPGeneral,
                       [(set v4f64:$FRT, (PPCfre v4f64:$FRB))]>;
  def QVFRES : QPXA4_Int<0, 24, "qvfres", int_ppc_qpx_qvfres>;
  let isCodeGenOnly = 1 in
  def QVFRESs : AForm_4a<0, 24, (outs qsrc:$FRT), (ins qsrc:$FRB),
                         "qvfres $FRT, $FRB", IIC_FPGeneral,
                         [(set v4f32:$FRT, (PPCfre v4f32:$FRB))]>;

  def QVFRSQRTE : AForm_4a<4, 26, (outs qfrc:$FRT), (ins qfrc:$FRB),
                           "qvfrsqrte $FRT, $FRB", IIC_FPGeneral,
                           [(set v4f64:$FRT, (PPCfrsqrte v4f64:$FRB))]>;
  def QVFRSQRTES : QPXA4_Int<0, 26, "qvfrsqrtes", int_ppc_qpx_qvfrsqrtes>;
  let isCodeGenOnly = 1 in
  def QVFRSQRTESs : AForm_4a<0, 26, (outs qsrc:$FRT), (ins qsrc:$FRB),
                             "qvfrsqrtes $FRT, $FRB", IIC_FPGeneral,
                             [(set v4f32:$FRT, (PPCfrsqrte v4f32:$FRB))]>;

  // Multiply Instructions
  let isCommutable = 1 in {
    def QVFMUL : AForm_3<4, 25,
                        (outs qfrc:$FRT), (ins qfrc:$FRA, qfrc:$FRC),
                        "qvfmul $FRT, $FRA, $FRC", IIC_FPGeneral,
                        [(set v4f64:$FRT, (fmul v4f64:$FRA, v4f64:$FRC))]>;
    let isCodeGenOnly = 1 in
      def QVFMULS : QPXA3_Int<0, 25, "qvfmuls", int_ppc_qpx_qvfmuls>;
    def QVFMULSs : AForm_3<0, 25,
                          (outs qsrc:$FRT), (ins qsrc:$FRA, qsrc:$FRC),
                          "qvfmuls $FRT, $FRA, $FRC", IIC_FPGeneral,
                          [(set v4f32:$FRT, (fmul v4f32:$FRA, v4f32:$FRC))]>;
  }
  def QVFXMUL : QPXA3_Int<4, 17, "qvfxmul", int_ppc_qpx_qvfxmul>;
  def QVFXMULS : QPXA3_Int<0, 17, "qvfxmuls", int_ppc_qpx_qvfxmuls>;

  // Multiply-add instructions
  def QVFMADD : AForm_1<4, 29,
                      (outs qfrc:$FRT), (ins qfrc:$FRA, qfrc:$FRB, qfrc:$FRC),
                      "qvfmadd $FRT, $FRA, $FRC, $FRB", IIC_FPFused,
                      [(set v4f64:$FRT, (fma v4f64:$FRA, v4f64:$FRC, v4f64:$FRB))]>;
  let isCodeGenOnly = 1 in
    def QVFMADDS : QPXA1_Int<0, 29, "qvfmadds", int_ppc_qpx_qvfmadds>;
  def QVFMADDSs : AForm_1<0, 29,
                        (outs qsrc:$FRT), (ins qsrc:$FRA, qsrc:$FRB, qsrc:$FRC),
                        "qvfmadds $FRT, $FRA, $FRC, $FRB", IIC_FPFused,
                        [(set v4f32:$FRT, (fma v4f32:$FRA, v4f32:$FRC, v4f32:$FRB))]>;
  def QVFNMADD : AForm_1<4, 31,
                      (outs qfrc:$FRT), (ins qfrc:$FRA, qfrc:$FRB, qfrc:$FRC),
                      "qvfnmadd $FRT, $FRA, $FRC, $FRB", IIC_FPFused,
                      [(set v4f64:$FRT, (fneg (fma v4f64:$FRA, v4f64:$FRC,
                                                   v4f64:$FRB)))]>;
  let isCodeGenOnly = 1 in
    def QVFNMADDS : QPXA1_Int<0, 31, "qvfnmadds", int_ppc_qpx_qvfnmadds>;
  def QVFNMADDSs : AForm_1<0, 31,
                        (outs qsrc:$FRT), (ins qsrc:$FRA, qsrc:$FRB, qsrc:$FRC),
                        "qvfnmadds $FRT, $FRA, $FRC, $FRB", IIC_FPFused,
                        [(set v4f32:$FRT, (fneg (fma v4f32:$FRA, v4f32:$FRC,
                                                     v4f32:$FRB)))]>;
  def QVFMSUB : AForm_1<4, 28,
                      (outs qfrc:$FRT), (ins qfrc:$FRA, qfrc:$FRB, qfrc:$FRC),
                      "qvfmsub $FRT, $FRA, $FRC, $FRB", IIC_FPFused,
                      [(set v4f64:$FRT, (fma v4f64:$FRA, v4f64:$FRC,
                                             (fneg v4f64:$FRB)))]>;
  let isCodeGenOnly = 1 in
    def QVFMSUBS : QPXA1_Int<0, 28, "qvfmsubs", int_ppc_qpx_qvfmsubs>;
  def QVFMSUBSs : AForm_1<0, 28,
                      (outs qsrc:$FRT), (ins qsrc:$FRA, qsrc:$FRB, qsrc:$FRC),
                      "qvfmsubs $FRT, $FRA, $FRC, $FRB", IIC_FPFused,
                      [(set v4f32:$FRT, (fma v4f32:$FRA, v4f32:$FRC,
                                             (fneg v4f32:$FRB)))]>;
  def QVFNMSUB : AForm_1<4, 30,
                      (outs qfrc:$FRT), (ins qfrc:$FRA, qfrc:$FRB, qfrc:$FRC),
                      "qvfnmsub $FRT, $FRA, $FRC, $FRB", IIC_FPFused,
                      [(set v4f64:$FRT, (fneg (fma v4f64:$FRA, v4f64:$FRC,
                                              (fneg v4f64:$FRB))))]>;
  let isCodeGenOnly = 1 in
    def QVFNMSUBS : QPXA1_Int<0, 30, "qvfnmsubs", int_ppc_qpx_qvfnmsubs>;
  def QVFNMSUBSs : AForm_1<0, 30,
                      (outs qsrc:$FRT), (ins qsrc:$FRA, qsrc:$FRB, qsrc:$FRC),
                      "qvfnmsubs $FRT, $FRA, $FRC, $FRB", IIC_FPFused,
                      [(set v4f32:$FRT, (fneg (fma v4f32:$FRA, v4f32:$FRC,
                                              (fneg v4f32:$FRB))))]>;
  def QVFXMADD : QPXA1_Int<4, 9, "qvfxmadd", int_ppc_qpx_qvfxmadd>;
  def QVFXMADDS : QPXA1_Int<0, 9, "qvfxmadds", int_ppc_qpx_qvfxmadds>;
  def QVFXXNPMADD : QPXA1_Int<4, 11, "qvfxxnpmadd", int_ppc_qpx_qvfxxnpmadd>;
  def QVFXXNPMADDS : QPXA1_Int<0, 11, "qvfxxnpmadds", int_ppc_qpx_qvfxxnpmadds>;
  def QVFXXCPNMADD : QPXA1_Int<4, 3, "qvfxxcpnmadd", int_ppc_qpx_qvfxxcpnmadd>;
  def QVFXXCPNMADDS : QPXA1_Int<0, 3, "qvfxxcpnmadds", int_ppc_qpx_qvfxxcpnmadds>;
  def QVFXXMADD : QPXA1_Int<4, 1, "qvfxxmadd", int_ppc_qpx_qvfxxmadd>;
  def QVFXXMADDS : QPXA1_Int<0, 1, "qvfxxmadds", int_ppc_qpx_qvfxxmadds>;

  // Select Instruction
  let isCodeGenOnly = 1 in
    def QVFSEL : QPXA1s_Int<4, 23, "qvfsel", int_ppc_qpx_qvfsel>;
  def QVFSELb : AForm_1<4, 23, (outs qfrc:$FRT),
                        (ins qbrc:$FRA, qfrc:$FRB, qfrc:$FRC),
                        "qvfsel $FRT, $FRA, $FRC, $FRB", IIC_VecPerm,
                        [(set v4f64:$FRT, (vselect v4i1:$FRA,
                                                   v4f64:$FRC, v4f64:$FRB))]>;
  let isCodeGenOnly = 1 in
  def QVFSELbs : AForm_1<4, 23, (outs qsrc:$FRT),
                        (ins qbrc:$FRA, qsrc:$FRB, qsrc:$FRC),
                        "qvfsel $FRT, $FRA, $FRC, $FRB", IIC_VecPerm,
                        [(set v4f32:$FRT, (vselect v4i1:$FRA,
                                                   v4f32:$FRC, v4f32:$FRB))]>;
  let isCodeGenOnly = 1 in
  def QVFSELbb: AForm_1<4, 23, (outs qbrc:$FRT),
                        (ins qbrc:$FRA, qbrc:$FRB, qbrc:$FRC),
                        "qvfsel $FRT, $FRA, $FRC, $FRB", IIC_VecPerm,
                        [(set v4i1:$FRT, (vselect v4i1:$FRA,
                                                  v4i1:$FRC, v4i1:$FRB))]>;

  // SELECT_CC_* - Used to implement the SELECT_CC DAG operation.  Expanded after
  // instruction selection into a branch sequence.
  def SELECT_CC_QFRC: PPCCustomInserterPseudo<(outs qfrc:$dst), (ins crrc:$cond, qfrc:$T, qfrc:$F,
                              i32imm:$BROPC), "#SELECT_CC_QFRC",
                              []>;
  def SELECT_CC_QSRC: PPCCustomInserterPseudo<(outs qsrc:$dst), (ins crrc:$cond, qsrc:$T, qsrc:$F,
                              i32imm:$BROPC), "#SELECT_CC_QSRC",
                              []>;
  def SELECT_CC_QBRC: PPCCustomInserterPseudo<(outs qbrc:$dst), (ins crrc:$cond, qbrc:$T, qbrc:$F,
                              i32imm:$BROPC), "#SELECT_CC_QBRC",
                              []>;

  // SELECT_* pseudo instructions, like SELECT_CC_* but taking condition
  // register bit directly.
  def SELECT_QFRC: PPCCustomInserterPseudo<(outs qfrc:$dst), (ins crbitrc:$cond,
                          qfrc:$T, qfrc:$F), "#SELECT_QFRC",
                          [(set v4f64:$dst,
                                (select i1:$cond, v4f64:$T, v4f64:$F))]>;
  def SELECT_QSRC: PPCCustomInserterPseudo<(outs qsrc:$dst), (ins crbitrc:$cond,
                          qsrc:$T, qsrc:$F), "#SELECT_QSRC",
                          [(set v4f32:$dst,
                                (select i1:$cond, v4f32:$T, v4f32:$F))]>;
  def SELECT_QBRC: PPCCustomInserterPseudo<(outs qbrc:$dst), (ins crbitrc:$cond,
                          qbrc:$T, qbrc:$F), "#SELECT_QBRC",
                          [(set v4i1:$dst,
                                (select i1:$cond, v4i1:$T, v4i1:$F))]>;

  // Convert and Round Instructions
  def QVFCTID : QPXX19_Int<4, 814, "qvfctid", int_ppc_qpx_qvfctid>;
  let isCodeGenOnly = 1 in
    def QVFCTIDb : XForm_19<4, 814, (outs qbrc:$FRT), (ins qbrc:$FRB),
                            "qvfctid $FRT, $FRB", IIC_FPGeneral, []>;

  def QVFCTIDU : QPXX19_Int<4, 942, "qvfctidu", int_ppc_qpx_qvfctidu>;
  def QVFCTIDZ : QPXX19_Int<4, 815, "qvfctidz", int_ppc_qpx_qvfctidz>;
  def QVFCTIDUZ : QPXX19_Int<4, 943, "qvfctiduz", int_ppc_qpx_qvfctiduz>;
  def QVFCTIW : QPXX19_Int<4, 14, "qvfctiw", int_ppc_qpx_qvfctiw>;
  def QVFCTIWU : QPXX19_Int<4, 142, "qvfctiwu", int_ppc_qpx_qvfctiwu>;
  def QVFCTIWZ : QPXX19_Int<4, 15, "qvfctiwz", int_ppc_qpx_qvfctiwz>;
  def QVFCTIWUZ : QPXX19_Int<4, 143, "qvfctiwuz", int_ppc_qpx_qvfctiwuz>;
  def QVFCFID : QPXX19_Int<4, 846, "qvfcfid", int_ppc_qpx_qvfcfid>;
  let isCodeGenOnly = 1 in
    def QVFCFIDb : XForm_19<4, 846, (outs qbrc:$FRT), (ins qbrc:$FRB),
                            "qvfcfid $FRT, $FRB", IIC_FPGeneral, []>;

  def QVFCFIDU : QPXX19_Int<4, 974, "qvfcfidu", int_ppc_qpx_qvfcfidu>;
  def QVFCFIDS : QPXX19_Int<0, 846, "qvfcfids", int_ppc_qpx_qvfcfids>;
  def QVFCFIDUS : QPXX19_Int<0, 974, "qvfcfidus", int_ppc_qpx_qvfcfidus>;

  let isCodeGenOnly = 1 in
    def QVFRSP : QPXX19_Int<4, 12, "qvfrsp", int_ppc_qpx_qvfrsp>;
  def QVFRSPs : XForm_19<4, 12,
                      (outs qsrc:$FRT), (ins qfrc:$FRB),
                      "qvfrsp $FRT, $FRB", IIC_FPGeneral,
                      [(set v4f32:$FRT, (fround_inexact v4f64:$FRB))]>;

  def QVFRIZ : XForm_19<4, 424, (outs qfrc:$FRT), (ins qfrc:$FRB),
                        "qvfriz $FRT, $FRB", IIC_FPGeneral,
                        [(set v4f64:$FRT, (ftrunc v4f64:$FRB))]>;
  let isCodeGenOnly = 1 in
    def QVFRIZs : XForm_19<4, 424, (outs qsrc:$FRT), (ins qsrc:$FRB),
                           "qvfriz $FRT, $FRB", IIC_FPGeneral,
                           [(set v4f32:$FRT, (ftrunc v4f32:$FRB))]>;

  def QVFRIN : XForm_19<4, 392, (outs qfrc:$FRT), (ins qfrc:$FRB),
                        "qvfrin $FRT, $FRB", IIC_FPGeneral,
                        [(set v4f64:$FRT, (fround v4f64:$FRB))]>;
  let isCodeGenOnly = 1 in
    def QVFRINs : XForm_19<4, 392, (outs qsrc:$FRT), (ins qsrc:$FRB),
                           "qvfrin $FRT, $FRB", IIC_FPGeneral,
                           [(set v4f32:$FRT, (fround v4f32:$FRB))]>;

  def QVFRIP : XForm_19<4, 456, (outs qfrc:$FRT), (ins qfrc:$FRB),
                        "qvfrip $FRT, $FRB", IIC_FPGeneral,
                        [(set v4f64:$FRT, (fceil v4f64:$FRB))]>;
  let isCodeGenOnly = 1 in
    def QVFRIPs : XForm_19<4, 456, (outs qsrc:$FRT), (ins qsrc:$FRB),
                           "qvfrip $FRT, $FRB", IIC_FPGeneral,
                           [(set v4f32:$FRT, (fceil v4f32:$FRB))]>;

  def QVFRIM : XForm_19<4, 488, (outs qfrc:$FRT), (ins qfrc:$FRB),
                        "qvfrim $FRT, $FRB", IIC_FPGeneral,
                        [(set v4f64:$FRT, (ffloor v4f64:$FRB))]>;
  let isCodeGenOnly = 1 in
    def QVFRIMs : XForm_19<4, 488, (outs qsrc:$FRT), (ins qsrc:$FRB),
                           "qvfrim $FRT, $FRB", IIC_FPGeneral,
                           [(set v4f32:$FRT, (ffloor v4f32:$FRB))]>;

  // Move Instructions
  def QVFMR : XForm_19<4, 72,
                      (outs qfrc:$FRT), (ins qfrc:$FRB),
                      "qvfmr $FRT, $FRB", IIC_VecPerm,
                      [/* (set v4f64:$FRT, v4f64:$FRB) */]>;
  let isCodeGenOnly = 1 in {
    def QVFMRs : XForm_19<4, 72,
                         (outs qsrc:$FRT), (ins qsrc:$FRB),
                         "qvfmr $FRT, $FRB", IIC_VecPerm,
                         [/* (set v4f32:$FRT, v4f32:$FRB) */]>;
    def QVFMRb : XForm_19<4, 72,
                         (outs qbrc:$FRT), (ins qbrc:$FRB),
                         "qvfmr $FRT, $FRB", IIC_VecPerm,
                         [/* (set v4i1:$FRT, v4i1:$FRB) */]>;
  }
  def QVFNEG : XForm_19<4, 40,
                      (outs qfrc:$FRT), (ins qfrc:$FRB),
                      "qvfneg $FRT, $FRB", IIC_VecPerm,
                      [(set v4f64:$FRT, (fneg v4f64:$FRB))]>;
  let isCodeGenOnly = 1 in
    def QVFNEGs : XForm_19<4, 40,
                         (outs qsrc:$FRT), (ins qsrc:$FRB),
                         "qvfneg $FRT, $FRB", IIC_VecPerm,
                         [(set v4f32:$FRT, (fneg v4f32:$FRB))]>;
  def QVFABS : XForm_19<4, 264,
                      (outs qfrc:$FRT), (ins qfrc:$FRB),
                      "qvfabs $FRT, $FRB", IIC_VecPerm,
                      [(set v4f64:$FRT, (fabs v4f64:$FRB))]>;
  let isCodeGenOnly = 1 in
    def QVFABSs : XForm_19<4, 264,
                         (outs qsrc:$FRT), (ins qsrc:$FRB),
                         "qvfabs $FRT, $FRB", IIC_VecPerm,
                         [(set v4f32:$FRT, (fabs v4f32:$FRB))]>;
  def QVFNABS : XForm_19<4, 136,
                      (outs qfrc:$FRT), (ins qfrc:$FRB),
                      "qvfnabs $FRT, $FRB", IIC_VecPerm,
                      [(set v4f64:$FRT, (fneg (fabs v4f64:$FRB)))]>;
  let isCodeGenOnly = 1 in
    def QVFNABSs : XForm_19<4, 136,
                         (outs qsrc:$FRT), (ins qsrc:$FRB),
                         "qvfnabs $FRT, $FRB", IIC_VecPerm,
                         [(set v4f32:$FRT, (fneg (fabs v4f32:$FRB)))]>;
  def QVFCPSGN : XForm_18<4, 8,
                      (outs qfrc:$FRT), (ins qfrc:$FRA, qfrc:$FRB),
                      "qvfcpsgn $FRT, $FRA, $FRB", IIC_VecPerm,
                      [(set v4f64:$FRT, (fcopysign v4f64:$FRB, v4f64:$FRA))]>;
  let isCodeGenOnly = 1 in
    def QVFCPSGNs : XForm_18<4, 8,
                         (outs qsrc:$FRT), (ins qsrc:$FRA, qsrc:$FRB),
                         "qvfcpsgn $FRT, $FRA, $FRB", IIC_VecPerm,
                         [(set v4f32:$FRT, (fcopysign v4f32:$FRB, v4f32:$FRA))]>;

  def QVALIGNI : Z23Form_1<4, 5,
                      (outs qfrc:$FRT), (ins qfrc:$FRA, qfrc:$FRB, u2imm:$idx),
                      "qvaligni $FRT, $FRA, $FRB, $idx", IIC_VecPerm,
                      [(set v4f64:$FRT,
                            (PPCqvaligni v4f64:$FRA, v4f64:$FRB,
                                         (i32 imm:$idx)))]>;
  let isCodeGenOnly = 1 in
     def QVALIGNIs : Z23Form_1<4, 5,
                         (outs qsrc:$FRT), (ins qsrc:$FRA, qsrc:$FRB, u2imm:$idx),
                         "qvaligni $FRT, $FRA, $FRB, $idx", IIC_VecPerm,
                         [(set v4f32:$FRT,
                               (PPCqvaligni v4f32:$FRA, v4f32:$FRB,
                                            (i32 imm:$idx)))]>;
  let isCodeGenOnly = 1 in
     def QVALIGNIb : Z23Form_1<4, 5,
                         (outs qbrc:$FRT), (ins qbrc:$FRA, qbrc:$FRB, u2imm:$idx),
                         "qvaligni $FRT, $FRA, $FRB, $idx", IIC_VecPerm,
                         [(set v4i1:$FRT,
                               (PPCqvaligni v4i1:$FRA, v4i1:$FRB,
                                            (i32 imm:$idx)))]>;

  def QVESPLATI : Z23Form_2<4, 37,
                      (outs qfrc:$FRT), (ins qfrc:$FRA, u2imm:$idx),
                      "qvesplati $FRT, $FRA, $idx", IIC_VecPerm,
                      [(set v4f64:$FRT,
                            (PPCqvesplati v4f64:$FRA, (i32 imm:$idx)))]>;
  let isCodeGenOnly = 1 in
     def QVESPLATIs : Z23Form_2<4, 37,
                         (outs qsrc:$FRT), (ins qsrc:$FRA, u2imm:$idx),
                         "qvesplati $FRT, $FRA, $idx", IIC_VecPerm,
                         [(set v4f32:$FRT,
                               (PPCqvesplati v4f32:$FRA, (i32 imm:$idx)))]>;
  let isCodeGenOnly = 1 in
     def QVESPLATIb : Z23Form_2<4, 37,
                         (outs qbrc:$FRT), (ins qbrc:$FRA, u2imm:$idx),
                         "qvesplati $FRT, $FRA, $idx", IIC_VecPerm,
                         [(set v4i1:$FRT,
                               (PPCqvesplati v4i1:$FRA, (i32 imm:$idx)))]>;

  def QVFPERM : AForm_1<4, 6,
                      (outs qfrc:$FRT), (ins qfrc:$FRA, qfrc:$FRB, qfrc:$FRC),
                      "qvfperm $FRT, $FRA, $FRB, $FRC", IIC_VecPerm,
                      [(set v4f64:$FRT,
                            (PPCqvfperm v4f64:$FRA, v4f64:$FRB, v4f64:$FRC))]>;
  let isCodeGenOnly = 1 in
     def QVFPERMs : AForm_1<4, 6,
                         (outs qsrc:$FRT), (ins qsrc:$FRA, qsrc:$FRB, qfrc:$FRC),
                         "qvfperm $FRT, $FRA, $FRB, $FRC", IIC_VecPerm,
                         [(set v4f32:$FRT,
                               (PPCqvfperm v4f32:$FRA, v4f32:$FRB, v4f64:$FRC))]>;

  let isReMaterializable = 1, isAsCheapAsAMove = 1 in
  def QVGPCI : Z23Form_3<4, 133,
                      (outs qfrc:$FRT), (ins u12imm:$idx),
                      "qvgpci $FRT, $idx", IIC_VecPerm,
                      [(set v4f64:$FRT, (PPCqvgpci (u12:$idx)))]>;

  // Compare Instruction
  let isCodeGenOnly = 1 in
    def QVFTSTNAN : QPXX18_Int<4, 64, "qvftstnan", int_ppc_qpx_qvftstnan>;
  def QVFTSTNANb : XForm_18<4, 64, (outs qbrc:$FRT), (ins qfrc:$FRA, qfrc:$FRB),
                           "qvftstnan $FRT, $FRA, $FRB", IIC_FPCompare,
                           [(set v4i1:$FRT,
                                 (setcc v4f64:$FRA, v4f64:$FRB, SETUO))]>;
  let isCodeGenOnly = 1 in
  def QVFTSTNANbs : XForm_18<4, 64, (outs qbrc:$FRT), (ins qsrc:$FRA, qsrc:$FRB),
                            "qvftstnan $FRT, $FRA, $FRB", IIC_FPCompare,
                            [(set v4i1:$FRT,
                                  (setcc v4f32:$FRA, v4f32:$FRB, SETUO))]>;
  let isCodeGenOnly = 1 in
    def QVFCMPLT : QPXX18_Int<4, 96, "qvfcmplt", int_ppc_qpx_qvfcmplt>;
  def QVFCMPLTb : XForm_18<4, 96, (outs qbrc:$FRT), (ins qfrc:$FRA, qfrc:$FRB),
                           "qvfcmplt $FRT, $FRA, $FRB", IIC_FPCompare,
                           [(set v4i1:$FRT,
                                 (setcc v4f64:$FRA, v4f64:$FRB, SETOLT))]>;
  let isCodeGenOnly = 1 in
  def QVFCMPLTbs : XForm_18<4, 96, (outs qbrc:$FRT), (ins qsrc:$FRA, qsrc:$FRB),
                            "qvfcmplt $FRT, $FRA, $FRB", IIC_FPCompare,
                            [(set v4i1:$FRT,
                                  (setcc v4f32:$FRA, v4f32:$FRB, SETOLT))]>;
  let isCodeGenOnly = 1 in
    def QVFCMPGT : QPXX18_Int<4, 32, "qvfcmpgt", int_ppc_qpx_qvfcmpgt>;
  def QVFCMPGTb : XForm_18<4, 32, (outs qbrc:$FRT), (ins qfrc:$FRA, qfrc:$FRB),
                           "qvfcmpgt $FRT, $FRA, $FRB", IIC_FPCompare,
                           [(set v4i1:$FRT,
                                 (setcc v4f64:$FRA, v4f64:$FRB, SETOGT))]>;
  let isCodeGenOnly = 1 in
  def QVFCMPGTbs : XForm_18<4, 32, (outs qbrc:$FRT), (ins qsrc:$FRA, qsrc:$FRB),
                            "qvfcmpgt $FRT, $FRA, $FRB", IIC_FPCompare,
                            [(set v4i1:$FRT,
                                  (setcc v4f32:$FRA, v4f32:$FRB, SETOGT))]>;
  let isCodeGenOnly = 1 in
    def QVFCMPEQ : QPXX18_Int<4, 0, "qvfcmpeq", int_ppc_qpx_qvfcmpeq>;
  def QVFCMPEQb : XForm_18<4, 0, (outs qbrc:$FRT), (ins qfrc:$FRA, qfrc:$FRB),
                           "qvfcmpeq $FRT, $FRA, $FRB", IIC_FPCompare,
                           [(set v4i1:$FRT,
                                 (setcc v4f64:$FRA, v4f64:$FRB, SETOEQ))]>;
  let isCodeGenOnly = 1 in
  def QVFCMPEQbs : XForm_18<4, 0, (outs qbrc:$FRT), (ins qsrc:$FRA, qsrc:$FRB),
                            "qvfcmpeq $FRT, $FRA, $FRB", IIC_FPCompare,
                            [(set v4i1:$FRT,
                                  (setcc v4f32:$FRA, v4f32:$FRB, SETOEQ))]>;

  let isCodeGenOnly = 1 in
  def QVFLOGICAL : XForm_20<4, 4,
                      (outs qfrc:$FRT), (ins qfrc:$FRA, qfrc:$FRB, u12imm:$tttt),
                      "qvflogical $FRT, $FRA, $FRB, $tttt", IIC_VecPerm, []>;
  def QVFLOGICALb : XForm_20<4, 4,
                      (outs qbrc:$FRT), (ins qbrc:$FRA, qbrc:$FRB, u12imm:$tttt),
                      "qvflogical $FRT, $FRA, $FRB, $tttt", IIC_VecPerm, []>;
  let isCodeGenOnly = 1 in
  def QVFLOGICALs : XForm_20<4, 4,
                      (outs qbrc:$FRT), (ins qbrc:$FRA, qbrc:$FRB, u12imm:$tttt),
                      "qvflogical $FRT, $FRA, $FRB, $tttt", IIC_VecPerm, []>;

  // Load indexed instructions
  let mayLoad = 1 in {
    def QVLFDX : XForm_1_memOp<31, 583,
                              (outs qfrc:$FRT), (ins memrr:$src),
                              "qvlfdx $FRT, $src", IIC_LdStLFD,
                              [(set v4f64:$FRT, (load xoaddr:$src))]>;
    let isCodeGenOnly = 1 in
    def QVLFDXb : XForm_1_memOp<31, 583,
                                (outs qbrc:$FRT), (ins memrr:$src),
                                "qvlfdx $FRT, $src", IIC_LdStLFD, []>;

    let RC = 1 in
    def QVLFDXA : XForm_1<31, 583,
                        (outs qfrc:$FRT), (ins memrr:$src),
                        "qvlfdxa $FRT, $src", IIC_LdStLFD, []>;

    def QVLFDUX : XForm_1<31, 615,
                        (outs qfrc:$FRT, ptr_rc_nor0:$ea_result),
                        (ins memrr:$src),
                        "qvlfdux $FRT, $src", IIC_LdStLFDU, []>,
                        RegConstraint<"$src.ptrreg = $ea_result">,
                        NoEncode<"$ea_result">;
    let RC = 1 in
    def QVLFDUXA : XForm_1<31, 615,
                        (outs qfrc:$FRT), (ins memrr:$src),
                        "qvlfduxa $FRT, $src", IIC_LdStLFD, []>;

    def QVLFSX : XForm_1_memOp<31, 519,
                              (outs qfrc:$FRT), (ins memrr:$src),
                              "qvlfsx $FRT, $src", IIC_LdStLFD,
                              [(set v4f64:$FRT, (extloadv4f32 xoaddr:$src))]>;

    let isCodeGenOnly = 1 in
    def QVLFSXb : XForm_1<31, 519,
                        (outs qbrc:$FRT), (ins memrr:$src),
                        "qvlfsx $FRT, $src", IIC_LdStLFD,
                        [(set v4i1:$FRT, (PPCqvlfsb xoaddr:$src))]>;
    let isCodeGenOnly = 1 in
    def QVLFSXs : XForm_1_memOp<31, 519,
                                (outs qsrc:$FRT), (ins memrr:$src),
                                "qvlfsx $FRT, $src", IIC_LdStLFD,
                                [(set v4f32:$FRT, (load xoaddr:$src))]>;

    let RC = 1 in
    def QVLFSXA : XForm_1<31, 519,
                        (outs qfrc:$FRT), (ins memrr:$src),
                        "qvlfsxa $FRT, $src", IIC_LdStLFD, []>;

    def QVLFSUX : XForm_1<31, 551,
                        (outs qsrc:$FRT, ptr_rc_nor0:$ea_result),
                        (ins memrr:$src),
                        "qvlfsux $FRT, $src", IIC_LdStLFDU, []>,
                        RegConstraint<"$src.ptrreg = $ea_result">,
                        NoEncode<"$ea_result">;

    let RC = 1 in
    def QVLFSUXA : XForm_1<31, 551,
                        (outs qfrc:$FRT), (ins memrr:$src),
                        "qvlfsuxa $FRT, $src", IIC_LdStLFD, []>;

    def QVLFCDX : XForm_1<31, 71,
                        (outs qfrc:$FRT), (ins memrr:$src),
                        "qvlfcdx $FRT, $src", IIC_LdStLFD, []>;
    let RC = 1 in
    def QVLFCDXA : XForm_1<31, 71,
                        (outs qfrc:$FRT), (ins memrr:$src),
                        "qvlfcdxa $FRT, $src", IIC_LdStLFD, []>;

    def QVLFCDUX : XForm_1<31, 103,
                        (outs qfrc:$FRT), (ins memrr:$src),
                        "qvlfcdux $FRT, $src", IIC_LdStLFD, []>;
    let RC = 1 in
    def QVLFCDUXA : XForm_1<31, 103,
                        (outs qfrc:$FRT), (ins memrr:$src),
                        "qvlfcduxa $FRT, $src", IIC_LdStLFD, []>;

    def QVLFCSX : XForm_1<31, 7,
                        (outs qfrc:$FRT), (ins memrr:$src),
                        "qvlfcsx $FRT, $src", IIC_LdStLFD, []>;
    let isCodeGenOnly = 1 in
    def QVLFCSXs : XForm_1<31, 7,
                         (outs qsrc:$FRT), (ins memrr:$src),
                         "qvlfcsx $FRT, $src", IIC_LdStLFD, []>;

    let RC = 1 in
    def QVLFCSXA : XForm_1<31, 7,
                        (outs qfrc:$FRT), (ins memrr:$src),
                        "qvlfcsxa $FRT, $src", IIC_LdStLFD, []>;

    def QVLFCSUX : XForm_1<31, 39,
                        (outs qfrc:$FRT), (ins memrr:$src),
                        "qvlfcsux $FRT, $src", IIC_LdStLFD, []>;
    let RC = 1 in
    def QVLFCSUXA : XForm_1<31, 39,
                        (outs qfrc:$FRT), (ins memrr:$src),
                        "qvlfcsuxa $FRT, $src", IIC_LdStLFD, []>;

    def QVLFIWAX : XForm_1<31, 871,
                        (outs qfrc:$FRT), (ins memrr:$src),
                        "qvlfiwax $FRT, $src", IIC_LdStLFD, []>;
    let RC = 1 in
    def QVLFIWAXA : XForm_1<31, 871,
                        (outs qfrc:$FRT), (ins memrr:$src),
                        "qvlfiwaxa $FRT, $src", IIC_LdStLFD, []>;

    def QVLFIWZX : XForm_1<31, 839,
                        (outs qfrc:$FRT), (ins memrr:$src),
                        "qvlfiwzx $FRT, $src", IIC_LdStLFD, []>;
    let RC = 1 in
    def QVLFIWZXA : XForm_1<31, 839,
                        (outs qfrc:$FRT), (ins memrr:$src),
                        "qvlfiwzxa $FRT, $src", IIC_LdStLFD, []>;
  }


  def QVLPCLDX : XForm_1<31, 582,
                      (outs qfrc:$FRT), (ins memrr:$src),
                      "qvlpcldx $FRT, $src", IIC_LdStLFD, []>;
  def QVLPCLSX : XForm_1<31, 518,
                      (outs qfrc:$FRT), (ins memrr:$src),
                      "qvlpclsx $FRT, $src", IIC_LdStLFD, []>;
  let isCodeGenOnly = 1 in
    def QVLPCLSXint : XForm_11<31, 518,
                              (outs qfrc:$FRT), (ins G8RC:$src),
                              "qvlpclsx $FRT, 0, $src", IIC_LdStLFD, []>;
  def QVLPCRDX : XForm_1<31, 70,
                      (outs qfrc:$FRT), (ins memrr:$src),
                      "qvlpcrdx $FRT, $src", IIC_LdStLFD, []>;
  def QVLPCRSX : XForm_1<31, 6,
                      (outs qfrc:$FRT), (ins memrr:$src),
                      "qvlpcrsx $FRT, $src", IIC_LdStLFD, []>;

  // Store indexed instructions
  let mayStore = 1 in {
    def QVSTFDX : XForm_8_memOp<31, 711,
                        (outs), (ins qfrc:$FRT, memrr:$dst),
                        "qvstfdx $FRT, $dst", IIC_LdStSTFD,
                        [(store qfrc:$FRT, xoaddr:$dst)]>;
    let isCodeGenOnly = 1 in
    def QVSTFDXb : XForm_8_memOp<31, 711,
                        (outs), (ins qbrc:$FRT, memrr:$dst),
                        "qvstfdx $FRT, $dst", IIC_LdStSTFD, []>;

    let RC = 1 in
    def QVSTFDXA : XForm_8<31, 711,
                        (outs), (ins qfrc:$FRT, memrr:$dst),
                        "qvstfdxa $FRT, $dst", IIC_LdStSTFD, []>;

    def QVSTFDUX : XForm_8<31, 743, (outs ptr_rc_nor0:$ea_res),
                           (ins qfrc:$FRT, memrr:$dst),
                           "qvstfdux $FRT, $dst", IIC_LdStSTFDU, []>,
                           RegConstraint<"$dst.ptrreg = $ea_res">,
                           NoEncode<"$ea_res">;

    let RC = 1 in
    def QVSTFDUXA : XForm_8<31, 743,
                        (outs), (ins qfrc:$FRT, memrr:$dst),
                        "qvstfduxa $FRT, $dst", IIC_LdStSTFD, []>;

    def QVSTFDXI : XForm_8<31, 709,
                        (outs), (ins qfrc:$FRT, memrr:$dst),
                        "qvstfdxi $FRT, $dst", IIC_LdStSTFD, []>;
    let RC = 1 in
    def QVSTFDXIA : XForm_8<31, 709,
                        (outs), (ins qfrc:$FRT, memrr:$dst),
                        "qvstfdxia $FRT, $dst", IIC_LdStSTFD, []>;

    def QVSTFDUXI : XForm_8<31, 741,
                        (outs), (ins qfrc:$FRT, memrr:$dst),
                        "qvstfduxi $FRT, $dst", IIC_LdStSTFD, []>;
    let RC = 1 in
    def QVSTFDUXIA : XForm_8<31, 741,
                        (outs), (ins qfrc:$FRT, memrr:$dst),
                        "qvstfduxia $FRT, $dst", IIC_LdStSTFD, []>;

    def QVSTFSX : XForm_8_memOp<31, 647,
                        (outs), (ins qfrc:$FRT, memrr:$dst),
                        "qvstfsx $FRT, $dst", IIC_LdStSTFD,
                        [(truncstorev4f32 qfrc:$FRT, xoaddr:$dst)]>;
    let isCodeGenOnly = 1 in
    def QVSTFSXs : XForm_8_memOp<31, 647,
                         (outs), (ins qsrc:$FRT, memrr:$dst),
                         "qvstfsx $FRT, $dst", IIC_LdStSTFD,
                         [(store qsrc:$FRT, xoaddr:$dst)]>;

    let RC = 1 in
    def QVSTFSXA : XForm_8<31, 647,
                        (outs), (ins qfrc:$FRT, memrr:$dst),
                        "qvstfsxa $FRT, $dst", IIC_LdStSTFD, []>;

    def QVSTFSUX : XForm_8<31, 679, (outs ptr_rc_nor0:$ea_res),
                           (ins qsrc:$FRT, memrr:$dst),
                           "qvstfsux $FRT, $dst", IIC_LdStSTFDU, []>,
                           RegConstraint<"$dst.ptrreg = $ea_res">,
                           NoEncode<"$ea_res">;
    let isCodeGenOnly = 1 in
    def QVSTFSUXs: XForm_8<31, 679, (outs ptr_rc_nor0:$ea_res),
                           (ins qfrc:$FRT, memrr:$dst),
                           "qvstfsux $FRT, $dst", IIC_LdStSTFDU, []>,
                           RegConstraint<"$dst.ptrreg = $ea_res">,
                           NoEncode<"$ea_res">;

    let RC = 1 in
    def QVSTFSUXA : XForm_8<31, 679,
                        (outs), (ins qfrc:$FRT, memrr:$dst),
                        "qvstfsuxa $FRT, $dst", IIC_LdStSTFD, []>;

    def QVSTFSXI : XForm_8<31, 645,
                        (outs), (ins qfrc:$FRT, memrr:$dst),
                        "qvstfsxi $FRT, $dst", IIC_LdStSTFD, []>;
    let RC = 1 in
    def QVSTFSXIA : XForm_8<31, 645,
                        (outs), (ins qfrc:$FRT, memrr:$dst),
                        "qvstfsxia $FRT, $dst", IIC_LdStSTFD, []>;

    def QVSTFSUXI : XForm_8<31, 677,
                        (outs), (ins qfrc:$FRT, memrr:$dst),
                        "qvstfsuxi $FRT, $dst", IIC_LdStSTFD, []>;
    let RC = 1 in
    def QVSTFSUXIA : XForm_8<31, 677,
                        (outs), (ins qfrc:$FRT, memrr:$dst),
                        "qvstfsuxia $FRT, $dst", IIC_LdStSTFD, []>;

    def QVSTFCDX : XForm_8<31, 199,
                        (outs), (ins qfrc:$FRT, memrr:$dst),
                        "qvstfcdx $FRT, $dst", IIC_LdStSTFD, []>;
    let RC = 1 in
    def QVSTFCDXA : XForm_8<31, 199,
                        (outs), (ins qfrc:$FRT, memrr:$dst),
                        "qvstfcdxa $FRT, $dst", IIC_LdStSTFD, []>;

    def QVSTFCSX : XForm_8<31, 135,
                        (outs), (ins qfrc:$FRT, memrr:$dst),
                        "qvstfcsx $FRT, $dst", IIC_LdStSTFD, []>;
    let isCodeGenOnly = 1 in
    def QVSTFCSXs : XForm_8<31, 135,
                         (outs), (ins qsrc:$FRT, memrr:$dst),
                         "qvstfcsx $FRT, $dst", IIC_LdStSTFD, []>;

    let RC = 1 in
    def QVSTFCSXA : XForm_8<31, 135,
                        (outs), (ins qfrc:$FRT, memrr:$dst),
                        "qvstfcsxa $FRT, $dst", IIC_LdStSTFD, []>;

    def QVSTFCDUX : XForm_8<31, 231,
                        (outs), (ins qfrc:$FRT, memrr:$dst),
                        "qvstfcdux $FRT, $dst", IIC_LdStSTFD, []>;
    let RC = 1 in
    def QVSTFCDUXA : XForm_8<31, 231,
                        (outs), (ins qfrc:$FRT, memrr:$dst),
                        "qvstfcduxa $FRT, $dst", IIC_LdStSTFD, []>;

    def QVSTFCSUX : XForm_8<31, 167,
                        (outs), (ins qfrc:$FRT, memrr:$dst),
                        "qvstfcsux $FRT, $dst", IIC_LdStSTFD, []>;
    let RC = 1 in
    def QVSTFCSUXA : XForm_8<31, 167,
                        (outs), (ins qfrc:$FRT, memrr:$dst),
                        "qvstfcsuxa $FRT, $dst", IIC_LdStSTFD, []>;

    def QVSTFCDXI : XForm_8<31, 197,
                        (outs), (ins qfrc:$FRT, memrr:$dst),
                        "qvstfcdxi $FRT, $dst", IIC_LdStSTFD, []>;
    let RC = 1 in
    def QVSTFCDXIA : XForm_8<31, 197,
                        (outs), (ins qfrc:$FRT, memrr:$dst),
                        "qvstfcdxia $FRT, $dst", IIC_LdStSTFD, []>;

    def QVSTFCSXI : XForm_8<31, 133,
                        (outs), (ins qfrc:$FRT, memrr:$dst),
                        "qvstfcsxi $FRT, $dst", IIC_LdStSTFD, []>;
    let RC = 1 in
    def QVSTFCSXIA : XForm_8<31, 133,
                        (outs), (ins qfrc:$FRT, memrr:$dst),
                        "qvstfcsxia $FRT, $dst", IIC_LdStSTFD, []>;

    def QVSTFCDUXI : XForm_8<31, 229,
                        (outs), (ins qfrc:$FRT, memrr:$dst),
                        "qvstfcduxi $FRT, $dst", IIC_LdStSTFD, []>;
    let RC = 1 in
    def QVSTFCDUXIA : XForm_8<31, 229,
                        (outs), (ins qfrc:$FRT, memrr:$dst),
                        "qvstfcduxia $FRT, $dst", IIC_LdStSTFD, []>;

    def QVSTFCSUXI : XForm_8<31, 165,
                        (outs), (ins qfrc:$FRT, memrr:$dst),
                        "qvstfcsuxi $FRT, $dst", IIC_LdStSTFD, []>;
    let RC = 1 in
    def QVSTFCSUXIA : XForm_8<31, 165,
                        (outs), (ins qfrc:$FRT, memrr:$dst),
                        "qvstfcsuxia $FRT, $dst", IIC_LdStSTFD, []>;

    def QVSTFIWX : XForm_8<31, 967,
                        (outs), (ins qfrc:$FRT, memrr:$dst),
                        "qvstfiwx $FRT, $dst", IIC_LdStSTFD, []>;
    let RC = 1 in
    def QVSTFIWXA : XForm_8<31, 967,
                        (outs), (ins qfrc:$FRT, memrr:$dst),
                        "qvstfiwxa $FRT, $dst", IIC_LdStSTFD, []>;
  }
}

} // neverHasSideEffects
}

def : InstAlias<"qvfclr $FRT",
                (QVFLOGICALb qbrc:$FRT, qbrc:$FRT, qbrc:$FRT, 0)>;
def : InstAlias<"qvfand $FRT, $FRA, $FRB",
                (QVFLOGICALb qbrc:$FRT, qbrc:$FRA, qbrc:$FRB, 1)>;
def : InstAlias<"qvfandc $FRT, $FRA, $FRB",
                (QVFLOGICALb qbrc:$FRT, qbrc:$FRA, qbrc:$FRB, 4)>;
def : InstAlias<"qvfctfb $FRT, $FRA",
                (QVFLOGICALb qbrc:$FRT, qbrc:$FRA, qbrc:$FRA, 5)>;
def : InstAlias<"qvfxor $FRT, $FRA, $FRB",
                (QVFLOGICALb qbrc:$FRT, qbrc:$FRA, qbrc:$FRB, 6)>;
def : InstAlias<"qvfor $FRT, $FRA, $FRB",
                (QVFLOGICALb qbrc:$FRT, qbrc:$FRA, qbrc:$FRB, 7)>;
def : InstAlias<"qvfnor $FRT, $FRA, $FRB",
                (QVFLOGICALb qbrc:$FRT, qbrc:$FRA, qbrc:$FRB, 8)>;
def : InstAlias<"qvfequ $FRT, $FRA, $FRB",
                (QVFLOGICALb qbrc:$FRT, qbrc:$FRA, qbrc:$FRB, 9)>;
def : InstAlias<"qvfnot $FRT, $FRA",
                (QVFLOGICALb qbrc:$FRT, qbrc:$FRA, qbrc:$FRA, 10)>;
def : InstAlias<"qvforc $FRT, $FRA, $FRB",
                (QVFLOGICALb qbrc:$FRT, qbrc:$FRA, qbrc:$FRB, 13)>;
def : InstAlias<"qvfnand $FRT, $FRA, $FRB",
                (QVFLOGICALb qbrc:$FRT, qbrc:$FRA, qbrc:$FRB, 14)>;
def : InstAlias<"qvfset $FRT",
                (QVFLOGICALb qbrc:$FRT, qbrc:$FRT, qbrc:$FRT, 15)>;

//===----------------------------------------------------------------------===//
// Additional QPX Patterns
//

def : Pat<(v4f64 (scalar_to_vector f64:$A)),
          (INSERT_SUBREG (v4f64 (IMPLICIT_DEF)), $A, sub_64)>;
def : Pat<(v4f32 (scalar_to_vector f32:$A)),
          (INSERT_SUBREG (v4f32 (IMPLICIT_DEF)), $A, sub_64)>;

def : Pat<(f64 (extractelt v4f64:$S, 0)),
          (EXTRACT_SUBREG $S, sub_64)>;
def : Pat<(f32 (extractelt v4f32:$S, 0)),
          (EXTRACT_SUBREG $S, sub_64)>;

def : Pat<(f64 (extractelt v4f64:$S, 1)),
          (EXTRACT_SUBREG (QVESPLATI $S, 1), sub_64)>;
def : Pat<(f64 (extractelt v4f64:$S, 2)),
          (EXTRACT_SUBREG (QVESPLATI $S, 2), sub_64)>;
def : Pat<(f64 (extractelt v4f64:$S, 3)),
          (EXTRACT_SUBREG (QVESPLATI $S, 3), sub_64)>;

def : Pat<(f32 (extractelt v4f32:$S, 1)),
          (EXTRACT_SUBREG (QVESPLATIs $S, 1), sub_64)>;
def : Pat<(f32 (extractelt v4f32:$S, 2)),
          (EXTRACT_SUBREG (QVESPLATIs $S, 2), sub_64)>;
def : Pat<(f32 (extractelt v4f32:$S, 3)),
          (EXTRACT_SUBREG (QVESPLATIs $S, 3), sub_64)>;

def : Pat<(f64 (extractelt v4f64:$S, i64:$F)),
          (EXTRACT_SUBREG (QVFPERM $S, $S,
                                   (QVLPCLSXint (RLDICR $F, 2,
                                                        /* 63-2 = */ 61))),
                          sub_64)>;
def : Pat<(f32 (extractelt v4f32:$S, i64:$F)),
          (EXTRACT_SUBREG (QVFPERMs $S, $S,
                                    (QVLPCLSXint (RLDICR $F, 2,
                                                         /* 63-2 = */ 61))),
                          sub_64)>;

def : Pat<(int_ppc_qpx_qvfperm v4f64:$A, v4f64:$B, v4f64:$C),
          (QVFPERM $A, $B, $C)>;

def : Pat<(int_ppc_qpx_qvfcpsgn v4f64:$A, v4f64:$B),
          (QVFCPSGN $A, $B)>;

// FCOPYSIGN's operand types need not agree.
def : Pat<(fcopysign v4f64:$frB, v4f32:$frA),
          (QVFCPSGN (COPY_TO_REGCLASS $frA, QFRC), $frB)>;
def : Pat<(fcopysign QSRC:$frB, QFRC:$frA),
          (QVFCPSGNs (COPY_TO_REGCLASS $frA, QSRC), $frB)>;

def : Pat<(int_ppc_qpx_qvfneg v4f64:$A), (QVFNEG $A)>;
def : Pat<(int_ppc_qpx_qvfabs v4f64:$A), (QVFABS $A)>;
def : Pat<(int_ppc_qpx_qvfnabs v4f64:$A), (QVFNABS $A)>;

def : Pat<(int_ppc_qpx_qvfriz v4f64:$A), (QVFRIZ $A)>;
def : Pat<(int_ppc_qpx_qvfrin v4f64:$A), (QVFRIN $A)>;
def : Pat<(int_ppc_qpx_qvfrip v4f64:$A), (QVFRIP $A)>;
def : Pat<(int_ppc_qpx_qvfrim v4f64:$A), (QVFRIM $A)>;

def : Pat<(int_ppc_qpx_qvfre v4f64:$A), (QVFRE $A)>;
def : Pat<(int_ppc_qpx_qvfrsqrte v4f64:$A), (QVFRSQRTE $A)>;

def : Pat<(int_ppc_qpx_qvfadd v4f64:$A, v4f64:$B),
          (QVFADD $A, $B)>;
def : Pat<(int_ppc_qpx_qvfsub v4f64:$A, v4f64:$B),
          (QVFSUB $A, $B)>;
def : Pat<(int_ppc_qpx_qvfmul v4f64:$A, v4f64:$B),
          (QVFMUL $A, $B)>;

// Additional QVFNMSUB patterns: -a*c + b == -(a*c - b)
def : Pat<(fma (fneg v4f64:$A), v4f64:$C, v4f64:$B),
          (QVFNMSUB $A, $B, $C)>;
def : Pat<(fma v4f64:$A, (fneg v4f64:$C), v4f64:$B),
          (QVFNMSUB $A, $B, $C)>;
def : Pat<(fma (fneg v4f32:$A), v4f32:$C, v4f32:$B),
          (QVFNMSUBSs $A, $B, $C)>;
def : Pat<(fma v4f32:$A, (fneg v4f32:$C), v4f32:$B),
          (QVFNMSUBSs $A, $B, $C)>;

def : Pat<(int_ppc_qpx_qvfmadd v4f64:$A, v4f64:$B, v4f64:$C),
          (QVFMADD $A, $B, $C)>;
def : Pat<(int_ppc_qpx_qvfnmadd v4f64:$A, v4f64:$B, v4f64:$C),
          (QVFNMADD $A, $B, $C)>;
def : Pat<(int_ppc_qpx_qvfmsub v4f64:$A, v4f64:$B, v4f64:$C),
          (QVFMSUB $A, $B, $C)>;
def : Pat<(int_ppc_qpx_qvfnmsub v4f64:$A, v4f64:$B, v4f64:$C),
          (QVFNMSUB $A, $B, $C)>;

def : Pat<(int_ppc_qpx_qvlfd xoaddr:$src),
          (QVLFDX xoaddr:$src)>;
def : Pat<(int_ppc_qpx_qvlfda xoaddr:$src),
          (QVLFDXA xoaddr:$src)>;
def : Pat<(int_ppc_qpx_qvlfs xoaddr:$src),
          (QVLFSX xoaddr:$src)>;
def : Pat<(int_ppc_qpx_qvlfsa xoaddr:$src),
          (QVLFSXA xoaddr:$src)>;
def : Pat<(int_ppc_qpx_qvlfcda xoaddr:$src),
          (QVLFCDXA xoaddr:$src)>;
def : Pat<(int_ppc_qpx_qvlfcd xoaddr:$src),
          (QVLFCDX xoaddr:$src)>;
def : Pat<(int_ppc_qpx_qvlfcsa xoaddr:$src),
          (QVLFCSXA xoaddr:$src)>;
def : Pat<(int_ppc_qpx_qvlfcs xoaddr:$src),
          (QVLFCSX xoaddr:$src)>;
def : Pat<(int_ppc_qpx_qvlfda xoaddr:$src),
          (QVLFDXA xoaddr:$src)>;
def : Pat<(int_ppc_qpx_qvlfiwaa xoaddr:$src),
          (QVLFIWAXA xoaddr:$src)>;
def : Pat<(int_ppc_qpx_qvlfiwa xoaddr:$src),
          (QVLFIWAX xoaddr:$src)>;
def : Pat<(int_ppc_qpx_qvlfiwza xoaddr:$src),
          (QVLFIWZXA xoaddr:$src)>;
def : Pat<(int_ppc_qpx_qvlfiwz xoaddr:$src),
          (QVLFIWZX xoaddr:$src)>;
def : Pat<(int_ppc_qpx_qvlfsa xoaddr:$src),
          (QVLFSXA xoaddr:$src)>;
def : Pat<(int_ppc_qpx_qvlpcld xoaddr:$src),
          (QVLPCLDX xoaddr:$src)>;
def : Pat<(int_ppc_qpx_qvlpcls xoaddr:$src),
          (QVLPCLSX xoaddr:$src)>;
def : Pat<(int_ppc_qpx_qvlpcrd xoaddr:$src),
          (QVLPCRDX xoaddr:$src)>;
def : Pat<(int_ppc_qpx_qvlpcrs xoaddr:$src),
          (QVLPCRSX xoaddr:$src)>;

def : Pat<(int_ppc_qpx_qvstfd v4f64:$T, xoaddr:$dst),
          (QVSTFDX $T, xoaddr:$dst)>;
def : Pat<(int_ppc_qpx_qvstfs v4f64:$T, xoaddr:$dst),
          (QVSTFSX $T, xoaddr:$dst)>;
def : Pat<(int_ppc_qpx_qvstfcda v4f64:$T, xoaddr:$dst),
          (QVSTFCDXA $T, xoaddr:$dst)>;
def : Pat<(int_ppc_qpx_qvstfcd v4f64:$T, xoaddr:$dst),
          (QVSTFCDX $T, xoaddr:$dst)>;
def : Pat<(int_ppc_qpx_qvstfcsa v4f64:$T, xoaddr:$dst),
          (QVSTFCSXA $T, xoaddr:$dst)>;
def : Pat<(int_ppc_qpx_qvstfcs v4f64:$T, xoaddr:$dst),
          (QVSTFCSX $T, xoaddr:$dst)>;
def : Pat<(int_ppc_qpx_qvstfda v4f64:$T, xoaddr:$dst),
          (QVSTFDXA $T, xoaddr:$dst)>;
def : Pat<(int_ppc_qpx_qvstfiwa v4f64:$T, xoaddr:$dst),
          (QVSTFIWXA $T, xoaddr:$dst)>;
def : Pat<(int_ppc_qpx_qvstfiw v4f64:$T, xoaddr:$dst),
          (QVSTFIWX $T, xoaddr:$dst)>;
def : Pat<(int_ppc_qpx_qvstfsa v4f64:$T, xoaddr:$dst),
          (QVSTFSXA $T, xoaddr:$dst)>;

def : Pat<(pre_store v4f64:$rS, iPTR:$ptrreg, iPTR:$ptroff),
          (QVSTFDUX $rS, $ptrreg, $ptroff)>;
def : Pat<(pre_store v4f32:$rS, iPTR:$ptrreg, iPTR:$ptroff),
          (QVSTFSUX $rS, $ptrreg, $ptroff)>;
def : Pat<(pre_truncstv4f32 v4f64:$rS, iPTR:$ptrreg, iPTR:$ptroff),
          (QVSTFSUXs $rS, $ptrreg, $ptroff)>;

def : Pat<(int_ppc_qpx_qvflogical  v4f64:$A, v4f64:$B, (i32 imm:$idx)),
          (QVFLOGICAL $A, $B, imm:$idx)>;
def : Pat<(int_ppc_qpx_qvgpci (u12:$idx)),
          (QVGPCI imm:$idx)>;

def : Pat<(setcc v4f64:$FRA, v4f64:$FRB, SETOGE),
          (QVFLOGICALb (QVFCMPLTb $FRA, $FRB),
                       (QVFTSTNANb $FRA, $FRB), (i32 8))>;
def : Pat<(setcc v4f64:$FRA, v4f64:$FRB, SETOLE),
          (QVFLOGICALb (QVFCMPGTb $FRA, $FRB),
                       (QVFTSTNANb $FRA, $FRB), (i32 8))>;
def : Pat<(setcc v4f64:$FRA, v4f64:$FRB, SETONE),
          (QVFLOGICALb (QVFCMPEQb $FRA, $FRB),
                       (QVFTSTNANb $FRA, $FRB), (i32 8))>;
def : Pat<(setcc v4f64:$FRA, v4f64:$FRB, SETO),
          (QVFLOGICALb (QVFTSTNANb $FRA, $FRB),
                       (QVFTSTNANb $FRA, $FRB), (i32 10))>;
def : Pat<(setcc v4f64:$FRA, v4f64:$FRB, SETUEQ),
          (QVFLOGICALb (QVFCMPEQb $FRA, $FRB),
                       (QVFTSTNANb $FRA, $FRB), (i32 7))>;
def : Pat<(setcc v4f64:$FRA, v4f64:$FRB, SETUGT),
          (QVFLOGICALb (QVFCMPGTb $FRA, $FRB),
                       (QVFTSTNANb $FRA, $FRB), (i32 7))>;
def : Pat<(setcc v4f64:$FRA, v4f64:$FRB, SETUGE),
          (QVFLOGICALb (QVFTSTNANb $FRA, $FRB),
                       (QVFCMPLTb $FRA, $FRB), (i32 13))>;
def : Pat<(setcc v4f64:$FRA, v4f64:$FRB, SETULT),
          (QVFLOGICALb (QVFCMPLTb $FRA, $FRB),
                       (QVFTSTNANb $FRA, $FRB), (i32 7))>;
def : Pat<(setcc v4f64:$FRA, v4f64:$FRB, SETULE),
          (QVFLOGICALb (QVFTSTNANb $FRA, $FRB),
                       (QVFCMPGTb $FRA, $FRB), (i32 13))>;
def : Pat<(setcc v4f64:$FRA, v4f64:$FRB, SETUNE),
          (QVFLOGICALb (QVFTSTNANb $FRA, $FRB),
                       (QVFCMPEQb $FRA, $FRB), (i32 13))>;

def : Pat<(setcc v4f64:$FRA, v4f64:$FRB, SETEQ),
          (QVFCMPEQb $FRA, $FRB)>;
def : Pat<(setcc v4f64:$FRA, v4f64:$FRB, SETGT),
          (QVFCMPGTb $FRA, $FRB)>;
def : Pat<(setcc v4f64:$FRA, v4f64:$FRB, SETGE),
          (QVFLOGICALb (QVFCMPLTb $FRA, $FRB),
                       (QVFCMPLTb $FRA, $FRB), (i32 10))>;
def : Pat<(setcc v4f64:$FRA, v4f64:$FRB, SETLT),
          (QVFCMPLTb $FRA, $FRB)>;
def : Pat<(setcc v4f64:$FRA, v4f64:$FRB, SETLE),
          (QVFLOGICALb (QVFCMPGTb $FRA, $FRB),
                       (QVFCMPGTb $FRA, $FRB), (i32 10))>;
def : Pat<(setcc v4f64:$FRA, v4f64:$FRB, SETNE),
          (QVFLOGICALb (QVFCMPEQb $FRA, $FRB),
                       (QVFCMPEQb $FRA, $FRB), (i32 10))>;

def : Pat<(setcc v4f32:$FRA, v4f32:$FRB, SETOGE),
          (QVFLOGICALb (QVFCMPLTbs $FRA, $FRB),
                       (QVFTSTNANbs $FRA, $FRB), (i32 8))>;
def : Pat<(setcc v4f32:$FRA, v4f32:$FRB, SETOLE),
          (QVFLOGICALb (QVFCMPGTbs $FRA, $FRB),
                       (QVFTSTNANbs $FRA, $FRB), (i32 8))>;
def : Pat<(setcc v4f32:$FRA, v4f32:$FRB, SETONE),
          (QVFLOGICALb (QVFCMPEQbs $FRA, $FRB),
                       (QVFTSTNANbs $FRA, $FRB), (i32 8))>;
def : Pat<(setcc v4f32:$FRA, v4f32:$FRB, SETO),
          (QVFLOGICALb (QVFTSTNANbs $FRA, $FRB),
                       (QVFTSTNANbs $FRA, $FRB), (i32 10))>;
def : Pat<(setcc v4f32:$FRA, v4f32:$FRB, SETUEQ),
          (QVFLOGICALb (QVFCMPEQbs $FRA, $FRB),
                       (QVFTSTNANbs $FRA, $FRB), (i32 7))>;
def : Pat<(setcc v4f32:$FRA, v4f32:$FRB, SETUGT),
          (QVFLOGICALb (QVFCMPGTbs $FRA, $FRB),
                       (QVFTSTNANbs $FRA, $FRB), (i32 7))>;
def : Pat<(setcc v4f32:$FRA, v4f32:$FRB, SETUGE),
          (QVFLOGICALb (QVFTSTNANbs $FRA, $FRB),
                       (QVFCMPLTbs $FRA, $FRB), (i32 13))>;
def : Pat<(setcc v4f32:$FRA, v4f32:$FRB, SETULT),
          (QVFLOGICALb (QVFCMPLTbs $FRA, $FRB),
                       (QVFTSTNANbs $FRA, $FRB), (i32 7))>;
def : Pat<(setcc v4f32:$FRA, v4f32:$FRB, SETULE),
          (QVFLOGICALb (QVFTSTNANbs $FRA, $FRB),
                       (QVFCMPGTbs $FRA, $FRB), (i32 13))>;
def : Pat<(setcc v4f32:$FRA, v4f32:$FRB, SETUNE),
          (QVFLOGICALb (QVFTSTNANbs $FRA, $FRB),
                       (QVFCMPEQbs $FRA, $FRB), (i32 13))>;

def : Pat<(setcc v4f32:$FRA, v4f32:$FRB, SETEQ),
          (QVFCMPEQbs $FRA, $FRB)>;
def : Pat<(setcc v4f32:$FRA, v4f32:$FRB, SETGT),
          (QVFCMPGTbs $FRA, $FRB)>;
def : Pat<(setcc v4f32:$FRA, v4f32:$FRB, SETGE),
          (QVFLOGICALb (QVFCMPLTbs $FRA, $FRB),
                       (QVFCMPLTbs $FRA, $FRB), (i32 10))>;
def : Pat<(setcc v4f32:$FRA, v4f32:$FRB, SETLT),
          (QVFCMPLTbs $FRA, $FRB)>;
def : Pat<(setcc v4f32:$FRA, v4f32:$FRB, SETLE),
          (QVFLOGICALb (QVFCMPGTbs $FRA, $FRB),
                       (QVFCMPGTbs $FRA, $FRB), (i32 10))>;
def : Pat<(setcc v4f32:$FRA, v4f32:$FRB, SETNE),
          (QVFLOGICALb (QVFCMPEQbs $FRA, $FRB),
                       (QVFCMPEQbs $FRA, $FRB), (i32 10))>;

def : Pat<(and v4i1:$FRA, (not v4i1:$FRB)),
          (QVFLOGICALb $FRA, $FRB, (i32 4))>;
def : Pat<(not (or v4i1:$FRA, v4i1:$FRB)),
          (QVFLOGICALb $FRA, $FRB, (i32 8))>;
def : Pat<(not (xor v4i1:$FRA, v4i1:$FRB)),
          (QVFLOGICALb $FRA, $FRB, (i32 9))>;
def : Pat<(or v4i1:$FRA, (not v4i1:$FRB)),
          (QVFLOGICALb $FRA, $FRB, (i32 13))>;
def : Pat<(not (and v4i1:$FRA, v4i1:$FRB)),
          (QVFLOGICALb $FRA, $FRB, (i32 14))>;

def : Pat<(and v4i1:$FRA, v4i1:$FRB),
          (QVFLOGICALb $FRA, $FRB, (i32 1))>;
def : Pat<(or v4i1:$FRA, v4i1:$FRB),
          (QVFLOGICALb $FRA, $FRB, (i32 7))>;
def : Pat<(xor v4i1:$FRA, v4i1:$FRB),
          (QVFLOGICALb $FRA, $FRB, (i32 6))>;
def : Pat<(not v4i1:$FRA),
          (QVFLOGICALb $FRA, $FRA, (i32 10))>;

def : Pat<(v4f64 (fpextend v4f32:$src)),
          (COPY_TO_REGCLASS $src, QFRC)>;

def : Pat<(v4f32 (fround_exact v4f64:$src)),
          (COPY_TO_REGCLASS $src, QSRC)>;

// Extract the underlying floating-point values from the
// QPX (-1.0, 1.0) boolean representation.
def : Pat<(v4f64 (PPCqbflt v4i1:$src)),
          (COPY_TO_REGCLASS $src, QFRC)>;

def : Pat<(v4f64 (selectcc i1:$lhs, i1:$rhs, v4f64:$tval, v4f64:$fval, SETLT)),
          (SELECT_QFRC (CRANDC $lhs, $rhs), $tval, $fval)>;
def : Pat<(v4f64 (selectcc i1:$lhs, i1:$rhs, v4f64:$tval, v4f64:$fval, SETULT)),
          (SELECT_QFRC (CRANDC $rhs, $lhs), $tval, $fval)>;
def : Pat<(v4f64 (selectcc i1:$lhs, i1:$rhs, v4f64:$tval, v4f64:$fval, SETLE)),
          (SELECT_QFRC (CRORC  $lhs, $rhs), $tval, $fval)>;
def : Pat<(v4f64 (selectcc i1:$lhs, i1:$rhs, v4f64:$tval, v4f64:$fval, SETULE)),
          (SELECT_QFRC (CRORC  $rhs, $lhs), $tval, $fval)>;
def : Pat<(v4f64 (selectcc i1:$lhs, i1:$rhs, v4f64:$tval, v4f64:$fval, SETEQ)),
          (SELECT_QFRC (CREQV $lhs, $rhs), $tval, $fval)>;
def : Pat<(v4f64 (selectcc i1:$lhs, i1:$rhs, v4f64:$tval, v4f64:$fval, SETGE)),
          (SELECT_QFRC (CRORC  $rhs, $lhs), $tval, $fval)>;
def : Pat<(v4f64 (selectcc i1:$lhs, i1:$rhs, v4f64:$tval, v4f64:$fval, SETUGE)),
          (SELECT_QFRC (CRORC  $lhs, $rhs), $tval, $fval)>;
def : Pat<(v4f64 (selectcc i1:$lhs, i1:$rhs, v4f64:$tval, v4f64:$fval, SETGT)),
          (SELECT_QFRC (CRANDC $rhs, $lhs), $tval, $fval)>;
def : Pat<(v4f64 (selectcc i1:$lhs, i1:$rhs, v4f64:$tval, v4f64:$fval, SETUGT)),
          (SELECT_QFRC (CRANDC $lhs, $rhs), $tval, $fval)>;
def : Pat<(v4f64 (selectcc i1:$lhs, i1:$rhs, v4f64:$tval, v4f64:$fval, SETNE)),
          (SELECT_QFRC (CRXOR $lhs, $rhs), $tval, $fval)>;

def : Pat<(v4f32 (selectcc i1:$lhs, i1:$rhs, v4f32:$tval, v4f32:$fval, SETLT)),
          (SELECT_QSRC (CRANDC $lhs, $rhs), $tval, $fval)>;
def : Pat<(v4f32 (selectcc i1:$lhs, i1:$rhs, v4f32:$tval, v4f32:$fval, SETULT)),
          (SELECT_QSRC (CRANDC $rhs, $lhs), $tval, $fval)>;
def : Pat<(v4f32 (selectcc i1:$lhs, i1:$rhs, v4f32:$tval, v4f32:$fval, SETLE)),
          (SELECT_QSRC (CRORC  $lhs, $rhs), $tval, $fval)>;
def : Pat<(v4f32 (selectcc i1:$lhs, i1:$rhs, v4f32:$tval, v4f32:$fval, SETULE)),
          (SELECT_QSRC (CRORC  $rhs, $lhs), $tval, $fval)>;
def : Pat<(v4f32 (selectcc i1:$lhs, i1:$rhs, v4f32:$tval, v4f32:$fval, SETEQ)),
          (SELECT_QSRC (CREQV $lhs, $rhs), $tval, $fval)>;
def : Pat<(v4f32 (selectcc i1:$lhs, i1:$rhs, v4f32:$tval, v4f32:$fval, SETGE)),
          (SELECT_QSRC (CRORC  $rhs, $lhs), $tval, $fval)>;
def : Pat<(v4f32 (selectcc i1:$lhs, i1:$rhs, v4f32:$tval, v4f32:$fval, SETUGE)),
          (SELECT_QSRC (CRORC  $lhs, $rhs), $tval, $fval)>;
def : Pat<(v4f32 (selectcc i1:$lhs, i1:$rhs, v4f32:$tval, v4f32:$fval, SETGT)),
          (SELECT_QSRC (CRANDC $rhs, $lhs), $tval, $fval)>;
def : Pat<(v4f32 (selectcc i1:$lhs, i1:$rhs, v4f32:$tval, v4f32:$fval, SETUGT)),
          (SELECT_QSRC (CRANDC $lhs, $rhs), $tval, $fval)>;
def : Pat<(v4f32 (selectcc i1:$lhs, i1:$rhs, v4f32:$tval, v4f32:$fval, SETNE)),
          (SELECT_QSRC (CRXOR $lhs, $rhs), $tval, $fval)>;

def : Pat<(v4i1 (selectcc i1:$lhs, i1:$rhs, v4i1:$tval, v4i1:$fval, SETLT)),
          (SELECT_QBRC (CRANDC $lhs, $rhs), $tval, $fval)>;
def : Pat<(v4i1 (selectcc i1:$lhs, i1:$rhs, v4i1:$tval, v4i1:$fval, SETULT)),
          (SELECT_QBRC (CRANDC $rhs, $lhs), $tval, $fval)>;
def : Pat<(v4i1 (selectcc i1:$lhs, i1:$rhs, v4i1:$tval, v4i1:$fval, SETLE)),
          (SELECT_QBRC (CRORC  $lhs, $rhs), $tval, $fval)>;
def : Pat<(v4i1 (selectcc i1:$lhs, i1:$rhs, v4i1:$tval, v4i1:$fval, SETULE)),
          (SELECT_QBRC (CRORC  $rhs, $lhs), $tval, $fval)>;
def : Pat<(v4i1 (selectcc i1:$lhs, i1:$rhs, v4i1:$tval, v4i1:$fval, SETEQ)),
          (SELECT_QBRC (CREQV $lhs, $rhs), $tval, $fval)>;
def : Pat<(v4i1 (selectcc i1:$lhs, i1:$rhs, v4i1:$tval, v4i1:$fval, SETGE)),
          (SELECT_QBRC (CRORC  $rhs, $lhs), $tval, $fval)>;
def : Pat<(v4i1 (selectcc i1:$lhs, i1:$rhs, v4i1:$tval, v4i1:$fval, SETUGE)),
          (SELECT_QBRC (CRORC  $lhs, $rhs), $tval, $fval)>;
def : Pat<(v4i1 (selectcc i1:$lhs, i1:$rhs, v4i1:$tval, v4i1:$fval, SETGT)),
          (SELECT_QBRC (CRANDC $rhs, $lhs), $tval, $fval)>;
def : Pat<(v4i1 (selectcc i1:$lhs, i1:$rhs, v4i1:$tval, v4i1:$fval, SETUGT)),
          (SELECT_QBRC (CRANDC $lhs, $rhs), $tval, $fval)>;
def : Pat<(v4i1 (selectcc i1:$lhs, i1:$rhs, v4i1:$tval, v4i1:$fval, SETNE)),
          (SELECT_QBRC (CRXOR $lhs, $rhs), $tval, $fval)>;

} // end HasQPX

let Predicates = [HasQPX, NoNaNsFPMath] in {
def : Pat<(fminnum v4f64:$FRA, v4f64:$FRB),
          (QVFSELb (QVFCMPLTb $FRA, $FRB), $FRB, $FRA)>;
def : Pat<(fmaxnum v4f64:$FRA, v4f64:$FRB),
          (QVFSELb (QVFCMPGTb $FRA, $FRB), $FRB, $FRA)>;

def : Pat<(fminnum v4f32:$FRA, v4f32:$FRB),
          (QVFSELbs (QVFCMPLTbs $FRA, $FRB), $FRB, $FRA)>;
def : Pat<(fmaxnum v4f32:$FRA, v4f32:$FRB),
          (QVFSELbs (QVFCMPGTbs $FRA, $FRB), $FRB, $FRA)>;
}

let Predicates = [HasQPX, NaNsFPMath] in {
// When either of these operands is NaN, we should return the other operand.
// QVFCMPLT/QVFCMPGT return false is either operand is NaN, which means we need
// to explicitly or with a NaN test on the second operand.
def : Pat<(fminnum v4f64:$FRA, v4f64:$FRB),
          (QVFSELb (QVFLOGICALb (QVFCMPLTb $FRA, $FRB),
                                (QVFTSTNANb $FRB, $FRB), (i32 7)),
                   $FRB, $FRA)>;
def : Pat<(fmaxnum v4f64:$FRA, v4f64:$FRB),
          (QVFSELb (QVFLOGICALb (QVFCMPGTb $FRA, $FRB),
                                (QVFTSTNANb $FRB, $FRB), (i32 7)),
                   $FRB, $FRA)>;

def : Pat<(fminnum v4f32:$FRA, v4f32:$FRB),
          (QVFSELbs (QVFLOGICALb (QVFCMPLTbs $FRA, $FRB),
                                 (QVFTSTNANbs $FRB, $FRB), (i32 7)),
                   $FRB, $FRA)>;
def : Pat<(fmaxnum v4f32:$FRA, v4f32:$FRB),
          (QVFSELbs (QVFLOGICALb (QVFCMPGTbs $FRA, $FRB),
                                 (QVFTSTNANbs $FRB, $FRB), (i32 7)),
                   $FRB, $FRA)>;
}