home *** CD-ROM | disk | FTP | other *** search
/ Scene Storm / Scene Storm - Volume 1.iso / coding / tools / gcc / gcc270_src.lha / gcc-2.7.0-amiga / config / rs6000 / rs6000.md < prev    next >
Encoding:
Text File  |  1995-06-15  |  229.1 KB  |  7,240 lines

  1. ;; Machine description for IBM RISC System 6000 (POWER) for GNU C compiler
  2. ;; Copyright (C) 1990, 91, 92, 93, 94, 1995 Free Software Foundation, Inc.
  3. ;; Contributed by Richard Kenner (kenner@vlsi1.ultra.nyu.edu)
  4.  
  5. ;; This file is part of GNU CC.
  6.  
  7. ;; GNU CC is free software; you can redistribute it and/or modify
  8. ;; it under the terms of the GNU General Public License as published by
  9. ;; the Free Software Foundation; either version 2, or (at your option)
  10. ;; any later version.
  11.  
  12. ;; GNU CC is distributed in the hope that it will be useful,
  13. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15. ;; GNU General Public License for more details.
  16.  
  17. ;; You should have received a copy of the GNU General Public License
  18. ;; along with GNU CC; see the file COPYING.  If not, write to
  19. ;; the Free Software Foundation, 59 Temple Place - Suite 330,
  20. ;; Boston, MA 02111-1307, USA.
  21.  
  22. ;;- See file "rtl.def" for documentation on define_insn, match_*, et. al.
  23.  
  24. ;; Define an insn type attribute.  This is used in function unit delay
  25. ;; computations.
  26. (define_attr "type" "integer,load,fpload,imul,idiv,branch,compare,delayed_compare,fpcompare,mtjmpr,fp,dmul,sdiv,ddiv,ssqrt,dsqrt,jmpreg"
  27.   (const_string "integer"))
  28.  
  29. ;; Length (in bytes).
  30. (define_attr "length" ""
  31.   (if_then_else (eq_attr "type" "branch")
  32.         (if_then_else (and (ge (minus (pc) (match_dup 0))
  33.                        (const_int -32768))
  34.                    (lt (minus (pc) (match_dup 0))
  35.                        (const_int 32767)))
  36.                   (const_int 8)
  37.                   (const_int 12))
  38.         (const_int 4)))
  39.  
  40. ;; Processor type -- this attribute must exactly match the processor_type
  41. ;; enumeration in rs6000.h.
  42.  
  43. (define_attr "cpu" "rios1,rios2,ppc403,ppc601,ppc603,ppc604,ppc620"
  44.   (const (symbol_ref "rs6000_cpu_attr")))
  45.  
  46. ; (define_function_unit NAME MULTIPLICITY SIMULTANEITY
  47. ;            TEST READY-DELAY ISSUE-DELAY [CONFLICT-LIST])
  48.  
  49. ; Load/Store Unit -- POWER/2 and pure PowerPC only
  50. ; (POWER and 601 use Integer Unit)
  51. (define_function_unit "lsu" 1 0
  52.   (and (eq_attr "type" "load")
  53.        (eq_attr "cpu" "rios2,ppc603,ppc604,ppc620"))
  54.   2 0)
  55.  
  56. (define_function_unit "lsu" 1 0
  57.   (and (eq_attr "type" "fpload")
  58.        (eq_attr "cpu" "rios2,ppc603,ppc604,ppc620"))
  59.   2 0)
  60.  
  61. (define_function_unit "iu" 1 0
  62.   (and (eq_attr "type" "load")
  63.        (eq_attr "cpu" "rios1,ppc403,ppc601"))
  64.   2 0)
  65.  
  66. (define_function_unit "iu" 1 0
  67.   (and (eq_attr "type" "fpload")
  68.        (eq_attr "cpu" "rios1,ppc601"))
  69.   3 0)
  70.  
  71. ; Integer Unit (RIOS1, PPC601, PPC603)
  72. ; Trivial operations take one cycle which need not be listed here.
  73. (define_function_unit "iu" 1 0
  74.   (and (eq_attr "type" "imul")
  75.        (eq_attr "cpu" "rios1"))
  76.   3 3)
  77.  
  78. (define_function_unit "iu" 1 0
  79.   (and (eq_attr "type" "imul")
  80.        (eq_attr "cpu" "ppc403"))
  81.   4 4)
  82.  
  83. (define_function_unit "iu" 1 0
  84.   (and (eq_attr "type" "imul")
  85.        (eq_attr "cpu" "ppc601,ppc603"))
  86.   5 5)
  87.  
  88. (define_function_unit "iu" 1 0
  89.   (and (eq_attr "type" "idiv")
  90.        (eq_attr "cpu" "rios1"))
  91.   19 19)
  92.  
  93. (define_function_unit "iu" 1 0
  94.   (and (eq_attr "type" "idiv")
  95.        (eq_attr "cpu" "ppc403"))
  96.   33 33)
  97.  
  98. (define_function_unit "iu" 1 0
  99.   (and (eq_attr "type" "idiv")
  100.        (eq_attr "cpu" "ppc601"))
  101.   36 36)
  102.  
  103. (define_function_unit "iu" 1 0
  104.   (and (eq_attr "type" "idiv")
  105.        (eq_attr "cpu" "ppc603"))
  106.   37 36)
  107.  
  108. ; RIOS2 has two integer units: a primary one which can perform all
  109. ; operations and a secondary one which is fed in lock step with the first
  110. ; and can perform "simple" integer operations.
  111. (define_function_unit "iu2" 2 0
  112.   (and (eq_attr "type" "integer")
  113.        (eq_attr "cpu" "rios2"))
  114.   1 0
  115.   [(eq_attr "type" "imul,idiv")])
  116.  
  117. (define_function_unit "imuldiv" 1 0
  118.   (and (eq_attr "type" "imul")
  119.        (eq_attr "cpu" "rios2"))
  120.   2 2
  121.   [(eq_attr "type" "integer")])
  122.  
  123. (define_function_unit "imuldiv" 1 0
  124.   (and (eq_attr "type" "idiv")
  125.        (eq_attr "cpu" "rios2"))
  126.   13 13
  127.   [(eq_attr "type" "integer")])
  128.  
  129. ; PPC604 has three integer units: one primary and two secondary.
  130. (define_function_unit "iu3" 3 0
  131.   (and (eq_attr "type" "integer")
  132.        (eq_attr "cpu" "ppc604,ppc620"))
  133.   1 0
  134.   [(eq_attr "type" "imul,idiv")])
  135.  
  136. (define_function_unit "imuldiv" 1 0
  137.   (and (eq_attr "type" "imul")
  138.        (eq_attr "cpu" "ppc604,ppc620"))
  139.   4 2
  140.   [(eq_attr "type" "integer")])
  141.  
  142. (define_function_unit "imuldiv" 1 0
  143.   (and (eq_attr "type" "idiv")
  144.        (eq_attr "cpu" "ppc604,ppc620"))
  145.   20 19
  146.   [(eq_attr "type" "integer")])
  147.  
  148. ; Branch Processing Unit
  149. (define_function_unit "bpu" 1 0
  150.   (eq_attr "type" "compare")
  151.   4 0)
  152.  
  153. (define_function_unit "bpu" 1 0
  154.   (eq_attr "type" "delayed_compare")
  155.   5 0)
  156.  
  157. (define_function_unit "bpu" 1 0
  158.   (and (eq_attr "type" "fpcompare")
  159.        (eq_attr "cpu" "rios1,rios2"))
  160.   8 0)
  161.  
  162. (define_function_unit "bpu" 1 0
  163.   (and (eq_attr "type" "fpcompare")
  164.        (eq_attr "cpu" "ppc601,ppc603,ppc604,ppc620"))
  165.   4 0)
  166.  
  167. (define_function_unit "bpu" 1 0
  168.   (and (eq_attr "type" "mtjmpr")
  169.        (eq_attr "cpu" "rios1,rios2"))
  170.   5 0)
  171.  
  172. (define_function_unit "bpu" 1 0
  173.   (and (eq_attr "type" "mtjmpr")
  174.        (eq_attr "cpu" "ppc403,ppc601,ppc603,ppc604,ppc620"))
  175.   4 0)
  176.  
  177. ; Floating Point Unit (RIOS1, PPC601, PPC603, PPC604).
  178. (define_function_unit "fpu" 1 0
  179.   (and (eq_attr "type" "fp,dmul")
  180.        (eq_attr "cpu" "rios1"))
  181.   2 0)
  182.  
  183. (define_function_unit "fpu" 1 0
  184.   (and (eq_attr "type" "fp")
  185.        (eq_attr "cpu" "ppc601"))
  186.   4 0)
  187.  
  188. (define_function_unit "fpu" 1 0
  189.   (and (eq_attr "type" "fp")
  190.        (eq_attr "cpu" "ppc603,ppc604,ppc620"))
  191.   3 0)
  192.  
  193. (define_function_unit "fpu" 1 0
  194.   (and (eq_attr "type" "dmul")
  195.        (eq_attr "cpu" "ppc601"))
  196.   5 5)
  197.  
  198. (define_function_unit "fpu" 1 0
  199.   (and (eq_attr "type" "dmul")
  200.        (eq_attr "cpu" "ppc603"))
  201.   4 2)
  202.  
  203. (define_function_unit "fpu" 1 0
  204.   (and (eq_attr "type" "dmul")
  205.        (eq_attr "cpu" "ppc604,ppc620"))
  206.   3 0)
  207.  
  208. (define_function_unit "fpu" 1 0
  209.   (and (eq_attr "type" "sdiv,ddiv")
  210.        (eq_attr "cpu" "rios1"))
  211.   19 19)
  212.  
  213. (define_function_unit "fpu" 1 0
  214.   (and (eq_attr "type" "sdiv")
  215.        (eq_attr "cpu" "ppc601"))
  216.   17 17)
  217.  
  218. (define_function_unit "fpu" 1 0
  219.   (and (eq_attr "type" "sdiv")
  220.        (eq_attr "cpu" "ppc603,ppc604,ppc620"))
  221.   18 18)
  222.  
  223. (define_function_unit "fpu" 1 0
  224.   (and (eq_attr "type" "ddiv")
  225.        (eq_attr "cpu" "ppc601,ppc604,ppc620"))
  226.   31 31)
  227.  
  228. (define_function_unit "fpu" 1 0
  229.   (and (eq_attr "type" "ddiv")
  230.        (eq_attr "cpu" "ppc603"))
  231.   33 33)
  232.  
  233. (define_function_unit "fpu" 1 0
  234.   (and (eq_attr "type" "ssqrt")
  235.        (eq_attr "cpu" "ppc620"))
  236.   31 31)
  237.  
  238. (define_function_unit "fpu" 1 0
  239.   (and (eq_attr "type" "dsqrt")
  240.        (eq_attr "cpu" "ppc620"))
  241.   31 31)
  242.  
  243. ; RIOS2 has two symmetric FPUs.
  244. (define_function_unit "fpu2" 2 0
  245.   (and (eq_attr "type" "fp")
  246.        (eq_attr "cpu" "rios2"))
  247.   2 0)
  248.  
  249. (define_function_unit "fpu2" 2 0
  250.   (and (eq_attr "type" "dmul")
  251.        (eq_attr "cpu" "rios2"))
  252.   2 0)
  253.  
  254. (define_function_unit "fpu2" 2 0
  255.   (and (eq_attr "type" "sdiv,ddiv")
  256.        (eq_attr "cpu" "rios2"))
  257.   17 17)
  258.  
  259. (define_function_unit "fpu2" 2 0
  260.   (and (eq_attr "type" "ssqrt,dsqrt")
  261.        (eq_attr "cpu" "rios2"))
  262.   26 26)
  263.  
  264. ;; Start with fixed-point load and store insns.  Here we put only the more
  265. ;; complex forms.  Basic data transfer is done later.
  266.  
  267. (define_expand "zero_extendqidi2"
  268.   [(set (match_operand:DI 0 "gpc_reg_operand" "")
  269.     (zero_extend:DI (match_operand:QI 1 "gpc_reg_operand" "")))]
  270.   "TARGET_POWERPC64"
  271.   "")
  272.  
  273. (define_insn ""
  274.   [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
  275.     (zero_extend:DI (match_operand:QI 1 "reg_or_mem_operand" "m,r")))]
  276.   "TARGET_POWERPC64"
  277.   "@
  278.    lbz%U1%X1 %0,%1
  279.    rldicl %0,%1,0,56"
  280.   [(set_attr "type" "load,*")])
  281.  
  282. (define_insn ""
  283.   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
  284.     (compare:CC (zero_extend:DI (match_operand:QI 1 "gpc_reg_operand" "r"))
  285.             (const_int 0)))
  286.    (clobber (match_scratch:DI 2 "=r"))]
  287.   "TARGET_POWERPC64"
  288.   "rldicl. %2,%1,0,56"
  289.   [(set_attr "type" "compare")])
  290.  
  291. (define_insn ""
  292.   [(set (match_operand:CC 2 "cc_reg_operand" "=x")
  293.     (compare:CC (zero_extend:DI (match_operand:QI 1 "gpc_reg_operand" "r"))
  294.             (const_int 0)))
  295.    (set (match_operand:DI 0 "gpc_reg_operand" "=r")
  296.     (zero_extend:DI (match_dup 1)))]
  297.   "TARGET_POWERPC64"
  298.   "rldicl. %0,%1,0,56"
  299.   [(set_attr "type" "compare")])
  300.  
  301. (define_insn "extendqidi2"
  302.   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
  303.     (sign_extend:DI (match_operand:QI 1 "gpc_reg_operand" "r")))]
  304.   "TARGET_POWERPC64"
  305.   "extsb %0,%1")
  306.  
  307. (define_insn ""
  308.   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
  309.     (compare:CC (sign_extend:DI (match_operand:QI 1 "gpc_reg_operand" "r"))
  310.             (const_int 0)))
  311.    (clobber (match_scratch:DI 2 "=r"))]
  312.   "TARGET_POWERPC64"
  313.   "extsb. %2,%1"
  314.   [(set_attr "type" "compare")])
  315.  
  316. (define_insn ""
  317.   [(set (match_operand:CC 2 "cc_reg_operand" "=x")
  318.     (compare:CC (sign_extend:DI (match_operand:QI 1 "gpc_reg_operand" "r"))
  319.             (const_int 0)))
  320.    (set (match_operand:DI 0 "gpc_reg_operand" "=r")
  321.     (sign_extend:DI (match_dup 1)))]
  322.   "TARGET_POWERPC64"
  323.   "extsb. %0,%1"
  324.   [(set_attr "type" "compare")])
  325.  
  326. (define_expand "zero_extendhidi2"
  327.   [(set (match_operand:DI 0 "gpc_reg_operand" "")
  328.     (zero_extend:DI (match_operand:HI 1 "gpc_reg_operand" "")))]
  329.   "TARGET_POWERPC64"
  330.   "")
  331.  
  332. (define_insn ""
  333.   [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
  334.     (zero_extend:DI (match_operand:HI 1 "reg_or_mem_operand" "m,r")))]
  335.   "TARGET_POWERPC64"
  336.   "@
  337.    lhz%U1%X1 %0,%1
  338.    rldicl %0,%1,0,48"
  339.   [(set_attr "type" "load,*")])
  340.  
  341. (define_insn ""
  342.   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
  343.     (compare:CC (zero_extend:DI (match_operand:HI 1 "gpc_reg_operand" "r"))
  344.             (const_int 0)))
  345.    (clobber (match_scratch:DI 2 "=r"))]
  346.   "TARGET_POWERPC64"
  347.   "rldicl. %2,%1,0,48"
  348.   [(set_attr "type" "compare")])
  349.  
  350. (define_insn ""
  351.   [(set (match_operand:CC 2 "cc_reg_operand" "=x")
  352.     (compare:CC (zero_extend:DI (match_operand:HI 1 "gpc_reg_operand" "r"))
  353.             (const_int 0)))
  354.    (set (match_operand:DI 0 "gpc_reg_operand" "=r")
  355.     (zero_extend:DI (match_dup 1)))]
  356.   "TARGET_POWERPC64"
  357.   "rldicl. %0,%1,0,48"
  358.   [(set_attr "type" "compare")])
  359.  
  360. (define_expand "extendhidi2"
  361.   [(set (match_operand:DI 0 "gpc_reg_operand" "")
  362.     (sign_extend:DI (match_operand:HI 1 "gpc_reg_operand" "")))]
  363.   "TARGET_POWERPC64"
  364.   "")
  365.  
  366. (define_insn ""
  367.   [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
  368.     (sign_extend:DI (match_operand:HI 1 "reg_or_mem_operand" "m,r")))]
  369.   "TARGET_POWERPC64"
  370.   "@
  371.    lha%U1%X1 %0,%1
  372.    extsh %0,%1"
  373.   [(set_attr "type" "load,*")])
  374.  
  375. (define_insn ""
  376.   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
  377.     (compare:CC (sign_extend:DI (match_operand:HI 1 "gpc_reg_operand" "r"))
  378.             (const_int 0)))
  379.    (clobber (match_scratch:DI 2 "=r"))]
  380.   "TARGET_POWERPC64"
  381.   "extsh. %2,%1"
  382.   [(set_attr "type" "compare")])
  383.  
  384. (define_insn ""
  385.   [(set (match_operand:CC 2 "cc_reg_operand" "=x")
  386.     (compare:CC (sign_extend:DI (match_operand:HI 1 "gpc_reg_operand" "r"))
  387.             (const_int 0)))
  388.    (set (match_operand:DI 0 "gpc_reg_operand" "=r")
  389.     (sign_extend:DI (match_dup 1)))]
  390.   "TARGET_POWERPC64"
  391.   "extsh. %0,%1"
  392.   [(set_attr "type" "compare")])
  393.  
  394. (define_expand "zero_extendsidi2"
  395.   [(set (match_operand:DI 0 "gpc_reg_operand" "")
  396.     (zero_extend:DI (match_operand:SI 1 "gpc_reg_operand" "")))]
  397.   "TARGET_POWERPC64"
  398.   "")
  399.  
  400. (define_insn ""
  401.   [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
  402.     (zero_extend:DI (match_operand:SI 1 "reg_or_mem_operand" "m,r")))]
  403.   "TARGET_POWERPC64"
  404.   "@
  405.    lwz%U1%X1 %0,%1
  406.    rldicl %0,%1,0,32"
  407.   [(set_attr "type" "load,*")])
  408.  
  409. (define_insn ""
  410.   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
  411.     (compare:CC (zero_extend:DI (match_operand:SI 1 "gpc_reg_operand" "r"))
  412.             (const_int 0)))
  413.    (clobber (match_scratch:DI 2 "=r"))]
  414.   "TARGET_POWERPC64"
  415.   "rldicl. %2,%1,0,32"
  416.   [(set_attr "type" "compare")])
  417.  
  418. (define_insn ""
  419.   [(set (match_operand:CC 2 "cc_reg_operand" "=x")
  420.     (compare:CC (zero_extend:DI (match_operand:SI 1 "gpc_reg_operand" "r"))
  421.             (const_int 0)))
  422.    (set (match_operand:DI 0 "gpc_reg_operand" "=r")
  423.     (zero_extend:DI (match_dup 1)))]
  424.   "TARGET_POWERPC64"
  425.   "rldicl. %0,%1,0,32"
  426.   [(set_attr "type" "compare")])
  427.  
  428. (define_expand "extendsidi2"
  429.   [(set (match_operand:DI 0 "gpc_reg_operand" "")
  430.     (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" "")))]
  431.   "TARGET_POWERPC64"
  432.   "")
  433.  
  434. (define_insn ""
  435.   [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
  436.     (sign_extend:DI (match_operand:SI 1 "lwa_operand" "m,r")))]
  437.   "TARGET_POWERPC64"
  438.   "@
  439.    lwa%U1%X1 %0,%1
  440.    extsw %0,%1"
  441.   [(set_attr "type" "load,*")])
  442.  
  443. (define_insn ""
  444.   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
  445.     (compare:CC (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" "r"))
  446.             (const_int 0)))
  447.    (clobber (match_scratch:DI 2 "=r"))]
  448.   "TARGET_POWERPC64"
  449.   "extsw. %2,%1"
  450.   [(set_attr "type" "compare")])
  451.  
  452. (define_insn ""
  453.   [(set (match_operand:CC 2 "cc_reg_operand" "=x")
  454.     (compare:CC (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" "r"))
  455.             (const_int 0)))
  456.    (set (match_operand:DI 0 "gpc_reg_operand" "=r")
  457.     (sign_extend:DI (match_dup 1)))]
  458.   "TARGET_POWERPC64"
  459.   "extsw. %0,%1"
  460.   [(set_attr "type" "compare")])
  461.  
  462. (define_expand "zero_extendqisi2"
  463.   [(set (match_operand:SI 0 "gpc_reg_operand" "")
  464.     (zero_extend:SI (match_operand:QI 1 "gpc_reg_operand" "")))]
  465.   ""
  466.   "")
  467.  
  468. (define_insn ""
  469.   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
  470.     (zero_extend:SI (match_operand:QI 1 "reg_or_mem_operand" "m,r")))]
  471.   ""
  472.   "@
  473.    lbz%U1%X1 %0,%1
  474.    {rlinm|rlwinm} %0,%1,0,0xff"
  475.   [(set_attr "type" "load,*")])
  476.  
  477. (define_insn ""
  478.   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
  479.     (compare:CC (zero_extend:SI (match_operand:QI 1 "gpc_reg_operand" "r"))
  480.             (const_int 0)))
  481.    (clobber (match_scratch:SI 2 "=r"))]
  482.   ""
  483.   "{andil.|andi.} %2,%1,0xff"
  484.   [(set_attr "type" "compare")])
  485.  
  486. (define_insn ""
  487.   [(set (match_operand:CC 2 "cc_reg_operand" "=x")
  488.     (compare:CC (zero_extend:SI (match_operand:QI 1 "gpc_reg_operand" "r"))
  489.             (const_int 0)))
  490.    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
  491.     (zero_extend:SI (match_dup 1)))]
  492.   ""
  493.   "{andil.|andi.} %0,%1,0xff"
  494.   [(set_attr "type" "compare")])
  495.  
  496. (define_expand "extendqisi2"
  497.   [(use (match_operand:SI 0 "gpc_reg_operand" ""))
  498.    (use (match_operand:QI 1 "gpc_reg_operand" ""))]
  499.   ""
  500.   "
  501. {
  502.   if (TARGET_POWERPC)
  503.     emit_insn (gen_extendqisi2_ppc (operands[0], operands[1]));
  504.   else if (TARGET_POWER)
  505.     emit_insn (gen_extendqisi2_power (operands[0], operands[1]));
  506.   else
  507.     emit_insn (gen_extendqisi2_no_power (operands[0], operands[1]));
  508.   DONE;
  509. }")
  510.  
  511. (define_insn "extendqisi2_ppc"
  512.   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
  513.     (sign_extend:SI (match_operand:QI 1 "gpc_reg_operand" "r")))]
  514.   "TARGET_POWERPC"
  515.   "extsb %0,%1")
  516.  
  517. (define_insn ""
  518.   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
  519.     (compare:CC (sign_extend:SI (match_operand:QI 1 "gpc_reg_operand" "r"))
  520.             (const_int 0)))
  521.    (clobber (match_scratch:SI 2 "=r"))]
  522.   "TARGET_POWERPC"
  523.   "extsb. %2,%1"
  524.   [(set_attr "type" "compare")])
  525.  
  526. (define_insn ""
  527.   [(set (match_operand:CC 2 "cc_reg_operand" "=x")
  528.     (compare:CC (sign_extend:SI (match_operand:QI 1 "gpc_reg_operand" "r"))
  529.             (const_int 0)))
  530.    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
  531.     (sign_extend:SI (match_dup 1)))]
  532.   "TARGET_POWERPC"
  533.   "extsb. %0,%1"
  534.   [(set_attr "type" "compare")])
  535.  
  536. (define_expand "extendqisi2_power"
  537.   [(parallel [(set (match_dup 2)
  538.            (ashift:SI (match_operand:QI 1 "gpc_reg_operand" "")
  539.                   (const_int 24)))
  540.           (clobber (scratch:SI))])
  541.    (parallel [(set (match_operand:SI 0 "gpc_reg_operand" "")
  542.            (ashiftrt:SI (match_dup 2)
  543.                 (const_int 24)))
  544.           (clobber (scratch:SI))])]
  545.   "TARGET_POWER"
  546.   "
  547. { operands[1] = gen_lowpart (SImode, operands[1]);
  548.   operands[2] = gen_reg_rtx (SImode); }")
  549.  
  550. (define_expand "extendqisi2_no_power"
  551.   [(set (match_dup 2)
  552.     (ashift:SI (match_operand:QI 1 "gpc_reg_operand" "")
  553.            (const_int 24)))
  554.    (set (match_operand:SI 0 "gpc_reg_operand" "")
  555.     (ashiftrt:SI (match_dup 2)
  556.              (const_int 24)))]
  557.   "! TARGET_POWER && ! TARGET_POWERPC"
  558.   "
  559. { operands[1] = gen_lowpart (SImode, operands[1]);
  560.   operands[2] = gen_reg_rtx (SImode); }")
  561.  
  562. (define_expand "zero_extendqihi2"
  563.   [(set (match_operand:HI 0 "gpc_reg_operand" "")
  564.     (zero_extend:HI (match_operand:QI 1 "gpc_reg_operand" "")))]
  565.   ""
  566.   "")
  567.  
  568. (define_insn ""
  569.   [(set (match_operand:HI 0 "gpc_reg_operand" "=r,r")
  570.     (zero_extend:HI (match_operand:QI 1 "reg_or_mem_operand" "m,r")))]
  571.   ""
  572.   "@
  573.    lbz%U1%X1 %0,%1
  574.    {rlinm|rlwinm} %0,%1,0,0xff"
  575.   [(set_attr "type" "load,*")])
  576.  
  577. (define_insn ""
  578.   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
  579.     (compare:CC (zero_extend:HI (match_operand:QI 1 "gpc_reg_operand" "r"))
  580.             (const_int 0)))
  581.    (clobber (match_scratch:HI 2 "=r"))]
  582.   ""
  583.   "{andil.|andi.} %2,%1,0xff"
  584.   [(set_attr "type" "compare")])
  585.  
  586. (define_insn ""
  587.   [(set (match_operand:CC 2 "cc_reg_operand" "=x")
  588.     (compare:CC (zero_extend:HI (match_operand:QI 1 "gpc_reg_operand" "r"))
  589.             (const_int 0)))
  590.    (set (match_operand:HI 0 "gpc_reg_operand" "=r")
  591.     (zero_extend:HI (match_dup 1)))]
  592.   ""
  593.   "{andil.|andi.} %0,%1,0xff"
  594.   [(set_attr "type" "compare")])
  595.  
  596. (define_expand "extendqihi2"
  597.   [(use (match_operand:HI 0 "gpc_reg_operand" ""))
  598.    (use (match_operand:QI 1 "gpc_reg_operand" ""))]
  599.   ""
  600.   "
  601. {
  602.   if (TARGET_POWERPC)
  603.     emit_insn (gen_extendqihi2_ppc (operands[0], operands[1]));
  604.   else if (TARGET_POWER)
  605.     emit_insn (gen_extendqihi2_power (operands[0], operands[1]));
  606.   else
  607.     emit_insn (gen_extendqihi2_no_power (operands[0], operands[1]));
  608.   DONE;
  609. }")
  610.  
  611. (define_insn "extendqihi2_ppc"
  612.   [(set (match_operand:HI 0 "gpc_reg_operand" "=r")
  613.     (sign_extend:HI (match_operand:QI 1 "gpc_reg_operand" "r")))]
  614.   "TARGET_POWERPC"
  615.   "extsb %0,%1")
  616.  
  617. (define_insn ""
  618.   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
  619.     (compare:CC (sign_extend:HI (match_operand:QI 1 "gpc_reg_operand" "r"))
  620.             (const_int 0)))
  621.    (clobber (match_scratch:HI 2 "=r"))]
  622.   "TARGET_POWERPC"
  623.   "extsb. %2,%1"
  624.   [(set_attr "type" "compare")])
  625.  
  626. (define_insn ""
  627.   [(set (match_operand:CC 2 "cc_reg_operand" "=x")
  628.     (compare:CC (sign_extend:HI (match_operand:QI 1 "gpc_reg_operand" "r"))
  629.             (const_int 0)))
  630.    (set (match_operand:HI 0 "gpc_reg_operand" "=r")
  631.     (sign_extend:HI (match_dup 1)))]
  632.   "TARGET_POWERPC"
  633.   "extsb. %0,%1"
  634.   [(set_attr "type" "compare")])
  635.  
  636. (define_expand "extendqihi2_power"
  637.   [(parallel [(set (match_dup 2)
  638.            (ashift:SI (match_operand:QI 1 "gpc_reg_operand" "")
  639.                   (const_int 24)))
  640.           (clobber (scratch:SI))])
  641.    (parallel [(set (match_operand:HI 0 "gpc_reg_operand" "")
  642.            (ashiftrt:SI (match_dup 2)
  643.                 (const_int 24)))
  644.           (clobber (scratch:SI))])]
  645.   "TARGET_POWER"
  646.   "
  647. { operands[0] = gen_lowpart (SImode, operands[0]);
  648.   operands[1] = gen_lowpart (SImode, operands[1]);
  649.   operands[2] = gen_reg_rtx (SImode); }")
  650.  
  651. (define_expand "extendqihi2_no_power"
  652.   [(set (match_dup 2)
  653.     (ashift:SI (match_operand:QI 1 "gpc_reg_operand" "")
  654.            (const_int 24)))
  655.    (set (match_operand:HI 0 "gpc_reg_operand" "")
  656.     (ashiftrt:SI (match_dup 2)
  657.              (const_int 24)))]
  658.   "! TARGET_POWER && ! TARGET_POWERPC"
  659.   "
  660. { operands[0] = gen_lowpart (SImode, operands[0]);
  661.   operands[1] = gen_lowpart (SImode, operands[1]);
  662.   operands[2] = gen_reg_rtx (SImode); }")
  663.  
  664. (define_expand "zero_extendhisi2"
  665.   [(set (match_operand:SI 0 "gpc_reg_operand" "")
  666.     (zero_extend:SI (match_operand:HI 1 "gpc_reg_operand" "")))]
  667.   ""
  668.   "")
  669.  
  670. (define_insn ""
  671.   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
  672.     (zero_extend:SI (match_operand:HI 1 "reg_or_mem_operand" "m,r")))]
  673.   ""
  674.   "@
  675.    lhz%U1%X1 %0,%1
  676.    {rlinm|rlwinm} %0,%1,0,0xffff"
  677.   [(set_attr "type" "load,*")])
  678.  
  679. (define_insn ""
  680.   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
  681.     (compare:CC (zero_extend:SI (match_operand:HI 1 "gpc_reg_operand" "r"))
  682.             (const_int 0)))
  683.    (clobber (match_scratch:SI 2 "=r"))]
  684.   ""
  685.   "{andil.|andi.} %2,%1,0xffff"
  686.   [(set_attr "type" "compare")])
  687.  
  688. (define_insn ""
  689.   [(set (match_operand:CC 2 "cc_reg_operand" "=x")
  690.     (compare:CC (zero_extend:SI (match_operand:HI 1 "gpc_reg_operand" "r"))
  691.             (const_int 0)))
  692.    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
  693.     (zero_extend:SI (match_dup 1)))]
  694.   ""
  695.   "{andil.|andi.} %0,%1,0xffff"
  696.   [(set_attr "type" "compare")])
  697.  
  698. (define_expand "extendhisi2"
  699.   [(set (match_operand:SI 0 "gpc_reg_operand" "")
  700.     (sign_extend:SI (match_operand:HI 1 "gpc_reg_operand" "")))]
  701.   ""
  702.   "")
  703.  
  704. (define_insn ""
  705.   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
  706.     (sign_extend:SI (match_operand:HI 1 "reg_or_mem_operand" "m,r")))]
  707.   ""
  708.   "@
  709.    lha%U1%X1 %0,%1
  710.    {exts|extsh} %0,%1"
  711.   [(set_attr "type" "load,*")])
  712.  
  713. (define_insn ""
  714.   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
  715.     (compare:CC (sign_extend:SI (match_operand:HI 1 "gpc_reg_operand" "r"))
  716.             (const_int 0)))
  717.    (clobber (match_scratch:SI 2 "=r"))]
  718.   ""
  719.   "{exts.|extsh.} %2,%1"
  720.   [(set_attr "type" "compare")])
  721.  
  722. (define_insn ""
  723.   [(set (match_operand:CC 2 "cc_reg_operand" "=x")
  724.     (compare:CC (sign_extend:SI (match_operand:HI 1 "gpc_reg_operand" "r"))
  725.             (const_int 0)))
  726.    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
  727.     (sign_extend:SI (match_dup 1)))]
  728.   ""
  729.   "{exts.|extsh.} %0,%1"
  730.   [(set_attr "type" "compare")])
  731.  
  732. ;; Fixed-point arithmetic insns.
  733.  
  734. ;; Discourage ai/addic because of carry but provide it in an alternative
  735. ;; allowing register zero as source.
  736. (define_insn "addsi3"
  737.   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r,?r,r")
  738.     (plus:SI (match_operand:SI 1 "gpc_reg_operand" "%r,b,r,b")
  739.          (match_operand:SI 2 "add_operand" "r,I,I,J")))]
  740.   ""
  741.   "@
  742.    {cax|add} %0,%1,%2
  743.    {cal %0,%2(%1)|addi %0,%1,%2}
  744.    {ai|addic} %0,%1,%2
  745.    {cau|addis} %0,%1,%u2")
  746.  
  747. (define_insn ""
  748.   [(set (match_operand:CC 0 "cc_reg_operand" "=x,x")
  749.     (compare:CC (plus:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
  750.                  (match_operand:SI 2 "reg_or_short_operand" "r,I"))
  751.             (const_int 0)))
  752.    (clobber (match_scratch:SI 3 "=r,r"))]
  753.   ""
  754.   "@
  755.    {cax.|add.} %3,%1,%2
  756.    {ai.|addic.} %3,%1,%2"
  757.   [(set_attr "type" "compare")])
  758.  
  759. (define_insn ""
  760.   [(set (match_operand:CC 3 "cc_reg_operand" "=x,x")
  761.     (compare:CC (plus:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
  762.                  (match_operand:SI 2 "reg_or_short_operand" "r,I"))
  763.             (const_int 0)))
  764.    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
  765.     (plus:SI (match_dup 1) (match_dup 2)))]
  766.   ""
  767.   "@
  768.    {cax.|add.} %0,%1,%2
  769.    {ai.|addic.} %0,%1,%2"
  770.   [(set_attr "type" "compare")])
  771.  
  772. ;; Split an add that we can't do in one insn into two insns, each of which
  773. ;; does one 16-bit part.  This is used by combine.  Note that the low-order
  774. ;; add should be last in case the result gets used in an address.
  775.  
  776. (define_split
  777.   [(set (match_operand:SI 0 "gpc_reg_operand" "")
  778.     (plus:SI (match_operand:SI 1 "gpc_reg_operand" "")
  779.          (match_operand:SI 2 "non_add_cint_operand" "")))]
  780.   ""
  781.   [(set (match_dup 0) (plus:SI (match_dup 1) (match_dup 3)))
  782.    (set (match_dup 0) (plus:SI (match_dup 0) (match_dup 4)))]
  783. "
  784. {
  785.   int low = INTVAL (operands[2]) & 0xffff;
  786.   int high = (unsigned) INTVAL (operands[2]) >> 16;
  787.  
  788.   if (low & 0x8000)
  789.     high++, low |= 0xffff0000;
  790.  
  791.   operands[3] = gen_rtx (CONST_INT, VOIDmode, high << 16);
  792.   operands[4] = gen_rtx (CONST_INT, VOIDmode, low);
  793. }")
  794.  
  795. (define_insn "one_cmplsi2"
  796.   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
  797.     (not:SI (match_operand:SI 1 "gpc_reg_operand" "r")))]
  798.   ""
  799.   "nor %0,%1,%1")
  800.  
  801. (define_insn ""
  802.   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
  803.     (compare:CC (not:SI (match_operand:SI 1 "gpc_reg_operand" "r"))
  804.             (const_int 0)))
  805.    (clobber (match_scratch:SI 2 "=r"))]
  806.   ""
  807.   "nor. %2,%1,%1"
  808.   [(set_attr "type" "compare")])
  809.  
  810. (define_insn ""
  811.   [(set (match_operand:CC 2 "cc_reg_operand" "=x")
  812.     (compare:CC (not:SI (match_operand:SI 1 "gpc_reg_operand" "r"))
  813.             (const_int 0)))
  814.    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
  815.     (not:SI (match_dup 1)))]
  816.   ""
  817.   "nor. %0,%2,%1"
  818.   [(set_attr "type" "compare")])
  819.  
  820. (define_insn ""
  821.   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
  822.     (minus:SI (match_operand:SI 1 "reg_or_short_operand" "rI")
  823.           (match_operand:SI 2 "gpc_reg_operand" "r")))]
  824.   "! TARGET_POWERPC"
  825.   "{sf%I1|subf%I1c} %0,%2,%1")
  826.  
  827. (define_insn ""
  828.   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
  829.     (minus:SI (match_operand:SI 1 "reg_or_short_operand" "r,I")
  830.           (match_operand:SI 2 "gpc_reg_operand" "r,r")))]
  831.   "TARGET_POWERPC"
  832.   "@
  833.    subf %0,%2,%1
  834.    subfic %0,%2,%1")
  835.  
  836. (define_insn ""
  837.   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
  838.     (compare:CC (minus:SI (match_operand:SI 1 "gpc_reg_operand" "r")
  839.                   (match_operand:SI 2 "gpc_reg_operand" "r"))
  840.             (const_int 0)))
  841.    (clobber (match_scratch:SI 3 "=r"))]
  842.   "! TARGET_POWERPC"
  843.   "{sf.|subfc.} %3,%2,%1"
  844.   [(set_attr "type" "compare")])
  845.  
  846. (define_insn ""
  847.   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
  848.     (compare:CC (minus:SI (match_operand:SI 1 "gpc_reg_operand" "r")
  849.                   (match_operand:SI 2 "gpc_reg_operand" "r"))
  850.             (const_int 0)))
  851.    (clobber (match_scratch:SI 3 "=r"))]
  852.   "TARGET_POWERPC"
  853.   "subf. %3,%2,%1"
  854.   [(set_attr "type" "compare")])
  855.  
  856. (define_insn ""
  857.   [(set (match_operand:CC 3 "cc_reg_operand" "=x")
  858.     (compare:CC (minus:SI (match_operand:SI 1 "gpc_reg_operand" "r")
  859.                   (match_operand:SI 2 "gpc_reg_operand" "r"))
  860.             (const_int 0)))
  861.    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
  862.     (minus:SI (match_dup 1) (match_dup 2)))]
  863.   "! TARGET_POWERPC"
  864.   "{sf.|subfc.} %0,%2,%1"
  865.   [(set_attr "type" "compare")])
  866.  
  867. (define_insn ""
  868.   [(set (match_operand:CC 3 "cc_reg_operand" "=x")
  869.     (compare:CC (minus:SI (match_operand:SI 1 "gpc_reg_operand" "r")
  870.                   (match_operand:SI 2 "gpc_reg_operand" "r"))
  871.             (const_int 0)))
  872.    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
  873.     (minus:SI (match_dup 1) (match_dup 2)))]
  874.   "TARGET_POWERPC"
  875.   "subf. %0,%2,%1"
  876.   [(set_attr "type" "compare")])
  877.  
  878. (define_expand "subsi3"
  879.   [(set (match_operand:SI 0 "gpc_reg_operand" "")
  880.     (minus:SI (match_operand:SI 1 "reg_or_short_operand" "")
  881.           (match_operand:SI 2 "reg_or_cint_operand" "")))]
  882.   ""
  883.   "
  884. {
  885.   if (GET_CODE (operands[2]) == CONST_INT)
  886.     {
  887.       emit_insn (gen_addsi3 (operands[0], operands[1],
  888.                  negate_rtx (SImode, operands[2])));
  889.       DONE;
  890.     }
  891. }")
  892.  
  893. ;; For SMIN, SMAX, UMIN, and UMAX, we use DEFINE_EXPAND's that involve a doz[i]
  894. ;; instruction and some auxiliary computations.  Then we just have a single
  895. ;; DEFINE_INSN for doz[i] and the define_splits to make them if made by
  896. ;; combine.
  897.  
  898. (define_expand "sminsi3"
  899.   [(set (match_dup 3)
  900.     (if_then_else:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "")
  901.                 (match_operand:SI 2 "reg_or_short_operand" ""))
  902.              (const_int 0)
  903.              (minus:SI (match_dup 2) (match_dup 1))))
  904.    (set (match_operand:SI 0 "gpc_reg_operand" "")
  905.     (minus:SI (match_dup 2) (match_dup 3)))]
  906.   "TARGET_POWER"
  907.   "
  908. { operands[3] = gen_reg_rtx (SImode); }")
  909.  
  910. (define_split
  911.   [(set (match_operand:SI 0 "gpc_reg_operand" "")
  912.     (smin:SI (match_operand:SI 1 "gpc_reg_operand" "")
  913.          (match_operand:SI 2 "reg_or_short_operand" "")))
  914.    (clobber (match_operand:SI 3 "gpc_reg_operand" ""))]
  915.   "TARGET_POWER"
  916.   [(set (match_dup 3)
  917.     (if_then_else:SI (gt:SI (match_dup 1) (match_dup 2))
  918.              (const_int 0)
  919.              (minus:SI (match_dup 2) (match_dup 1))))
  920.    (set (match_dup 0) (minus:SI (match_dup 2) (match_dup 3)))]
  921.   "")
  922.  
  923. (define_expand "smaxsi3"
  924.   [(set (match_dup 3)
  925.     (if_then_else:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "")
  926.                 (match_operand:SI 2 "reg_or_short_operand" ""))
  927.              (const_int 0)
  928.              (minus:SI (match_dup 2) (match_dup 1))))
  929.    (set (match_operand:SI 0 "gpc_reg_operand" "")
  930.     (plus:SI (match_dup 3) (match_dup 1)))]
  931.   "TARGET_POWER"
  932.   "
  933. { operands[3] = gen_reg_rtx (SImode); }")
  934.  
  935. (define_split
  936.   [(set (match_operand:SI 0 "gpc_reg_operand" "")
  937.     (smax:SI (match_operand:SI 1 "gpc_reg_operand" "")
  938.          (match_operand:SI 2 "reg_or_short_operand" "")))
  939.    (clobber (match_operand:SI 3 "gpc_reg_operand" ""))]
  940.   "TARGET_POWER"
  941.   [(set (match_dup 3)
  942.     (if_then_else:SI (gt:SI (match_dup 1) (match_dup 2))
  943.              (const_int 0)
  944.              (minus:SI (match_dup 2) (match_dup 1))))
  945.    (set (match_dup 0) (plus:SI (match_dup 3) (match_dup 1)))]
  946.   "")
  947.  
  948. (define_expand "uminsi3"
  949.   [(set (match_dup 3) (xor:SI (match_operand:SI 1 "gpc_reg_operand" "")
  950.                   (match_dup 5)))
  951.    (set (match_dup 4) (xor:SI (match_operand:SI 2 "gpc_reg_operand" "")
  952.                   (match_dup 5)))
  953.    (set (match_dup 3) (if_then_else:SI (gt (match_dup 3) (match_dup 4))
  954.                        (const_int 0)
  955.                        (minus:SI (match_dup 4) (match_dup 3))))
  956.    (set (match_operand:SI 0 "gpc_reg_operand" "")
  957.     (minus:SI (match_dup 2) (match_dup 3)))]
  958.   "TARGET_POWER"
  959.   "
  960. {
  961.   operands[3] = gen_reg_rtx (SImode);
  962.   operands[4] = gen_reg_rtx (SImode);
  963.   operands[5] = GEN_INT (-2147483647 - 1);
  964. }")
  965.  
  966. (define_expand "umaxsi3"
  967.   [(set (match_dup 3) (xor:SI (match_operand:SI 1 "gpc_reg_operand" "")
  968.                   (match_dup 5)))
  969.    (set (match_dup 4) (xor:SI (match_operand:SI 2 "gpc_reg_operand" "")
  970.                   (match_dup 5)))
  971.    (set (match_dup 3) (if_then_else:SI (gt (match_dup 3) (match_dup 4))
  972.                        (const_int 0)
  973.                        (minus:SI (match_dup 4) (match_dup 3))))
  974.    (set (match_operand:SI 0 "gpc_reg_operand" "")
  975.     (plus:SI (match_dup 3) (match_dup 1)))]
  976.   "TARGET_POWER"
  977.   "
  978. {
  979.   operands[3] = gen_reg_rtx (SImode);
  980.   operands[4] = gen_reg_rtx (SImode);
  981.   operands[5] = GEN_INT (-2147483647 - 1);
  982. }")
  983.  
  984. (define_insn ""
  985.   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
  986.     (if_then_else:SI (gt (match_operand:SI 1 "gpc_reg_operand" "r")
  987.                  (match_operand:SI 2 "reg_or_short_operand" "rI"))
  988.              (const_int 0)
  989.              (minus:SI (match_dup 2) (match_dup 1))))]
  990.   "TARGET_POWER"
  991.   "doz%I2 %0,%1,%2")
  992.  
  993. (define_insn ""
  994.   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
  995.     (compare:CC
  996.      (if_then_else:SI (gt (match_operand:SI 1 "gpc_reg_operand" "r")
  997.                   (match_operand:SI 2 "reg_or_short_operand" "rI"))
  998.               (const_int 0)
  999.               (minus:SI (match_dup 2) (match_dup 1)))
  1000.      (const_int 0)))
  1001.    (clobber (match_scratch:SI 3 "=r"))]
  1002.   "TARGET_POWER"
  1003.   "doz%I2. %3,%1,%2"
  1004.   [(set_attr "type" "delayed_compare")])
  1005.  
  1006. (define_insn ""
  1007.   [(set (match_operand:CC 3 "cc_reg_operand" "=x")
  1008.     (compare:CC
  1009.      (if_then_else:SI (gt (match_operand:SI 1 "gpc_reg_operand" "r")
  1010.                   (match_operand:SI 2 "reg_or_short_operand" "rI"))
  1011.               (const_int 0)
  1012.               (minus:SI (match_dup 2) (match_dup 1)))
  1013.      (const_int 0)))
  1014.    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
  1015.     (if_then_else:SI (gt (match_dup 1) (match_dup 2))
  1016.              (const_int 0)
  1017.              (minus:SI (match_dup 2) (match_dup 1))))]
  1018.   "TARGET_POWER"
  1019.   "doz%I2. %0,%1,%2"
  1020.   [(set_attr "type" "delayed_compare")])
  1021.  
  1022. ;; We don't need abs with condition code because such comparisons should
  1023. ;; never be done.
  1024. (define_expand "abssi2"
  1025.   [(set (match_operand:SI 0 "gpc_reg_operand" "")
  1026.     (abs:SI (match_operand:SI 1 "gpc_reg_operand" "")))]
  1027.   ""
  1028.   "
  1029. {
  1030.   if (!TARGET_POWER)
  1031.     {
  1032.       emit_insn (gen_abssi2_nopower (operands[0], operands[1]));
  1033.       DONE;
  1034.     }
  1035. }")
  1036.  
  1037. (define_insn "abssi2_power"
  1038.   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
  1039.     (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r")))]
  1040.   "TARGET_POWER"
  1041.   "abs %0,%1")
  1042.  
  1043. (define_insn "abssi2_nopower"
  1044.   [(set (match_operand:SI 0 "gpc_reg_operand" "=&r,r")
  1045.     (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r,0")))
  1046.    (clobber (match_scratch:SI 2 "=&r,&r"))]
  1047.   "!TARGET_POWER"
  1048.   "*
  1049. {
  1050.   return (TARGET_POWERPC)
  1051.     ? \"{srai|srawi} %2,%1,31\;xor %0,%2,%1\;subf %0,%2,%0\"
  1052.     : \"{srai|srawi} %2,%1,31\;xor %0,%2,%1\;{sf|subfc} %0,%2,%0\";
  1053. }"
  1054.   [(set_attr "length" "12")])
  1055.  
  1056. (define_split
  1057.   [(set (match_operand:SI 0 "gpc_reg_operand" "=&r,r")
  1058.     (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r,0")))
  1059.    (clobber (match_scratch:SI 2 "=&r,&r"))]
  1060.   "!TARGET_POWER && reload_completed"
  1061.   [(set (match_dup 2) (ashiftrt:SI (match_dup 1) (const_int 31)))
  1062.    (set (match_dup 0) (xor:SI (match_dup 2) (match_dup 1)))
  1063.    (set (match_dup 0) (minus:SI (match_dup 2) (match_dup 0)))]
  1064.   "")
  1065.  
  1066. (define_insn ""
  1067.   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
  1068.     (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r"))))]
  1069.   "TARGET_POWER"
  1070.   "nabs %0,%1")
  1071.  
  1072. (define_insn ""
  1073.   [(set (match_operand:SI 0 "gpc_reg_operand" "=&r,r")
  1074.     (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r,0"))))
  1075.    (clobber (match_scratch:SI 2 "=&r,&r"))]
  1076.   "!TARGET_POWER"
  1077.   "*
  1078. {
  1079.   return (TARGET_POWERPC)
  1080.     ? \"{srai|srawi} %2,%1,31\;xor %0,%2,%1\;subf %0,%0,%2\"
  1081.     : \"{srai|srawi} %2,%1,31\;xor %0,%2,%1\;{sf|subfc} %0,%0,%2\";
  1082. }"
  1083.   [(set_attr "length" "12")])
  1084.  
  1085. (define_split
  1086.   [(set (match_operand:SI 0 "gpc_reg_operand" "=&r,r")
  1087.     (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r,0"))))
  1088.    (clobber (match_scratch:SI 2 "=&r,&r"))]
  1089.   "!TARGET_POWER && reload_completed"
  1090.   [(set (match_dup 2) (ashiftrt:SI (match_dup 1) (const_int 31)))
  1091.    (set (match_dup 0) (xor:SI (match_dup 2) (match_dup 1)))
  1092.    (set (match_dup 0) (minus:SI (match_dup 0) (match_dup 2)))]
  1093.   "")
  1094.  
  1095. (define_insn "negsi2"
  1096.   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
  1097.     (neg:SI (match_operand:SI 1 "gpc_reg_operand" "r")))]
  1098.   ""
  1099.   "neg %0,%1")
  1100.  
  1101. (define_insn ""
  1102.   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
  1103.     (compare:CC (neg:SI (match_operand:SI 1 "gpc_reg_operand" "r"))
  1104.             (const_int 0)))
  1105.    (clobber (match_scratch:SI 2 "=r"))]
  1106.   ""
  1107.   "neg. %2,%1"
  1108.   [(set_attr "type" "compare")])
  1109.  
  1110. (define_insn ""
  1111.   [(set (match_operand:CC 2 "cc_reg_operand" "=x")
  1112.     (compare:CC (neg:SI (match_operand:SI 1 "gpc_reg_operand" "r"))
  1113.             (const_int 0)))
  1114.    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
  1115.     (neg:SI (match_dup 1)))]
  1116.   ""
  1117.   "neg. %0,%1"
  1118.   [(set_attr "type" "compare")])
  1119.  
  1120. (define_insn "ffssi2"
  1121.   [(set (match_operand:SI 0 "gpc_reg_operand" "=&r")
  1122.     (ffs:SI (match_operand:SI 1 "gpc_reg_operand" "r")))]
  1123.   ""
  1124.   "neg %0,%1\;and %0,%0,%1\;{cntlz|cntlzw} %0,%0\;{sfi|subfic} %0,%0,32"
  1125.   [(set_attr "length" "16")])
  1126.  
  1127. (define_expand "mulsi3"
  1128.   [(use (match_operand:SI 0 "gpc_reg_operand" ""))
  1129.    (use (match_operand:SI 1 "gpc_reg_operand" ""))
  1130.    (use (match_operand:SI 2 "reg_or_short_operand" ""))]
  1131.   ""
  1132.   "
  1133. {
  1134.   if (TARGET_POWER)
  1135.     emit_insn (gen_mulsi3_mq (operands[0], operands[1], operands[2]));
  1136.   else
  1137.     emit_insn (gen_mulsi3_no_mq (operands[0], operands[1], operands[2]));
  1138.   DONE;
  1139. }")
  1140.  
  1141. (define_insn "mulsi3_mq"
  1142.   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
  1143.     (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
  1144.          (match_operand:SI 2 "reg_or_short_operand" "r,I")))
  1145.    (clobber (match_scratch:SI 3 "=q,q"))]
  1146.   "TARGET_POWER"
  1147.   "@
  1148.    {muls|mullw} %0,%1,%2
  1149.    {muli|mulli} %0,%1,%2"
  1150.    [(set_attr "type" "imul")])
  1151.  
  1152. (define_insn "mulsi3_no_mq"
  1153.   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
  1154.     (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
  1155.          (match_operand:SI 2 "reg_or_short_operand" "r,I")))]
  1156.   "! TARGET_POWER"
  1157.   "@
  1158.    mullw %0,%1,%2
  1159.    mulli %0,%1,%2"
  1160.    [(set_attr "type" "imul")])
  1161.  
  1162. (define_insn ""
  1163.   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
  1164.     (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r")
  1165.                  (match_operand:SI 2 "gpc_reg_operand" "r"))
  1166.             (const_int 0)))
  1167.    (clobber (match_scratch:SI 3 "=r"))
  1168.    (clobber (match_scratch:SI 4 "=q"))]
  1169.   "TARGET_POWER"
  1170.   "{muls.|mullw.} %3,%1,%2"
  1171.   [(set_attr "type" "delayed_compare")])
  1172.  
  1173. (define_insn ""
  1174.   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
  1175.     (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r")
  1176.                  (match_operand:SI 2 "gpc_reg_operand" "r"))
  1177.             (const_int 0)))
  1178.    (clobber (match_scratch:SI 3 "=r"))]
  1179.   "! TARGET_POWER"
  1180.   "mullw. %3,%1,%2"
  1181.   [(set_attr "type" "delayed_compare")])
  1182.  
  1183. (define_insn ""
  1184.   [(set (match_operand:CC 3 "cc_reg_operand" "=x")
  1185.     (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r")
  1186.                  (match_operand:SI 2 "gpc_reg_operand" "r"))
  1187.             (const_int 0)))
  1188.    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
  1189.     (mult:SI (match_dup 1) (match_dup 2)))
  1190.    (clobber (match_scratch:SI 4 "=q"))]
  1191.   "TARGET_POWER"
  1192.   "{muls.|mullw.} %0,%1,%2"
  1193.   [(set_attr "type" "delayed_compare")])
  1194.  
  1195. (define_insn ""
  1196.   [(set (match_operand:CC 3 "cc_reg_operand" "=x")
  1197.     (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r")
  1198.                  (match_operand:SI 2 "gpc_reg_operand" "r"))
  1199.             (const_int 0)))
  1200.    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
  1201.     (mult:SI (match_dup 1) (match_dup 2)))]
  1202.   "! TARGET_POWER"
  1203.   "mullw. %0,%1,%2"
  1204.   [(set_attr "type" "delayed_compare")])
  1205.  
  1206. ;; Operand 1 is divided by operand 2; quotient goes to operand
  1207. ;; 0 and remainder to operand 3.
  1208. ;; ??? At some point, see what, if anything, we can do about if (x % y == 0).
  1209.  
  1210. (define_expand "divmodsi4"
  1211.   [(parallel [(set (match_operand:SI 0 "gpc_reg_operand" "")
  1212.            (div:SI (match_operand:SI 1 "gpc_reg_operand" "")
  1213.                (match_operand:SI 2 "gpc_reg_operand" "")))
  1214.           (set (match_operand:SI 3 "gpc_reg_operand" "")
  1215.            (mod:SI (match_dup 1) (match_dup 2)))])]
  1216.   "TARGET_POWER || (! TARGET_POWER && ! TARGET_POWERPC)"
  1217.   "
  1218. {
  1219.   if (! TARGET_POWER && ! TARGET_POWERPC)
  1220.     {
  1221.       emit_move_insn (gen_rtx (REG, SImode, 3), operands[1]);
  1222.       emit_move_insn (gen_rtx (REG, SImode, 4), operands[2]);
  1223.       emit_insn (gen_divss_call ());
  1224.       emit_move_insn (operands[0], gen_rtx (REG, SImode, 3));
  1225.       emit_move_insn (operands[3], gen_rtx (REG, SImode, 4));
  1226.       DONE;
  1227.     }
  1228. }")
  1229.  
  1230. (define_insn ""
  1231.   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
  1232.     (div:SI (match_operand:SI 1 "gpc_reg_operand" "r")
  1233.         (match_operand:SI 2 "gpc_reg_operand" "r")))
  1234.    (set (match_operand:SI 3 "gpc_reg_operand" "=q")
  1235.     (mod:SI (match_dup 1) (match_dup 2)))]
  1236.   "TARGET_POWER"
  1237.   "divs %0,%1,%2"
  1238.   [(set_attr "type" "idiv")])
  1239.  
  1240. (define_insn ""
  1241.   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
  1242.         (div:SI (match_operand:SI 1 "gpc_reg_operand" "r")
  1243.                 (match_operand:SI 2 "gpc_reg_operand" "r")))]
  1244.   "TARGET_POWERPC"
  1245.   "divw %0,%1,%2"
  1246.   [(set_attr "type" "idiv")])
  1247.  
  1248. (define_expand "udivsi3"
  1249.   [(set (match_operand:SI 0 "gpc_reg_operand" "")
  1250.         (udiv:SI (match_operand:SI 1 "gpc_reg_operand" "")
  1251.                  (match_operand:SI 2 "gpc_reg_operand" "")))]
  1252.   "TARGET_POWERPC || (! TARGET_POWER && ! TARGET_POWERPC)"
  1253.   "
  1254. {
  1255.   if (! TARGET_POWER && ! TARGET_POWERPC)
  1256.     {
  1257.       emit_move_insn (gen_rtx (REG, SImode, 3), operands[1]);
  1258.       emit_move_insn (gen_rtx (REG, SImode, 4), operands[2]);
  1259.       emit_insn (gen_quous_call ());
  1260.       emit_move_insn (operands[0], gen_rtx (REG, SImode, 3));
  1261.       DONE;
  1262.     }
  1263. }")
  1264.  
  1265. (define_insn ""
  1266.   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
  1267.         (udiv:SI (match_operand:SI 1 "gpc_reg_operand" "r")
  1268.                  (match_operand:SI 2 "gpc_reg_operand" "r")))]
  1269.   "TARGET_POWERPC"
  1270.   "divwu %0,%1,%2"
  1271.   [(set_attr "type" "idiv")])
  1272.  
  1273. ;; For powers of two we can do srai/aze for divide and then adjust for
  1274. ;; modulus.  If it isn't a power of two, FAIL on POWER so divmodsi4 will be
  1275. ;; used; for PowerPC, force operands into register and do a normal divide;
  1276. ;; for AIX common-mode, use quoss call on register operands.
  1277. (define_expand "divsi3"
  1278.   [(set (match_operand:SI 0 "gpc_reg_operand" "")
  1279.     (div:SI (match_operand:SI 1 "gpc_reg_operand" "")
  1280.         (match_operand:SI 2 "reg_or_cint_operand" "")))]
  1281.   ""
  1282.   "
  1283. {
  1284.   if (GET_CODE (operands[2]) == CONST_INT
  1285.       && exact_log2 (INTVAL (operands[2])) >= 0)
  1286.     ;
  1287.   else if (TARGET_POWER && ! TARGET_POWERPC)
  1288.     FAIL;
  1289.   else
  1290.     operands[2] = force_reg (SImode, operands[2]);
  1291.  
  1292.   if (! TARGET_POWER && ! TARGET_POWERPC)
  1293.     {
  1294.       emit_move_insn (gen_rtx (REG, SImode, 3), operands[1]);
  1295.       emit_move_insn (gen_rtx (REG, SImode, 4), operands[2]);
  1296.       emit_insn (gen_quoss_call ());
  1297.       emit_move_insn (operands[0], gen_rtx (REG, SImode, 3));
  1298.       DONE;
  1299.     }
  1300. }")
  1301.  
  1302. (define_expand "modsi3"
  1303.   [(use (match_operand:SI 0 "gpc_reg_operand" ""))
  1304.    (use (match_operand:SI 1 "gpc_reg_operand" ""))
  1305.    (use (match_operand:SI 2 "reg_or_cint_operand" ""))]
  1306.   ""
  1307.   "
  1308. {
  1309.   int i = exact_log2 (INTVAL (operands[2]));
  1310.   rtx temp1;
  1311.   rtx temp2;
  1312.  
  1313.   if (GET_CODE (operands[2]) != CONST_INT || i < 0)
  1314.     FAIL;
  1315.  
  1316.   temp1 = gen_reg_rtx (SImode);
  1317.   temp2 = gen_reg_rtx (SImode);
  1318.  
  1319.   emit_insn (gen_divsi3 (temp1, operands[1], operands[2]));
  1320.   emit_insn (gen_ashlsi3 (temp2, temp1, GEN_INT (i)));
  1321.   emit_insn (gen_subsi3 (operands[0], operands[1], temp2));
  1322.   DONE;
  1323. }")
  1324.  
  1325. (define_insn ""
  1326.   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
  1327.     (div:SI (match_operand:SI 1 "gpc_reg_operand" "r")
  1328.         (match_operand:SI 2 "const_int_operand" "N")))]
  1329.   "exact_log2 (INTVAL (operands[2])) >= 0"
  1330.   "{srai|srawi} %0,%1,%p2\;{aze|addze} %0,%0"
  1331.   [(set_attr "length" "8")])
  1332.  
  1333. (define_insn ""
  1334.   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
  1335.     (compare:CC (div:SI (match_operand:SI 1 "gpc_reg_operand" "r")
  1336.                 (match_operand:SI 2 "const_int_operand" "N"))
  1337.             (const_int 0)))
  1338.    (clobber (match_scratch:SI 3 "=r"))]
  1339.   "exact_log2 (INTVAL (operands[2])) >= 0"
  1340.   "{srai|srawi} %3,%1,%p2\;{aze.|addze.} %3,%3"
  1341.   [(set_attr "type" "compare")
  1342.    (set_attr "length" "8")])
  1343.  
  1344. (define_insn ""
  1345.   [(set (match_operand:CC 3 "cc_reg_operand" "=x")
  1346.     (compare:CC (div:SI (match_operand:SI 1 "gpc_reg_operand" "r")
  1347.                 (match_operand:SI 2 "const_int_operand" "N"))
  1348.             (const_int 0)))
  1349.    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
  1350.     (div:SI (match_dup 1) (match_dup 2)))]
  1351.   "exact_log2 (INTVAL (operands[2])) >= 0"
  1352.   "{srai|srawi} %0,%1,%p2\;{aze.|addze.} %0,%0"
  1353.   [(set_attr "type" "compare")
  1354.    (set_attr "length" "8")])
  1355.  
  1356. (define_insn ""
  1357.   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
  1358.     (udiv:SI
  1359.      (plus:DI (ashift:DI
  1360.            (zero_extend:DI (match_operand:SI 1 "gpc_reg_operand" "r"))
  1361.            (const_int 32))
  1362.           (zero_extend:DI (match_operand:SI 4 "register_operand" "2")))
  1363.      (match_operand:SI 3 "gpc_reg_operand" "r")))
  1364.    (set (match_operand:SI 2 "register_operand" "=*q")
  1365.     (umod:SI
  1366.      (plus:DI (ashift:DI
  1367.            (zero_extend:DI (match_dup 1)) (const_int 32))
  1368.           (zero_extend:DI (match_dup 4)))
  1369.      (match_dup 3)))]
  1370.   "TARGET_POWER"
  1371.   "div %0,%1,%3"
  1372.   [(set_attr "type" "idiv")])
  1373.  
  1374. ;; To do unsigned divide we handle the cases of the divisor looking like a
  1375. ;; negative number.  If it is a constant that is less than 2**31, we don't
  1376. ;; have to worry about the branches.  So make a few subroutines here.
  1377. ;;
  1378. ;; First comes the normal case.
  1379. (define_expand "udivmodsi4_normal"
  1380.   [(set (match_dup 4) (const_int 0))
  1381.    (parallel [(set (match_operand:SI 0 "" "")
  1382.            (udiv:SI (plus:DI (ashift:DI (zero_extend:DI (match_dup 4))
  1383.                         (const_int 32))
  1384.                      (zero_extend:DI (match_operand:SI 1 "" "")))
  1385.                 (match_operand:SI 2 "" "")))
  1386.           (set (match_operand:SI 3 "" "")
  1387.            (umod:SI (plus:DI (ashift:DI (zero_extend:DI (match_dup 4))
  1388.                         (const_int 32))
  1389.                      (zero_extend:DI (match_dup 1)))
  1390.                 (match_dup 2)))])]
  1391.   "TARGET_POWER"
  1392.   "
  1393. { operands[4] = gen_reg_rtx (SImode); }")
  1394.  
  1395. ;; This handles the branches.
  1396. (define_expand "udivmodsi4_tests"
  1397.   [(set (match_operand:SI 0 "" "") (const_int 0))
  1398.    (set (match_operand:SI 3 "" "") (match_operand:SI 1 "" ""))
  1399.    (set (match_dup 5) (compare:CCUNS (match_dup 1) (match_operand:SI 2 "" "")))
  1400.    (set (pc) (if_then_else (ltu (match_dup 5) (const_int 0))
  1401.                (label_ref (match_operand:SI 4 "" "")) (pc)))
  1402.    (set (match_dup 0) (const_int 1))
  1403.    (set (match_dup 3) (minus:SI (match_dup 1) (match_dup 2)))
  1404.    (set (match_dup 6) (compare:CC (match_dup 2) (const_int 0)))
  1405.    (set (pc) (if_then_else (lt (match_dup 6) (const_int 0))
  1406.                (label_ref (match_dup 4)) (pc)))]
  1407.   "TARGET_POWER"
  1408.   "
  1409. { operands[5] = gen_reg_rtx (CCUNSmode);
  1410.   operands[6] = gen_reg_rtx (CCmode);
  1411. }")
  1412.  
  1413. (define_expand "udivmodsi4"
  1414.   [(parallel [(set (match_operand:SI 0 "gpc_reg_operand" "")
  1415.            (udiv:SI (match_operand:SI 1 "gpc_reg_operand" "")
  1416.                 (match_operand:SI 2 "reg_or_cint_operand" "")))
  1417.           (set (match_operand:SI 3 "gpc_reg_operand" "")
  1418.            (umod:SI (match_dup 1) (match_dup 2)))])]
  1419.   ""
  1420.   "
  1421. {
  1422.   rtx label = 0;
  1423.  
  1424.   if (! TARGET_POWER)
  1425.     if (! TARGET_POWERPC)
  1426.       {
  1427.     emit_move_insn (gen_rtx (REG, SImode, 3), operands[1]);
  1428.     emit_move_insn (gen_rtx (REG, SImode, 4), operands[2]);
  1429.     emit_insn (gen_divus_call ());
  1430.     emit_move_insn (operands[0], gen_rtx (REG, SImode, 3));
  1431.     emit_move_insn (operands[3], gen_rtx (REG, SImode, 4));
  1432.     DONE;
  1433.       }
  1434.     else
  1435.       FAIL;
  1436.  
  1437.   if (GET_CODE (operands[2]) != CONST_INT || INTVAL (operands[2]) < 0)
  1438.     {
  1439.       operands[2] = force_reg (SImode, operands[2]);
  1440.       label = gen_label_rtx ();
  1441.       emit (gen_udivmodsi4_tests (operands[0], operands[1], operands[2],
  1442.                   operands[3], label));
  1443.     }
  1444.   else
  1445.     operands[2] = force_reg (SImode, operands[2]);
  1446.  
  1447.   emit (gen_udivmodsi4_normal (operands[0], operands[1], operands[2],
  1448.                    operands[3]));
  1449.   if (label)
  1450.     emit_label (label);
  1451.  
  1452.   DONE;
  1453. }")
  1454.  
  1455. ;; AIX architecture-independent common-mode multiply (DImode),
  1456. ;; divide/modulus, and quotient subroutine calls.  Input operands in R3 and
  1457. ;; R4; results in R3 and sometimes R4; link register always clobbered by bla
  1458. ;; instruction; R0 sometimes clobbered; also, MQ sometimes clobbered but
  1459. ;; assumed unused if generating common-mode, so ignore.
  1460. (define_insn "mulh_call"
  1461.   [(set (reg:SI 3)
  1462.     (truncate:SI
  1463.      (lshiftrt:DI (mult:DI (sign_extend:DI (reg:SI 3))
  1464.                    (sign_extend:DI (reg:SI 4)))
  1465.               (const_int 32))))
  1466.    (clobber (match_scratch:SI 0 "=l"))]
  1467.   "! TARGET_POWER && ! TARGET_POWERPC"
  1468.   "bla __mulh")
  1469.  
  1470. (define_insn "mull_call"
  1471.   [(set (reg:DI 3)
  1472.     (mult:DI (sign_extend:DI (reg:SI 3))
  1473.          (sign_extend:DI (reg:SI 4))))
  1474.    (clobber (match_scratch:SI 0 "=l"))
  1475.    (clobber (reg:SI 0))]
  1476.   "! TARGET_POWER && ! TARGET_POWERPC"
  1477.   "bla __mull")
  1478.  
  1479. (define_insn "divss_call"
  1480.   [(set (reg:SI 3)
  1481.     (div:SI (reg:SI 3) (reg:SI 4)))
  1482.    (set (reg:SI 4)
  1483.     (mod:SI (reg:SI 3) (reg:SI 4)))
  1484.    (clobber (match_scratch:SI 0 "=l"))
  1485.    (clobber (reg:SI 0))]
  1486.   "! TARGET_POWER && ! TARGET_POWERPC"
  1487.   "bla __divss")
  1488.  
  1489. (define_insn "divus_call"
  1490.   [(set (reg:SI 3)
  1491.     (udiv:SI (reg:SI 3) (reg:SI 4)))
  1492.    (set (reg:SI 4)
  1493.     (umod:SI (reg:SI 3) (reg:SI 4)))
  1494.    (clobber (match_scratch:SI 0 "=l"))
  1495.    (clobber (reg:SI 0))]
  1496.   "! TARGET_POWER && ! TARGET_POWERPC"
  1497.   "bla __divus")
  1498.  
  1499. (define_insn "quoss_call"
  1500.   [(set (reg:SI 3)
  1501.     (div:SI (reg:SI 3) (reg:SI 4)))
  1502.    (clobber (match_scratch:SI 0 "=l"))]
  1503.   "! TARGET_POWER && ! TARGET_POWERPC"
  1504.   "bla __quoss")
  1505.  
  1506. (define_insn "quous_call"
  1507.   [(set (reg:SI 3)
  1508.     (udiv:SI (reg:SI 3) (reg:SI 4)))
  1509.    (clobber (match_scratch:SI 0 "=l"))
  1510.    (clobber (reg:SI 0))]
  1511.   "! TARGET_POWER && ! TARGET_POWERPC"
  1512.   "bla __quous")
  1513.  
  1514. (define_insn "andsi3"
  1515.   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r")
  1516.     (and:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r")
  1517.         (match_operand:SI 2 "and_operand" "?r,L,K,J")))
  1518.    (clobber (match_scratch:CC 3 "=X,X,x,x"))]
  1519.   ""
  1520.   "@
  1521.    and %0,%1,%2
  1522.    {rlinm|rlwinm} %0,%1,0,%m2,%M2
  1523.    {andil.|andi.} %0,%1,%b2
  1524.    {andiu.|andis.} %0,%1,%u2")
  1525.  
  1526. (define_insn ""
  1527.   [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,x,x")
  1528.     (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r")
  1529.                 (match_operand:SI 2 "and_operand" "r,K,J,L"))
  1530.             (const_int 0)))
  1531.    (clobber (match_scratch:SI 3 "=r,r,r,r"))]
  1532.   ""
  1533.   "@
  1534.    and. %3,%1,%2
  1535.    {andil.|andi.} %3,%1,%b2
  1536.    {andiu.|andis.} %3,%1,%u2
  1537.    {rlinm.|rlwinm.} %3,%1,0,%m2,%M2"
  1538.   [(set_attr "type" "compare,compare,compare,delayed_compare")])
  1539.  
  1540. (define_insn ""
  1541.   [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,x,x")
  1542.     (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r")
  1543.                 (match_operand:SI 2 "and_operand" "r,K,J,L"))
  1544.             (const_int 0)))
  1545.    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r")
  1546.     (and:SI (match_dup 1) (match_dup 2)))]
  1547.   ""
  1548.   "@
  1549.    and. %0,%1,%2
  1550.    {andil.|andi.} %0,%1,%b2
  1551.    {andiu.|andis.} %0,%1,%u2
  1552.    {rlinm.|rlwinm.} %0,%1,0,%m2,%M2"
  1553.   [(set_attr "type" "compare,compare,compare,delayed_compare")])
  1554.  
  1555. ;; Take a AND with a constant that cannot be done in a single insn and try to
  1556. ;; split it into two insns.  This does not verify that the insns are valid
  1557. ;; since this need not be done as combine will do it.
  1558.  
  1559. (define_split
  1560.   [(set (match_operand:SI 0 "gpc_reg_operand" "")
  1561.     (and:SI (match_operand:SI 1 "gpc_reg_operand" "")
  1562.         (match_operand:SI 2 "non_and_cint_operand" "")))]
  1563.   ""
  1564.   [(set (match_dup 0) (and:SI (match_dup 1) (match_dup 3)))
  1565.    (set (match_dup 0) (and:SI (match_dup 0) (match_dup 4)))]
  1566.   "
  1567. {
  1568.   int maskval = INTVAL (operands[2]);
  1569.   int i, transitions, last_bit_value;
  1570.   int orig = maskval, first_c = maskval, second_c;
  1571.  
  1572.   /* We know that MASKVAL must have more than 2 bit-transitions.  Start at
  1573.      the low-order bit and count for the third transition.  When we get there,
  1574.      make a first mask that has everything to the left of that position
  1575.      a one.  Then make the second mask to turn off whatever else is needed.  */
  1576.  
  1577.   for (i = 1, transitions = 0, last_bit_value = maskval & 1; i < 32; i++)
  1578.     {
  1579.       if (((maskval >>= 1) & 1) != last_bit_value)
  1580.     last_bit_value ^= 1, transitions++;
  1581.  
  1582.       if (transitions > 2)
  1583.     {
  1584.       first_c |= (~0) << i;
  1585.       break;
  1586.     }
  1587.     }
  1588.  
  1589.   second_c = orig | ~ first_c;
  1590.  
  1591.   operands[3] = gen_rtx (CONST_INT, VOIDmode, first_c);
  1592.   operands[4] = gen_rtx (CONST_INT, VOIDmode, second_c);
  1593. }")
  1594.  
  1595. (define_insn "iorsi3"
  1596.   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r")
  1597.     (ior:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r")
  1598.         (match_operand:SI 2 "logical_operand" "r,K,J")))]
  1599.   ""
  1600.   "@
  1601.    or %0,%1,%2
  1602.    {oril|ori} %0,%1,%b2
  1603.    {oriu|oris} %0,%1,%u2")
  1604.  
  1605. (define_insn ""
  1606.   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
  1607.     (compare:CC (ior:SI (match_operand:SI 1 "gpc_reg_operand" "%r")
  1608.                 (match_operand:SI 2 "gpc_reg_operand" "r"))
  1609.             (const_int 0)))
  1610.    (clobber (match_scratch:SI 3 "=r"))]
  1611.   ""
  1612.   "or. %3,%1,%2"
  1613.   [(set_attr "type" "compare")])
  1614.  
  1615. (define_insn ""
  1616.   [(set (match_operand:CC 3 "cc_reg_operand" "=x")
  1617.     (compare:CC (ior:SI (match_operand:SI 1 "gpc_reg_operand" "%r")
  1618.                 (match_operand:SI 2 "gpc_reg_operand" "r"))
  1619.             (const_int 0)))
  1620.    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
  1621.     (ior:SI (match_dup 1) (match_dup 2)))]
  1622.   ""
  1623.   "or. %0,%1,%2"
  1624.   [(set_attr "type" "compare")])
  1625.  
  1626. ;; Split an IOR that we can't do in one insn into two insns, each of which
  1627. ;; does one 16-bit part.  This is used by combine.
  1628.  
  1629. (define_split
  1630.   [(set (match_operand:SI 0 "gpc_reg_operand" "")
  1631.     (ior:SI (match_operand:SI 1 "gpc_reg_operand" "")
  1632.         (match_operand:SI 2 "non_logical_cint_operand" "")))]
  1633.   ""
  1634.   [(set (match_dup 0) (ior:SI (match_dup 1) (match_dup 3)))
  1635.    (set (match_dup 0) (ior:SI (match_dup 0) (match_dup 4)))]
  1636. "
  1637. {
  1638.   operands[3] = gen_rtx (CONST_INT, VOIDmode,
  1639.              INTVAL (operands[2]) & 0xffff0000);
  1640.   operands[4] = gen_rtx (CONST_INT, VOIDmode, INTVAL (operands[2]) & 0xffff);
  1641. }")
  1642.  
  1643. (define_insn "xorsi3"
  1644.   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r")
  1645.     (xor:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r")
  1646.         (match_operand:SI 2 "logical_operand" "r,K,J")))]
  1647.   ""
  1648.   "@
  1649.    xor %0,%1,%2
  1650.    {xoril|xori} %0,%1,%b2
  1651.    {xoriu|xoris} %0,%1,%u2")
  1652.  
  1653. (define_insn ""
  1654.   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
  1655.     (compare:CC (xor:SI (match_operand:SI 1 "gpc_reg_operand" "%r")
  1656.                 (match_operand:SI 2 "gpc_reg_operand" "r"))
  1657.             (const_int 0)))
  1658.    (clobber (match_scratch:SI 3 "=r"))]
  1659.   ""
  1660.   "xor. %3,%1,%2"
  1661.   [(set_attr "type" "compare")])
  1662.  
  1663. (define_insn ""
  1664.   [(set (match_operand:CC 3 "cc_reg_operand" "=x")
  1665.     (compare:CC (xor:SI (match_operand:SI 1 "gpc_reg_operand" "%r")
  1666.                 (match_operand:SI 2 "gpc_reg_operand" "r"))
  1667.             (const_int 0)))
  1668.    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
  1669.     (xor:SI (match_dup 1) (match_dup 2)))]
  1670.   ""
  1671.   "xor. %0,%1,%2"
  1672.   [(set_attr "type" "compare")])
  1673.  
  1674. ;; Split an XOR that we can't do in one insn into two insns, each of which
  1675. ;; does one 16-bit part.  This is used by combine.
  1676.  
  1677. (define_split
  1678.   [(set (match_operand:SI 0 "gpc_reg_operand" "")
  1679.     (xor:SI (match_operand:SI 1 "gpc_reg_operand" "")
  1680.         (match_operand:SI 2 "non_logical_cint_operand" "")))]
  1681.   ""
  1682.   [(set (match_dup 0) (xor:SI (match_dup 1) (match_dup 3)))
  1683.    (set (match_dup 0) (xor:SI (match_dup 0) (match_dup 4)))]
  1684. "
  1685. {
  1686.   operands[3] = gen_rtx (CONST_INT, VOIDmode,
  1687.              INTVAL (operands[2]) & 0xffff0000);
  1688.   operands[4] = gen_rtx (CONST_INT, VOIDmode, INTVAL (operands[2]) & 0xffff);
  1689. }")
  1690.  
  1691. (define_insn ""
  1692.   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
  1693.     (not:SI (xor:SI (match_operand:SI 1 "gpc_reg_operand" "%r")
  1694.             (match_operand:SI 2 "gpc_reg_operand" "r"))))]
  1695.    ""
  1696.    "eqv %0,%1,%2")
  1697.  
  1698. (define_insn ""
  1699.   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
  1700.     (compare:CC (not:SI (xor:SI (match_operand:SI 1 "gpc_reg_operand" "%r")
  1701.                     (match_operand:SI 2 "gpc_reg_operand" "r")))
  1702.             (const_int 0)))
  1703.    (clobber (match_scratch:SI 3 "=r"))]
  1704.    ""
  1705.    "eqv. %3,%1,%2"
  1706.    [(set_attr "type" "compare")])
  1707.  
  1708. (define_insn ""
  1709.   [(set (match_operand:CC 3 "cc_reg_operand" "=x")
  1710.     (compare:CC (not:SI (xor:SI (match_operand:SI 1 "gpc_reg_operand" "%r")
  1711.                     (match_operand:SI 2 "gpc_reg_operand" "r")))
  1712.             (const_int 0)))
  1713.    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
  1714.     (not:SI (xor:SI (match_dup 1) (match_dup 2))))]
  1715.    ""
  1716.    "eqv. %0,%1,%2"
  1717.    [(set_attr "type" "compare")])
  1718.  
  1719. (define_insn ""
  1720.   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
  1721.     (and:SI (not:SI (match_operand:SI 1 "gpc_reg_operand" "r"))
  1722.         (match_operand:SI 2 "gpc_reg_operand" "r")))]
  1723.   ""
  1724.   "andc %0,%2,%1")
  1725.  
  1726. (define_insn ""
  1727.   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
  1728.     (compare:CC (and:SI (not:SI (match_operand:SI 1 "gpc_reg_operand" "r"))
  1729.                 (match_operand:SI 2 "gpc_reg_operand" "r"))
  1730.             (const_int 0)))
  1731.    (clobber (match_scratch:SI 3 "=r"))]
  1732.   ""
  1733.   "andc. %3,%2,%1"
  1734.   [(set_attr "type" "compare")])
  1735.  
  1736. (define_insn ""
  1737.   [(set (match_operand:CC 3 "cc_reg_operand" "=x")
  1738.     (compare:CC (and:SI (not:SI (match_operand:SI 1 "gpc_reg_operand" "r"))
  1739.                 (match_operand:SI 2 "gpc_reg_operand" "r"))
  1740.             (const_int 0)))
  1741.    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
  1742.     (and:SI (not:SI (match_dup 1)) (match_dup 2)))]
  1743.   ""
  1744.   "andc. %0,%2,%1"
  1745.   [(set_attr "type" "compare")])
  1746.  
  1747. (define_insn ""
  1748.   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
  1749.     (ior:SI (not:SI (match_operand:SI 1 "gpc_reg_operand" "r"))
  1750.         (match_operand:SI 2 "gpc_reg_operand" "r")))]
  1751.   ""
  1752.   "orc %0,%2,%1")
  1753.  
  1754. (define_insn ""
  1755.   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
  1756.     (compare:CC (ior:SI (not:SI (match_operand:SI 1 "gpc_reg_operand" "r"))
  1757.                 (match_operand:SI 2 "gpc_reg_operand" "r"))
  1758.             (const_int 0)))
  1759.    (clobber (match_scratch:SI 3 "=r"))]
  1760.   ""
  1761.   "orc. %3,%2,%1"
  1762.   [(set_attr "type" "compare")])
  1763.  
  1764. (define_insn ""
  1765.   [(set (match_operand:CC 3 "cc_reg_operand" "=x")
  1766.     (compare:CC (ior:SI (not:SI (match_operand:SI 1 "gpc_reg_operand" "r"))
  1767.                 (match_operand:SI 2 "gpc_reg_operand" "r"))
  1768.             (const_int 0)))
  1769.    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
  1770.     (ior:SI (not:SI (match_dup 1)) (match_dup 2)))]
  1771.   ""
  1772.   "orc. %0,%2,%1"
  1773.   [(set_attr "type" "compare")])
  1774.  
  1775. (define_insn ""
  1776.   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
  1777.     (ior:SI (not:SI (match_operand:SI 1 "gpc_reg_operand" "%r"))
  1778.         (not:SI (match_operand:SI 2 "gpc_reg_operand" "r"))))]
  1779.   ""
  1780.   "nand %0,%1,%2")
  1781.  
  1782. (define_insn ""
  1783.   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
  1784.     (compare:CC (ior:SI (not:SI (match_operand:SI 1 "gpc_reg_operand" "%r"))
  1785.                 (not:SI (match_operand:SI 2 "gpc_reg_operand" "r")))
  1786.             (const_int 0)))
  1787.    (clobber (match_scratch:SI 3 "=r"))]
  1788.   ""
  1789.   "nand. %3,%1,%2"
  1790.   [(set_attr "type" "compare")])
  1791.  
  1792. (define_insn ""
  1793.   [(set (match_operand:CC 3 "cc_reg_operand" "=x")
  1794.     (compare:CC (ior:SI (not:SI (match_operand:SI 1 "gpc_reg_operand" "%r"))
  1795.                 (not:SI (match_operand:SI 2 "gpc_reg_operand" "r")))
  1796.             (const_int 0)))
  1797.    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
  1798.     (ior:SI (not:SI (match_dup 1)) (not:SI (match_dup 2))))]
  1799.   ""
  1800.   "nand. %0,%1,%2"
  1801.   [(set_attr "type" "compare")])
  1802.  
  1803. (define_insn ""
  1804.   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
  1805.     (and:SI (not:SI (match_operand:SI 1 "gpc_reg_operand" "%r"))
  1806.         (not:SI (match_operand:SI 2 "gpc_reg_operand" "r"))))]
  1807.   ""
  1808.   "nor %0,%1,%2")
  1809.  
  1810. (define_insn ""
  1811.   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
  1812.     (compare:CC (and:SI (not:SI (match_operand:SI 1 "gpc_reg_operand" "%r"))
  1813.                 (not:SI (match_operand:SI 2 "gpc_reg_operand" "r")))
  1814.             (const_int 0)))
  1815.    (clobber (match_scratch:SI 3 "=r"))]
  1816.   ""
  1817.   "nor. %3,%1,%2"
  1818.   [(set_attr "type" "compare")])
  1819.  
  1820. (define_insn ""
  1821.   [(set (match_operand:CC 3 "cc_reg_operand" "=x")
  1822.     (compare:CC (and:SI (not:SI (match_operand:SI 1 "gpc_reg_operand" "%r"))
  1823.                 (not:SI (match_operand:SI 2 "gpc_reg_operand" "r")))
  1824.             (const_int 0)))
  1825.    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
  1826.     (and:SI (not:SI (match_dup 1)) (not:SI (match_dup 2))))]
  1827.   ""
  1828.   "nor. %0,%1,%2"
  1829.   [(set_attr "type" "compare")])
  1830.  
  1831. ;; maskir insn.  We need four forms because things might be in arbitrary
  1832. ;; orders.  Don't define forms that only set CR fields because these
  1833. ;; would modify an input register.
  1834.  
  1835. (define_insn ""
  1836.   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
  1837.     (ior:SI (and:SI (not:SI (match_operand:SI 2 "gpc_reg_operand" "r"))
  1838.             (match_operand:SI 1 "gpc_reg_operand" "0"))
  1839.         (and:SI (match_dup 2)
  1840.             (match_operand:SI 3 "gpc_reg_operand" "r"))))]
  1841.   "TARGET_POWER"
  1842.   "maskir %0,%3,%2")
  1843.  
  1844. (define_insn ""
  1845.   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
  1846.     (ior:SI (and:SI (not:SI (match_operand:SI 2 "gpc_reg_operand" "r"))
  1847.             (match_operand:SI 1 "gpc_reg_operand" "0"))
  1848.         (and:SI (match_operand:SI 3 "gpc_reg_operand" "r")
  1849.             (match_dup 2))))]
  1850.   "TARGET_POWER"
  1851.   "maskir %0,%3,%2")
  1852.  
  1853. (define_insn ""
  1854.   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
  1855.     (ior:SI (and:SI (match_operand:SI 2 "gpc_reg_operand" "r")
  1856.             (match_operand:SI 3 "gpc_reg_operand" "r"))
  1857.         (and:SI (not:SI (match_dup 2))
  1858.             (match_operand:SI 1 "gpc_reg_operand" "0"))))]
  1859.   "TARGET_POWER"
  1860.   "maskir %0,%3,%2")
  1861.  
  1862. (define_insn ""
  1863.   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
  1864.     (ior:SI (and:SI (match_operand:SI 3 "gpc_reg_operand" "r")
  1865.             (match_operand:SI 2 "gpc_reg_operand" "r"))
  1866.         (and:SI (not:SI (match_dup 2))
  1867.             (match_operand:SI 1 "gpc_reg_operand" "0"))))]
  1868.   "TARGET_POWER"
  1869.   "maskir %0,%3,%2")
  1870.  
  1871. (define_insn ""
  1872.   [(set (match_operand:CC 4 "cc_reg_operand" "=x")
  1873.     (compare:CC
  1874.      (ior:SI (and:SI (not:SI (match_operand:SI 2 "gpc_reg_operand" "r"))
  1875.              (match_operand:SI 1 "gpc_reg_operand" "0"))
  1876.          (and:SI (match_dup 2)
  1877.              (match_operand:SI 3 "gpc_reg_operand" "r")))
  1878.      (const_int 0)))
  1879.    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
  1880.     (ior:SI (and:SI (not:SI (match_dup 2)) (match_dup 1))
  1881.         (and:SI (match_dup 2) (match_dup 3))))]
  1882.   "TARGET_POWER"
  1883.   "maskir. %0,%3,%2"
  1884.   [(set_attr "type" "compare")])
  1885.  
  1886. (define_insn ""
  1887.   [(set (match_operand:CC 4 "cc_reg_operand" "=x")
  1888.     (compare:CC
  1889.      (ior:SI (and:SI (not:SI (match_operand:SI 2 "gpc_reg_operand" "r"))
  1890.              (match_operand:SI 1 "gpc_reg_operand" "0"))
  1891.          (and:SI (match_operand:SI 3 "gpc_reg_operand" "r")
  1892.              (match_dup 2)))
  1893.      (const_int 0)))
  1894.    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
  1895.     (ior:SI (and:SI (not:SI (match_dup 2)) (match_dup 1))
  1896.         (and:SI (match_dup 3) (match_dup 2))))]
  1897.   "TARGET_POWER"
  1898.   "maskir. %0,%3,%2"
  1899.   [(set_attr "type" "compare")])
  1900.  
  1901. (define_insn ""
  1902.   [(set (match_operand:CC 4 "cc_reg_operand" "=x")
  1903.     (compare:CC
  1904.      (ior:SI (and:SI (match_operand:SI 2 "gpc_reg_operand" "r")
  1905.              (match_operand:SI 3 "gpc_reg_operand" "r"))
  1906.          (and:SI (not:SI (match_dup 2))
  1907.              (match_operand:SI 1 "gpc_reg_operand" "0")))
  1908.      (const_int 0)))
  1909.    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
  1910.     (ior:SI (and:SI (match_dup 2) (match_dup 3))
  1911.         (and:SI (not:SI (match_dup 2)) (match_dup 1))))]
  1912.   "TARGET_POWER"
  1913.   "maskir. %0,%3,%2"
  1914.   [(set_attr "type" "compare")])
  1915.  
  1916. (define_insn ""
  1917.   [(set (match_operand:CC 4 "cc_reg_operand" "=x")
  1918.     (compare:CC
  1919.      (ior:SI (and:SI (match_operand:SI 3 "gpc_reg_operand" "r")
  1920.              (match_operand:SI 2 "gpc_reg_operand" "r"))
  1921.          (and:SI (not:SI (match_dup 2))
  1922.              (match_operand:SI 1 "gpc_reg_operand" "0")))
  1923.      (const_int 0)))
  1924.    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
  1925.     (ior:SI (and:SI (match_dup 3) (match_dup 2))
  1926.         (and:SI (not:SI (match_dup 2)) (match_dup 1))))]
  1927.   "TARGET_POWER"
  1928.   "maskir. %0,%3,%2"
  1929.   [(set_attr "type" "compare")])
  1930.  
  1931. ;; Rotate and shift insns, in all their variants.  These support shifts,
  1932. ;; field inserts and extracts, and various combinations thereof.
  1933. (define_expand "insv"
  1934.   [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
  1935.              (match_operand:SI 1 "const_int_operand" "i")
  1936.              (match_operand:SI 2 "const_int_operand" "i"))
  1937.     (match_operand:SI 3 "gpc_reg_operand" "r"))]
  1938.   ""
  1939.   "
  1940. {
  1941.   /* Do not handle 16/8 bit structures that fit in HI/QI modes directly, since
  1942.      the (SUBREG:SI (REG:HI xxx)) that is otherwise generated can confuse the
  1943.      compiler if the address of the structure is taken later.  */
  1944.   if (GET_CODE (operands[0]) == SUBREG
  1945.       && (GET_MODE_SIZE (GET_MODE (SUBREG_REG (operands[0]))) < UNITS_PER_WORD))
  1946.     FAIL;
  1947. }")
  1948.  
  1949. (define_insn ""
  1950.   [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
  1951.              (match_operand:SI 1 "const_int_operand" "i")
  1952.              (match_operand:SI 2 "const_int_operand" "i"))
  1953.     (match_operand:SI 3 "gpc_reg_operand" "r"))]
  1954.   ""
  1955.   "*
  1956. {
  1957.   int start = INTVAL (operands[2]) & 31;
  1958.   int size = INTVAL (operands[1]) & 31;
  1959.  
  1960.   operands[4] = gen_rtx (CONST_INT, VOIDmode, 32 - start - size);
  1961.   operands[1] = gen_rtx (CONST_INT, VOIDmode, start + size - 1);
  1962.   return \"{rlimi|rlwimi} %0,%3,%4,%h2,%h1\";
  1963. }")
  1964.  
  1965. (define_insn ""
  1966.   [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
  1967.              (match_operand:SI 1 "const_int_operand" "i")
  1968.              (match_operand:SI 2 "const_int_operand" "i"))
  1969.     (ashift:SI (match_operand:SI 3 "gpc_reg_operand" "r")
  1970.            (match_operand:SI 4 "const_int_operand" "i")))]
  1971.   ""
  1972.   "*
  1973. {
  1974.   int shift = INTVAL (operands[4]) & 31;
  1975.   int start = INTVAL (operands[2]) & 31;
  1976.   int size = INTVAL (operands[1]) & 31;
  1977.  
  1978.   operands[4] = gen_rtx (CONST_INT, VOIDmode, (shift - start - size) & 31);
  1979.   operands[1] = gen_rtx (CONST_INT, VOIDmode, start + size - 1);
  1980.   return \"{rlimi|rlwimi} %0,%3,%4,%h2,%h1\";
  1981. }")
  1982.  
  1983. (define_insn ""
  1984.   [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
  1985.              (match_operand:SI 1 "const_int_operand" "i")
  1986.              (match_operand:SI 2 "const_int_operand" "i"))
  1987.     (ashiftrt:SI (match_operand:SI 3 "gpc_reg_operand" "r")
  1988.              (match_operand:SI 4 "const_int_operand" "i")))]
  1989.   ""
  1990.   "*
  1991. {
  1992.   int shift = INTVAL (operands[4]) & 31;
  1993.   int start = INTVAL (operands[2]) & 31;
  1994.   int size = INTVAL (operands[1]) & 31;
  1995.  
  1996.   operands[4] = gen_rtx (CONST_INT, VOIDmode, (32 - shift - start - size) & 31);
  1997.   operands[1] = gen_rtx (CONST_INT, VOIDmode, start + size - 1);
  1998.   return \"{rlimi|rlwimi} %0,%3,%4,%h2,%h1\";
  1999. }")
  2000.  
  2001. (define_insn ""
  2002.   [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
  2003.              (match_operand:SI 1 "const_int_operand" "i")
  2004.              (match_operand:SI 2 "const_int_operand" "i"))
  2005.     (lshiftrt:SI (match_operand:SI 3 "gpc_reg_operand" "r")
  2006.              (match_operand:SI 4 "const_int_operand" "i")))]
  2007.   ""
  2008.   "*
  2009. {
  2010.   int shift = INTVAL (operands[4]) & 31;
  2011.   int start = INTVAL (operands[2]) & 31;
  2012.   int size = INTVAL (operands[1]) & 31;
  2013.  
  2014.   operands[4] = gen_rtx (CONST_INT, VOIDmode, (32 - shift - start - size) & 31);
  2015.   operands[1] = gen_rtx (CONST_INT, VOIDmode, start + size - 1);
  2016.   return \"{rlimi|rlwimi} %0,%3,%4,%h2,%h1\";
  2017. }")
  2018.  
  2019. (define_insn ""
  2020.   [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
  2021.              (match_operand:SI 1 "const_int_operand" "i")
  2022.              (match_operand:SI 2 "const_int_operand" "i"))
  2023.     (zero_extract:SI (match_operand:SI 3 "gpc_reg_operand" "r")
  2024.              (match_operand:SI 4 "const_int_operand" "i")
  2025.              (match_operand:SI 5 "const_int_operand" "i")))]
  2026.   "INTVAL (operands[4]) >= INTVAL (operands[1])"
  2027.   "*
  2028. {
  2029.   int extract_start = INTVAL (operands[5]) & 31;
  2030.   int extract_size = INTVAL (operands[4]) & 31;
  2031.   int insert_start = INTVAL (operands[2]) & 31;
  2032.   int insert_size = INTVAL (operands[1]) & 31;
  2033.  
  2034. /* Align extract field with insert field */
  2035.   operands[5] = gen_rtx (CONST_INT, VOIDmode,
  2036.              (extract_start + extract_size - insert_start - insert_size) & 31);
  2037.   operands[1] = gen_rtx (CONST_INT, VOIDmode, insert_start + insert_size - 1);
  2038.   return \"{rlimi|rlwimi} %0,%3,%5,%h2,%h1\";
  2039. }")
  2040.  
  2041. (define_expand "extzv"
  2042.   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
  2043.     (zero_extract:SI (match_operand:SI 1 "gpc_reg_operand" "r")
  2044.              (match_operand:SI 2 "const_int_operand" "i")
  2045.              (match_operand:SI 3 "const_int_operand" "i")))]
  2046.   ""
  2047.   "
  2048. {
  2049.   /* Do not handle 16/8 bit structures that fit in HI/QI modes directly, since
  2050.      the (SUBREG:SI (REG:HI xxx)) that is otherwise generated can confuse the
  2051.      compiler if the address of the structure is taken later.  */
  2052.   if (GET_CODE (operands[0]) == SUBREG
  2053.       && (GET_MODE_SIZE (GET_MODE (SUBREG_REG (operands[0]))) < UNITS_PER_WORD))
  2054.     FAIL;
  2055. }")
  2056.  
  2057. (define_insn ""
  2058.   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
  2059.     (zero_extract:SI (match_operand:SI 1 "gpc_reg_operand" "r")
  2060.              (match_operand:SI 2 "const_int_operand" "i")
  2061.              (match_operand:SI 3 "const_int_operand" "i")))]
  2062.   ""
  2063.   "*
  2064. {
  2065.   int start = INTVAL (operands[3]) & 31;
  2066.   int size = INTVAL (operands[2]) & 31;
  2067.  
  2068.   if (start + size >= 32)
  2069.     operands[3] = const0_rtx;
  2070.   else
  2071.     operands[3] = gen_rtx (CONST_INT, VOIDmode, start + size);
  2072.   return \"{rlinm|rlwinm} %0,%1,%3,%s2,31\";
  2073. }")
  2074.  
  2075. (define_insn ""
  2076.   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
  2077.     (compare:CC (zero_extract:SI (match_operand:SI 1 "gpc_reg_operand" "r")
  2078.              (match_operand:SI 2 "const_int_operand" "i")
  2079.              (match_operand:SI 3 "const_int_operand" "i"))
  2080.             (const_int 0)))
  2081.    (clobber (match_scratch:SI 4 "=r"))]
  2082.   ""
  2083.   "*
  2084. {
  2085.   int start = INTVAL (operands[3]) & 31;
  2086.   int size = INTVAL (operands[2]) & 31;
  2087.  
  2088.   /* If the bitfield being tested fits in the upper or lower half of a
  2089.      word, it is possible to use andiu. or andil. to test it.  This is
  2090.      useful because the condition register set-use delay is smaller for
  2091.      andi[ul]. than for rlinm.  This doesn't work when the starting bit
  2092.      position is 0 because the LT and GT bits may be set wrong.  */
  2093.  
  2094.   if ((start > 0 && start + size <= 16) || start >= 16)
  2095.     {
  2096.       operands[3] = gen_rtx (CONST_INT, VOIDmode,
  2097.                  ((1 << (16 - (start & 15)))
  2098.                   - (1 << (16 - (start & 15) - size))));
  2099.       if (start < 16)
  2100.     return \"{andiu.|andis.} %4,%1,%3\";
  2101.       else
  2102.     return \"{andil.|andi.} %4,%1,%3\";
  2103.     }
  2104.  
  2105.   if (start + size >= 32)
  2106.     operands[3] = const0_rtx;
  2107.   else
  2108.     operands[3] = gen_rtx (CONST_INT, VOIDmode, start + size);
  2109.   return \"{rlinm.|rlwinm.} %4,%1,%3,%s2,31\";
  2110. }"
  2111.   [(set_attr "type" "compare")])
  2112.  
  2113. (define_insn ""
  2114.   [(set (match_operand:CC 4 "cc_reg_operand" "=x")
  2115.     (compare:CC (zero_extract:SI (match_operand:SI 1 "gpc_reg_operand" "r")
  2116.              (match_operand:SI 2 "const_int_operand" "i")
  2117.              (match_operand:SI 3 "const_int_operand" "i"))
  2118.             (const_int 0)))
  2119.    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
  2120.     (zero_extract:SI (match_dup 1) (match_dup 2) (match_dup 3)))]
  2121.   ""
  2122.   "*
  2123. {
  2124.   int start = INTVAL (operands[3]) & 31;
  2125.   int size = INTVAL (operands[2]) & 31;
  2126.  
  2127.   if (start >= 16 && start + size == 32)
  2128.     {
  2129.       operands[3] = gen_rtx (CONST_INT, VOIDmode, (1 << (32 - start)) - 1);
  2130.       return \"{andil.|andi.} %0,%1,%3\";
  2131.     }
  2132.  
  2133.   if (start + size >= 32)
  2134.     operands[3] = const0_rtx;
  2135.   else
  2136.     operands[3] = gen_rtx (CONST_INT, VOIDmode, start + size);
  2137.   return \"{rlinm.|rlwinm.} %0,%1,%3,%s2,31\";
  2138. }"
  2139.   [(set_attr "type" "delayed_compare")])
  2140.  
  2141. (define_insn "rotlsi3"
  2142.   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
  2143.     (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r")
  2144.            (match_operand:SI 2 "reg_or_cint_operand" "ri")))]
  2145.   ""
  2146.   "{rl%I2nm|rlw%I2nm} %0,%1,%h2,0xffffffff")
  2147.  
  2148. (define_insn ""
  2149.   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
  2150.     (compare:CC (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r")
  2151.                    (match_operand:SI 2 "reg_or_cint_operand" "ri"))
  2152.             (const_int 0)))
  2153.    (clobber (match_scratch:SI 3 "=r"))]
  2154.   ""
  2155.   "{rl%I2nm.|rlw%I2nm.} %3,%1,%h2,0xffffffff"
  2156.   [(set_attr "type" "delayed_compare")])
  2157.  
  2158. (define_insn ""
  2159.   [(set (match_operand:CC 3 "cc_reg_operand" "=x")
  2160.     (compare:CC (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r")
  2161.                    (match_operand:SI 2 "reg_or_cint_operand" "ri"))
  2162.             (const_int 0)))
  2163.    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
  2164.     (rotate:SI (match_dup 1) (match_dup 2)))]
  2165.   ""
  2166.   "{rl%I2nm.|rlw%I2nm.} %0,%1,%h2,0xffffffff"
  2167.   [(set_attr "type" "delayed_compare")])
  2168.  
  2169. (define_insn ""
  2170.   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
  2171.     (and:SI (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r")
  2172.                (match_operand:SI 2 "reg_or_cint_operand" "ri"))
  2173.         (match_operand:SI 3 "mask_operand" "L")))]
  2174.   ""
  2175.   "{rl%I2nm|rlw%I2nm} %0,%1,%h2,%m3,%M3")
  2176.  
  2177. (define_insn ""
  2178.   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
  2179.     (compare:CC (and:SI
  2180.              (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r")
  2181.                 (match_operand:SI 2 "reg_or_cint_operand" "ri"))
  2182.              (match_operand:SI 3 "mask_operand" "L"))
  2183.             (const_int 0)))
  2184.    (clobber (match_scratch:SI 4 "=r"))]
  2185.   ""
  2186.   "{rl%I2nm.|rlw%I2nm.} %4,%1,%h2,%m3,%M3"
  2187.   [(set_attr "type" "delayed_compare")])
  2188.  
  2189. (define_insn ""
  2190.   [(set (match_operand:CC 4 "cc_reg_operand" "=x")
  2191.     (compare:CC (and:SI
  2192.              (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r")
  2193.                 (match_operand:SI 2 "reg_or_cint_operand" "ri"))
  2194.              (match_operand:SI 3 "mask_operand" "L"))
  2195.             (const_int 0)))
  2196.    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
  2197.     (and:SI (rotate:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
  2198.   ""
  2199.   "{rl%I2nm.|rlw%I2nm.} %0,%1,%h2,%m3,%M3"
  2200.   [(set_attr "type" "delayed_compare")])
  2201.  
  2202. (define_insn ""
  2203.   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
  2204.     (zero_extend:SI
  2205.      (subreg:QI
  2206.       (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r")
  2207.              (match_operand:SI 2 "reg_or_cint_operand" "ri")) 0)))]
  2208.   ""
  2209.   "{rl%I2nm|rlw%I2nm} %0,%1,%h2,0xff")
  2210.  
  2211. (define_insn ""
  2212.   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
  2213.     (compare:CC (zero_extend:SI
  2214.              (subreg:QI
  2215.               (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r")
  2216.                  (match_operand:SI 2 "reg_or_cint_operand" "ri")) 0))
  2217.             (const_int 0)))
  2218.    (clobber (match_scratch:SI 3 "=r"))]
  2219.   ""
  2220.   "{rl%I2nm.|rlw%I2nm.} %3,%1,%h2,0xff"
  2221.   [(set_attr "type" "delayed_compare")])
  2222.  
  2223. (define_insn ""
  2224.   [(set (match_operand:CC 3 "cc_reg_operand" "=x")
  2225.     (compare:CC (zero_extend:SI
  2226.              (subreg:QI
  2227.               (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r")
  2228.                  (match_operand:SI 2 "reg_or_cint_operand" "ri")) 0))
  2229.             (const_int 0)))
  2230.    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
  2231.     (zero_extend:SI (subreg:QI (rotate:SI (match_dup 1) (match_dup 2)) 0)))]
  2232.   ""
  2233.   "{rl%I2nm.|rlw%I2nm.} %0,%1,%h2,0xff"
  2234.   [(set_attr "type" "delayed_compare")])
  2235.  
  2236. (define_insn ""
  2237.   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
  2238.     (zero_extend:SI
  2239.      (subreg:HI
  2240.       (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r")
  2241.              (match_operand:SI 2 "reg_or_cint_operand" "ri")) 0)))]
  2242.   ""
  2243.   "{rl%I2nm|rlw%I2nm} %0,%1,%h2,0xffff")
  2244.  
  2245. (define_insn ""
  2246.   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
  2247.     (compare:CC (zero_extend:SI
  2248.              (subreg:HI
  2249.               (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r")
  2250.                  (match_operand:SI 2 "reg_or_cint_operand" "ri")) 0))
  2251.             (const_int 0)))
  2252.    (clobber (match_scratch:SI 3 "=r"))]
  2253.   ""
  2254.   "{rl%I2nm.|rlw%I2nm.} %3,%1,%h2,0xffff"
  2255.   [(set_attr "type" "delayed_compare")])
  2256.  
  2257. (define_insn ""
  2258.   [(set (match_operand:CC 3 "cc_reg_operand" "=x")
  2259.     (compare:CC (zero_extend:SI
  2260.              (subreg:HI
  2261.               (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r")
  2262.                  (match_operand:SI 2 "reg_or_cint_operand" "ri")) 0))
  2263.             (const_int 0)))
  2264.    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
  2265.     (zero_extend:SI (subreg:HI (rotate:SI (match_dup 1) (match_dup 2)) 0)))]
  2266.   ""
  2267.   "{rl%I2nm.|rlw%I2nm.} %0,%1,%h2,0xffff"
  2268.   [(set_attr "type" "delayed_compare")])
  2269.  
  2270. ;; Note that we use "sle." instead of "sl." so that we can set
  2271. ;; SHIFT_COUNT_TRUNCATED.
  2272.  
  2273. (define_expand "ashlsi3"
  2274.   [(use (match_operand:SI 0 "gpc_reg_operand" ""))
  2275.    (use (match_operand:SI 1 "gpc_reg_operand" ""))
  2276.    (use (match_operand:SI 2 "reg_or_cint_operand" ""))]
  2277.   ""
  2278.   "
  2279. {
  2280.   if (TARGET_POWER)
  2281.     emit_insn (gen_ashlsi3_power (operands[0], operands[1], operands[2]));
  2282.   else
  2283.     emit_insn (gen_ashlsi3_no_power (operands[0], operands[1], operands[2]));
  2284.   DONE;
  2285. }")
  2286.  
  2287. (define_insn "ashlsi3_power"
  2288.   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
  2289.     (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
  2290.            (match_operand:SI 2 "reg_or_cint_operand" "r,i")))
  2291.    (clobber (match_scratch:SI 3 "=q,X"))]
  2292.   "TARGET_POWER"
  2293.   "@
  2294.    sle %0,%1,%2
  2295.    {sli|slwi} %0,%1,%h2"
  2296.   [(set_attr "length" "8")])
  2297.  
  2298. (define_insn "ashlsi3_no_power"
  2299.   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
  2300.     (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r")
  2301.            (match_operand:SI 2 "reg_or_cint_operand" "ri")))]
  2302.   "! TARGET_POWER"
  2303.   "slw%I2 %0,%1,%h2"
  2304.   [(set_attr "length" "8")])
  2305.  
  2306. (define_insn ""
  2307.   [(set (match_operand:CC 0 "cc_reg_operand" "=x,x")
  2308.     (compare:CC (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
  2309.                    (match_operand:SI 2 "reg_or_cint_operand" "r,i"))
  2310.             (const_int 0)))
  2311.    (clobber (match_scratch:SI 3 "=r,r"))
  2312.    (clobber (match_scratch:SI 4 "=q,X"))]
  2313.   "TARGET_POWER"
  2314.   "@
  2315.    sle. %3,%1,%2
  2316.    {sli.|slwi.} %3,%1,%h2"
  2317.   [(set_attr "type" "delayed_compare")])
  2318.  
  2319. (define_insn ""
  2320.   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
  2321.     (compare:CC (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r")
  2322.                    (match_operand:SI 2 "reg_or_cint_operand" "ri"))
  2323.             (const_int 0)))
  2324.    (clobber (match_scratch:SI 3 "=r"))]
  2325.   "! TARGET_POWER"
  2326.   "slw%I2. %3,%1,%h2"
  2327.   [(set_attr "type" "delayed_compare")])
  2328.  
  2329. (define_insn ""
  2330.   [(set (match_operand:CC 3 "cc_reg_operand" "=x,x")
  2331.     (compare:CC (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
  2332.                    (match_operand:SI 2 "reg_or_cint_operand" "r,i"))
  2333.             (const_int 0)))
  2334.    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
  2335.     (ashift:SI (match_dup 1) (match_dup 2)))
  2336.    (clobber (match_scratch:SI 4 "=q,X"))]
  2337.   "TARGET_POWER"
  2338.   "@
  2339.    sle. %0,%1,%2
  2340.    {sli.|slwi.} %0,%1,%h2"
  2341.   [(set_attr "type" "delayed_compare")])
  2342.  
  2343. (define_insn ""
  2344.   [(set (match_operand:CC 3 "cc_reg_operand" "=x")
  2345.     (compare:CC (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r")
  2346.                    (match_operand:SI 2 "reg_or_cint_operand" "ri"))
  2347.             (const_int 0)))
  2348.    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
  2349.     (ashift:SI (match_dup 1) (match_dup 2)))]
  2350.   "! TARGET_POWER"
  2351.   "slw%I2. %0,%1,%h2"
  2352.   [(set_attr "type" "delayed_compare")])
  2353.  
  2354. (define_insn ""
  2355.   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
  2356.     (and:SI (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r")
  2357.                (match_operand:SI 2 "const_int_operand" "i"))
  2358.         (match_operand:SI 3 "mask_operand" "L")))]
  2359.   "includes_lshift_p (operands[2], operands[3])"
  2360.   "{rlinm|rlwinm} %0,%1,%h2,%m3,%M3")
  2361.  
  2362. (define_insn ""
  2363.   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
  2364.     (compare:CC
  2365.      (and:SI (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r")
  2366.                 (match_operand:SI 2 "const_int_operand" "i"))
  2367.          (match_operand:SI 3 "mask_operand" "L"))
  2368.      (const_int 0)))
  2369.    (clobber (match_scratch:SI 4 "=r"))]
  2370.   "includes_lshift_p (operands[2], operands[3])"
  2371.   "{rlinm.|rlwinm.} %4,%1,%h2,%m3,%M3"
  2372.   [(set_attr "type" "delayed_compare")])
  2373.  
  2374. (define_insn ""
  2375.   [(set (match_operand:CC 4 "cc_reg_operand" "=x")
  2376.     (compare:CC
  2377.      (and:SI (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r")
  2378.                 (match_operand:SI 2 "const_int_operand" "i"))
  2379.          (match_operand:SI 3 "mask_operand" "L"))
  2380.      (const_int 0)))
  2381.    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
  2382.     (and:SI (ashift:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
  2383.   "includes_lshift_p (operands[2], operands[3])"
  2384.   "{rlinm.|rlwinm.} %0,%1,%h2,%m3,%M3"
  2385.   [(set_attr "type" "delayed_compare")])
  2386.  
  2387. ;; The AIX assembler mis-handles "sri x,x,0", so write that case as
  2388. ;; "sli x,x,0".
  2389. (define_expand "lshrsi3"
  2390.   [(use (match_operand:SI 0 "gpc_reg_operand" ""))
  2391.    (use (match_operand:SI 1 "gpc_reg_operand" ""))
  2392.    (use (match_operand:SI 2 "reg_or_cint_operand" ""))]
  2393.   ""
  2394.   "
  2395. {
  2396.   if (TARGET_POWER)
  2397.     emit_insn (gen_lshrsi3_power (operands[0], operands[1], operands[2]));
  2398.   else
  2399.     emit_insn (gen_lshrsi3_no_power (operands[0], operands[1], operands[2]));
  2400.   DONE;
  2401. }")
  2402.  
  2403. (define_insn "lshrsi3_power"
  2404.   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
  2405.     (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
  2406.              (match_operand:SI 2 "reg_or_cint_operand" "r,i")))
  2407.    (clobber (match_scratch:SI 3 "=q,X"))]
  2408.   "TARGET_POWER"
  2409.   "@
  2410.   sre %0,%1,%2
  2411.   {s%A2i|s%A2wi} %0,%1,%h2")
  2412.  
  2413. (define_insn "lshrsi3_no_power"
  2414.   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
  2415.     (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
  2416.              (match_operand:SI 2 "reg_or_cint_operand" "ri")))]
  2417.   "! TARGET_POWER"
  2418.   "srw%I2 %0,%1,%h2")
  2419.  
  2420. (define_insn ""
  2421.   [(set (match_operand:CC 0 "cc_reg_operand" "=x,x")
  2422.     (compare:CC (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
  2423.                  (match_operand:SI 2 "reg_or_cint_operand" "r,i"))
  2424.             (const_int 0)))
  2425.    (clobber (match_scratch:SI 3 "=r,r"))
  2426.    (clobber (match_scratch:SI 4 "=q,X"))]
  2427.   "TARGET_POWER"
  2428.   "@
  2429.   sre. %3,%1,%2
  2430.   {s%A2i.|s%A2wi.} %3,%1,%h2"
  2431.   [(set_attr "type" "delayed_compare")])
  2432.  
  2433. (define_insn ""
  2434.   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
  2435.     (compare:CC (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
  2436.                  (match_operand:SI 2 "reg_or_cint_operand" "ri"))
  2437.             (const_int 0)))
  2438.    (clobber (match_scratch:SI 3 "=r"))]
  2439.   "! TARGET_POWER"
  2440.   "srw%I2. %3,%1,%h2"
  2441.   [(set_attr "type" "delayed_compare")])
  2442.  
  2443. (define_insn ""
  2444.   [(set (match_operand:CC 3 "cc_reg_operand" "=x,x")
  2445.     (compare:CC (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
  2446.                  (match_operand:SI 2 "reg_or_cint_operand" "r,i"))
  2447.             (const_int 0)))
  2448.    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
  2449.     (lshiftrt:SI (match_dup 1) (match_dup 2)))
  2450.    (clobber (match_scratch:SI 4 "=q,X"))]
  2451.   "TARGET_POWER"
  2452.   "@
  2453.   sre. %0,%1,%2
  2454.   {s%A2i.|s%A2wi.} %0,%1,%h2"
  2455.   [(set_attr "type" "delayed_compare")])
  2456.  
  2457. (define_insn ""
  2458.   [(set (match_operand:CC 3 "cc_reg_operand" "=x")
  2459.     (compare:CC (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
  2460.                  (match_operand:SI 2 "reg_or_cint_operand" "ri"))
  2461.             (const_int 0)))
  2462.    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
  2463.     (lshiftrt:SI (match_dup 1) (match_dup 2)))]
  2464.   "! TARGET_POWER"
  2465.   "srw%I2. %0,%1,%h2"
  2466.   [(set_attr "type" "delayed_compare")])
  2467.  
  2468. (define_insn ""
  2469.   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
  2470.     (and:SI (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
  2471.                  (match_operand:SI 2 "const_int_operand" "i"))
  2472.         (match_operand:SI 3 "mask_operand" "L")))]
  2473.   "includes_rshift_p (operands[2], operands[3])"
  2474.   "{rlinm|rlwinm} %0,%1,%s2,%m3,%M3")
  2475.  
  2476. (define_insn ""
  2477.   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
  2478.     (compare:CC
  2479.      (and:SI (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
  2480.                   (match_operand:SI 2 "const_int_operand" "i"))
  2481.          (match_operand:SI 3 "mask_operand" "L"))
  2482.      (const_int 0)))
  2483.    (clobber (match_scratch:SI 4 "=r"))]
  2484.   "includes_rshift_p (operands[2], operands[3])"
  2485.   "{rlinm.|rlwinm.} %4,%1,%s2,%m3,%M3"
  2486.   [(set_attr "type" "delayed_compare")])
  2487.  
  2488. (define_insn ""
  2489.   [(set (match_operand:CC 4 "cc_reg_operand" "=x")
  2490.     (compare:CC
  2491.      (and:SI (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
  2492.                   (match_operand:SI 2 "const_int_operand" "i"))
  2493.          (match_operand:SI 3 "mask_operand" "L"))
  2494.      (const_int 0)))
  2495.    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
  2496.     (and:SI (lshiftrt:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
  2497.   "includes_rshift_p (operands[2], operands[3])"
  2498.   "{rlinm.|rlwinm.} %0,%1,%s2,%m3,%M3"
  2499.   [(set_attr "type" "delayed_compare")])
  2500.  
  2501. (define_insn ""
  2502.   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
  2503.     (zero_extend:SI
  2504.      (subreg:QI
  2505.       (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
  2506.                (match_operand:SI 2 "const_int_operand" "i")) 0)))]
  2507.   "includes_rshift_p (operands[2], gen_rtx (CONST_INT, VOIDmode, 255))"
  2508.   "{rlinm|rlwinm} %0,%1,%s2,0xff")
  2509.  
  2510. (define_insn ""
  2511.   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
  2512.     (compare:CC
  2513.      (zero_extend:SI
  2514.       (subreg:QI
  2515.        (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
  2516.             (match_operand:SI 2 "const_int_operand" "i")) 0))
  2517.      (const_int 0)))
  2518.    (clobber (match_scratch:SI 3 "=r"))]
  2519.   "includes_rshift_p (operands[2], gen_rtx (CONST_INT, VOIDmode, 255))"
  2520.   "{rlinm.|rlwinm.} %3,%1,%s2,0xff"
  2521.   [(set_attr "type" "delayed_compare")])
  2522.  
  2523. (define_insn ""
  2524.   [(set (match_operand:CC 3 "cc_reg_operand" "=x")
  2525.     (compare:CC
  2526.      (zero_extend:SI
  2527.       (subreg:QI
  2528.        (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
  2529.             (match_operand:SI 2 "const_int_operand" "i")) 0))
  2530.      (const_int 0)))
  2531.    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
  2532.     (zero_extend:SI (subreg:QI (lshiftrt:SI (match_dup 1) (match_dup 2)) 0)))]
  2533.   "includes_rshift_p (operands[2], gen_rtx (CONST_INT, VOIDmode, 255))"
  2534.   "{rlinm.|rlwinm.} %0,%1,%s2,0xff"
  2535.   [(set_attr "type" "delayed_compare")])
  2536.  
  2537. (define_insn ""
  2538.   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
  2539.     (zero_extend:SI
  2540.      (subreg:HI
  2541.       (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
  2542.                (match_operand:SI 2 "const_int_operand" "i")) 0)))]
  2543.   "includes_rshift_p (operands[2], gen_rtx (CONST_INT, VOIDmode, 65535))"
  2544.   "{rlinm|rlwinm} %0,%1,%s2,0xffff")
  2545.  
  2546. (define_insn ""
  2547.   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
  2548.     (compare:CC
  2549.      (zero_extend:SI
  2550.       (subreg:HI
  2551.        (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
  2552.             (match_operand:SI 2 "const_int_operand" "i")) 0))
  2553.      (const_int 0)))
  2554.    (clobber (match_scratch:SI 3 "=r"))]
  2555.   "includes_rshift_p (operands[2], gen_rtx (CONST_INT, VOIDmode, 65535))"
  2556.   "{rlinm.|rlwinm.} %3,%1,%s2,0xffff"
  2557.   [(set_attr "type" "delayed_compare")])
  2558.  
  2559. (define_insn ""
  2560.   [(set (match_operand:CC 3 "cc_reg_operand" "=x")
  2561.     (compare:CC
  2562.      (zero_extend:SI
  2563.       (subreg:HI
  2564.        (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
  2565.             (match_operand:SI 2 "const_int_operand" "i")) 0))
  2566.      (const_int 0)))
  2567.    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
  2568.     (zero_extend:SI (subreg:HI (lshiftrt:SI (match_dup 1) (match_dup 2)) 0)))]
  2569.   "includes_rshift_p (operands[2], gen_rtx (CONST_INT, VOIDmode, 65535))"
  2570.   "{rlinm.|rlwinm.} %0,%1,%s2,0xffff"
  2571.   [(set_attr "type" "delayed_compare")])
  2572.  
  2573. (define_insn ""
  2574.   [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
  2575.              (const_int 1)
  2576.              (match_operand:SI 1 "gpc_reg_operand" "r"))
  2577.     (ashiftrt:SI (match_operand:SI 2 "gpc_reg_operand" "r")
  2578.              (const_int 31)))]
  2579.   "TARGET_POWER"
  2580.   "rrib %0,%1,%2")
  2581.  
  2582. (define_insn ""
  2583.   [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
  2584.              (const_int 1)
  2585.              (match_operand:SI 1 "gpc_reg_operand" "r"))
  2586.     (lshiftrt:SI (match_operand:SI 2 "gpc_reg_operand" "r")
  2587.              (const_int 31)))]
  2588.   "TARGET_POWER"
  2589.   "rrib %0,%1,%2")
  2590.  
  2591. (define_insn ""
  2592.   [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
  2593.              (const_int 1)
  2594.              (match_operand:SI 1 "gpc_reg_operand" "r"))
  2595.     (zero_extract:SI (match_operand:SI 2 "gpc_reg_operand" "r")
  2596.              (const_int 1)
  2597.              (const_int 0)))]
  2598.   "TARGET_POWER"
  2599.   "rrib %0,%1,%2")
  2600.  
  2601. (define_expand "ashrsi3"
  2602.   [(set (match_operand:SI 0 "gpc_reg_operand" "")
  2603.     (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
  2604.              (match_operand:SI 2 "reg_or_cint_operand" "")))]
  2605.   ""
  2606.   "
  2607. {
  2608.   if (TARGET_POWER)
  2609.     emit_insn (gen_ashrsi3_power (operands[0], operands[1], operands[2]));
  2610.   else
  2611.     emit_insn (gen_ashrsi3_no_power (operands[0], operands[1], operands[2]));
  2612.   DONE;
  2613. }")
  2614.  
  2615. (define_insn "ashrsi3_power"
  2616.   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
  2617.     (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
  2618.              (match_operand:SI 2 "reg_or_cint_operand" "r,i")))
  2619.    (clobber (match_scratch:SI 3 "=q,X"))]
  2620.   "TARGET_POWER"
  2621.   "@
  2622.    srea %0,%1,%2
  2623.    {srai|srawi} %0,%1,%h2")
  2624.  
  2625. (define_insn "ashrsi3_no_power"
  2626.   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
  2627.     (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
  2628.              (match_operand:SI 2 "reg_or_cint_operand" "ri")))]
  2629.   "! TARGET_POWER"
  2630.   "sraw%I2 %0,%1,%h2")
  2631.  
  2632. (define_insn ""
  2633.   [(set (match_operand:CC 0 "cc_reg_operand" "=x,x")
  2634.     (compare:CC (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
  2635.                  (match_operand:SI 2 "reg_or_cint_operand" "r,i"))
  2636.             (const_int 0)))
  2637.    (clobber (match_scratch:SI 3 "=r,r"))
  2638.    (clobber (match_scratch:SI 4 "=q,X"))]
  2639.   "TARGET_POWER"
  2640.   "@
  2641.    srea. %3,%1,%2
  2642.    {srai.|srawi.} %3,%1,%h2"
  2643.   [(set_attr "type" "delayed_compare")])
  2644.  
  2645. (define_insn ""
  2646.   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
  2647.     (compare:CC (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
  2648.                  (match_operand:SI 2 "reg_or_cint_operand" "ri"))
  2649.             (const_int 0)))
  2650.    (clobber (match_scratch:SI 3 "=r"))]
  2651.   "! TARGET_POWER"
  2652.   "sraw%I2. %3,%1,%h2"
  2653.   [(set_attr "type" "delayed_compare")])
  2654.  
  2655. (define_insn ""
  2656.   [(set (match_operand:CC 3 "cc_reg_operand" "=x,x")
  2657.     (compare:CC (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
  2658.                  (match_operand:SI 2 "reg_or_cint_operand" "r,i"))
  2659.             (const_int 0)))
  2660.    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
  2661.     (ashiftrt:SI (match_dup 1) (match_dup 2)))
  2662.    (clobber (match_scratch:SI 4 "=q,X"))]
  2663.   "TARGET_POWER"
  2664.   "@
  2665.    srea. %0,%1,%2
  2666.    {srai.|srawi.} %0,%1,%h2"
  2667.   [(set_attr "type" "delayed_compare")])
  2668.  
  2669. (define_insn ""
  2670.   [(set (match_operand:CC 3 "cc_reg_operand" "=x")
  2671.     (compare:CC (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
  2672.                  (match_operand:SI 2 "reg_or_cint_operand" "ri"))
  2673.             (const_int 0)))
  2674.    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
  2675.     (ashiftrt:SI (match_dup 1) (match_dup 2)))]
  2676.   "! TARGET_POWER"
  2677.   "sraw%I2. %0,%1,%h2"
  2678.   [(set_attr "type" "delayed_compare")])
  2679.  
  2680. ;; Floating-point insns, excluding normal data motion.
  2681. ;;
  2682. ;; PowerPC has a full set of single-precision floating point instructions.
  2683. ;;
  2684. ;; For the POWER architecture, we pretend that we have both SFmode and
  2685. ;; DFmode insns, while, in fact, all fp insns are actually done in double.
  2686. ;; The only conversions we will do will be when storing to memory.  In that
  2687. ;; case, we will use the "frsp" instruction before storing.
  2688. ;;
  2689. ;; Note that when we store into a single-precision memory location, we need to
  2690. ;; use the frsp insn first.  If the register being stored isn't dead, we
  2691. ;; need a scratch register for the frsp.  But this is difficult when the store
  2692. ;; is done by reload.  It is not incorrect to do the frsp on the register in
  2693. ;; this case, we just lose precision that we would have otherwise gotten but
  2694. ;; is not guaranteed.  Perhaps this should be tightened up at some point.
  2695.  
  2696. (define_insn "extendsfdf2"
  2697.   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
  2698.     (float_extend:DF (match_operand:SF 1 "gpc_reg_operand" "f")))]
  2699.   "TARGET_HARD_FLOAT"
  2700.   "*
  2701. {
  2702.   if (REGNO (operands[0]) == REGNO (operands[1]))
  2703.     return \"\";
  2704.   else
  2705.     return \"fmr %0,%1\";
  2706. }"
  2707.   [(set_attr "type" "fp")])
  2708.  
  2709. (define_insn "truncdfsf2"
  2710.   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
  2711.     (float_truncate:SF (match_operand:DF 1 "gpc_reg_operand" "f")))]
  2712.   "TARGET_HARD_FLOAT"
  2713.   "frsp %0,%1"
  2714.   [(set_attr "type" "fp")])
  2715.  
  2716. (define_insn "aux_truncdfsf2"
  2717.   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
  2718.     (unspec:SF [(match_operand:SF 1 "gpc_reg_operand" "f")] 0))]
  2719.   "! TARGET_POWERPC && TARGET_HARD_FLOAT"
  2720.   "frsp %0,%1"
  2721.   [(set_attr "type" "fp")])
  2722.  
  2723. (define_insn "negsf2"
  2724.   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
  2725.     (neg:SF (match_operand:SF 1 "gpc_reg_operand" "f")))]
  2726.   "TARGET_HARD_FLOAT"
  2727.   "fneg %0,%1"
  2728.   [(set_attr "type" "fp")])
  2729.  
  2730. (define_insn "abssf2"
  2731.   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
  2732.     (abs:SF (match_operand:SF 1 "gpc_reg_operand" "f")))]
  2733.   "TARGET_HARD_FLOAT"
  2734.   "fabs %0,%1"
  2735.   [(set_attr "type" "fp")])
  2736.  
  2737. (define_insn ""
  2738.   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
  2739.     (neg:SF (abs:SF (match_operand:SF 1 "gpc_reg_operand" "f"))))]
  2740.   "TARGET_HARD_FLOAT"
  2741.   "fnabs %0,%1"
  2742.   [(set_attr "type" "fp")])
  2743.  
  2744. (define_expand "addsf3"
  2745.   [(set (match_operand:SF 0 "gpc_reg_operand" "")
  2746.     (plus:SF (match_operand:SF 1 "gpc_reg_operand" "")
  2747.          (match_operand:SF 2 "gpc_reg_operand" "")))]
  2748.   "TARGET_HARD_FLOAT"
  2749.   "")
  2750.  
  2751. (define_insn ""
  2752.   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
  2753.     (plus:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
  2754.          (match_operand:SF 2 "gpc_reg_operand" "f")))]
  2755.   "TARGET_POWERPC && TARGET_HARD_FLOAT"
  2756.   "fadds %0,%1,%2"
  2757.   [(set_attr "type" "fp")])
  2758.  
  2759. (define_insn ""
  2760.   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
  2761.     (plus:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
  2762.          (match_operand:SF 2 "gpc_reg_operand" "f")))]
  2763.   "! TARGET_POWERPC && TARGET_HARD_FLOAT"
  2764.   "{fa|fadd} %0,%1,%2"
  2765.   [(set_attr "type" "fp")])
  2766.  
  2767. (define_expand "subsf3"
  2768.   [(set (match_operand:SF 0 "gpc_reg_operand" "")
  2769.     (minus:SF (match_operand:SF 1 "gpc_reg_operand" "")
  2770.           (match_operand:SF 2 "gpc_reg_operand" "")))]
  2771.   "TARGET_HARD_FLOAT"
  2772.   "")
  2773.  
  2774. (define_insn ""
  2775.   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
  2776.     (minus:SF (match_operand:SF 1 "gpc_reg_operand" "f")
  2777.           (match_operand:SF 2 "gpc_reg_operand" "f")))]
  2778.   "TARGET_POWERPC && TARGET_HARD_FLOAT"
  2779.   "fsubs %0,%1,%2"
  2780.   [(set_attr "type" "fp")])
  2781.  
  2782. (define_insn ""
  2783.   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
  2784.     (minus:SF (match_operand:SF 1 "gpc_reg_operand" "f")
  2785.           (match_operand:SF 2 "gpc_reg_operand" "f")))]
  2786.   "! TARGET_POWERPC && TARGET_HARD_FLOAT"
  2787.   "{fs|fsub} %0,%1,%2"
  2788.   [(set_attr "type" "fp")])
  2789.  
  2790. (define_expand "mulsf3"
  2791.   [(set (match_operand:SF 0 "gpc_reg_operand" "")
  2792.     (mult:SF (match_operand:SF 1 "gpc_reg_operand" "")
  2793.          (match_operand:SF 2 "gpc_reg_operand" "")))]
  2794.   "TARGET_HARD_FLOAT"
  2795.   "")
  2796.  
  2797. (define_insn ""
  2798.   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
  2799.     (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
  2800.          (match_operand:SF 2 "gpc_reg_operand" "f")))]
  2801.   "TARGET_POWERPC && TARGET_HARD_FLOAT"
  2802.   "fmuls %0,%1,%2"
  2803.   [(set_attr "type" "fp")])
  2804.  
  2805. (define_insn ""
  2806.   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
  2807.     (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
  2808.          (match_operand:SF 2 "gpc_reg_operand" "f")))]
  2809.   "! TARGET_POWERPC && TARGET_HARD_FLOAT"
  2810.   "{fm|fmul} %0,%1,%2"
  2811.   [(set_attr "type" "fp")])
  2812.  
  2813. (define_expand "divsf3"
  2814.   [(set (match_operand:SF 0 "gpc_reg_operand" "")
  2815.     (div:SF (match_operand:SF 1 "gpc_reg_operand" "")
  2816.         (match_operand:SF 2 "gpc_reg_operand" "")))]
  2817.   "TARGET_HARD_FLOAT"
  2818.   "")
  2819.  
  2820. (define_insn ""
  2821.   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
  2822.     (div:SF (match_operand:SF 1 "gpc_reg_operand" "f")
  2823.         (match_operand:SF 2 "gpc_reg_operand" "f")))]
  2824.   "TARGET_POWERPC && TARGET_HARD_FLOAT"
  2825.   "fdivs %0,%1,%2"
  2826.   [(set_attr "type" "sdiv")])
  2827.  
  2828. (define_insn ""
  2829.   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
  2830.     (div:SF (match_operand:SF 1 "gpc_reg_operand" "f")
  2831.         (match_operand:SF 2 "gpc_reg_operand" "f")))]
  2832.   "! TARGET_POWERPC && TARGET_HARD_FLOAT"
  2833.   "{fd|fdiv} %0,%1,%2"
  2834.   [(set_attr "type" "sdiv")])
  2835.  
  2836. (define_insn ""
  2837.   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
  2838.     (plus:SF (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
  2839.               (match_operand:SF 2 "gpc_reg_operand" "f"))
  2840.          (match_operand:SF 3 "gpc_reg_operand" "f")))]
  2841.   "TARGET_POWERPC && TARGET_HARD_FLOAT"
  2842.   "fmadds %0,%1,%2,%3"
  2843.   [(set_attr "type" "fp")])
  2844.  
  2845. (define_insn ""
  2846.   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
  2847.     (plus:SF (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
  2848.               (match_operand:SF 2 "gpc_reg_operand" "f"))
  2849.          (match_operand:SF 3 "gpc_reg_operand" "f")))]
  2850.   "! TARGET_POWERPC && TARGET_HARD_FLOAT"
  2851.   "{fma|fmadd} %0,%1,%2,%3"
  2852.   [(set_attr "type" "fp")])
  2853.  
  2854. (define_insn ""
  2855.   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
  2856.     (minus:SF (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
  2857.                (match_operand:SF 2 "gpc_reg_operand" "f"))
  2858.           (match_operand:SF 3 "gpc_reg_operand" "f")))]
  2859.   "TARGET_POWERPC && TARGET_HARD_FLOAT"
  2860.   "fmsubs %0,%1,%2,%3"
  2861.   [(set_attr "type" "fp")])
  2862.  
  2863. (define_insn ""
  2864.   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
  2865.     (minus:SF (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
  2866.                (match_operand:SF 2 "gpc_reg_operand" "f"))
  2867.           (match_operand:SF 3 "gpc_reg_operand" "f")))]
  2868.   "! TARGET_POWERPC && TARGET_HARD_FLOAT"
  2869.   "{fms|fmsub} %0,%1,%2,%3"
  2870.   [(set_attr "type" "fp")])
  2871.  
  2872. (define_insn ""
  2873.   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
  2874.     (neg:SF (plus:SF (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
  2875.                   (match_operand:SF 2 "gpc_reg_operand" "f"))
  2876.              (match_operand:SF 3 "gpc_reg_operand" "f"))))]
  2877.   "TARGET_POWERPC && TARGET_HARD_FLOAT"
  2878.   "fnmadds %0,%1,%2,%3"
  2879.   [(set_attr "type" "fp")])
  2880.  
  2881. (define_insn ""
  2882.   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
  2883.     (neg:SF (plus:SF (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
  2884.                   (match_operand:SF 2 "gpc_reg_operand" "f"))
  2885.              (match_operand:SF 3 "gpc_reg_operand" "f"))))]
  2886.   "! TARGET_POWERPC && TARGET_HARD_FLOAT"
  2887.   "{fnma|fnmadd} %0,%1,%2,%3"
  2888.   [(set_attr "type" "fp")])
  2889.  
  2890. (define_insn ""
  2891.   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
  2892.     (neg:SF (minus:SF (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
  2893.                    (match_operand:SF 2 "gpc_reg_operand" "f"))
  2894.               (match_operand:SF 3 "gpc_reg_operand" "f"))))]
  2895.   "TARGET_POWERPC && TARGET_HARD_FLOAT"
  2896.   "fnmsubs %0,%1,%2,%3"
  2897.   [(set_attr "type" "fp")])
  2898.  
  2899. (define_insn ""
  2900.   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
  2901.     (neg:SF (minus:SF (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
  2902.                    (match_operand:SF 2 "gpc_reg_operand" "f"))
  2903.               (match_operand:SF 3 "gpc_reg_operand" "f"))))]
  2904.   "! TARGET_POWERPC && TARGET_HARD_FLOAT"
  2905.   "{fnms|fnmsub} %0,%1,%2,%3"
  2906.   [(set_attr "type" "fp")])
  2907.  
  2908. (define_expand "sqrtsf2"
  2909.   [(set (match_operand:SF 0 "gpc_reg_operand" "")
  2910.     (sqrt:SF (match_operand:SF 1 "gpc_reg_operand" "")))]
  2911.   "(TARGET_PPC_GPOPT || TARGET_POWER2) && TARGET_HARD_FLOAT"
  2912.   "")
  2913.  
  2914. (define_insn ""
  2915.   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
  2916.     (sqrt:SF (match_operand:SF 1 "gpc_reg_operand" "f")))]
  2917.   "TARGET_PPC_GPOPT && TARGET_HARD_FLOAT"
  2918.   "fsqrts %0,%1"
  2919.   [(set_attr "type" "ssqrt")])
  2920.  
  2921. (define_insn ""
  2922.   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
  2923.     (sqrt:SF (match_operand:SF 1 "gpc_reg_operand" "f")))]
  2924.   "TARGET_POWER2 && TARGET_HARD_FLOAT"
  2925.   "fsqrt %0,%1"
  2926.   [(set_attr "type" "dsqrt")])
  2927.  
  2928. ;; For MIN, MAX, and conditional move, we use DEFINE_EXPAND's that involve a
  2929. ;; fsel instruction and some auxiliary computations.  Then we just have a
  2930. ;; single DEFINE_INSN for fsel and the define_splits to make them if made by
  2931. ;; combine.
  2932. (define_expand "maxsf3"
  2933.   [(set (match_dup 3)
  2934.     (minus:SF (match_operand:SF 1 "gpc_reg_operand" "")
  2935.           (match_operand:SF 2 "gpc_reg_operand" "")))
  2936.    (set (match_operand:SF 0 "gpc_reg_operand" "")
  2937.     (if_then_else:SF (ge (match_dup 3)
  2938.                  (const_int 0))
  2939.              (match_dup 1)
  2940.              (match_dup 2)))]
  2941.   "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT"
  2942.   "
  2943. { operands[3] = gen_reg_rtx (SFmode); }")
  2944.  
  2945. (define_split
  2946.   [(set (match_operand:SF 0 "gpc_reg_operand" "")
  2947.     (smax:SF (match_operand:SF 1 "gpc_reg_operand" "")
  2948.          (match_operand:SF 2 "gpc_reg_operand" "")))
  2949.    (clobber (match_operand:SF 3 "gpc_reg_operand" ""))]
  2950.   "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT"
  2951.   [(set (match_dup 3)
  2952.     (minus:SF (match_dup 1) (match_dup 2)))
  2953.    (set (match_dup 0)
  2954.     (if_then_else:SF (ge (match_dup 3)
  2955.                  (const_int 0))
  2956.              (match_dup 1)
  2957.              (match_dup 2)))]
  2958.   "")
  2959.  
  2960. (define_expand "minsf3"
  2961.   [(set (match_dup 3)
  2962.     (minus:SF (match_operand:SF 2 "gpc_reg_operand" "")
  2963.           (match_operand:SF 1 "gpc_reg_operand" "")))
  2964.    (set (match_operand:SF 0 "gpc_reg_operand" "")
  2965.     (if_then_else:SF (ge (match_dup 3)
  2966.                  (const_int 0))
  2967.              (match_dup 1)
  2968.              (match_dup 2)))]
  2969.   "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT"
  2970.   "
  2971. { operands[3] = gen_reg_rtx (SFmode); }")
  2972.  
  2973. (define_split
  2974.   [(set (match_operand:SF 0 "gpc_reg_operand" "")
  2975.     (smin:SF (match_operand:SF 1 "gpc_reg_operand" "")
  2976.          (match_operand:SF 2 "gpc_reg_operand" "")))
  2977.    (clobber (match_operand:SF 3 "gpc_reg_operand" ""))]
  2978.   "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT"
  2979.   [(set (match_dup 3)
  2980.     (minus:SF (match_dup 2) (match_dup 1)))
  2981.    (set (match_dup 0)
  2982.     (if_then_else:SF (ge (match_dup 3)
  2983.                  (const_int 0))
  2984.              (match_dup 1)
  2985.              (match_dup 2)))]
  2986.   "")
  2987.  
  2988. (define_expand "movsfcc"
  2989.    [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
  2990.      (if_then_else:SF (match_operand 1 "comparison_operator" "")
  2991.               (match_operand:SF 2 "gpc_reg_operand" "f")
  2992.               (match_operand:SF 3 "gpc_reg_operand" "f")))]
  2993.   "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT"
  2994.   "
  2995. {
  2996.   rtx temp, op0, op1;
  2997.   enum rtx_code code = GET_CODE (operands[1]);
  2998.   if (! rs6000_compare_fp_p)
  2999.     FAIL;
  3000.   switch (code)
  3001.     {
  3002.     case GE: case EQ: case NE:
  3003.       op0 = rs6000_compare_op0;
  3004.       op1 = rs6000_compare_op1;
  3005.       break;
  3006.     case GT:
  3007.       op0 = rs6000_compare_op1;
  3008.       op1 = rs6000_compare_op0;
  3009.       temp = operands[2]; operands[2] = operands[3]; operands[3] = temp;
  3010.       break;
  3011.     case LE:
  3012.       op0 = rs6000_compare_op1;
  3013.       op1 = rs6000_compare_op0;
  3014.       break;
  3015.     case LT:
  3016.       op0 = rs6000_compare_op0;
  3017.       op1 = rs6000_compare_op1;
  3018.       temp = operands[2]; operands[2] = operands[3]; operands[3] = temp;
  3019.       break;
  3020.     default:
  3021.       FAIL;
  3022.     }
  3023.   if (GET_MODE (rs6000_compare_op0) == DFmode)
  3024.     {
  3025.       temp = gen_reg_rtx (DFmode);
  3026.       emit_insn (gen_subdf3 (temp, op0, op1));
  3027.       emit_insn (gen_fseldfsf4 (operands[0], temp, operands[2], operands[3]));
  3028.       if (code == EQ)
  3029.     {
  3030.       emit_insn (gen_negdf2 (temp, temp));
  3031.       emit_insn (gen_fseldfsf4 (operands[0], temp, operands[0], operands[3]));
  3032.     }
  3033.       if (code == NE)
  3034.     {
  3035.       emit_insn (gen_negdf2 (temp, temp));
  3036.       emit_insn (gen_fseldfsf4 (operands[0], temp, operands[3], operands[0]));
  3037.     }
  3038.     }
  3039.   else
  3040.     {
  3041.       temp = gen_reg_rtx (SFmode);
  3042.       emit_insn (gen_subsf3 (temp, op0, op1));
  3043.       emit_insn (gen_fselsfsf4 (operands[0], temp, operands[2], operands[3]));
  3044.       if (code == EQ)
  3045.     {
  3046.       emit_insn (gen_negsf2 (temp, temp));
  3047.       emit_insn (gen_fselsfsf4 (operands[0], temp, operands[0], operands[3]));
  3048.     }
  3049.       if (code == NE)
  3050.     {
  3051.       emit_insn (gen_negsf2 (temp, temp));
  3052.       emit_insn (gen_fselsfsf4 (operands[0], temp, operands[3], operands[0]));
  3053.     }
  3054.     }
  3055.   DONE;
  3056. }")
  3057.  
  3058. (define_insn "fselsfsf4"
  3059.   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
  3060.     (if_then_else:SF (ge (match_operand:SF 1 "gpc_reg_operand" "f")
  3061.                  (const_int 0))
  3062.              (match_operand:SF 2 "gpc_reg_operand" "f")
  3063.              (match_operand:SF 3 "gpc_reg_operand" "f")))]
  3064.   "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT"
  3065.   "fsel %0,%1,%2,%3"
  3066.   [(set_attr "type" "fp")])
  3067.  
  3068. (define_insn "fseldfsf4"
  3069.   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
  3070.     (if_then_else:SF (ge (match_operand:DF 1 "gpc_reg_operand" "f")
  3071.                  (const_int 0))
  3072.              (match_operand:SF 2 "gpc_reg_operand" "f")
  3073.              (match_operand:SF 3 "gpc_reg_operand" "f")))]
  3074.   "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT"
  3075.   "fsel %0,%1,%2,%3"
  3076.   [(set_attr "type" "fp")])
  3077.  
  3078. (define_insn "negdf2"
  3079.   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
  3080.     (neg:DF (match_operand:DF 1 "gpc_reg_operand" "f")))]
  3081.   "TARGET_HARD_FLOAT"
  3082.   "fneg %0,%1"
  3083.   [(set_attr "type" "fp")])
  3084.  
  3085. (define_insn "absdf2"
  3086.   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
  3087.     (abs:DF (match_operand:DF 1 "gpc_reg_operand" "f")))]
  3088.   "TARGET_HARD_FLOAT"
  3089.   "fabs %0,%1"
  3090.   [(set_attr "type" "fp")])
  3091.  
  3092. (define_insn ""
  3093.   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
  3094.     (neg:DF (abs:DF (match_operand:DF 1 "gpc_reg_operand" "f"))))]
  3095.   "TARGET_HARD_FLOAT"
  3096.   "fnabs %0,%1"
  3097.   [(set_attr "type" "fp")])
  3098.  
  3099. (define_insn "adddf3"
  3100.   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
  3101.     (plus:DF (match_operand:DF 1 "gpc_reg_operand" "%f")
  3102.          (match_operand:DF 2 "gpc_reg_operand" "f")))]
  3103.   "TARGET_HARD_FLOAT"
  3104.   "{fa|fadd} %0,%1,%2"
  3105.   [(set_attr "type" "fp")])
  3106.  
  3107. (define_insn "subdf3"
  3108.   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
  3109.     (minus:DF (match_operand:DF 1 "gpc_reg_operand" "f")
  3110.           (match_operand:DF 2 "gpc_reg_operand" "f")))]
  3111.   "TARGET_HARD_FLOAT"
  3112.   "{fs|fsub} %0,%1,%2"
  3113.   [(set_attr "type" "fp")])
  3114.  
  3115. (define_insn "muldf3"
  3116.   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
  3117.     (mult:DF (match_operand:DF 1 "gpc_reg_operand" "%f")
  3118.          (match_operand:DF 2 "gpc_reg_operand" "f")))]
  3119.   "TARGET_HARD_FLOAT"
  3120.   "{fm|fmul} %0,%1,%2"
  3121.   [(set_attr "type" "dmul")])
  3122.  
  3123. (define_insn "divdf3"
  3124.   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
  3125.     (div:DF (match_operand:DF 1 "gpc_reg_operand" "f")
  3126.         (match_operand:DF 2 "gpc_reg_operand" "f")))]
  3127.   "TARGET_HARD_FLOAT"
  3128.   "{fd|fdiv} %0,%1,%2"
  3129.   [(set_attr "type" "ddiv")])
  3130.  
  3131. (define_insn ""
  3132.   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
  3133.     (plus:DF (mult:DF (match_operand:DF 1 "gpc_reg_operand" "%f")
  3134.               (match_operand:DF 2 "gpc_reg_operand" "f"))
  3135.          (match_operand:DF 3 "gpc_reg_operand" "f")))]
  3136.   "TARGET_HARD_FLOAT"
  3137.   "{fma|fmadd} %0,%1,%2,%3"
  3138.   [(set_attr "type" "dmul")])
  3139.  
  3140. (define_insn ""
  3141.   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
  3142.     (minus:DF (mult:DF (match_operand:DF 1 "gpc_reg_operand" "%f")
  3143.                (match_operand:DF 2 "gpc_reg_operand" "f"))
  3144.           (match_operand:DF 3 "gpc_reg_operand" "f")))]
  3145.   "TARGET_HARD_FLOAT"
  3146.   "{fms|fmsub} %0,%1,%2,%3"
  3147.   [(set_attr "type" "dmul")])
  3148.  
  3149. (define_insn ""
  3150.   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
  3151.     (neg:DF (plus:DF (mult:DF (match_operand:DF 1 "gpc_reg_operand" "%f")
  3152.                   (match_operand:DF 2 "gpc_reg_operand" "f"))
  3153.              (match_operand:DF 3 "gpc_reg_operand" "f"))))]
  3154.   "TARGET_HARD_FLOAT"
  3155.   "{fnma|fnmadd} %0,%1,%2,%3"
  3156.   [(set_attr "type" "dmul")])
  3157.  
  3158. (define_insn ""
  3159.   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
  3160.     (neg:DF (minus:DF (mult:DF (match_operand:DF 1 "gpc_reg_operand" "%f")
  3161.                    (match_operand:DF 2 "gpc_reg_operand" "f"))
  3162.               (match_operand:DF 3 "gpc_reg_operand" "f"))))]
  3163.   "TARGET_HARD_FLOAT"
  3164.   "{fnms|fnmsub} %0,%1,%2,%3"
  3165.   [(set_attr "type" "dmul")])
  3166.  
  3167. (define_insn "sqrtdf2"
  3168.   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
  3169.     (sqrt:DF (match_operand:DF 1 "gpc_reg_operand" "f")))]
  3170.   "(TARGET_PPC_GPOPT || TARGET_POWER2) && TARGET_HARD_FLOAT"
  3171.   "fsqrt %0,%1"
  3172.   [(set_attr "type" "dsqrt")])
  3173.  
  3174. ;; For MIN, MAX, and conditional move, we use DEFINE_EXPAND's that involve a
  3175. ;; fsel instruction and some auxiliary computations.  Then we just have a
  3176. ;; single DEFINE_INSN for fsel and the define_splits to make them if made by
  3177. ;; combine.
  3178.  
  3179. (define_expand "maxdf3"
  3180.   [(set (match_dup 3)
  3181.     (minus:DF (match_operand:DF 1 "gpc_reg_operand" "")
  3182.           (match_operand:DF 2 "gpc_reg_operand" "")))
  3183.    (set (match_operand:DF 0 "gpc_reg_operand" "")
  3184.     (if_then_else:DF (ge (match_dup 3)
  3185.                  (const_int 0))
  3186.              (match_dup 1)
  3187.              (match_dup 2)))]
  3188.   "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT"
  3189.   "
  3190. { operands[3] = gen_reg_rtx (DFmode); }")
  3191.  
  3192. (define_split
  3193.   [(set (match_operand:DF 0 "gpc_reg_operand" "")
  3194.     (smax:DF (match_operand:DF 1 "gpc_reg_operand" "")
  3195.          (match_operand:DF 2 "gpc_reg_operand" "")))
  3196.    (clobber (match_operand:DF 3 "gpc_reg_operand" ""))]
  3197.   "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT"
  3198.   [(set (match_dup 3)
  3199.     (minus:DF (match_dup 1) (match_dup 2)))
  3200.    (set (match_dup 0)
  3201.     (if_then_else:DF (ge (match_dup 3)
  3202.                  (const_int 0))
  3203.              (match_dup 1)
  3204.              (match_dup 2)))]
  3205.   "")
  3206.  
  3207. (define_expand "mindf3"
  3208.   [(set (match_dup 3)
  3209.     (minus:DF (match_operand:DF 2 "gpc_reg_operand" "")
  3210.           (match_operand:DF 1 "gpc_reg_operand" "")))
  3211.    (set (match_operand:DF 0 "gpc_reg_operand" "")
  3212.     (if_then_else:DF (ge (match_dup 3)
  3213.                  (const_int 0))
  3214.              (match_dup 1)
  3215.              (match_dup 2)))]
  3216.   "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT"
  3217.   "
  3218. { operands[3] = gen_reg_rtx (DFmode); }")
  3219.  
  3220. (define_split
  3221.   [(set (match_operand:DF 0 "gpc_reg_operand" "")
  3222.     (smin:DF (match_operand:DF 1 "gpc_reg_operand" "")
  3223.          (match_operand:DF 2 "gpc_reg_operand" "")))
  3224.    (clobber (match_operand:DF 3 "gpc_reg_operand" ""))]
  3225.   "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT"
  3226.   [(set (match_dup 3)
  3227.     (minus:DF (match_dup 2) (match_dup 1)))
  3228.    (set (match_dup 0)
  3229.     (if_then_else:DF (ge (match_dup 3)
  3230.                  (const_int 0))
  3231.              (match_dup 1)
  3232.              (match_dup 2)))]
  3233.   "")
  3234.  
  3235. (define_expand "movdfcc"
  3236.    [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
  3237.      (if_then_else:DF (match_operand 1 "comparison_operator" "")
  3238.               (match_operand:DF 2 "gpc_reg_operand" "f")
  3239.               (match_operand:DF 3 "gpc_reg_operand" "f")))]
  3240.   "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT"
  3241.   "
  3242. {
  3243.   rtx temp, op0, op1;
  3244.   enum rtx_code code = GET_CODE (operands[1]);
  3245.   if (! rs6000_compare_fp_p)
  3246.     FAIL;
  3247.   switch (code)
  3248.     {
  3249.     case GE: case EQ: case NE:
  3250.       op0 = rs6000_compare_op0;
  3251.       op1 = rs6000_compare_op1;
  3252.       break;
  3253.     case GT:
  3254.       op0 = rs6000_compare_op1;
  3255.       op1 = rs6000_compare_op0;
  3256.       temp = operands[2]; operands[2] = operands[3]; operands[3] = temp;
  3257.       break;
  3258.     case LE:
  3259.       op0 = rs6000_compare_op1;
  3260.       op1 = rs6000_compare_op0;
  3261.       break;
  3262.     case LT:
  3263.       op0 = rs6000_compare_op0;
  3264.       op1 = rs6000_compare_op1;
  3265.       temp = operands[2]; operands[2] = operands[3]; operands[3] = temp;
  3266.       break;
  3267.     default:
  3268.       FAIL;
  3269.     }
  3270.   if (GET_MODE (rs6000_compare_op0) == DFmode)
  3271.     {
  3272.       temp = gen_reg_rtx (DFmode);
  3273.       emit_insn (gen_subdf3 (temp, op0, op1));
  3274.       emit_insn (gen_fseldfdf4 (operands[0], temp, operands[2], operands[3]));
  3275.       if (code == EQ)
  3276.     {
  3277.       emit_insn (gen_negdf2 (temp, temp));
  3278.       emit_insn (gen_fseldfdf4 (operands[0], temp, operands[0], operands[3]));
  3279.     }
  3280.       if (code == NE)
  3281.     {
  3282.       emit_insn (gen_negdf2 (temp, temp));
  3283.       emit_insn (gen_fseldfdf4 (operands[0], temp, operands[3], operands[0]));
  3284.     }
  3285.     }
  3286.   else
  3287.     {
  3288.       temp = gen_reg_rtx (SFmode);
  3289.       emit_insn (gen_subsf3 (temp, op0, op1));
  3290.       emit_insn (gen_fselsfdf4 (operands[0], temp, operands[2], operands[3]));
  3291.       if (code == EQ)
  3292.     {
  3293.       emit_insn (gen_negsf2 (temp, temp));
  3294.       emit_insn (gen_fselsfdf4 (operands[0], temp, operands[0], operands[3]));
  3295.     }
  3296.       if (code == NE)
  3297.     {
  3298.       emit_insn (gen_negsf2 (temp, temp));
  3299.       emit_insn (gen_fselsfdf4 (operands[0], temp, operands[3], operands[0]));
  3300.     }
  3301.     }
  3302.   DONE;
  3303. }")
  3304.  
  3305. (define_insn "fseldfdf4"
  3306.   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
  3307.     (if_then_else:DF (ge (match_operand:DF 1 "gpc_reg_operand" "f")
  3308.                  (const_int 0))
  3309.              (match_operand:DF 2 "gpc_reg_operand" "f")
  3310.              (match_operand:DF 3 "gpc_reg_operand" "f")))]
  3311.   "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT"
  3312.   "fsel %0,%1,%2,%3"
  3313.   [(set_attr "type" "fp")])
  3314.  
  3315. (define_insn "fselsfdf4"
  3316.   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
  3317.     (if_then_else:DF (ge (match_operand:SF 1 "gpc_reg_operand" "f")
  3318.                  (const_int 0))
  3319.              (match_operand:DF 2 "gpc_reg_operand" "f")
  3320.              (match_operand:DF 3 "gpc_reg_operand" "f")))]
  3321.   "TARGET_PPC_GFXOPT"
  3322.   "fsel %0,%1,%2,%3"
  3323.   [(set_attr "type" "fp")])
  3324.  
  3325. ;; Conversions to and from floating-point.
  3326. (define_expand "floatsidf2"
  3327.   [(set (match_dup 2)
  3328.     (plus:DI (zero_extend:DI
  3329.           (xor:SI (match_operand:SI 1 "gpc_reg_operand" "")
  3330.               (match_dup 3)))
  3331.          (match_dup 4)))
  3332.    (set (match_operand:DF 0 "gpc_reg_operand" "")
  3333.     (minus:DF (subreg:DF (match_dup 2) 0)
  3334.           (match_dup 5)))]
  3335.   "! TARGET_POWERPC64 && TARGET_HARD_FLOAT"
  3336.   "
  3337. {
  3338.   operands[2] = gen_reg_rtx (DImode);
  3339.   operands[3] = gen_rtx (CONST_INT, VOIDmode, 0x80000000);
  3340.   operands[4] = rs6000_immed_double_const (0, 0x43300000, DImode);
  3341.   operands[5] = force_reg (DFmode, rs6000_immed_double_const (0x43300000,
  3342.                                   0x80000000,
  3343.                                   DFmode));
  3344. }")
  3345.  
  3346. (define_expand "floatunssidf2"
  3347.   [(set (match_dup 2)
  3348.     (plus:DI (zero_extend:DI (match_operand:SI 1 "gpc_reg_operand" ""))
  3349.          (match_dup 3)))
  3350.    (set (match_operand:DF 0 "gpc_reg_operand" "")
  3351.     (minus:DF (subreg:DF (match_dup 2) 0)
  3352.           (match_dup 4)))]
  3353.   "! TARGET_POWERPC64 && TARGET_HARD_FLOAT"
  3354.   "
  3355. {
  3356.   operands[2] = gen_reg_rtx (DImode);
  3357.   operands[3] = rs6000_immed_double_const (0, 0x43300000, DImode);
  3358.   operands[4] = force_reg (DFmode, rs6000_immed_double_const (0x43300000, 0, DFmode));
  3359. }")
  3360.  
  3361. ;; For the above two cases, we always split.
  3362. (define_split
  3363.   [(set (match_operand:DI 0 "gpc_reg_operand" "")
  3364.     (plus:DI (zero_extend:DI
  3365.           (xor:SI (match_operand:SI 1 "gpc_reg_operand" "")
  3366.               (match_operand:SI 2 "logical_operand" "")))
  3367.          (match_operand:DI 3 "low_32_bit_operand" "")))]
  3368.   "reload_completed"
  3369.   [(set (match_dup 6) (xor:SI (match_dup 1) (match_dup 2)))
  3370.    (set (match_dup 4) (match_dup 5))]
  3371.   "
  3372. { operands[4] = operand_subword (operands[0], 0, 0, DImode);
  3373.   operands[5] = operand_subword (operands[3], 0, 0, DImode);
  3374.   operands[6] = operand_subword (operands[0], 1, 0, DImode);
  3375. }")
  3376.  
  3377. (define_insn ""
  3378.   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
  3379.     (plus:DI (zero_extend:DI
  3380.           (xor:SI (match_operand:SI 1 "gpc_reg_operand" "%r")
  3381.               (match_operand:SI 2 "logical_operand" "rKJ")))
  3382.          (match_operand:DI 3 "low_32_bit_operand" "n")))]
  3383.   ""
  3384.   "#"
  3385.   [(set_attr "length" "8")])
  3386.  
  3387. (define_split
  3388.   [(set (match_operand:DI 0 "gpc_reg_operand" "=")
  3389.     (plus:DI (zero_extend:DI (match_operand:SI 1 "gpc_reg_operand" ""))
  3390.          (match_operand:DI 2 "low_32_bit_operand" "")))]
  3391.   "reload_completed"
  3392.   [(set (match_dup 3) (match_dup 4))
  3393.    (set (match_dup 5) (match_dup 1))]
  3394.   "
  3395. { operands[3] = operand_subword (operands[0], 0, 0, DImode);
  3396.   operands[4] = operand_subword (operands[2], 0, 0, DImode);
  3397.   operands[5] = operand_subword (operands[0], 1, 0, DImode);
  3398.  
  3399.   if (rtx_equal_p (operands[1], operands[5]))
  3400.     {
  3401.       emit_move_insn (operands[3], operands[4]);
  3402.       DONE;
  3403.     }
  3404.  
  3405.   if (rtx_equal_p (operands[1], operands[3]))
  3406.     {
  3407.       rtx temp;
  3408.  
  3409.       temp = operands[3]; operands[3] = operands[5]; operands[5] = temp;
  3410.       temp = operands[4]; operands[4] = operands[1]; operands[1] = temp;
  3411.     }
  3412. }")
  3413.  
  3414. (define_insn ""
  3415.   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
  3416.     (plus:DI (zero_extend:DI (match_operand:SI 1 "gpc_reg_operand" "r"))
  3417.          (match_operand:DI 2 "low_32_bit_operand" "n")))]
  3418.   ""
  3419.   "#"
  3420.   [(set_attr "length" "8")])
  3421.  
  3422. (define_expand "fix_truncdfsi2"
  3423.   [(set (match_operand:SI 0 "gpc_reg_operand" "")
  3424.     (fix:SI (match_operand:DF 1 "gpc_reg_operand" "")))]
  3425.   "TARGET_HARD_FLOAT"
  3426.   "
  3427. {
  3428.   if (TARGET_POWER2 || TARGET_POWERPC)
  3429.     {
  3430.       rtx stack_slot = assign_stack_temp (DImode, 8, 0),
  3431.     temp = gen_reg_rtx (DImode);
  3432.  
  3433.       emit_insn (gen_fpcvtsi (temp, operands[1]));
  3434.       emit_move_insn (stack_slot, temp);
  3435.       emit_move_insn (operands[0],
  3436.               operand_subword (stack_slot, 1, 0, DImode));
  3437.       DONE;
  3438.     }
  3439.   else
  3440.     {
  3441.       emit_insn (gen_trunc_call (operands[0], operands[1],
  3442.                  gen_rtx (SYMBOL_REF, Pmode, RS6000_ITRUNC)));
  3443.       DONE;
  3444.     }
  3445. }")
  3446.  
  3447. (define_insn "fpcvtsi"
  3448.   [(set (match_operand:DI 0 "gpc_reg_operand" "=f")
  3449.     (sign_extend:DI
  3450.      (fix:SI (match_operand:DF 1 "gpc_reg_operand" "f"))))]
  3451.   "(TARGET_POWER2 || TARGET_POWERPC) && TARGET_HARD_FLOAT"
  3452.   "{fcirz|fctiwz} %0,%1"
  3453.   [(set_attr "type" "fp")])
  3454.  
  3455. (define_expand "fixuns_truncdfsi2"
  3456.   [(set (match_operand:SI 0 "gpc_reg_operand" "")
  3457.     (unsigned_fix:SI (match_operand:DF 1 "gpc_reg_operand" "")))]
  3458.   "! TARGET_POWER2 && ! TARGET_POWERPC && TARGET_HARD_FLOAT"
  3459.   "
  3460. {
  3461.   emit_insn (gen_trunc_call (operands[0], operands[1],
  3462.                  gen_rtx (SYMBOL_REF, Pmode, RS6000_UITRUNC)));
  3463.   DONE;
  3464. }")
  3465.  
  3466. (define_expand "trunc_call"
  3467.   [(parallel [(set (match_operand:SI 0 "" "")
  3468.            (fix:SI (match_operand:DF 1 "" "")))
  3469.           (use (match_operand:SI 2 "" ""))])]
  3470.   "TARGET_HARD_FLOAT"
  3471.   "
  3472. {
  3473.   rtx insns = gen_trunc_call_rtl (operands[0], operands[1], operands[2]);
  3474.   rtx first = XVECEXP (insns, 0, 0);
  3475.   rtx last = XVECEXP (insns, 0, XVECLEN (insns, 0) - 1);
  3476.  
  3477.   REG_NOTES (first) = gen_rtx (INSN_LIST, REG_LIBCALL, last,
  3478.                    REG_NOTES (first));
  3479.   REG_NOTES (last) = gen_rtx (INSN_LIST, REG_RETVAL, first, REG_NOTES (last));
  3480.  
  3481.   emit_insn (insns);
  3482.   DONE;
  3483. }")
  3484.  
  3485. (define_expand "trunc_call_rtl"
  3486.   [(set (reg:DF 33) (match_operand:DF 1 "gpc_reg_operand" ""))
  3487.    (use (reg:DF 33))
  3488.    (parallel [(set (reg:SI 3)
  3489.            (call (mem:SI (match_operand 2 "" "")) (const_int 0)))
  3490.           (clobber (scratch:SI))])
  3491.    (set (match_operand:SI 0 "gpc_reg_operand" "")
  3492.     (reg:SI 3))]
  3493.   "TARGET_HARD_FLOAT"
  3494.   "
  3495. {
  3496.   rs6000_trunc_used = 1;
  3497. }")
  3498.  
  3499. (define_insn "floatdidf2"
  3500.   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
  3501.     (float:DF (match_operand:DI 1 "gpc_reg_operand" "f")))]
  3502.   "TARGET_POWERPC64 && TARGET_HARD_FLOAT"
  3503.   "fcfid %0,%1"
  3504.   [(set_attr "type" "fp")])
  3505.  
  3506. (define_insn "fix_truncdfdi2"
  3507.   [(set (match_operand:DI 0 "gpc_reg_operand" "=f")
  3508.     (fix:DI (match_operand:DF 1 "gpc_reg_operand" "f")))]
  3509.   "TARGET_POWERPC64 && TARGET_HARD_FLOAT"
  3510.   "fctidz %0,%1"
  3511.   [(set_attr "type" "fp")])
  3512.  
  3513. ;; Define the DImode operations that can be done in a small number
  3514. ;; of instructions.
  3515. (define_expand "adddi3"
  3516.   [(set (match_operand:DI 0 "gpc_reg_operand" "")
  3517.     (plus:DI (match_operand:DI 1 "gpc_reg_operand" "")
  3518.          (match_operand:DI 2 "reg_or_short_operand" "")))]
  3519.   ""
  3520.   "
  3521. {
  3522.   if (! TARGET_POWER && ! TARGET_POWERPC64
  3523.       && short_cint_operand (operands[2], DImode))
  3524.     FAIL;
  3525. }")
  3526.  
  3527. (define_insn ""
  3528.   [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
  3529.     (plus:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r")
  3530.          (match_operand:DI 2 "reg_or_short_operand" "r,I")))]
  3531.   "TARGET_POWER && ! TARGET_POWERPC64"
  3532.   "@
  3533.    {a|addc} %L0,%L1,%L2\;{ae|adde} %0,%1,%2
  3534.    {ai|addic} %L0,%L1,%2\;{a%G2e|add%G2e} %0,%1"
  3535.   [(set_attr "length" "8")])
  3536.  
  3537. (define_insn ""
  3538.   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
  3539.     (plus:DI (match_operand:DI 1 "gpc_reg_operand" "%r")
  3540.          (match_operand:DI 2 "gpc_reg_operand" "r")))]
  3541.   "! TARGET_POWER && ! TARGET_POWERPC64"
  3542.   "addc %L0,%L1,%L2\;adde %0,%1,%2"
  3543.   [(set_attr "length" "8")])
  3544.  
  3545. (define_expand "subdi3"
  3546.   [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
  3547.     (minus:DI (match_operand:DI 1 "reg_or_short_operand" "r,I")
  3548.           (match_operand:DI 2 "gpc_reg_operand" "r,r")))]
  3549.   ""
  3550.   "
  3551. {
  3552.   if (! TARGET_POWER && ! TARGET_POWERPC64
  3553.       && short_cint_operand (operands[1], DImode))
  3554.     FAIL;
  3555. }")
  3556.  
  3557. (define_insn ""
  3558.   [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
  3559.     (minus:DI (match_operand:DI 1 "reg_or_short_operand" "r,I")
  3560.           (match_operand:DI 2 "gpc_reg_operand" "r,r")))]
  3561.   "TARGET_POWER && ! TARGET_POWERPC64"
  3562.   "@
  3563.    {sf|subfc} %L0,%L2,%L1\;{sfe|subfe} %0,%2,%1
  3564.    {sfi|subfic} %L0,%L2,%1\;{sf%G1e|subf%G1e} %0,%2"
  3565.   [(set_attr "length" "8")])
  3566.  
  3567. (define_insn ""
  3568.   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
  3569.     (minus:DI (match_operand:DI 1 "gpc_reg_operand" "r")
  3570.           (match_operand:DI 2 "gpc_reg_operand" "r")))]
  3571.   "! TARGET_POWER && ! TARGET_POWERPC64"
  3572.   "subfc %L0,%L2,%L1\;subfe %0,%2,%1"
  3573.   [(set_attr "length" "8")])
  3574.  
  3575. (define_expand "negdi2"
  3576.   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
  3577.     (neg:DI (match_operand:DI 1 "gpc_reg_operand" "r")))]
  3578.   ""
  3579.   "")
  3580.  
  3581. (define_insn ""
  3582.   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
  3583.     (neg:DI (match_operand:DI 1 "gpc_reg_operand" "r")))]
  3584.   "! TARGET_POWERPC64"
  3585.   "{sfi|subfic} %L0,%L1,0\;{sfze|subfze} %0,%1"
  3586.   [(set_attr "length" "8")])
  3587.  
  3588. (define_expand "mulsidi3"
  3589.   [(set (match_operand:DI 0 "gpc_reg_operand" "")
  3590.     (mult:DI (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" ""))
  3591.          (sign_extend:DI (match_operand:SI 2 "gpc_reg_operand" ""))))]
  3592.   ""
  3593.   "
  3594. {
  3595.   if (! TARGET_POWER && ! TARGET_POWERPC)
  3596.     {
  3597.       emit_move_insn (gen_rtx (REG, SImode, 3), operands[1]);
  3598.       emit_move_insn (gen_rtx (REG, SImode, 4), operands[2]);
  3599.       emit_insn (gen_mull_call ());
  3600.       emit_move_insn (operand_subword (operands[0], 0, 0, DImode),
  3601.               gen_rtx (REG, SImode, 3));
  3602.       emit_move_insn (operand_subword (operands[0], 1, 0, DImode),
  3603.               gen_rtx (REG, SImode, 4));
  3604.       DONE;
  3605.     }
  3606.   else if (TARGET_POWER)
  3607.     {
  3608.       emit_insn (gen_mulsidi3_mq (operands[0], operands[1], operands[2]));
  3609.       DONE;
  3610.     }
  3611. }")
  3612.  
  3613. (define_insn "mulsidi3_mq"
  3614.   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
  3615.     (mult:DI (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" "%r"))
  3616.          (sign_extend:DI (match_operand:SI 2 "gpc_reg_operand" "r"))))
  3617.    (clobber (match_scratch:SI 3 "=q"))]
  3618.   "TARGET_POWER"
  3619.   "mul %0,%1,%2\;mfmq %L0"
  3620.   [(set_attr "type" "imul")
  3621.    (set_attr "length" "8")])
  3622.  
  3623. (define_insn ""
  3624.   [(set (match_operand:DI 0 "gpc_reg_operand" "=&r")
  3625.     (mult:DI (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" "%r"))
  3626.          (sign_extend:DI (match_operand:SI 2 "gpc_reg_operand" "r"))))]
  3627.   "TARGET_POWERPC && ! TARGET_POWERPC64"
  3628.   "mulhw %0,%1,%2\;mullw %L0,%1,%2"
  3629.   [(set_attr "type" "imul")
  3630.    (set_attr "length" "8")])
  3631.  
  3632. (define_expand "smulsi3_highpart"
  3633.   [(set (match_operand:SI 0 "gpc_reg_operand" "")
  3634.     (truncate:SI
  3635.      (lshiftrt:DI (mult:DI (sign_extend:DI
  3636.                 (match_operand:SI 1 "gpc_reg_operand" "%r"))
  3637.                    (sign_extend:DI
  3638.                 (match_operand:SI 2 "gpc_reg_operand" "r")))
  3639.               (const_int 32))))]
  3640.   ""
  3641.   "
  3642. {
  3643.   if (! TARGET_POWER && ! TARGET_POWERPC)
  3644.     {
  3645.       emit_move_insn (gen_rtx (REG, SImode, 3), operands[1]);
  3646.       emit_move_insn (gen_rtx (REG, SImode, 4), operands[2]);
  3647.       emit_insn (gen_mulh_call ());
  3648.       emit_move_insn (operands[0], gen_rtx (REG, SImode, 3));
  3649.       DONE;
  3650.     }
  3651.   else if (TARGET_POWER)
  3652.     {
  3653.       emit_insn (gen_smulsi3_highpart_mq (operands[0], operands[1], operands[2]));
  3654.       DONE;
  3655.     }
  3656. }")
  3657.  
  3658. (define_insn "smulsi3_highpart_mq"
  3659.   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
  3660.     (truncate:SI
  3661.      (lshiftrt:DI (mult:DI (sign_extend:DI
  3662.                 (match_operand:SI 1 "gpc_reg_operand" "%r"))
  3663.                    (sign_extend:DI
  3664.                 (match_operand:SI 2 "gpc_reg_operand" "r")))
  3665.               (const_int 32))))
  3666.    (clobber (match_scratch:SI 3 "=q"))]
  3667.   "TARGET_POWER"
  3668.   "mul %0,%1,%2"
  3669.   [(set_attr "type" "imul")])
  3670.  
  3671. (define_insn ""
  3672.   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
  3673.     (truncate:SI
  3674.      (lshiftrt:DI (mult:DI (sign_extend:DI
  3675.                 (match_operand:SI 1 "gpc_reg_operand" "%r"))
  3676.                    (sign_extend:DI
  3677.                 (match_operand:SI 2 "gpc_reg_operand" "r")))
  3678.               (const_int 32))))]
  3679.   "TARGET_POWERPC"
  3680.   "mulhw %0,%1,%2"
  3681.   [(set_attr "type" "imul")])
  3682.  
  3683. (define_insn "umulsi3_highpart"
  3684.   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
  3685.     (truncate:SI
  3686.      (lshiftrt:DI (mult:DI (zero_extend:DI
  3687.                 (match_operand:SI 1 "gpc_reg_operand" "%r"))
  3688.                    (zero_extend:DI
  3689.                 (match_operand:SI 2 "gpc_reg_operand" "r")))
  3690.               (const_int 32))))]
  3691.   "TARGET_POWERPC"
  3692.   "mulhwu %0,%1,%2"
  3693.   [(set_attr "type" "imul")])
  3694.  
  3695. ;; If operands 0 and 2 are in the same register, we have a problem.  But
  3696. ;; operands 0 and 1 (the usual case) can be in the same register.  That's
  3697. ;; why we have the strange constraints below.
  3698. (define_insn "ashldi3"
  3699.   [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r,r,&r")
  3700.     (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r,r,0,r")
  3701.            (match_operand:SI 2 "reg_or_cint_operand" "M,i,r,r")))
  3702.    (clobber (match_scratch:SI 3 "=X,q,q,q"))]
  3703.   "TARGET_POWER"
  3704.   "@
  3705.    {sli|slwi} %0,%L1,%h2\;{cal %L0,0(0)|li %L0,0}
  3706.    sl%I2q %L0,%L1,%h2\;sll%I2q %0,%1,%h2
  3707.    sl%I2q %L0,%L1,%h2\;sll%I2q %0,%1,%h2
  3708.    sl%I2q %L0,%L1,%h2\;sll%I2q %0,%1,%h2"
  3709.   [(set_attr "length" "8")])
  3710.  
  3711. (define_insn "lshrdi3"
  3712.   [(set (match_operand:DI 0 "gpc_reg_operand" "=&r,r,r,&r")
  3713.     (lshiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r,r,0,r")
  3714.              (match_operand:SI 2 "reg_or_cint_operand" "M,i,r,r")))
  3715.    (clobber (match_scratch:SI 3 "=X,q,q,q"))]
  3716.   "TARGET_POWER"
  3717.   "@
  3718.    {cal %0,0(0)|li %0,0}\;{s%A2i|s%A2wi} %L0,%1,%h2
  3719.    sr%I2q %0,%1,%h2\;srl%I2q %L0,%L1,%h2
  3720.    sr%I2q %0,%1,%h2\;srl%I2q %L0,%L1,%h2
  3721.    sr%I2q %0,%1,%h2\;srl%I2q %L0,%L1,%h2"
  3722.   [(set_attr "length" "8")])
  3723.  
  3724. ;; Shift by a variable amount is too complex to be worth open-coding.  We
  3725. ;; just handle shifts by constants.
  3726.  
  3727. (define_expand "ashrdi3"
  3728.   [(parallel [(set (match_operand:DI 0 "gpc_reg_operand" "")
  3729.            (ashiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "")
  3730.                 (match_operand:SI 2 "general_operand" "")))
  3731.           (clobber (match_scratch:SI 3 ""))])]
  3732.   "TARGET_POWER"
  3733.   "
  3734. { if (GET_CODE (operands[2]) != CONST_INT)
  3735.     FAIL;
  3736. }")
  3737.  
  3738. (define_insn ""
  3739.   [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
  3740.     (ashiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
  3741.              (match_operand:SI 2 "const_int_operand" "M,i")))
  3742.    (clobber (match_scratch:SI 3 "=X,q"))]
  3743.   "TARGET_POWER"
  3744.   "@
  3745.    {srai|srawi} %0,%1,31\;{srai|srawi} %L0,%1,%h2
  3746.    sraiq %0,%1,%h2\;srliq %L0,%L1,%h2"
  3747.   [(set_attr "length" "8")])
  3748.  
  3749. ;; PowerPC64 DImode operations.
  3750.  
  3751. (define_insn "ffsdi2"
  3752.   [(set (match_operand:DI 0 "gpc_reg_operand" "=&r")
  3753.     (ffs:DI (match_operand:DI 1 "gpc_reg_operand" "r")))]
  3754.   "TARGET_POWERPC64"
  3755.   "neg %0,%1\;and %0,%0,%1\;cntlzd %0,%0\;subfic %0,%0,64"
  3756.   [(set_attr "length" "16")])
  3757.  
  3758. (define_insn "muldi3"
  3759.   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
  3760.     (mult:DI (match_operand:DI 1 "gpc_reg_operand" "%r")
  3761.          (match_operand:DI 2 "gpc_reg_operand" "r")))]
  3762.   "TARGET_POWERPC64"
  3763.   "mulld %0,%1,%2"
  3764.    [(set_attr "type" "imul")])
  3765.  
  3766. (define_insn "smuldi3_highpart"
  3767.   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
  3768.     (truncate:DI
  3769.      (lshiftrt:TI (mult:TI (sign_extend:TI
  3770.                 (match_operand:DI 1 "gpc_reg_operand" "%r"))
  3771.                    (sign_extend:TI
  3772.                 (match_operand:DI 2 "gpc_reg_operand" "r")))
  3773.               (const_int 64))))]
  3774.   "TARGET_POWERPC64"
  3775.   "mulhd %0,%1,%2"
  3776.   [(set_attr "type" "imul")])
  3777.  
  3778. (define_insn "umuldi3_highpart"
  3779.   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
  3780.     (truncate:DI
  3781.      (lshiftrt:TI (mult:TI (zero_extend:TI
  3782.                 (match_operand:DI 1 "gpc_reg_operand" "%r"))
  3783.                    (zero_extend:TI
  3784.                 (match_operand:DI 2 "gpc_reg_operand" "r")))
  3785.               (const_int 64))))]
  3786.   "TARGET_POWERPC64"
  3787.   "mulhdu %0,%1,%2"
  3788.   [(set_attr "type" "imul")])
  3789.  
  3790. (define_insn "divdi3"
  3791.   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
  3792.         (div:DI (match_operand:DI 1 "gpc_reg_operand" "r")
  3793.                  (match_operand:DI 2 "gpc_reg_operand" "r")))]
  3794.   "TARGET_POWERPC64"
  3795.   "divd %0,%1,%2"
  3796.   [(set_attr "type" "idiv")])
  3797.  
  3798. (define_insn "udivdi3"
  3799.   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
  3800.         (udiv:DI (match_operand:DI 1 "gpc_reg_operand" "r")
  3801.                  (match_operand:DI 2 "gpc_reg_operand" "r")))]
  3802.   "TARGET_POWERPC64"
  3803.   "divdu %0,%1,%2"
  3804.   [(set_attr "type" "idiv")])
  3805.  
  3806. (define_insn "rotldi3"
  3807.   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
  3808.     (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r")
  3809.            (match_operand:DI 2 "reg_or_cint_operand" "ri")))]
  3810.   "TARGET_POWERPC64"
  3811.   "rld%I2cl %0,%1,%h2,0")
  3812.  
  3813. (define_insn ""
  3814.   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
  3815.     (compare:CC (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r")
  3816.                    (match_operand:DI 2 "reg_or_cint_operand" "ri"))
  3817.             (const_int 0)))
  3818.    (clobber (match_scratch:DI 3 "=r"))]
  3819.   "TARGET_POWERPC64"
  3820.   "rld%I2cl. %3,%1,%h2,0"
  3821.   [(set_attr "type" "delayed_compare")])
  3822.  
  3823. (define_insn ""
  3824.   [(set (match_operand:CC 3 "cc_reg_operand" "=x")
  3825.     (compare:CC (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r")
  3826.                    (match_operand:DI 2 "reg_or_cint_operand" "ri"))
  3827.             (const_int 0)))
  3828.    (set (match_operand:DI 0 "gpc_reg_operand" "=r")
  3829.     (rotate:DI (match_dup 1) (match_dup 2)))]
  3830.   "TARGET_POWERPC64"
  3831.   "rld%I2cl. %0,%1,%h2,0"
  3832.   [(set_attr "type" "delayed_compare")])
  3833.  
  3834. ;; Now define ways of moving data around.
  3835. ;;
  3836. ;; For SI, we special-case integers that can't be loaded in one insn.  We
  3837. ;; do the load 16-bits at a time.  We could do this by loading from memory,
  3838. ;; and this is even supposed to be faster, but it is simpler not to get
  3839. ;; integers in the TOC.
  3840. (define_expand "movsi"
  3841.   [(set (match_operand:SI 0 "general_operand" "")
  3842.     (match_operand:SI 1 "any_operand" ""))]
  3843.   ""
  3844.   "
  3845. {
  3846.   if (GET_CODE (operands[0]) != REG)
  3847.     operands[1] = force_reg (SImode, operands[1]);
  3848.  
  3849.   if (CONSTANT_P (operands[1]) && GET_CODE (operands[1]) != CONST_INT
  3850.       && ! LEGITIMATE_CONSTANT_POOL_ADDRESS_P (operands[1]))
  3851.     {
  3852.       /* If we are to limit the number of things we put in the TOC and
  3853.      this is a symbol plus a constant we can add in one insn,
  3854.      just put the sumbol in the TOC and add the constant.  Don't do
  3855.      this if reload is in progress.  */
  3856.       if (GET_CODE (operands[1]) == CONST
  3857.       && TARGET_NO_SUM_IN_TOC && ! reload_in_progress
  3858.       && GET_CODE (XEXP (operands[1], 0)) == PLUS
  3859.       && add_operand (XEXP (XEXP (operands[1], 0), 1), SImode)
  3860.       && (GET_CODE (XEXP (XEXP (operands[1], 0), 0)) == LABEL_REF
  3861.           || GET_CODE (XEXP (XEXP (operands[1], 0), 0)) == SYMBOL_REF)
  3862.       && ! side_effects_p (operands[0]))
  3863.     {
  3864.       rtx sym = force_const_mem (SImode, XEXP (XEXP (operands[1], 0), 0));
  3865.       rtx other = XEXP (XEXP (operands[1], 0), 1);
  3866.  
  3867.       emit_insn (gen_addsi3 (operands[0], force_reg (SImode, sym), other));
  3868.       DONE;
  3869.     }
  3870.  
  3871.       operands[1] = force_const_mem (SImode, operands[1]);
  3872.       if (! memory_address_p (SImode, XEXP (operands[1], 0))
  3873.       && ! reload_in_progress)
  3874.     operands[1] = change_address (operands[1], SImode,
  3875.                       XEXP (operands[1], 0));
  3876.     }
  3877.  
  3878.   if (GET_CODE (operands[1]) == CONST_INT
  3879.       && (unsigned) (INTVAL (operands[1]) + 0x8000) >= 0x10000
  3880.       && (INTVAL (operands[1]) & 0xffff) != 0)
  3881.     {
  3882.       emit_move_insn (operands[0],
  3883.               gen_rtx (CONST_INT, VOIDmode,
  3884.                    INTVAL (operands[1]) & 0xffff0000));
  3885.       emit_insn (gen_iorsi3 (operands[0], operands[0],
  3886.                  gen_rtx (CONST_INT, VOIDmode,
  3887.                       INTVAL (operands[1]) & 0xffff)));
  3888.       DONE;
  3889.     }
  3890. }")
  3891.  
  3892. (define_insn ""
  3893.   [(set (match_operand:SI 0 "nonimmediate_operand" "=r,r,m,r,r,r,r,*q,*c*l,*h")
  3894.     (match_operand:SI 1 "input_operand" "r,m,r,I,J,R,*h,r,r,0"))]
  3895.   "gpc_reg_operand (operands[0], SImode)
  3896.    || gpc_reg_operand (operands[1], SImode)"
  3897.   "@
  3898.    mr %0,%1
  3899.    {l%U1%X1|lwz%U1%X1} %0,%1
  3900.    {st%U0%X0|stw%U0%X0} %1,%0
  3901.    {lil|li} %0,%1
  3902.    {liu|lis} %0,%u1
  3903.    {cal|la} %0,%1(%*)
  3904.    mf%1 %0
  3905.    mt%0 %1
  3906.    mt%0 %1
  3907.    cror 0,0,0"
  3908.   [(set_attr "type" "*,load,*,*,*,*,*,*,mtjmpr,*")])
  3909.  
  3910. ;; Split a load of a large constant into the appropriate two-insn
  3911. ;; sequence.
  3912.  
  3913. (define_split
  3914.   [(set (match_operand:SI 0 "gpc_reg_operand" "")
  3915.     (match_operand:SI 1 "const_int_operand" ""))]
  3916.   "(unsigned) (INTVAL (operands[1]) + 0x8000) >= 0x10000
  3917.    && (INTVAL (operands[1]) & 0xffff) != 0"
  3918.   [(set (match_dup 0)
  3919.     (match_dup 2))
  3920.    (set (match_dup 0)
  3921.     (ior:SI (match_dup 0)
  3922.         (match_dup 3)))]
  3923.   "
  3924. {
  3925.   operands[2] = gen_rtx (CONST_INT, VOIDmode,
  3926.              INTVAL (operands[1]) & 0xffff0000);
  3927.   operands[3] = gen_rtx (CONST_INT, VOIDmode, INTVAL (operands[1]) & 0xffff);
  3928. }")
  3929.  
  3930. (define_insn ""
  3931.   [(set (match_operand:CC 2 "cc_reg_operand" "=x")
  3932.     (compare:CC (match_operand:SI 1 "gpc_reg_operand" "r")
  3933.             (const_int 0)))
  3934.    (set (match_operand:SI 0 "gpc_reg_operand" "=r") (match_dup 1))]
  3935.   ""
  3936.   "mr. %0,%1"
  3937.   [(set_attr "type" "compare")])
  3938.  
  3939. (define_expand "movhi"
  3940.   [(set (match_operand:HI 0 "general_operand" "")
  3941.     (match_operand:HI 1 "any_operand" ""))]
  3942.   ""
  3943.   "
  3944. {
  3945.   if (GET_CODE (operands[0]) != REG)
  3946.     operands[1] = force_reg (HImode, operands[1]);
  3947.  
  3948.   if (CONSTANT_P (operands[1]) && GET_CODE (operands[1]) != CONST_INT)
  3949.     {
  3950.       operands[1] = force_const_mem (HImode, operands[1]);
  3951.       if (! memory_address_p (HImode, XEXP (operands[1], 0))
  3952.       && ! reload_in_progress)
  3953.     operands[1] = change_address (operands[1], HImode,
  3954.                       XEXP (operands[1], 0));
  3955.     }
  3956. }")
  3957.  
  3958. (define_insn ""
  3959.   [(set (match_operand:HI 0 "nonimmediate_operand" "=r,r,m,r,r,*q,*c*l,*h")
  3960.     (match_operand:HI 1 "input_operand" "r,m,r,i,*h,r,r,0"))]
  3961.   "gpc_reg_operand (operands[0], HImode)
  3962.    || gpc_reg_operand (operands[1], HImode)"
  3963.   "@
  3964.    mr %0,%1
  3965.    lhz%U1%X1 %0,%1
  3966.    sth%U0%X0 %1,%0
  3967.    {lil|li} %0,%w1
  3968.    mf%1 %0
  3969.    mt%0 %1
  3970.    mt%0 %1
  3971.    cror 0,0,0"
  3972.   [(set_attr "type" "*,load,*,*,*,*,mtjmpr,*")])
  3973.  
  3974. (define_expand "movqi"
  3975.   [(set (match_operand:QI 0 "general_operand" "")
  3976.     (match_operand:QI 1 "any_operand" ""))]
  3977.   ""
  3978.   "
  3979. {
  3980.   if (GET_CODE (operands[0]) != REG)
  3981.     operands[1] = force_reg (QImode, operands[1]);
  3982.  
  3983.   if (CONSTANT_P (operands[1]) && GET_CODE (operands[1]) != CONST_INT)
  3984.     {
  3985.       operands[1] = force_const_mem (QImode, operands[1]);
  3986.       if (! memory_address_p (QImode, XEXP (operands[1], 0))
  3987.       && ! reload_in_progress)
  3988.     operands[1] = change_address (operands[1], QImode,
  3989.                       XEXP (operands[1], 0));
  3990.     }
  3991. }")
  3992.  
  3993. (define_insn ""
  3994.   [(set (match_operand:QI 0 "nonimmediate_operand" "=r,r,m,r,r,*q,*c*l,*h")
  3995.     (match_operand:QI 1 "input_operand" "r,m,r,i,*h,r,r,0"))]
  3996.   "gpc_reg_operand (operands[0], QImode)
  3997.    || gpc_reg_operand (operands[1], QImode)"
  3998.   "@
  3999.    mr %0,%1
  4000.    lbz%U1%X1 %0,%1
  4001.    stb%U0%X0 %1,%0
  4002.    {lil|li} %0,%1
  4003.    mf%1 %0
  4004.    mt%0 %1
  4005.    mt%0 %1
  4006.    cror 0,0,0"
  4007.   [(set_attr "type" "*,load,*,*,*,*,mtjmpr,*")])
  4008.  
  4009. ;; Here is how to move condition codes around.  When we store CC data in
  4010. ;; an integer register or memory, we store just the high-order 4 bits.
  4011. ;; This lets us not shift in the most common case of CR0.
  4012. (define_expand "movcc"
  4013.   [(set (match_operand:CC 0 "nonimmediate_operand" "")
  4014.     (match_operand:CC 1 "nonimmediate_operand" ""))]
  4015.   ""
  4016.   "")
  4017.  
  4018. (define_insn ""
  4019.   [(set (match_operand:CC 0 "nonimmediate_operand" "=y,x,y,r,r,r,r,m")
  4020.     (match_operand:CC 1 "nonimmediate_operand" "y,r,r,x,y,r,m,r"))]
  4021.   "register_operand (operands[0], CCmode)
  4022.    || register_operand (operands[1], CCmode)"
  4023.   "@
  4024.    mcrf %0,%1
  4025.    mtcrf 128,%1
  4026.    {rlinm|rlwinm} %1,%1,%F0,0xffffffff\;mtcrf %R0,%1\;{rlinm|rlwinm} %1,%1,%f0,0xffffffff
  4027.    mfcr %0
  4028.    mfcr %0\;{rlinm|rlwinm} %0,%0,%f1,0xf0000000
  4029.    mr %0,%1
  4030.    {l%U1%X1|lwz%U1%X1} %0,%1
  4031.    {st%U0%U1|stw%U0%U1} %1,%0"
  4032.   [(set_attr "type" "*,*,*,compare,*,*,load,*")
  4033.    (set_attr "length" "*,*,12,*,8,*,*,*")])
  4034.  
  4035. ;; For floating-point, we normally deal with the floating-point registers
  4036. ;; unless -msoft-float is used.  The sole exception is that parameter passing
  4037. ;; can produce floating-point values in fixed-point registers.  Unless the
  4038. ;; value is a simple constant or already in memory, we deal with this by
  4039. ;; allocating memory and copying the value explicitly via that memory location.
  4040. (define_expand "movsf"
  4041.   [(set (match_operand:SF 0 "nonimmediate_operand" "")
  4042.     (match_operand:SF 1 "any_operand" ""))]
  4043.   ""
  4044.   "
  4045. {
  4046.   /* If we are called from reload, we might be getting a SUBREG of a hard
  4047.      reg.  So expand it.  */
  4048.   if (GET_CODE (operands[0]) == SUBREG
  4049.       && GET_CODE (SUBREG_REG (operands[0])) == REG
  4050.       && REGNO (SUBREG_REG (operands[0])) < FIRST_PSEUDO_REGISTER)
  4051.     operands[0] = alter_subreg (operands[0]);
  4052.   if (GET_CODE (operands[1]) == SUBREG
  4053.       && GET_CODE (SUBREG_REG (operands[1])) == REG
  4054.       && REGNO (SUBREG_REG (operands[1])) < FIRST_PSEUDO_REGISTER)
  4055.     operands[1] = alter_subreg (operands[1]);
  4056.  
  4057.   if (TARGET_SOFT_FLOAT && GET_CODE (operands[0]) == MEM)
  4058.     operands[1] = force_reg (SFmode, operands[1]);
  4059.  
  4060.   else if (TARGET_HARD_FLOAT)
  4061.     {
  4062.       if (GET_CODE (operands[1]) == REG && REGNO (operands[1]) < 32)
  4063.     {
  4064.       /* If this is a store to memory or another integer register do the
  4065.          move directly.  Otherwise store to a temporary stack slot and
  4066.          load from there into a floating point register.  */
  4067.  
  4068.       if (GET_CODE (operands[0]) == MEM
  4069.           || (GET_CODE (operands[0]) == REG
  4070.           && (REGNO (operands[0]) < 32
  4071.               || (reload_in_progress
  4072.               && REGNO (operands[0]) >= FIRST_PSEUDO_REGISTER))))
  4073.         {
  4074.           emit_move_insn (operand_subword (operands[0], 0, 0, SFmode),
  4075.                   operand_subword (operands[1], 0, 0, SFmode));
  4076.           DONE;
  4077.         }
  4078.       else
  4079.         {
  4080.           rtx stack_slot = assign_stack_temp (SFmode, 4, 0);
  4081.  
  4082.           emit_move_insn (stack_slot, operands[1]);
  4083.           emit_move_insn (operands[0], stack_slot);
  4084.           DONE;
  4085.         }
  4086.     }
  4087.  
  4088.       if (GET_CODE (operands[0]) == MEM)
  4089.     {
  4090.       /* If operands[1] is a register, it may have double-precision data
  4091.          in it, so truncate it to single precision.  We need not do
  4092.          this for POWERPC.  */
  4093.       if (! TARGET_POWERPC && TARGET_HARD_FLOAT
  4094.           && GET_CODE (operands[1]) == REG)
  4095.         {
  4096.           rtx newreg
  4097.         = reload_in_progress ? operands[1] : gen_reg_rtx (SFmode);
  4098.           emit_insn (gen_aux_truncdfsf2 (newreg, operands[1]));
  4099.           operands[1] = newreg;
  4100.         }
  4101.  
  4102.       operands[1] = force_reg (SFmode, operands[1]);
  4103.     }
  4104.  
  4105.       if (GET_CODE (operands[0]) == REG && REGNO (operands[0]) < 32)
  4106.     {
  4107.       if (GET_CODE (operands[1]) == MEM
  4108. #if HOST_FLOAT_FORMAT == TARGET_FLOAT_FORMAT && ! defined(REAL_IS_NOT_DOUBLE)
  4109.           || GET_CODE (operands[1]) == CONST_DOUBLE
  4110. #endif
  4111.           || (GET_CODE (operands[1]) == REG
  4112.           && (REGNO (operands[1]) < 32
  4113.               || (reload_in_progress
  4114.               && REGNO (operands[1]) >= FIRST_PSEUDO_REGISTER))))
  4115.         {
  4116.           emit_move_insn (operand_subword (operands[0], 0, 0, SFmode),
  4117.                   operand_subword (operands[1], 0, 0, SFmode));
  4118.           DONE;
  4119.         }
  4120.       else
  4121.         {
  4122.           rtx stack_slot = assign_stack_temp (SFmode, 4, 0);
  4123.  
  4124.           emit_move_insn (stack_slot, operands[1]);
  4125.           emit_move_insn (operands[0], stack_slot);
  4126.           DONE;
  4127.         }
  4128.     }
  4129.     }
  4130.  
  4131.   if (CONSTANT_P (operands[1]))
  4132.     {
  4133.       operands[1] = force_const_mem (SFmode, operands[1]);
  4134.       if (! memory_address_p (SFmode, XEXP (operands[1], 0))
  4135.       && ! reload_in_progress)
  4136.     operands[1] = change_address (operands[1], SFmode,
  4137.                       XEXP (operands[1], 0));
  4138.     }
  4139. }")
  4140.  
  4141. (define_split
  4142.   [(set (match_operand:SF 0 "gpc_reg_operand" "")
  4143.     (match_operand:SF 1 "easy_fp_constant" ""))]
  4144.   "reload_completed && REGNO (operands[0]) <= 31"
  4145.   [(set (match_dup 2) (match_dup 3))]
  4146.   "
  4147. { operands[2] = operand_subword (operands[0], 0, 0, SFmode);
  4148.   operands[3] = operand_subword (operands[1], 0, 0, SFmode); }")
  4149.  
  4150. (define_insn ""
  4151.   [(set (match_operand:SF 0 "fp_reg_or_mem_operand" "=f,f,m")
  4152.     (match_operand:SF 1 "input_operand" "f,m,f"))]
  4153.   "(gpc_reg_operand (operands[0], SFmode)
  4154.    || gpc_reg_operand (operands[1], SFmode)) && TARGET_HARD_FLOAT"
  4155.   "@
  4156.    fmr %0,%1
  4157.    lfs%U1%X1 %0,%1
  4158.    stfs%U0%X0 %1,%0"
  4159.   [(set_attr "type" "fp,fpload,*")])
  4160.  
  4161. (define_insn ""
  4162.   [(set (match_operand:SF 0 "nonimmediate_operand" "=r,r,m,r,r,r")
  4163.     (match_operand:SF 1 "input_operand" "r,m,r,I,J,R"))]
  4164.   "(gpc_reg_operand (operands[0], SFmode)
  4165.    || gpc_reg_operand (operands[1], SFmode)) && TARGET_SOFT_FLOAT"
  4166.   "@
  4167.    mr %0,%1
  4168.    {l%U1%X1|lwz%U1%X1} %0,%1
  4169.    {st%U0%X0|stw%U0%X0} %1,%0
  4170.    {lil|li} %0,%1
  4171.    {liu|lis} %0,%u1
  4172.    {cal|la} %0,%1(%*)"
  4173.   [(set_attr "type" "*,load,*,*,*,*")])
  4174.  
  4175.  
  4176. (define_expand "movdf"
  4177.   [(set (match_operand:DF 0 "nonimmediate_operand" "")
  4178.     (match_operand:DF 1 "any_operand" ""))]
  4179.   ""
  4180.   "
  4181. {
  4182.   if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
  4183.     {
  4184.       emit_move_insn (operand_subword (operands[0], 1, 1, DFmode),
  4185.               operand_subword_force (operands[1], 1, DFmode));
  4186.       emit_move_insn (operand_subword (operands[0], 0, 1, DFmode),
  4187.               operand_subword_force (operands[1], 0, DFmode));
  4188.       DONE;
  4189.     }
  4190.  
  4191.   if (GET_CODE (operands[0]) != REG)
  4192.     operands[1] = force_reg (DFmode, operands[1]);
  4193.  
  4194.   if (CONSTANT_P (operands[1]) && ! easy_fp_constant (operands[1], DFmode))
  4195.     {
  4196.       operands[1] = force_const_mem (DFmode, operands[1]);
  4197.       if (! memory_address_p (DFmode, XEXP (operands[1], 0))
  4198.       && ! reload_in_progress)
  4199.     operands[1] = change_address (operands[1], DFmode,
  4200.                       XEXP (operands[1], 0));
  4201.     }
  4202. }")
  4203.  
  4204. (define_split
  4205.   [(set (match_operand:DF 0 "gpc_reg_operand" "")
  4206.     (match_operand:DF 1 "easy_fp_constant" ""))]
  4207.   "reload_completed && REGNO (operands[0]) <= 31"
  4208.   [(set (match_dup 2) (match_dup 3))
  4209.    (set (match_dup 4) (match_dup 5))]
  4210.   "
  4211. { operands[2] = operand_subword (operands[0], 0, 0, DFmode);
  4212.   operands[3] = operand_subword (operands[1], 0, 0, DFmode);
  4213.   operands[4] = operand_subword (operands[0], 1, 0, DFmode);
  4214.   operands[5] = operand_subword (operands[1], 1, 0, DFmode); }")
  4215.  
  4216. ;; Don't have reload use general registers to load a constant.  First,
  4217. ;; it might not work if the output operand has is the equivalent of
  4218. ;; a non-offsettable memref, but also it is less efficient than loading
  4219. ;; the constant into an FP register, since it will probably be used there.
  4220. ;; The "??" is a kludge until we can figure out a more reasonable way
  4221. ;; of handling these non-offsettable values.
  4222. (define_insn ""
  4223.   [(set (match_operand:DF 0 "nonimmediate_operand" "=!r,??r,o,!r,f,f,m")
  4224.     (match_operand:DF 1 "input_operand" "r,o,r,G,f,m,f"))]
  4225.   "! TARGET_POWERPC64 && TARGET_HARD_FLOAT
  4226.    && (register_operand (operands[0], DFmode)
  4227.        || register_operand (operands[1], DFmode))"
  4228.   "*
  4229. {
  4230.   switch (which_alternative)
  4231.     {
  4232.     case 0:
  4233.       /* We normally copy the low-numbered register first.  However, if
  4234.      the first register operand 0 is the same as the second register of
  4235.      operand 1, we must copy in the opposite order.  */
  4236.       if (REGNO (operands[0]) == REGNO (operands[1]) + 1)
  4237.     return \"mr %L0,%L1\;mr %0,%1\";
  4238.       else
  4239.     return \"mr %0,%1\;mr %L0,%L1\";
  4240.     case 1:
  4241.       /* If the low-address word is used in the address, we must load it
  4242.      last.  Otherwise, load it first.  Note that we cannot have
  4243.      auto-increment in that case since the address register is known to be
  4244.      dead.  */
  4245.       if (refers_to_regno_p (REGNO (operands[0]), REGNO (operands[0]) + 1,
  4246.                  operands [1], 0))
  4247.     return \"{l|lwz} %L0,%L1\;{l|lwz} %0,%1\";
  4248.       else
  4249.     return \"{l%U1|lwz%U1} %0,%1\;{l|lwz} %L0,%L1\";
  4250.     case 2:
  4251.       return \"{st%U0|stw%U0} %1,%0\;{st|stw} %L1,%L0\";
  4252.     case 3:
  4253.       return \"#\";
  4254.     case 4:
  4255.       return \"fmr %0,%1\";
  4256.     case 5:
  4257.       return \"lfd%U1%X1 %0,%1\";
  4258.     case 6:
  4259.       return \"stfd%U0%X0 %1,%0\";
  4260.     }
  4261. }"
  4262.   [(set_attr "type" "*,load,*,*,fp,fpload,*")
  4263.    (set_attr "length" "8,8,8,8,*,*,*")])
  4264.  
  4265. (define_insn ""
  4266.   [(set (match_operand:DF 0 "nonimmediate_operand" "=r,r,o,r")
  4267.     (match_operand:DF 1 "input_operand" "r,o,r,G"))]
  4268.   "! TARGET_POWERPC64 && TARGET_SOFT_FLOAT
  4269.    && (register_operand (operands[0], DFmode)
  4270.        || register_operand (operands[1], DFmode))"
  4271.   "*
  4272. {
  4273.   switch (which_alternative)
  4274.     {
  4275.     case 0:
  4276.       /* We normally copy the low-numbered register first.  However, if
  4277.      the first register operand 0 is the same as the second register of
  4278.      operand 1, we must copy in the opposite order.  */
  4279.       if (REGNO (operands[0]) == REGNO (operands[1]) + 1)
  4280.     return \"mr %L0,%L1\;mr %0,%1\";
  4281.       else
  4282.     return \"mr %0,%1\;mr %L0,%L1\";
  4283.     case 1:
  4284.       /* If the low-address word is used in the address, we must load it
  4285.      last.  Otherwise, load it first.  Note that we cannot have
  4286.      auto-increment in that case since the address register is known to be
  4287.      dead.  */
  4288.       if (refers_to_regno_p (REGNO (operands[0]), REGNO (operands[0]) + 1,
  4289.                  operands [1], 0))
  4290.     return \"{l|lwz} %L0,%L1\;{l|lwz} %0,%1\";
  4291.       else
  4292.     return \"{l%U1|lwz%U1} %0,%1\;{l|lwz} %L0,%L1\";
  4293.     case 2:
  4294.       return \"{st%U0|stw%U0} %1,%0\;{st|stw} %L1,%L0\";
  4295.     case 3:
  4296.       return \"#\";
  4297.     }
  4298. }"
  4299.   [(set_attr "type" "*,load,*,*")
  4300.    (set_attr "length" "8,8,8,8")])
  4301.  
  4302. (define_insn ""
  4303.   [(set (match_operand:DF 0 "nonimmediate_operand" "=!r,??r,o,!r,f,f,m")
  4304.     (match_operand:DF 1 "input_operand" "r,o,r,G,f,m,f"))]
  4305.   "TARGET_POWERPC64 && TARGET_HARD_FLOAT
  4306.    && (register_operand (operands[0], DFmode)
  4307.        || register_operand (operands[1], DFmode))"
  4308.   "@
  4309.    mr %0,%1
  4310.    ld%U1%X1 %0,%1
  4311.    sd%U0%X0 %1,%0
  4312.    #
  4313.    fmr %0,%1
  4314.    lfd%U1%X1 %0,%1
  4315.    stfd%U0%X0 %1,%0"
  4316.   [(set_attr "type" "*,load,*,*,fp,fpload,*")])
  4317.  
  4318. (define_insn ""
  4319.   [(set (match_operand:DF 0 "nonimmediate_operand" "=r,r,o,r")
  4320.     (match_operand:DF 1 "input_operand" "r,o,r,G"))]
  4321.   "TARGET_POWERPC64 && TARGET_SOFT_FLOAT
  4322.    && (register_operand (operands[0], DFmode)
  4323.        || register_operand (operands[1], DFmode))"
  4324.   "@
  4325.    mr %0,%1
  4326.    ld%U1%X1 %0,%1
  4327.    sd%U0%X0 %1,%0
  4328.    #"
  4329.   [(set_attr "type" "*,load,*,*")])
  4330.  
  4331. ;; Next come the multi-word integer load and store and the load and store
  4332. ;; multiple insns.
  4333. (define_expand "movdi"
  4334.   [(set (match_operand:DI 0 "general_operand" "")
  4335.     (match_operand:DI 1 "general_operand" ""))]
  4336.   ""
  4337.   "
  4338. {
  4339.   if (GET_CODE (operands[1]) == CONST_DOUBLE
  4340.       || GET_CODE (operands[1]) == CONST_INT)
  4341.     {
  4342.       emit_move_insn (operand_subword (operands[0], 0, 0, DImode),
  4343.               operand_subword (operands[1], 0, 0, DImode));
  4344.       emit_move_insn (operand_subword (operands[0], 1, 0, DImode),
  4345.               operand_subword (operands[1], 1, 0, DImode));
  4346.       DONE;
  4347.     }
  4348.  
  4349.   if (GET_CODE (operands[0]) == MEM)
  4350.     operands[1] = force_reg (DImode, operands[1]);
  4351.  
  4352.       /* Stores between FPR and any non-FPR registers must go through a
  4353.          temporary stack slot.  */
  4354.  
  4355.   if (GET_CODE (operands[0]) == REG && GET_CODE (operands[1]) == REG
  4356.       && ((FP_REGNO_P (REGNO (operands[0]))
  4357.        && ! FP_REGNO_P (REGNO (operands[1])))
  4358.       || (FP_REGNO_P (REGNO (operands[1]))
  4359.           && ! FP_REGNO_P (REGNO (operands[0])))))
  4360.     {
  4361.       rtx stack_slot = assign_stack_temp (DImode, 8, 0);
  4362.  
  4363.       emit_move_insn (stack_slot, operands[1]);
  4364.       emit_move_insn (operands[0], stack_slot);
  4365.       DONE;
  4366.     }
  4367. }")
  4368.  
  4369. (define_insn ""
  4370.   [(set (match_operand:DI 0 "nonimmediate_operand" "=r,r,m,f,f,m")
  4371.     (match_operand:DI 1 "input_operand" "r,m,r,f,m,f"))]
  4372.   "! TARGET_POWERPC64 && (gpc_reg_operand (operands[0], DImode)
  4373.    || gpc_reg_operand (operands[1], DImode))"
  4374.   "*
  4375. {
  4376.   switch (which_alternative)
  4377.     {
  4378.     case 0:
  4379.       /* We normally copy the low-numbered register first.  However, if
  4380.      the first register operand 0 is the same as the second register of
  4381.      operand 1, we must copy in the opposite order.  */
  4382.       if (REGNO (operands[0]) == REGNO (operands[1]) + 1)
  4383.     return \"mr %L0,%L1\;mr %0,%1\";
  4384.       else
  4385.     return \"mr %0,%1\;mr %L0,%L1\";
  4386.     case 1:
  4387.       /* If the low-address word is used in the address, we must load it
  4388.      last.  Otherwise, load it first.  Note that we cannot have
  4389.      auto-increment in that case since the address register is known to be
  4390.      dead.  */
  4391.       if (refers_to_regno_p (REGNO (operands[0]), REGNO (operands[0]) + 1,
  4392.                  operands [1], 0))
  4393.     return \"{l|lwz} %L0,%L1\;{l|lwz} %0,%1\";
  4394.       else
  4395.     return \"{l%U1|lwz%U1} %0,%1\;{l|lwz} %L0,%L1\";
  4396.     case 2:
  4397.       return \"{st%U0|stw%U0} %1,%0\;{st|stw} %L1,%L0\";
  4398.     case 3:
  4399.       return \"fmr %0,%1\";
  4400.     case 4:
  4401.       return \"lfd%U1%X1 %0,%1\";
  4402.     case 5:
  4403.       return \"stfd%U0%X0 %1,%0\";
  4404.     }
  4405. }"
  4406.   [(set_attr "type" "*,load,*,fp,fpload,*")
  4407.    (set_attr "length" "8,8,8,*,*,*")])
  4408.  
  4409. (define_insn ""
  4410.   [(set (match_operand:DI 0 "nonimmediate_operand" "=r,r,m,r,r,r,f,f,m,r,*h")
  4411.     (match_operand:DI 1 "input_operand" "r,m,r,I,J,R,f,m,f,*h,r"))]
  4412.   "TARGET_POWERPC64 && (gpc_reg_operand (operands[0], DImode)
  4413.    || gpc_reg_operand (operands[1], DImode))"
  4414.   "@
  4415.    mr %0,%1
  4416.    ld%U1%X1 %0,%1
  4417.    sd%U0%X0 %1,%0
  4418.    li %0,%1
  4419.    lis %0,%u1
  4420.    {cal|la} %0,%1(%*)
  4421.    fmr %0,%1
  4422.    lfd%U1%X1 %0,%1
  4423.    stfd%U0%X0 %1,%0
  4424.    mf%1 %0
  4425.    mt%0 %1"
  4426.   [(set_attr "type" "*,load,*,*,*,*,fp,fpload,*,*,mtjmpr")])
  4427.  
  4428. ;; TImode is similar, except that we usually want to compute the address into
  4429. ;; a register and use lsi/stsi (the exception is during reload).  MQ is also
  4430. ;; clobbered in stsi for POWER, so we need a SCRATCH for it.
  4431. (define_expand "movti"
  4432.   [(parallel [(set (match_operand:TI 0 "general_operand" "")
  4433.            (match_operand:TI 1 "general_operand" ""))
  4434.           (clobber (scratch:SI))])]
  4435.   "TARGET_STRING || TARGET_POWERPC64"
  4436.   "
  4437. {
  4438.   if (GET_CODE (operands[0]) == MEM)
  4439.     operands[1] = force_reg (TImode, operands[1]);
  4440.  
  4441.   if (GET_CODE (operands[0]) == MEM
  4442.       && GET_CODE (XEXP (operands[0], 0)) != REG
  4443.       && ! reload_in_progress)
  4444.     operands[0] = change_address (operands[0], TImode,
  4445.                   copy_addr_to_reg (XEXP (operands[0], 0)));
  4446.  
  4447.   if (GET_CODE (operands[1]) == MEM
  4448.       && GET_CODE (XEXP (operands[1], 0)) != REG
  4449.       && ! reload_in_progress)
  4450.     operands[1] = change_address (operands[1], TImode,
  4451.                   copy_addr_to_reg (XEXP (operands[1], 0)));
  4452. }")
  4453.  
  4454. ;; We say that MQ is clobbered in the last alternative because the first
  4455. ;; alternative would never get used otherwise since it would need a reload
  4456. ;; while the 2nd alternative would not.  We put memory cases first so they
  4457. ;; are preferred.  Otherwise, we'd try to reload the output instead of
  4458. ;; giving the SCRATCH mq.
  4459. (define_insn ""
  4460.   [(set (match_operand:TI 0 "reg_or_mem_operand" "=Q,m,????r,????r,????r")
  4461.     (match_operand:TI 1 "reg_or_mem_operand" "r,r,r,Q,m"))
  4462.    (clobber (match_scratch:SI 2 "=q,q#X,X,X,X"))]
  4463.   "TARGET_STRING && TARGET_POWER && ! TARGET_POWERPC64
  4464.    && (gpc_reg_operand (operands[0], TImode) || gpc_reg_operand (operands[1], TImode))"
  4465.   "*
  4466. {
  4467.   switch (which_alternative)
  4468.     {
  4469.     default:
  4470.       abort ();
  4471.  
  4472.     case 0:
  4473.       return \"{stsi|stswi} %1,%P0,16\";
  4474.  
  4475.     case 1:
  4476.       return \"{st%U0|stw%U0} %1,%0\;{st|stw} %L1,%L0\;{st|stw} %Y1,%Y0\;{st|stw} %Z1,%Z0\";
  4477.  
  4478.     case 2:
  4479.       /* Normally copy registers with lowest numbered register copied first.
  4480.      But copy in the other order if the first register of the output
  4481.      is the second, third, or fourth register in the input.  */
  4482.       if (REGNO (operands[0]) >= REGNO (operands[1]) + 1
  4483.       && REGNO (operands[0]) <= REGNO (operands[1]) + 3)
  4484.     return \"mr %Z0,%Z1\;mr %Y0,%Y1\;mr %L0,%L1\;mr %0,%1\";
  4485.       else
  4486.     return \"mr %0,%1\;mr %L0,%L1\;mr %Y0,%Y1\;mr %Z0,%Z1\";
  4487.     case 3:
  4488.       /* If the address is not used in the output, we can use lsi.  Otherwise,
  4489.      fall through to generating four loads.  */
  4490.       if (! reg_overlap_mentioned_p (operands[0], operands[1]))
  4491.     return \"{lsi|lswi} %0,%P1,16\";
  4492.       /* ... fall through ... */
  4493.     case 4:
  4494.       /* If the address register is the same as the register for the lowest-
  4495.      addressed word, load it last.  Similarly for the next two words.
  4496.      Otherwise load lowest address to highest.  */
  4497.       if (refers_to_regno_p (REGNO (operands[0]), REGNO (operands[0]) + 1,
  4498.                  operands[1], 0))
  4499.     return \"{l|lwz} %L0,%L1\;{l|lwz} %Y0,%Y1\;{l|lwz} %Z0,%Z1\;{l|lwz} %0,%1\";
  4500.       else if (refers_to_regno_p (REGNO (operands[0]) + 1,
  4501.                   REGNO (operands[0]) + 2, operands[1], 0))
  4502.     return \"{l|lwz} %0,%1\;{l|lwz} %Y0,%Y1\;{l|lwz} %Z0,%Z1\;{l|lwz} %L0,%L1\";
  4503.       else if (refers_to_regno_p (REGNO (operands[0]) + 2,
  4504.                   REGNO (operands[0]) + 3, operands[1], 0))
  4505.     return \"{l|lwz} %0,%1\;{l|lwz} %L0,%L1\;{l|lwz} %Z0,%Z1\;{l|lwz} %Y0,%Y1\";
  4506.       else
  4507.     return \"{l%U1|lwz%U1} %0,%1\;{l|lwz} %L0,%L1\;{l|lwz} %Y0,%Y1\;{l|lwz} %Z0,%Z1\";
  4508.     }
  4509. }"
  4510.   [(set_attr "type" "*,load,load,*,*")
  4511.    (set_attr "length" "*,16,16,*,16")])
  4512.  
  4513. (define_insn ""
  4514.   [(set (match_operand:TI 0 "reg_or_mem_operand" "=m,????r,????r")
  4515.     (match_operand:TI 1 "reg_or_mem_operand" "r,r,m"))
  4516.    (clobber (match_scratch:SI 2 "=X,X,X"))]
  4517.   "TARGET_STRING && !TARGET_POWER && ! TARGET_POWERPC64
  4518.    && (gpc_reg_operand (operands[0], TImode) || gpc_reg_operand (operands[1], TImode))"
  4519.   "*
  4520. {
  4521.   switch (which_alternative)
  4522.     {
  4523.     default:
  4524.       abort ();
  4525.  
  4526.     case 0:
  4527.       return \"{st%U0|stw%U0} %1,%0\;{st|stw} %L1,%L0\;{st|stw} %Y1,%Y0\;{st|stw} %Z1,%Z0\";
  4528.  
  4529.     case 1:
  4530.       /* Normally copy registers with lowest numbered register copied first.
  4531.      But copy in the other order if the first register of the output
  4532.      is the second, third, or fourth register in the input.  */
  4533.       if (REGNO (operands[0]) >= REGNO (operands[1]) + 1
  4534.       && REGNO (operands[0]) <= REGNO (operands[1]) + 3)
  4535.     return \"mr %Z0,%Z1\;mr %Y0,%Y1\;mr %L0,%L1\;mr %0,%1\";
  4536.       else
  4537.     return \"mr %0,%1\;mr %L0,%L1\;mr %Y0,%Y1\;mr %Z0,%Z1\";
  4538.     case 2:
  4539.       /* If the address register is the same as the register for the lowest-
  4540.      addressed word, load it last.  Similarly for the next two words.
  4541.      Otherwise load lowest address to highest.  */
  4542.       if (refers_to_regno_p (REGNO (operands[0]), REGNO (operands[0]) + 1,
  4543.                  operands[1], 0))
  4544.     return \"{l|lwz} %L0,%L1\;{l|lwz} %Y0,%Y1\;{l|lwz} %Z0,%Z1\;{l|lwz} %0,%1\";
  4545.       else if (refers_to_regno_p (REGNO (operands[0]) + 1,
  4546.                   REGNO (operands[0]) + 2, operands[1], 0))
  4547.     return \"{l|lwz} %0,%1\;{l|lwz} %Y0,%Y1\;{l|lwz} %Z0,%Z1\;{l|lwz} %L0,%L1\";
  4548.       else if (refers_to_regno_p (REGNO (operands[0]) + 2,
  4549.                   REGNO (operands[0]) + 3, operands[1], 0))
  4550.     return \"{l|lwz} %0,%1\;{l|lwz} %L0,%L1\;{l|lwz} %Z0,%Z1\;{l|lwz} %Y0,%Y1\";
  4551.       else
  4552.     return \"{l%U1|lwz%U1} %0,%1\;{l|lwz} %L0,%L1\;{l|lwz} %Y0,%Y1\;{l|lwz} %Z0,%Z1\";
  4553.     }
  4554. }"
  4555.   [(set_attr "type" "load,*,*")
  4556.    (set_attr "length" "16,16,16")])
  4557.  
  4558. (define_insn ""
  4559.   [(set (match_operand:TI 0 "nonimmediate_operand" "=r,r,m")
  4560.     (match_operand:TI 1 "input_operand" "r,m,r"))]
  4561.   "TARGET_POWERPC64 && (gpc_reg_operand (operands[0], TImode)
  4562.    || gpc_reg_operand (operands[1], TImode))"
  4563.   "*
  4564. {
  4565.   switch (which_alternative)
  4566.     {
  4567.     case 0:
  4568.       /* We normally copy the low-numbered register first.  However, if
  4569.      the first register operand 0 is the same as the second register of
  4570.      operand 1, we must copy in the opposite order.  */
  4571.       if (REGNO (operands[0]) == REGNO (operands[1]) + 1)
  4572.     return \"mr %L0,%L1\;mr %0,%1\";
  4573.       else
  4574.     return \"mr %0,%1\;mr %L0,%L1\";
  4575.     case 1:
  4576.       /* If the low-address word is used in the address, we must load it
  4577.      last.  Otherwise, load it first.  Note that we cannot have
  4578.      auto-increment in that case since the address register is known to be
  4579.      dead.  */
  4580.       if (refers_to_regno_p (REGNO (operands[0]), REGNO (operands[0]) + 1,
  4581.                  operands [1], 0))
  4582.     return \"ld %L0,%L1\;ld %0,%1\";
  4583.       else
  4584.     return \"ld%U1 %0,%1\;ld %L0,%L1\";
  4585.     case 2:
  4586.       return \"std%U0 %1,%0\;std %L1,%L0\";
  4587.     }
  4588. }"
  4589.   [(set_attr "type" "*,load,*")
  4590.    (set_attr "length" "8,8,8")])
  4591.  
  4592. (define_expand "load_multiple"
  4593.   [(match_par_dup 3 [(set (match_operand:SI 0 "" "")
  4594.               (match_operand:SI 1 "" ""))
  4595.              (use (match_operand:SI 2 "" ""))])]
  4596.   "TARGET_STRING"
  4597.   "
  4598. {
  4599.   int regno;
  4600.   int count;
  4601.   rtx from;
  4602.   int i;
  4603.  
  4604.   /* Support only loading a constant number of fixed-point registers from
  4605.      memory and only bother with this if more than two; the machine
  4606.      doesn't support more than eight.  */
  4607.   if (GET_CODE (operands[2]) != CONST_INT
  4608.       || INTVAL (operands[2]) <= 2
  4609.       || INTVAL (operands[2]) > 8
  4610.       || GET_CODE (operands[1]) != MEM
  4611.       || GET_CODE (operands[0]) != REG
  4612.       || REGNO (operands[0]) >= 32)
  4613.     FAIL;
  4614.  
  4615.   count = INTVAL (operands[2]);
  4616.   regno = REGNO (operands[0]);
  4617.  
  4618.   operands[3] = gen_rtx (PARALLEL, VOIDmode, rtvec_alloc (count));
  4619.   from = force_reg (SImode, XEXP (operands[1], 0));
  4620.  
  4621.   for (i = 0; i < count; i++)
  4622.     XVECEXP (operands[3], 0, i)
  4623.       = gen_rtx (SET, VOIDmode, gen_rtx (REG, SImode, regno + i),
  4624.          gen_rtx (MEM, SImode, plus_constant (from, i * 4)));
  4625. }")
  4626.  
  4627. (define_insn ""
  4628.   [(match_parallel 0 "load_multiple_operation"
  4629.            [(set (match_operand:SI 1 "gpc_reg_operand" "=r")
  4630.              (match_operand:SI 2 "indirect_operand" "Q"))])]
  4631.   "TARGET_STRING"
  4632.   "*
  4633. {
  4634.   /* We have to handle the case where the pseudo used to contain the address
  4635.      is assigned to one of the output registers.  In that case, do the
  4636.      lsi, but then load the correct value.  This is a bit of a mess, but is
  4637.      the best we can do.
  4638.      We set the length attribute to the maximum possible size (8 bytes).  */
  4639.   static char result[100];
  4640.   char newload[40];
  4641.   int i;
  4642.  
  4643.   strcpy (result, \"{lsi|lswi} %1,%P2,%N0\");
  4644.   for (i = 0; i < XVECLEN (operands[0], 0); i++)
  4645.     if (refers_to_regno_p (REGNO (operands[1]) + i,
  4646.                REGNO (operands[1]) + i + 1, operands[2], 0))
  4647.       {
  4648.     sprintf (newload, \"\;{l|lwz} %d,%d(%d)\",
  4649.          REGNO (operands[1]) + i,
  4650.          i * 4, REGNO (XEXP (operands[2], 0)));
  4651.     strcat (result, newload);
  4652.       }
  4653.  
  4654.   return result;
  4655. }"
  4656.   [(set_attr "type" "load")
  4657.    (set_attr "length" "8")])
  4658.  
  4659.  
  4660. (define_expand "store_multiple"
  4661.   [(match_par_dup 3 [(set (match_operand:SI 0 "" "")
  4662.               (match_operand:SI 1 "" ""))
  4663.              (clobber (scratch:SI))
  4664.              (use (match_operand:SI 2 "" ""))])]
  4665.   "TARGET_STRING"
  4666.   "
  4667. {
  4668.   int regno;
  4669.   int count;
  4670.   rtx to;
  4671.   int i;
  4672.  
  4673.   /* Support only storing a constant number of fixed-point registers to
  4674.      memory and only bother with this if more than two; the machine
  4675.      doesn't support more than eight.  */
  4676.   if (GET_CODE (operands[2]) != CONST_INT
  4677.       || INTVAL (operands[2]) <= 2
  4678.       || INTVAL (operands[2]) > 8
  4679.       || GET_CODE (operands[0]) != MEM
  4680.       || GET_CODE (operands[1]) != REG
  4681.       || REGNO (operands[1]) >= 32)
  4682.     FAIL;
  4683.  
  4684.   count = INTVAL (operands[2]);
  4685.   regno = REGNO (operands[1]);
  4686.  
  4687.   operands[3] = gen_rtx (PARALLEL, VOIDmode, rtvec_alloc (count + 1));
  4688.   to = force_reg (SImode, XEXP (operands[0], 0));
  4689.  
  4690.   XVECEXP (operands[3], 0, 0)
  4691.     = gen_rtx (SET, VOIDmode, gen_rtx (MEM, SImode, to), operands[1]);
  4692.   XVECEXP (operands[3], 0, 1) = gen_rtx (CLOBBER, VOIDmode,
  4693.                           gen_rtx (SCRATCH, SImode));
  4694.  
  4695.   for (i = 1; i < count; i++)
  4696.     XVECEXP (operands[3], 0, i + 1)
  4697.       = gen_rtx (SET, VOIDmode,
  4698.          gen_rtx (MEM, SImode, plus_constant (to, i * 4)),
  4699.          gen_rtx (REG, SImode, regno + i));
  4700. }")
  4701.  
  4702. (define_insn ""
  4703.   [(match_parallel 0 "store_multiple_operation"
  4704.            [(set (match_operand:SI 1 "indirect_operand" "=Q")
  4705.              (match_operand:SI 2 "gpc_reg_operand" "r"))
  4706.             (clobber (match_scratch:SI 3 "=q"))])]
  4707.   "TARGET_STRING && TARGET_POWER"
  4708.   "{stsi|stswi} %2,%P1,%O0")
  4709.  
  4710. (define_insn ""
  4711.   [(match_parallel 0 "store_multiple_operation"
  4712.            [(set (match_operand:SI 1 "indirect_operand" "=Q")
  4713.              (match_operand:SI 2 "gpc_reg_operand" "r"))
  4714.             (clobber (match_scratch:SI 3 "X"))])]
  4715.   "TARGET_STRING && !TARGET_POWER"
  4716.   "{stsi|stswi} %2,%P1,%O0")
  4717.  
  4718.  
  4719. ;; String/block move insn.
  4720. ;; Argument 0 is the destination
  4721. ;; Argument 1 is the source
  4722. ;; Argument 2 is the length
  4723. ;; Argument 3 is the alignment
  4724.  
  4725. (define_expand "movstrsi"
  4726.   [(parallel [(set (match_operand:BLK 0 "memory_operand" "")
  4727.            (match_operand:BLK 1 "memory_operand" ""))
  4728.           (use (match_operand:SI 2 "general_operand" ""))
  4729.           (use (match_operand:SI 3 "immediate_operand" ""))])]
  4730.   ""
  4731.   "
  4732. {
  4733.   if (expand_block_move (operands))
  4734.     DONE;
  4735.   else
  4736.     FAIL;
  4737. }")
  4738.  
  4739. ;; Move up to 32 bytes at a time.  The fixed registers are needed because the
  4740. ;; register allocator doesn't have a clue about allocating 8 word registers
  4741. (define_expand "movstrsi_8reg"
  4742.   [(parallel [(set (mem:BLK (match_operand:SI 0 "register_operand" ""))
  4743.            (mem:BLK (match_operand:SI 1 "register_operand" "")))
  4744.           (use (match_operand:SI 2 "immediate_operand" ""))
  4745.           (use (match_operand:SI 3 "immediate_operand" ""))
  4746.           (clobber (reg:SI  5))
  4747.           (clobber (reg:SI  6))
  4748.           (clobber (reg:SI  7))
  4749.           (clobber (reg:SI  8))
  4750.           (clobber (reg:SI  9))
  4751.           (clobber (reg:SI 10))
  4752.           (clobber (reg:SI 11))
  4753.           (clobber (reg:SI 12))
  4754.           (clobber (match_scratch:SI 4 ""))])]
  4755.   "TARGET_STRING"
  4756.   "")
  4757.  
  4758. (define_insn ""
  4759.   [(set (mem:BLK (match_operand:SI 0 "register_operand" "b"))
  4760.     (mem:BLK (match_operand:SI 1 "register_operand" "b")))
  4761.    (use (match_operand:SI 2 "immediate_operand" "i"))
  4762.    (use (match_operand:SI 3 "immediate_operand" "i"))
  4763.    (clobber (match_operand:SI 4 "register_operand" "=r"))
  4764.    (clobber (reg:SI  6))
  4765.    (clobber (reg:SI  7))
  4766.    (clobber (reg:SI  8))
  4767.    (clobber (reg:SI  9))
  4768.    (clobber (reg:SI 10))
  4769.    (clobber (reg:SI 11))
  4770.    (clobber (reg:SI 12))
  4771.    (clobber (match_scratch:SI 5 "=q"))]
  4772.   "TARGET_STRING && TARGET_POWER
  4773.    && ((INTVAL (operands[2]) > 24 && INTVAL (operands[2]) < 32) || INTVAL (operands[2]) == 0)
  4774.    && (REGNO (operands[0]) < 5 || REGNO (operands[0]) > 12)
  4775.    && (REGNO (operands[1]) < 5 || REGNO (operands[1]) > 12)
  4776.    && REGNO (operands[4]) == 5"
  4777.   "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
  4778.   [(set_attr "length" "8")])
  4779.  
  4780. (define_insn ""
  4781.   [(set (mem:BLK (match_operand:SI 0 "register_operand" "b"))
  4782.     (mem:BLK (match_operand:SI 1 "register_operand" "b")))
  4783.    (use (match_operand:SI 2 "immediate_operand" "i"))
  4784.    (use (match_operand:SI 3 "immediate_operand" "i"))
  4785.    (clobber (match_operand:SI 4 "register_operand" "=r"))
  4786.    (clobber (reg:SI  6))
  4787.    (clobber (reg:SI  7))
  4788.    (clobber (reg:SI  8))
  4789.    (clobber (reg:SI  9))
  4790.    (clobber (reg:SI 10))
  4791.    (clobber (reg:SI 11))
  4792.    (clobber (reg:SI 12))
  4793.    (clobber (match_scratch:SI 5 "X"))]
  4794.   "TARGET_STRING && !TARGET_POWER
  4795.    && ((INTVAL (operands[2]) > 24 && INTVAL (operands[2]) < 32) || INTVAL (operands[2]) == 0)
  4796.    && (REGNO (operands[0]) < 5 || REGNO (operands[0]) > 12)
  4797.    && (REGNO (operands[1]) < 5 || REGNO (operands[1]) > 12)
  4798.    && REGNO (operands[4]) == 5"
  4799.   "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
  4800.   [(set_attr "length" "8")])
  4801.  
  4802. ;; Move up to 24 bytes at a time.  The fixed registers are needed because the
  4803. ;; register allocator doesn't have a clue about allocating 6 word registers
  4804. (define_expand "movstrsi_6reg"
  4805.   [(parallel [(set (mem:BLK (match_operand:SI 0 "register_operand" ""))
  4806.            (mem:BLK (match_operand:SI 1 "register_operand" "")))
  4807.           (use (match_operand:SI 2 "immediate_operand" ""))
  4808.           (use (match_operand:SI 3 "immediate_operand" ""))
  4809.           (clobber (reg:SI  7))
  4810.           (clobber (reg:SI  8))
  4811.           (clobber (reg:SI  9))
  4812.           (clobber (reg:SI 10))
  4813.           (clobber (reg:SI 11))
  4814.           (clobber (reg:SI 12))
  4815.           (clobber (match_scratch:SI 4 ""))])]
  4816.   "TARGET_STRING"
  4817.   "")
  4818.  
  4819. (define_insn ""
  4820.   [(set (mem:BLK (match_operand:SI 0 "register_operand" "b"))
  4821.     (mem:BLK (match_operand:SI 1 "register_operand" "b")))
  4822.    (use (match_operand:SI 2 "immediate_operand" "i"))
  4823.    (use (match_operand:SI 3 "immediate_operand" "i"))
  4824.    (clobber (match_operand:SI 4 "register_operand" "=r"))
  4825.    (clobber (reg:SI  8))
  4826.    (clobber (reg:SI  9))
  4827.    (clobber (reg:SI 10))
  4828.    (clobber (reg:SI 11))
  4829.    (clobber (reg:SI 12))
  4830.    (clobber (match_scratch:SI 5 "=q"))]
  4831.   "TARGET_STRING && TARGET_POWER
  4832.    && INTVAL (operands[2]) > 16 && INTVAL (operands[2]) <= 24
  4833.    && (REGNO (operands[0]) < 7 || REGNO (operands[0]) > 12)
  4834.    && (REGNO (operands[1]) < 7 || REGNO (operands[1]) > 12)
  4835.    && REGNO (operands[4]) == 7"
  4836.   "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
  4837.   [(set_attr "length" "8")])
  4838.  
  4839. (define_insn ""
  4840.   [(set (mem:BLK (match_operand:SI 0 "register_operand" "b"))
  4841.     (mem:BLK (match_operand:SI 1 "register_operand" "b")))
  4842.    (use (match_operand:SI 2 "immediate_operand" "i"))
  4843.    (use (match_operand:SI 3 "immediate_operand" "i"))
  4844.    (clobber (match_operand:SI 4 "register_operand" "=r"))
  4845.    (clobber (reg:SI  8))
  4846.    (clobber (reg:SI  9))
  4847.    (clobber (reg:SI 10))
  4848.    (clobber (reg:SI 11))
  4849.    (clobber (reg:SI 12))
  4850.    (clobber (match_scratch:SI 5 "X"))]
  4851.   "TARGET_STRING && !TARGET_POWER
  4852.    && INTVAL (operands[2]) > 16 && INTVAL (operands[2]) <= 32
  4853.    && (REGNO (operands[0]) < 7 || REGNO (operands[0]) > 12)
  4854.    && (REGNO (operands[1]) < 7 || REGNO (operands[1]) > 12)
  4855.    && REGNO (operands[4]) == 7"
  4856.   "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
  4857.   [(set_attr "length" "8")])
  4858.  
  4859. ;; Move up to 16 bytes at a time, using 4 fixed registers to avoid spill problems
  4860. ;; with TImode
  4861. (define_expand "movstrsi_4reg"
  4862.   [(parallel [(set (mem:BLK (match_operand:SI 0 "register_operand" ""))
  4863.            (mem:BLK (match_operand:SI 1 "register_operand" "")))
  4864.           (use (match_operand:SI 2 "immediate_operand" ""))
  4865.           (use (match_operand:SI 3 "immediate_operand" ""))
  4866.           (clobber (reg:SI  9))
  4867.           (clobber (reg:SI 10))
  4868.           (clobber (reg:SI 11))
  4869.           (clobber (reg:SI 12))
  4870.           (clobber (match_scratch:SI 4 ""))])]
  4871.   "TARGET_STRING"
  4872.   "")
  4873.  
  4874. (define_insn ""
  4875.   [(set (mem:BLK (match_operand:SI 0 "register_operand" "b"))
  4876.     (mem:BLK (match_operand:SI 1 "register_operand" "b")))
  4877.    (use (match_operand:SI 2 "immediate_operand" "i"))
  4878.    (use (match_operand:SI 3 "immediate_operand" "i"))
  4879.    (clobber (match_operand:SI 4 "register_operand" "=r"))
  4880.    (clobber (reg:SI 10))
  4881.    (clobber (reg:SI 11))
  4882.    (clobber (reg:SI 12))
  4883.    (clobber (match_scratch:SI 5 "=q"))]
  4884.   "TARGET_STRING && TARGET_POWER
  4885.    && INTVAL (operands[2]) > 8 && INTVAL (operands[2]) <= 16
  4886.    && (REGNO (operands[0]) < 9 || REGNO (operands[0]) > 12)
  4887.    && (REGNO (operands[1]) < 9 || REGNO (operands[1]) > 12)
  4888.    && REGNO (operands[4]) == 9"
  4889.   "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
  4890.   [(set_attr "length" "8")])
  4891.  
  4892. (define_insn ""
  4893.   [(set (mem:BLK (match_operand:SI 0 "register_operand" "b"))
  4894.     (mem:BLK (match_operand:SI 1 "register_operand" "b")))
  4895.    (use (match_operand:SI 2 "immediate_operand" "i"))
  4896.    (use (match_operand:SI 3 "immediate_operand" "i"))
  4897.    (clobber (match_operand:SI 4 "register_operand" "=r"))
  4898.    (clobber (reg:SI 10))
  4899.    (clobber (reg:SI 11))
  4900.    (clobber (reg:SI 12))
  4901.    (clobber (match_scratch:SI 5 "X"))]
  4902.   "TARGET_STRING && !TARGET_POWER
  4903.    && INTVAL (operands[2]) > 8 && INTVAL (operands[2]) <= 16
  4904.    && (REGNO (operands[0]) < 9 || REGNO (operands[0]) > 12)
  4905.    && (REGNO (operands[1]) < 9 || REGNO (operands[1]) > 12)
  4906.    && REGNO (operands[4]) == 9"
  4907.   "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
  4908.   [(set_attr "length" "8")])
  4909.  
  4910. ;; Move up to 8 bytes at a time.
  4911. (define_expand "movstrsi_2reg"
  4912.   [(parallel [(set (mem:BLK (match_operand:SI 0 "register_operand" ""))
  4913.            (mem:BLK (match_operand:SI 1 "register_operand" "")))
  4914.           (use (match_operand:SI 2 "immediate_operand" ""))
  4915.           (use (match_operand:SI 3 "immediate_operand" ""))
  4916.           (clobber (match_scratch:DI 4 ""))
  4917.           (clobber (match_scratch:SI 5 ""))])]
  4918.   "TARGET_STRING && !TARGET_64BIT"
  4919.   "")
  4920.  
  4921. (define_insn ""
  4922.   [(set (mem:BLK (match_operand:SI 0 "register_operand" "b"))
  4923.     (mem:BLK (match_operand:SI 1 "register_operand" "b")))
  4924.    (use (match_operand:SI 2 "immediate_operand" "i"))
  4925.    (use (match_operand:SI 3 "immediate_operand" "i"))
  4926.    (clobber (match_scratch:DI 4 "=&r"))
  4927.    (clobber (match_scratch:SI 5 "=q"))]
  4928.   "TARGET_STRING && TARGET_POWER && !TARGET_64BIT
  4929.    && INTVAL (operands[2]) > 4 && INTVAL (operands[2]) <= 8"
  4930.   "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
  4931.   [(set_attr "length" "8")])
  4932.  
  4933. (define_insn ""
  4934.   [(set (mem:BLK (match_operand:SI 0 "register_operand" "b"))
  4935.     (mem:BLK (match_operand:SI 1 "register_operand" "b")))
  4936.    (use (match_operand:SI 2 "immediate_operand" "i"))
  4937.    (use (match_operand:SI 3 "immediate_operand" "i"))
  4938.    (clobber (match_scratch:DI 4 "=&r"))
  4939.    (clobber (match_scratch:SI 5 "X"))]
  4940.   "TARGET_STRING && !TARGET_POWER && !TARGET_64BIT
  4941.    && INTVAL (operands[2]) > 4 && INTVAL (operands[2]) <= 8"
  4942.   "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
  4943.   [(set_attr "length" "8")])
  4944.  
  4945. ;; Move up to 4 bytes at a time.
  4946. (define_expand "movstrsi_1reg"
  4947.   [(parallel [(set (mem:BLK (match_operand:SI 0 "register_operand" ""))
  4948.            (mem:BLK (match_operand:SI 1 "register_operand" "")))
  4949.           (use (match_operand:SI 2 "immediate_operand" ""))
  4950.           (use (match_operand:SI 3 "immediate_operand" ""))
  4951.           (clobber (match_scratch:SI 4 ""))
  4952.           (clobber (match_scratch:SI 5 ""))])]
  4953.   "TARGET_STRING"
  4954.   "")
  4955.  
  4956. (define_insn ""
  4957.   [(set (mem:BLK (match_operand:SI 0 "register_operand" "b"))
  4958.     (mem:BLK (match_operand:SI 1 "register_operand" "b")))
  4959.    (use (match_operand:SI 2 "immediate_operand" "i"))
  4960.    (use (match_operand:SI 3 "immediate_operand" "i"))
  4961.    (clobber (match_scratch:SI 4 "=&r"))
  4962.    (clobber (match_scratch:SI 5 "=q"))]
  4963.   "TARGET_STRING && TARGET_POWER
  4964.    && INTVAL (operands[2]) > 0 && INTVAL (operands[2]) <= 4"
  4965.   "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
  4966.   [(set_attr "length" "8")])
  4967.  
  4968. (define_insn ""
  4969.   [(set (mem:BLK (match_operand:SI 0 "register_operand" "b"))
  4970.     (mem:BLK (match_operand:SI 1 "register_operand" "b")))
  4971.    (use (match_operand:SI 2 "immediate_operand" "i"))
  4972.    (use (match_operand:SI 3 "immediate_operand" "i"))
  4973.    (clobber (match_scratch:SI 4 "=&r"))
  4974.    (clobber (match_scratch:SI 5 "X"))]
  4975.   "TARGET_STRING && !TARGET_POWER
  4976.    && INTVAL (operands[2]) > 0 && INTVAL (operands[2]) <= 4"
  4977.   "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
  4978.   [(set_attr "length" "8")])
  4979.  
  4980.  
  4981. ;; Define insns that do load or store with update.  Some of these we can
  4982. ;; get by using pre-decrement or pre-increment, but the hardware can also
  4983. ;; do cases where the increment is not the size of the object.
  4984. ;;
  4985. ;; In all these cases, we use operands 0 and 1 for the register being
  4986. ;; incremented because those are the operands that local-alloc will
  4987. ;; tie and these are the pair most likely to be tieable (and the ones
  4988. ;; that will benefit the most).
  4989.  
  4990. (define_insn ""
  4991.   [(set (match_operand:DI 3 "gpc_reg_operand" "=r,r")
  4992.     (mem:DI (plus:DI (match_operand:DI 1 "gpc_reg_operand" "0,0")
  4993.              (match_operand:DI 2 "reg_or_short_operand" "r,I"))))
  4994.    (set (match_operand:DI 0 "gpc_reg_operand" "=b,b")
  4995.     (plus:DI (match_dup 1) (match_dup 2)))]
  4996.   "TARGET_POWERPC64"
  4997.   "@
  4998.    ldux %3,%0,%2
  4999.    ldu %3,%2(%0)"
  5000.   [(set_attr "type" "load")])
  5001.  
  5002. (define_insn ""
  5003.   [(set (match_operand:DI 3 "gpc_reg_operand" "=r")
  5004.     (sign_extend:DI
  5005.      (mem:SI (plus:DI (match_operand:DI 1 "gpc_reg_operand" "0")
  5006.               (match_operand:DI 2 "gpc_reg_operand" "r")))))
  5007.    (set (match_operand:DI 0 "gpc_reg_operand" "=b")
  5008.     (plus:DI (match_dup 1) (match_dup 2)))]
  5009.   "TARGET_POWERPC64"
  5010.   "lwaux %3,%0,%2"
  5011.   [(set_attr "type" "load")])
  5012.  
  5013. (define_insn ""
  5014.   [(set (mem:DI (plus:DI (match_operand:DI 1 "gpc_reg_operand" "0,0")
  5015.              (match_operand:DI 2 "reg_or_short_operand" "r,I")))
  5016.     (match_operand:DI 3 "gpc_reg_operand" "r,r"))
  5017.    (set (match_operand:DI 0 "gpc_reg_operand" "=b,b")
  5018.     (plus:DI (match_dup 1) (match_dup 2)))]
  5019.   "TARGET_POWERPC64"
  5020.   "@
  5021.    stdux %3,%0,%2
  5022.    stdu %3,%2(%0)")
  5023.  
  5024. (define_insn ""
  5025.   [(set (match_operand:SI 3 "gpc_reg_operand" "=r,r")
  5026.     (mem:SI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
  5027.              (match_operand:SI 2 "reg_or_short_operand" "r,I"))))
  5028.    (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
  5029.     (plus:SI (match_dup 1) (match_dup 2)))]
  5030.   ""
  5031.   "@
  5032.    {lux|lwzux} %3,%0,%2
  5033.    {lu|lwzu} %3,%2(%0)"
  5034.   [(set_attr "type" "load")])
  5035.  
  5036. (define_insn ""
  5037.   [(set (mem:SI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
  5038.              (match_operand:SI 2 "reg_or_short_operand" "r,I")))
  5039.     (match_operand:SI 3 "gpc_reg_operand" "r,r"))
  5040.    (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
  5041.     (plus:SI (match_dup 1) (match_dup 2)))]
  5042.   ""
  5043.   "@
  5044.    {stux|stwux} %3,%0,%2
  5045.    {stu|stwu} %3,%2(%0)")
  5046.  
  5047. (define_insn ""
  5048.   [(set (match_operand:HI 3 "gpc_reg_operand" "=r,r")
  5049.     (mem:HI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
  5050.              (match_operand:SI 2 "reg_or_short_operand" "r,I"))))
  5051.    (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
  5052.     (plus:SI (match_dup 1) (match_dup 2)))]
  5053.   ""
  5054.   "@
  5055.    lhzux %3,%0,%2
  5056.    lhzu %3,%2(%0)"
  5057.   [(set_attr "type" "load")])
  5058.  
  5059. (define_insn ""
  5060.   [(set (match_operand:SI 3 "gpc_reg_operand" "=r,r")
  5061.     (zero_extend:SI
  5062.      (mem:HI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
  5063.               (match_operand:SI 2 "reg_or_short_operand" "r,I")))))
  5064.    (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
  5065.     (plus:SI (match_dup 1) (match_dup 2)))]
  5066.   ""
  5067.   "@
  5068.    lhzux %3,%0,%2
  5069.    lhzu %3,%2(%0)"
  5070.   [(set_attr "type" "load")])
  5071.  
  5072. (define_insn ""
  5073.   [(set (match_operand:SI 3 "gpc_reg_operand" "=r,r")
  5074.     (sign_extend:SI
  5075.      (mem:HI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
  5076.               (match_operand:SI 2 "reg_or_short_operand" "r,I")))))
  5077.    (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
  5078.     (plus:SI (match_dup 1) (match_dup 2)))]
  5079.   ""
  5080.   "@
  5081.    lhaux %3,%0,%2
  5082.    lhau %3,%2(%0)"
  5083.   [(set_attr "type" "load")])
  5084.  
  5085. (define_insn ""
  5086.   [(set (mem:HI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
  5087.              (match_operand:SI 2 "reg_or_short_operand" "r,I")))
  5088.     (match_operand:HI 3 "gpc_reg_operand" "r,r"))
  5089.    (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
  5090.     (plus:SI (match_dup 1) (match_dup 2)))]
  5091.   ""
  5092.   "@
  5093.    sthux %3,%0,%2
  5094.    sthu %3,%2(%0)")
  5095.  
  5096. (define_insn ""
  5097.   [(set (match_operand:QI 3 "gpc_reg_operand" "=r,r")
  5098.     (mem:QI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
  5099.              (match_operand:SI 2 "reg_or_short_operand" "r,I"))))
  5100.    (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
  5101.     (plus:SI (match_dup 1) (match_dup 2)))]
  5102.   ""
  5103.   "@
  5104.    lbzux %3,%0,%2
  5105.    lbzu %3,%2(%0)"
  5106.   [(set_attr "type" "load")])
  5107.  
  5108. (define_insn ""
  5109.   [(set (match_operand:SI 3 "gpc_reg_operand" "=r,r")
  5110.     (zero_extend:SI
  5111.      (mem:QI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
  5112.               (match_operand:SI 2 "reg_or_short_operand" "r,I")))))
  5113.    (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
  5114.     (plus:SI (match_dup 1) (match_dup 2)))]
  5115.   ""
  5116.   "@
  5117.    lbzux %3,%0,%2
  5118.    lbzu %3,%2(%0)"
  5119.   [(set_attr "type" "load")])
  5120.  
  5121. (define_insn ""
  5122.   [(set (mem:QI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
  5123.              (match_operand:SI 2 "reg_or_short_operand" "r,I")))
  5124.     (match_operand:QI 3 "gpc_reg_operand" "r,r"))
  5125.    (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
  5126.     (plus:SI (match_dup 1) (match_dup 2)))]
  5127.   ""
  5128.   "@
  5129.    stbux %3,%0,%2
  5130.    stbu %3,%2(%0)")
  5131.  
  5132. (define_insn ""
  5133.   [(set (match_operand:SF 3 "gpc_reg_operand" "=f,f")
  5134.     (mem:SF (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
  5135.              (match_operand:SI 2 "reg_or_short_operand" "r,I"))))
  5136.    (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
  5137.     (plus:SI (match_dup 1) (match_dup 2)))]
  5138.   "TARGET_HARD_FLOAT"
  5139.   "@
  5140.    lfsux %3,%0,%2
  5141.    lfsu %3,%2(%0)"
  5142.   [(set_attr "type" "fpload")])
  5143.  
  5144. (define_insn ""
  5145.   [(set (mem:SF (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
  5146.              (match_operand:SI 2 "reg_or_short_operand" "r,I")))
  5147.     (match_operand:SF 3 "gpc_reg_operand" "f,f"))
  5148.    (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
  5149.     (plus:SI (match_dup 1) (match_dup 2)))]
  5150.   "TARGET_HARD_FLOAT"
  5151.   "@
  5152.    stfsux %3,%0,%2
  5153.    stfsu %3,%2(%0)")
  5154.  
  5155. (define_insn ""
  5156.   [(set (match_operand:DF 3 "gpc_reg_operand" "=f,f")
  5157.     (mem:DF (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
  5158.              (match_operand:SI 2 "reg_or_short_operand" "r,I"))))
  5159.    (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
  5160.     (plus:SI (match_dup 1) (match_dup 2)))]
  5161.   "TARGET_HARD_FLOAT"
  5162.   "@
  5163.    lfdux %3,%0,%2
  5164.    lfdu %3,%2(%0)"
  5165.   [(set_attr "type" "fpload")])
  5166.  
  5167. (define_insn ""
  5168.   [(set (mem:DF (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
  5169.              (match_operand:SI 2 "reg_or_short_operand" "r,I")))
  5170.     (match_operand:DF 3 "gpc_reg_operand" "f,f"))
  5171.    (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
  5172.     (plus:SI (match_dup 1) (match_dup 2)))]
  5173.   "TARGET_HARD_FLOAT"
  5174.   "@
  5175.    stfdux %3,%0,%2
  5176.    stfdu %3,%2(%0)")
  5177.  
  5178. ;; Peephole to convert two consecutive FP loads or stores into lfq/stfq.
  5179.  
  5180. (define_peephole
  5181.   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
  5182.     (match_operand:DF 1 "memory_operand" ""))
  5183.    (set (match_operand:DF 2 "gpc_reg_operand" "=f")
  5184.     (match_operand:DF 3 "memory_operand" ""))]
  5185.   "TARGET_POWER2
  5186.    && TARGET_HARD_FLOAT
  5187.    && registers_ok_for_quad_peep (operands[0], operands[2])
  5188.    && ! MEM_VOLATILE_P (operands[1]) && ! MEM_VOLATILE_P (operands[3])
  5189.    && addrs_ok_for_quad_peep (XEXP (operands[1], 0), XEXP (operands[3], 0))"
  5190.   "lfq%U1%X1 %0,%1")
  5191.  
  5192. (define_peephole
  5193.   [(set (match_operand:DF 0 "memory_operand" "")
  5194.     (match_operand:DF 1 "gpc_reg_operand" "f"))
  5195.    (set (match_operand:DF 2 "memory_operand" "")
  5196.     (match_operand:DF 3 "gpc_reg_operand" "f"))]
  5197.   "TARGET_POWER2
  5198.    && TARGET_HARD_FLOAT
  5199.    && registers_ok_for_quad_peep (operands[1], operands[3])
  5200.    && ! MEM_VOLATILE_P (operands[0]) && ! MEM_VOLATILE_P (operands[2])
  5201.    && addrs_ok_for_quad_peep (XEXP (operands[0], 0), XEXP (operands[2], 0))"
  5202.   "stfq%U0%X0 %1,%0")
  5203.  
  5204. ;; Next come insns related to the calling sequence.
  5205. ;;
  5206. ;; First, an insn to allocate new stack space for dynamic use (e.g., alloca).
  5207. ;; We move the back-chain and decrement the stack pointer.
  5208.  
  5209. (define_expand "allocate_stack"
  5210.   [(set (reg:SI 1)
  5211.     (minus:SI (reg:SI 1) (match_operand:SI 0 "reg_or_short_operand" "")))]
  5212.   ""
  5213.   "
  5214. { rtx chain = gen_reg_rtx (SImode);
  5215.   rtx stack_bot = gen_rtx (MEM, Pmode, stack_pointer_rtx);
  5216.  
  5217.   emit_move_insn (chain, stack_bot);
  5218.   emit_insn (gen_subsi3 (stack_pointer_rtx, stack_pointer_rtx, operands[0]));
  5219.   emit_move_insn (stack_bot, chain);
  5220.   DONE;
  5221. }")
  5222.  
  5223. ;; These patterns say how to save and restore the stack pointer.  We need not
  5224. ;; save the stack pointer at function level since we are careful to
  5225. ;; preserve the backchain.  At block level, we have to restore the backchain
  5226. ;; when we restore the stack pointer.
  5227. ;;
  5228. ;; For nonlocal gotos, we must save both the stack pointer and its
  5229. ;; backchain and restore both.  Note that in the nonlocal case, the
  5230. ;; save area is a memory location.
  5231.  
  5232. (define_expand "save_stack_function"
  5233.   [(use (const_int 0))]
  5234.   ""
  5235.   "")
  5236.  
  5237. (define_expand "restore_stack_function"
  5238.   [(use (const_int 0))]
  5239.   ""
  5240.   "")
  5241.  
  5242. (define_expand "restore_stack_block"
  5243.   [(set (match_dup 2) (mem:SI (match_operand:SI 0 "register_operand" "")))
  5244.    (set (match_dup 0) (match_operand:SI 1 "register_operand" ""))
  5245.    (set (mem:SI (match_dup 0)) (match_dup 2))]
  5246.   ""
  5247.   "
  5248. { operands[2] = gen_reg_rtx (SImode); }")
  5249.  
  5250. (define_expand "save_stack_nonlocal"
  5251.   [(match_operand:DI 0 "memory_operand" "")
  5252.    (match_operand:SI 1 "register_operand" "")]
  5253.   ""
  5254.   "
  5255. {
  5256.   rtx temp = gen_reg_rtx (SImode);
  5257.  
  5258.   /* Copy the backchain to the first word, sp to the second.  */
  5259.   emit_move_insn (temp, gen_rtx (MEM, SImode, operands[1]));
  5260.   emit_move_insn (operand_subword (operands[0], 0, 0, DImode), temp);
  5261.   emit_move_insn (operand_subword (operands[0], 1, 0, DImode), operands[1]);
  5262.   DONE;
  5263. }")
  5264.  
  5265. (define_expand "restore_stack_nonlocal"
  5266.   [(match_operand:SI 0 "register_operand" "")
  5267.    (match_operand:DI 1 "memory_operand" "")]
  5268.   ""
  5269.   "
  5270. {
  5271.   rtx temp = gen_reg_rtx (SImode);
  5272.  
  5273.   /* Restore the backchain from the first word, sp from the second.  */
  5274.   emit_move_insn (temp, operand_subword (operands[1], 0, 0, DImode));
  5275.   emit_move_insn (operands[0], operand_subword (operands[1], 1, 0, DImode));
  5276.   emit_move_insn (gen_rtx (MEM, SImode, operands[0]), temp);
  5277.   DONE;
  5278. }")
  5279.  
  5280. ;; A function pointer is a pointer to a data area whose first word contains
  5281. ;; the actual address of the function, whose second word contains a pointer
  5282. ;; to its TOC, and whose third word contains a value to place in the static
  5283. ;; chain register (r11).  Note that if we load the static chain, our
  5284. ;; "trampoline" need not have any executable code.
  5285. ;;
  5286. ;; operands[0] is an SImode pseudo in which we place the address of the
  5287. ;;            function.
  5288. ;; operands[1] is the address of data area of the function to call
  5289.  
  5290. (define_expand "call_via_ptr"
  5291.   [(set (match_operand:SI 0 "gpc_reg_operand" "")
  5292.     (mem:SI (match_operand:SI 1 "gpc_reg_operand" "")))
  5293.    (set (mem:SI (plus:SI (reg:SI 1) (const_int 20)))
  5294.     (reg:SI 2))
  5295.    (set (reg:SI 2)
  5296.     (mem:SI (plus:SI (match_dup 1)
  5297.              (const_int 4))))
  5298.    (set (reg:SI 11)
  5299.     (mem:SI (plus:SI (match_dup 1)
  5300.              (const_int 8))))
  5301.    (use (reg:SI 2))
  5302.    (use (reg:SI 11))]
  5303.   ""
  5304.   "")
  5305.  
  5306. (define_expand "call"
  5307.   [(parallel [(call (mem:SI (match_operand:SI 0 "address_operand" ""))
  5308.             (match_operand 1 "" ""))
  5309.           (clobber (scratch:SI))])]
  5310.   ""
  5311.   "
  5312. {
  5313.   if (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != CONST_INT)
  5314.     abort ();
  5315.  
  5316.   operands[0] = XEXP (operands[0], 0);
  5317.   if (GET_CODE (operands[0]) != SYMBOL_REF)
  5318.     {
  5319. #ifndef USING_SVR4_H
  5320.       /* AIX function pointers are really pointers to a three word area */
  5321.       rtx temp = gen_reg_rtx (SImode);
  5322.  
  5323.       emit_insn (gen_call_via_ptr (temp, force_reg (SImode, operands[0])));
  5324.       operands[0] = temp;
  5325. #endif    /* !USING_SVR4_H */
  5326.     }
  5327. }")
  5328.  
  5329. (define_expand "call_value"
  5330.   [(parallel [(set (match_operand 0 "" "")
  5331.            (call (mem:SI (match_operand:SI 1 "address_operand" ""))
  5332.              (match_operand 2 "" "")))
  5333.           (clobber (scratch:SI))])]
  5334.   ""
  5335.   "
  5336. {
  5337.   if (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != CONST_INT)
  5338.     abort ();
  5339.  
  5340.   operands[1] = XEXP (operands[1], 0);
  5341.   if (GET_CODE (operands[1]) != SYMBOL_REF)
  5342.     {
  5343. #ifndef USING_SVR4_H
  5344.       /* AIX function pointers are really pointers to a three word area */
  5345.       rtx temp = gen_reg_rtx (SImode);
  5346.  
  5347.       emit_insn (gen_call_via_ptr (temp, force_reg (SImode, operands[1])));
  5348.       operands[1] = temp;
  5349. #endif    /* !USING_SVR4_H */
  5350.     }
  5351. }")
  5352.  
  5353. ;; Call to function in current module.  No TOC pointer reload needed.
  5354.  
  5355. (define_insn ""
  5356.   [(call (mem:SI (match_operand:SI 0 "current_file_function_operand" "s"))
  5357.      (match_operand 1 "" "g"))
  5358.    (clobber (match_scratch:SI 2 "=l"))]
  5359.   ""
  5360.   "bl %z0")
  5361.  
  5362. ;; Call to function which may be in another module.  Restore the TOC
  5363. ;; pointer (r2) after the call unless this is System V.
  5364.  
  5365. (define_insn ""
  5366.   [(call (mem:SI (match_operand:SI 0 "call_operand" "l,s"))
  5367.      (match_operand 1 "" "fg,fg"))
  5368.    (clobber (match_scratch:SI 2 "=l,l"))]
  5369.   ""
  5370.   "*
  5371. {
  5372. #ifndef USING_SVR4_H
  5373.   if (GET_CODE (operands[0]) == REG)
  5374.     return \"{brl|blrl}\;{l|lwz} 2,20(1)\";
  5375.  
  5376.   return \"bl %z0\;%.\";
  5377.  
  5378. #else
  5379.   if (GET_CODE (operands[0]) == REG)
  5380.     return \"{brl|blrl}\";
  5381.  
  5382.   return \"bl %z0\";
  5383. #endif
  5384. }"
  5385.   [(set_attr "length" "8")])
  5386.  
  5387. (define_insn ""
  5388.   [(set (match_operand 0 "" "=fg")
  5389.     (call (mem:SI (match_operand:SI 1 "current_file_function_operand" "s"))
  5390.           (match_operand 2 "" "g")))
  5391.    (clobber (match_scratch:SI 3 "=l"))]
  5392.   ""
  5393.   "bl %z1")
  5394.  
  5395. (define_insn ""
  5396.   [(set (match_operand 0 "" "=fg,fg")
  5397.     (call (mem:SI (match_operand:SI 1 "call_operand" "l,s"))
  5398.           (match_operand 2 "" "fg,fg")))
  5399.    (clobber (match_scratch:SI 3 "=l,l"))]
  5400.   ""
  5401.   "*
  5402. {
  5403. #ifndef USING_SVR4_H
  5404.   if (GET_CODE (operands[1]) == REG)
  5405.     return \"{brl|blrl}\;{l|lwz} 2,20(1)\";
  5406.  
  5407.   return \"bl %z1\;%.\";
  5408.  
  5409. #else
  5410.   if (GET_CODE (operands[1]) == REG)
  5411.     return \"{brl|blrl}\";
  5412.  
  5413.   return \"bl %z1\";
  5414. #endif
  5415. }"
  5416.   [(set_attr "length" "8")])
  5417.  
  5418. ;; Call subroutine returning any type.
  5419.  
  5420. (define_expand "untyped_call"
  5421.   [(parallel [(call (match_operand 0 "" "")
  5422.             (const_int 0))
  5423.           (match_operand 1 "" "")
  5424.           (match_operand 2 "" "")])]
  5425.   ""
  5426.   "
  5427. {
  5428.   int i;
  5429.  
  5430.   emit_call_insn (gen_call (operands[0], const0_rtx, NULL, const0_rtx));
  5431.  
  5432.   for (i = 0; i < XVECLEN (operands[2], 0); i++)
  5433.     {
  5434.       rtx set = XVECEXP (operands[2], 0, i);
  5435.       emit_move_insn (SET_DEST (set), SET_SRC (set));
  5436.     }
  5437.  
  5438.   /* The optimizer does not know that the call sets the function value
  5439.      registers we stored in the result block.  We avoid problems by
  5440.      claiming that all hard registers are used and clobbered at this
  5441.      point.  */
  5442.   emit_insn (gen_blockage ());
  5443.  
  5444.   DONE;
  5445. }")
  5446.  
  5447. ;; UNSPEC_VOLATILE is considered to use and clobber all hard registers and
  5448. ;; all of memory.  This blocks insns from being moved across this point.
  5449.  
  5450. (define_insn "blockage"
  5451.   [(unspec_volatile [(const_int 0)] 0)]
  5452.   ""
  5453.   "")
  5454.  
  5455. ;; Compare insns are next.  Note that the RS/6000 has two types of compares,
  5456. ;; signed & unsigned, and one type of branch.
  5457. ;;
  5458. ;; Start with the DEFINE_EXPANDs to generate the rtl for compares, scc
  5459. ;; insns, and branches.  We store the operands of compares until we see
  5460. ;; how it is used.
  5461. (define_expand "cmpsi"
  5462.   [(set (cc0)
  5463.         (compare (match_operand:SI 0 "gpc_reg_operand" "")
  5464.            (match_operand:SI 1 "reg_or_short_operand" "")))]
  5465.   ""
  5466.   "
  5467. {
  5468.   /* Take care of the possibility that operands[1] might be negative but
  5469.      this might be a logical operation.  That insn doesn't exist.  */
  5470.   if (GET_CODE (operands[1]) == CONST_INT
  5471.       && INTVAL (operands[1]) < 0)
  5472.     operands[1] = force_reg (SImode, operands[1]);
  5473.  
  5474.   rs6000_compare_op0 = operands[0];
  5475.   rs6000_compare_op1 = operands[1];
  5476.   rs6000_compare_fp_p = 0;
  5477.   DONE;
  5478. }")
  5479.  
  5480. (define_expand "cmpsf"
  5481.   [(set (cc0) (compare (match_operand:SF 0 "gpc_reg_operand" "")
  5482.                (match_operand:SF 1 "gpc_reg_operand" "")))]
  5483.   "TARGET_HARD_FLOAT"
  5484.   "
  5485. {
  5486.   rs6000_compare_op0 = operands[0];
  5487.   rs6000_compare_op1 = operands[1];
  5488.   rs6000_compare_fp_p = 1;
  5489.   DONE;
  5490. }")
  5491.  
  5492. (define_expand "cmpdf"
  5493.   [(set (cc0) (compare (match_operand:DF 0 "gpc_reg_operand" "")
  5494.                (match_operand:DF 1 "gpc_reg_operand" "")))]
  5495.   "TARGET_HARD_FLOAT"
  5496.   "
  5497. {
  5498.   rs6000_compare_op0 = operands[0];
  5499.   rs6000_compare_op1 = operands[1];
  5500.   rs6000_compare_fp_p = 1;
  5501.   DONE;
  5502. }")
  5503.  
  5504. (define_expand "beq"
  5505.   [(set (match_dup 2) (match_dup 1))
  5506.    (set (pc)
  5507.     (if_then_else (eq (match_dup 2)
  5508.               (const_int 0))
  5509.               (label_ref (match_operand 0 "" ""))
  5510.               (pc)))]
  5511.   ""
  5512.   "
  5513. { enum machine_mode mode = rs6000_compare_fp_p ? CCFPmode : CCmode;
  5514.   operands[1] = gen_rtx (COMPARE, mode,
  5515.              rs6000_compare_op0, rs6000_compare_op1);
  5516.   operands[2] = gen_reg_rtx (mode);
  5517. }")
  5518.  
  5519. (define_expand "bne"
  5520.   [(set (match_dup 2) (match_dup 1))
  5521.    (set (pc)
  5522.     (if_then_else (ne (match_dup 2)
  5523.               (const_int 0))
  5524.               (label_ref (match_operand 0 "" ""))
  5525.               (pc)))]
  5526.   ""
  5527.   "
  5528. { enum machine_mode mode = rs6000_compare_fp_p ? CCFPmode : CCmode;
  5529.   operands[1] = gen_rtx (COMPARE, mode,
  5530.              rs6000_compare_op0, rs6000_compare_op1);
  5531.   operands[2] = gen_reg_rtx (mode);
  5532. }")
  5533.  
  5534. (define_expand "blt"
  5535.   [(set (match_dup 2) (match_dup 1))
  5536.    (set (pc)
  5537.     (if_then_else (lt (match_dup 2)
  5538.               (const_int 0))
  5539.               (label_ref (match_operand 0 "" ""))
  5540.               (pc)))]
  5541.   ""
  5542.   "
  5543. { enum machine_mode mode = rs6000_compare_fp_p ? CCFPmode : CCmode;
  5544.   operands[1] = gen_rtx (COMPARE, mode,
  5545.              rs6000_compare_op0, rs6000_compare_op1);
  5546.   operands[2] = gen_reg_rtx (mode);
  5547. }")
  5548.  
  5549. (define_expand "bgt"
  5550.   [(set (match_dup 2) (match_dup 1))
  5551.    (set (pc)
  5552.     (if_then_else (gt (match_dup 2)
  5553.               (const_int 0))
  5554.               (label_ref (match_operand 0 "" ""))
  5555.               (pc)))]
  5556.   ""
  5557.   "
  5558. { enum machine_mode mode = rs6000_compare_fp_p ? CCFPmode : CCmode;
  5559.   operands[1] = gen_rtx (COMPARE, mode,
  5560.              rs6000_compare_op0, rs6000_compare_op1);
  5561.   operands[2] = gen_reg_rtx (mode);
  5562. }")
  5563.  
  5564. (define_expand "ble"
  5565.   [(set (match_dup 2) (match_dup 1))
  5566.    (set (pc)
  5567.     (if_then_else (le (match_dup 2)
  5568.               (const_int 0))
  5569.               (label_ref (match_operand 0 "" ""))
  5570.               (pc)))]
  5571.   ""
  5572.   "
  5573. { enum machine_mode mode = rs6000_compare_fp_p ? CCFPmode : CCmode;
  5574.   operands[1] = gen_rtx (COMPARE, mode,
  5575.              rs6000_compare_op0, rs6000_compare_op1);
  5576.   operands[2] = gen_reg_rtx (mode);
  5577. }")
  5578.  
  5579. (define_expand "bge"
  5580.   [(set (match_dup 2) (match_dup 1))
  5581.    (set (pc)
  5582.     (if_then_else (ge (match_dup 2)
  5583.               (const_int 0))
  5584.               (label_ref (match_operand 0 "" ""))
  5585.               (pc)))]
  5586.   ""
  5587.   "
  5588. { enum machine_mode mode = rs6000_compare_fp_p ? CCFPmode : CCmode;
  5589.   operands[1] = gen_rtx (COMPARE, mode,
  5590.              rs6000_compare_op0, rs6000_compare_op1);
  5591.   operands[2] = gen_reg_rtx (mode);
  5592. }")
  5593.  
  5594. (define_expand "bgtu"
  5595.   [(set (match_dup 2) (match_dup 1))
  5596.    (set (pc)
  5597.     (if_then_else (gtu (match_dup 2)
  5598.                (const_int 0))
  5599.               (label_ref (match_operand 0 "" ""))
  5600.               (pc)))]
  5601.   ""
  5602.   "
  5603. { operands[1] = gen_rtx (COMPARE, CCUNSmode,
  5604.              rs6000_compare_op0, rs6000_compare_op1);
  5605.   operands[2] = gen_reg_rtx (CCUNSmode);
  5606. }")
  5607.  
  5608. (define_expand "bltu"
  5609.   [(set (match_dup 2) (match_dup 1))
  5610.    (set (pc)
  5611.     (if_then_else (ltu (match_dup 2)
  5612.                (const_int 0))
  5613.               (label_ref (match_operand 0 "" ""))
  5614.               (pc)))]
  5615.   ""
  5616.   "
  5617. { operands[1] = gen_rtx (COMPARE, CCUNSmode,
  5618.              rs6000_compare_op0, rs6000_compare_op1);
  5619.   operands[2] = gen_reg_rtx (CCUNSmode);
  5620. }")
  5621.  
  5622. (define_expand "bgeu"
  5623.   [(set (match_dup 2) (match_dup 1))
  5624.    (set (pc)
  5625.     (if_then_else (geu (match_dup 2)
  5626.                (const_int 0))
  5627.               (label_ref (match_operand 0 "" ""))
  5628.               (pc)))]
  5629.   ""
  5630.   "
  5631. { operands[1] = gen_rtx (COMPARE, CCUNSmode,
  5632.              rs6000_compare_op0, rs6000_compare_op1);
  5633.   operands[2] = gen_reg_rtx (CCUNSmode);
  5634. }")
  5635.  
  5636. (define_expand "bleu"
  5637.   [(set (match_dup 2) (match_dup 1))
  5638.    (set (pc)
  5639.     (if_then_else (leu (match_dup 2)
  5640.                (const_int 0))
  5641.               (label_ref (match_operand 0 "" ""))
  5642.               (pc)))]
  5643.   ""
  5644.   "
  5645. { operands[1] = gen_rtx (COMPARE, CCUNSmode,
  5646.              rs6000_compare_op0, rs6000_compare_op1);
  5647.   operands[2] = gen_reg_rtx (CCUNSmode);
  5648. }")
  5649.  
  5650. ;; For SNE, we would prefer that the xor/abs sequence be used for integers.
  5651. ;; For SEQ, likewise, except that comparisons with zero should be done
  5652. ;; with an scc insns.  However, due to the order that combine see the
  5653. ;; resulting insns, we must, in fact, allow SEQ for integers.  Fail in
  5654. ;; the cases we don't want to handle.
  5655. (define_expand "seq"
  5656.   [(set (match_dup 2) (match_dup 1))
  5657.    (set (match_operand:SI 0 "gpc_reg_operand" "")
  5658.     (eq:SI (match_dup 2) (const_int 0)))]
  5659.   ""
  5660.   "
  5661. { enum machine_mode mode = rs6000_compare_fp_p ? CCFPmode : CCmode;
  5662.   operands[1] = gen_rtx (COMPARE, mode,
  5663.              rs6000_compare_op0, rs6000_compare_op1);
  5664.   operands[2] = gen_reg_rtx (mode);
  5665. }")
  5666.  
  5667. (define_expand "sne"
  5668.   [(set (match_dup 2) (match_dup 1))
  5669.    (set (match_operand:SI 0 "gpc_reg_operand" "")
  5670.     (ne:SI (match_dup 2) (const_int 0)))]
  5671.   ""
  5672.   "
  5673. { if (! rs6000_compare_fp_p)
  5674.     FAIL;
  5675.  
  5676.   operands[1] = gen_rtx (COMPARE, CCFPmode,
  5677.              rs6000_compare_op0, rs6000_compare_op1);
  5678.   operands[2] = gen_reg_rtx (CCFPmode);
  5679. }")
  5680.  
  5681. ;; A > 0 is best done using the portable sequence, so fail in that case.
  5682. (define_expand "sgt"
  5683.   [(set (match_dup 2) (match_dup 1))
  5684.    (set (match_operand:SI 0 "gpc_reg_operand" "")
  5685.     (gt:SI (match_dup 2) (const_int 0)))]
  5686.   ""
  5687.   "
  5688. { enum machine_mode mode = rs6000_compare_fp_p ? CCFPmode : CCmode;
  5689.  
  5690.   if (! rs6000_compare_fp_p && rs6000_compare_op1 == const0_rtx)
  5691.     FAIL;
  5692.  
  5693.   operands[1] = gen_rtx (COMPARE, mode,
  5694.              rs6000_compare_op0, rs6000_compare_op1);
  5695.   operands[2] = gen_reg_rtx (mode);
  5696. }")
  5697.  
  5698. ;; A < 0 is best done in the portable way for A an integer.
  5699. (define_expand "slt"
  5700.   [(set (match_dup 2) (match_dup 1))
  5701.    (set (match_operand:SI 0 "gpc_reg_operand" "")
  5702.     (lt:SI (match_dup 2) (const_int 0)))]
  5703.   ""
  5704.   "
  5705. { enum machine_mode mode = rs6000_compare_fp_p ? CCFPmode : CCmode;
  5706.  
  5707.   if (! rs6000_compare_fp_p && rs6000_compare_op1 == const0_rtx)
  5708.     FAIL;
  5709.  
  5710.   operands[1] = gen_rtx (COMPARE, mode,
  5711.              rs6000_compare_op0, rs6000_compare_op1);
  5712.   operands[2] = gen_reg_rtx (mode);
  5713. }")
  5714.  
  5715. (define_expand "sge"
  5716.   [(set (match_dup 2) (match_dup 1))
  5717.    (set (match_operand:SI 0 "gpc_reg_operand" "")
  5718.     (ge:SI (match_dup 2) (const_int 0)))]
  5719.   ""
  5720.   "
  5721. { enum machine_mode mode = rs6000_compare_fp_p ? CCFPmode : CCmode;
  5722.   operands[1] = gen_rtx (COMPARE, mode,
  5723.              rs6000_compare_op0, rs6000_compare_op1);
  5724.   operands[2] = gen_reg_rtx (mode);
  5725. }")
  5726.  
  5727. ;; A <= 0 is best done the portable way for A an integer.
  5728. (define_expand "sle"
  5729.   [(set (match_dup 2) (match_dup 1))
  5730.    (set (match_operand:SI 0 "gpc_reg_operand" "")
  5731.     (le:SI (match_dup 2) (const_int 0)))]
  5732.   ""
  5733.   "
  5734. { enum machine_mode mode = rs6000_compare_fp_p ? CCFPmode : CCmode;
  5735.  
  5736.   if (! rs6000_compare_fp_p && rs6000_compare_op1 == const0_rtx)
  5737.     FAIL;
  5738.  
  5739.   operands[1] = gen_rtx (COMPARE, mode,
  5740.              rs6000_compare_op0, rs6000_compare_op1);
  5741.   operands[2] = gen_reg_rtx (mode);
  5742. }")
  5743.  
  5744. (define_expand "sgtu"
  5745.   [(set (match_dup 2) (match_dup 1))
  5746.    (set (match_operand:SI 0 "gpc_reg_operand" "")
  5747.     (gtu:SI (match_dup 2) (const_int 0)))]
  5748.   ""
  5749.   "
  5750. { operands[1] = gen_rtx (COMPARE, CCUNSmode,
  5751.              rs6000_compare_op0, rs6000_compare_op1);
  5752.   operands[2] = gen_reg_rtx (CCUNSmode);
  5753. }")
  5754.  
  5755. (define_expand "sltu"
  5756.   [(set (match_dup 2) (match_dup 1))
  5757.    (set (match_operand:SI 0 "gpc_reg_operand" "")
  5758.     (ltu:SI (match_dup 2) (const_int 0)))]
  5759.   ""
  5760.   "
  5761. { operands[1] = gen_rtx (COMPARE, CCUNSmode,
  5762.              rs6000_compare_op0, rs6000_compare_op1);
  5763.   operands[2] = gen_reg_rtx (CCUNSmode);
  5764. }")
  5765.  
  5766. (define_expand "sgeu"
  5767.   [(set (match_dup 2) (match_dup 1))
  5768.    (set (match_operand:SI 0 "gpc_reg_operand" "")
  5769.     (geu:SI (match_dup 2) (const_int 0)))]
  5770.   ""
  5771.   "
  5772. { operands[1] = gen_rtx (COMPARE, CCUNSmode,
  5773.              rs6000_compare_op0, rs6000_compare_op1);
  5774.   operands[2] = gen_reg_rtx (CCUNSmode);
  5775. }")
  5776.  
  5777. (define_expand "sleu"
  5778.   [(set (match_dup 2) (match_dup 1))
  5779.    (set (match_operand:SI 0 "gpc_reg_operand" "")
  5780.     (leu:SI (match_dup 2) (const_int 0)))]
  5781.   ""
  5782.   "
  5783. { operands[1] = gen_rtx (COMPARE, CCUNSmode,
  5784.              rs6000_compare_op0, rs6000_compare_op1);
  5785.   operands[2] = gen_reg_rtx (CCUNSmode);
  5786. }")
  5787.  
  5788. ;; Here are the actual compare insns.
  5789. (define_insn ""
  5790.   [(set (match_operand:CC 0 "cc_reg_operand" "=y")
  5791.     (compare:CC (match_operand:SI 1 "gpc_reg_operand" "r")
  5792.             (match_operand:SI 2 "reg_or_short_operand" "rI")))]
  5793.   ""
  5794.   "{cmp%I2|cmpw%I2} %0,%1,%2"
  5795.   [(set_attr "type" "compare")])
  5796.  
  5797. ;; If we are comparing a register for equality with a large constant,
  5798. ;; we can do this with an XOR followed by a compare.  But we need a scratch
  5799. ;; register for the result of the XOR.
  5800.  
  5801. (define_split
  5802.   [(set (match_operand:CC 0 "cc_reg_operand" "")
  5803.     (compare:CC (match_operand:SI 1 "gpc_reg_operand" "")
  5804.             (match_operand:SI 2 "non_short_cint_operand" "")))
  5805.    (clobber (match_operand:SI 3 "gpc_reg_operand" ""))]
  5806.   "find_single_use (operands[0], insn, 0)
  5807.    && (GET_CODE (*find_single_use (operands[0], insn, 0)) == EQ
  5808.        || GET_CODE (*find_single_use (operands[0], insn, 0)) == NE)"
  5809.   [(set (match_dup 3) (xor:SI (match_dup 1) (match_dup 4)))
  5810.    (set (match_dup 0) (compare:CC (match_dup 3) (match_dup 5)))]
  5811.   "
  5812. {
  5813.   /* Get the constant we are comparing against, C,  and see what it looks like
  5814.      sign-extended to 16 bits.  Then see what constant could be XOR'ed
  5815.      with C to get the sign-extended value.  */
  5816.  
  5817.   int c = INTVAL (operands[2]);
  5818.   int sextc = (c << 16) >> 16;
  5819.   int xorv = c ^ sextc;
  5820.  
  5821.   operands[4] = gen_rtx (CONST_INT, VOIDmode, xorv);
  5822.   operands[5] = gen_rtx (CONST_INT, VOIDmode, sextc);
  5823. }")
  5824.  
  5825. (define_insn ""
  5826.   [(set (match_operand:CCUNS 0 "cc_reg_operand" "=y")
  5827.     (compare:CCUNS (match_operand:SI 1 "gpc_reg_operand" "r")
  5828.                (match_operand:SI 2 "reg_or_u_short_operand" "rI")))]
  5829.   ""
  5830.   "{cmpl%I2|cmplw%I2} %0,%1,%W2"
  5831.   [(set_attr "type" "compare")])
  5832.  
  5833. ;; The following two insns don't exist as single insns, but if we provide
  5834. ;; them, we can swap an add and compare, which will enable us to overlap more
  5835. ;; of the required delay between a compare and branch.  We generate code for
  5836. ;; them by splitting.
  5837.  
  5838. (define_insn ""
  5839.   [(set (match_operand:CC 3 "cc_reg_operand" "=y")
  5840.     (compare:CC (match_operand:SI 1 "gpc_reg_operand" "r")
  5841.             (match_operand:SI 2 "short_cint_operand" "i")))
  5842.    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
  5843.     (plus:SI (match_dup 1) (match_operand:SI 4 "short_cint_operand" "i")))]
  5844.   ""
  5845.   "#"
  5846.   [(set_attr "length" "8")])
  5847.  
  5848. (define_insn ""
  5849.   [(set (match_operand:CCUNS 3 "cc_reg_operand" "=y")
  5850.     (compare:CCUNS (match_operand:SI 1 "gpc_reg_operand" "r")
  5851.                (match_operand:SI 2 "u_short_cint_operand" "i")))
  5852.    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
  5853.     (plus:SI (match_dup 1) (match_operand:SI 4 "short_cint_operand" "i")))]
  5854.   ""
  5855.   "#"
  5856.   [(set_attr "length" "8")])
  5857.  
  5858. (define_split
  5859.   [(set (match_operand:CC 3 "cc_reg_operand" "")
  5860.     (compare:CC (match_operand:SI 1 "gpc_reg_operand" "")
  5861.             (match_operand:SI 2 "short_cint_operand" "")))
  5862.    (set (match_operand:SI 0 "gpc_reg_operand" "")
  5863.     (plus:SI (match_dup 1) (match_operand:SI 4 "short_cint_operand" "")))]
  5864.   ""
  5865.   [(set (match_dup 3) (compare:CC (match_dup 1) (match_dup 2)))
  5866.    (set (match_dup 0) (plus:SI (match_dup 1) (match_dup 4)))])
  5867.  
  5868. (define_split
  5869.   [(set (match_operand:CCUNS 3 "cc_reg_operand" "")
  5870.     (compare:CCUNS (match_operand:SI 1 "gpc_reg_operand" "")
  5871.                (match_operand:SI 2 "u_short_cint_operand" "")))
  5872.    (set (match_operand:SI 0 "gpc_reg_operand" "")
  5873.     (plus:SI (match_dup 1) (match_operand:SI 4 "short_cint_operand" "")))]
  5874.   ""
  5875.   [(set (match_dup 3) (compare:CCUNS (match_dup 1) (match_dup 2)))
  5876.    (set (match_dup 0) (plus:SI (match_dup 1) (match_dup 4)))])
  5877.  
  5878. (define_insn ""
  5879.   [(set (match_operand:CCFP 0 "cc_reg_operand" "=y")
  5880.     (compare:CCFP (match_operand:SF 1 "gpc_reg_operand" "f")
  5881.               (match_operand:SF 2 "gpc_reg_operand" "f")))]
  5882.   "TARGET_HARD_FLOAT"
  5883.   "fcmpu %0,%1,%2"
  5884.   [(set_attr "type" "fpcompare")])
  5885.  
  5886. (define_insn ""
  5887.   [(set (match_operand:CCFP 0 "cc_reg_operand" "=y")
  5888.     (compare:CCFP (match_operand:DF 1 "gpc_reg_operand" "f")
  5889.               (match_operand:DF 2 "gpc_reg_operand" "f")))]
  5890.   "TARGET_HARD_FLOAT"
  5891.   "fcmpu %0,%1,%2"
  5892.   [(set_attr "type" "fpcompare")])
  5893.  
  5894. ;; Now we have the scc insns.  We can do some combinations because of the
  5895. ;; way the machine works.
  5896. ;;
  5897. ;; Note that this is probably faster if we can put an insn between the
  5898. ;; mfcr and rlinm, but this is tricky.  Let's leave it for now.  In most
  5899. ;; cases the insns below which don't use an intermediate CR field will
  5900. ;; be used instead.
  5901. (define_insn ""
  5902.   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
  5903.     (match_operator:SI 1 "scc_comparison_operator"
  5904.                [(match_operand 2 "cc_reg_operand" "y")
  5905.                 (const_int 0)]))]
  5906.   ""
  5907.   "%D1mfcr %0\;{rlinm|rlwinm} %0,%0,%J1,1"
  5908.   [(set_attr "length" "12")])
  5909.  
  5910. (define_insn ""
  5911.   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
  5912.     (compare:CC (match_operator:SI 1 "scc_comparison_operator"
  5913.                        [(match_operand 2 "cc_reg_operand" "y")
  5914.                     (const_int 0)])
  5915.             (const_int 0)))
  5916.    (set (match_operand:SI 3 "gpc_reg_operand" "=r")
  5917.     (match_op_dup 1 [(match_dup 2) (const_int 0)]))]
  5918.   ""
  5919.   "%D1mfcr %3\;{rlinm.|rlwinm.} %3,%3,%J1,1"
  5920.   [(set_attr "type" "delayed_compare")
  5921.    (set_attr "length" "12")])
  5922.  
  5923. (define_insn ""
  5924.   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
  5925.     (ashift:SI (match_operator:SI 1 "scc_comparison_operator"
  5926.                       [(match_operand 2 "cc_reg_operand" "y")
  5927.                        (const_int 0)])
  5928.            (match_operand:SI 3 "const_int_operand" "n")))]
  5929.   ""
  5930.   "*
  5931. {
  5932.   int is_bit = ccr_bit (operands[1], 1);
  5933.   int put_bit = 31 - (INTVAL (operands[3]) & 31);
  5934.   int count;
  5935.  
  5936.   if (is_bit >= put_bit)
  5937.     count = is_bit - put_bit;
  5938.   else
  5939.     count = 32 - (put_bit - is_bit);
  5940.  
  5941.   operands[4] = gen_rtx (CONST_INT, VOIDmode, count);
  5942.   operands[5] = gen_rtx (CONST_INT, VOIDmode, put_bit);
  5943.  
  5944.   return \"%D1mfcr %0\;{rlinm|rlwinm} %0,%0,%4,%5,%5\";
  5945. }"
  5946.  [(set_attr "length" "12")])
  5947.  
  5948. (define_insn ""
  5949.   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
  5950.     (compare:CC
  5951.      (ashift:SI (match_operator:SI 1 "scc_comparison_operator"
  5952.                        [(match_operand 2 "cc_reg_operand" "y")
  5953.                     (const_int 0)])
  5954.             (match_operand:SI 3 "const_int_operand" "n"))
  5955.      (const_int 0)))
  5956.    (set (match_operand:SI 4 "gpc_reg_operand" "=r")
  5957.     (ashift:SI (match_op_dup 1 [(match_dup 2) (const_int 0)])
  5958.            (match_dup 3)))]
  5959.   ""
  5960.   "*
  5961. {
  5962.   int is_bit = ccr_bit (operands[1], 1);
  5963.   int put_bit = 31 - (INTVAL (operands[3]) & 31);
  5964.   int count;
  5965.  
  5966.   if (is_bit >= put_bit)
  5967.     count = is_bit - put_bit;
  5968.   else
  5969.     count = 32 - (put_bit - is_bit);
  5970.  
  5971.   operands[5] = gen_rtx (CONST_INT, VOIDmode, count);
  5972.   operands[6] = gen_rtx (CONST_INT, VOIDmode, put_bit);
  5973.  
  5974.   return \"%D1mfcr %4\;{rlinm.|rlwinm.} %4,%4,%5,%6,%6\";
  5975. }"
  5976.   [(set_attr "type" "delayed_compare")
  5977.    (set_attr "length" "12")])
  5978.  
  5979. ;; If we are comparing the result of two comparisons, this can be done
  5980. ;; using creqv or crxor.
  5981.  
  5982. (define_insn ""
  5983.   [(set (match_operand:CCEQ 0 "cc_reg_operand" "=y")
  5984.     (compare:CCEQ (match_operator 1 "scc_comparison_operator"
  5985.                   [(match_operand 2 "cc_reg_operand" "y")
  5986.                    (const_int 0)])
  5987.               (match_operator 3 "scc_comparison_operator"
  5988.                   [(match_operand 4 "cc_reg_operand" "y")
  5989.                    (const_int 0)])))]
  5990.   "REGNO (operands[2]) != REGNO (operands[4])"
  5991.   "*
  5992. {
  5993.   enum rtx_code code1, code2;
  5994.  
  5995.   code1 = GET_CODE (operands[1]);
  5996.   code2 = GET_CODE (operands[3]);
  5997.  
  5998.   if ((code1 == EQ || code1 == LT || code1 == GT
  5999.        || code1 == LTU || code1 == GTU
  6000.        || (code1 != NE && GET_MODE (operands[2]) == CCFPmode))
  6001.       !=
  6002.       (code2 == EQ || code2 == LT || code2 == GT
  6003.        || code2 == LTU || code2 == GTU
  6004.        || (code2 != NE && GET_MODE (operands[4]) == CCFPmode)))
  6005.     return \"%C1%C3crxor %E0,%j1,%j3\";
  6006.   else
  6007.     return \"%C1%C3creqv %E0,%j1,%j3\";
  6008. }"
  6009.   [(set_attr "length" "12")])
  6010.  
  6011. ;; There is a 3 cycle delay between consecutive mfcr instructions
  6012. ;; so it is useful to combine 2 scc instructions to use only one mfcr.
  6013.  
  6014. (define_peephole
  6015.   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
  6016.     (match_operator:SI 1 "scc_comparison_operator"
  6017.                [(match_operand 2 "cc_reg_operand" "y")
  6018.                 (const_int 0)]))
  6019.    (set (match_operand:SI 3 "gpc_reg_operand" "=r")
  6020.     (match_operator:SI 4 "scc_comparison_operator"
  6021.                [(match_operand 5 "cc_reg_operand" "y")
  6022.                 (const_int 0)]))]
  6023.    "REGNO (operands[2]) != REGNO (operands[5])"
  6024.    "%D1%D4mfcr %3\;{rlinm|rlwinm} %0,%3,%J1,1\;{rlinm|rlwinm} %3,%3,%J4,1"
  6025.    [(set_attr "length" "20")])
  6026.  
  6027. ;; There are some scc insns that can be done directly, without a compare.
  6028. ;; These are faster because they don't involve the communications between
  6029. ;; the FXU and branch units.   In fact, we will be replacing all of the
  6030. ;; integer scc insns here or in the portable methods in emit_store_flag.
  6031. ;;
  6032. ;; Also support (neg (scc ..)) since that construct is used to replace
  6033. ;; branches, (plus (scc ..) ..) since that construct is common and
  6034. ;; takes no more insns than scc, and (and (neg (scc ..)) ..) in the
  6035. ;; cases where it is no more expensive than (neg (scc ..)).
  6036.  
  6037. ;; Have reload force a constant into a register for the simple insns that
  6038. ;; otherwise won't accept constants.  We do this because it is faster than
  6039. ;; the cmp/mfcr sequence we would otherwise generate.
  6040.  
  6041. (define_insn ""
  6042.   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r,r")
  6043.     (eq:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r")
  6044.            (match_operand:SI 2 "reg_or_cint_operand" "r,O,K,J,I")))
  6045.    (clobber (match_scratch:SI 3 "=r,&r,r,r,r"))]
  6046.   ""
  6047.   "@
  6048.    xor %0,%1,%2\;{sfi|subfic} %3,%0,0\;{ae|adde} %0,%3,%0
  6049.    {sfi|subfic} %3,%1,0\;{ae|adde} %0,%3,%1
  6050.    {xoril|xori} %0,%1,%b2\;{sfi|subfic} %3,%0,0\;{ae|adde} %0,%3,%0
  6051.    {xoriu|xoris} %0,%1,%u2\;{sfi|subfic} %3,%0,0\;{ae|adde} %0,%3,%0
  6052.    {sfi|subfic} %0,%1,%2\;{sfi|subfic} %3,%0,0\;{ae|adde} %0,%3,%0"
  6053.   [(set_attr "length" "12,8,12,12,12")])
  6054.  
  6055. (define_insn ""
  6056.   [(set (match_operand:CC 4 "cc_reg_operand" "=x,x,x,x,x")
  6057.     (compare:CC
  6058.      (eq:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r")
  6059.         (match_operand:SI 2 "reg_or_cint_operand" "r,O,K,J,I"))
  6060.      (const_int 0)))
  6061.    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r,r")
  6062.     (eq:SI (match_dup 1) (match_dup 2)))
  6063.    (clobber (match_scratch:SI 3 "=r,&r,r,r,r"))]
  6064.   ""
  6065.   "@
  6066.    xor %0,%1,%2\;{sfi|subfic} %3,%0,0\;{ae.|adde.} %0,%3,%0
  6067.    {sfi|subfic} %3,%1,0\;{ae.|adde.} %0,%3,%1
  6068.    {xoril|xori} %0,%1,%b2\;{sfi|subfic} %3,%0,0\;{ae.|adde.} %0,%3,%0
  6069.    {xoriu|xoris} %0,%1,%u2\;{sfi|subfic} %3,%0,0\;{ae.|adde.} %0,%3,%0
  6070.    {sfi|subfic} %0,%1,%2\;{sfi|subfic} %3,%0,0\;{ae.|adde.} %0,%3,%0"
  6071.   [(set_attr "type" "compare")
  6072.    (set_attr "length" "12,8,12,12,12")])
  6073.  
  6074. ;; We have insns of the form shown by the first define_insn below.  If
  6075. ;; there is something inside the comparison operation, we must split it.
  6076. (define_split
  6077.   [(set (match_operand:SI 0 "gpc_reg_operand" "")
  6078.     (plus:SI (match_operator 1 "comparison_operator"
  6079.                  [(match_operand:SI 2 "" "")
  6080.                   (match_operand:SI 3
  6081.                             "reg_or_cint_operand" "")])
  6082.          (match_operand:SI 4 "gpc_reg_operand" "")))
  6083.    (clobber (match_operand:SI 5 "register_operand" ""))]
  6084.   "! gpc_reg_operand (operands[2], SImode)"
  6085.   [(set (match_dup 5) (match_dup 2))
  6086.    (set (match_dup 2) (plus:SI (match_op_dup 1 [(match_dup 2) (match_dup 3)])
  6087.                    (match_dup 4)))])
  6088.  
  6089. (define_insn ""
  6090.   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r,r")
  6091.     (plus:SI (eq:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r")
  6092.             (match_operand:SI 2 "reg_or_cint_operand" "r,O,K,J,I"))
  6093.          (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r,r")))
  6094.    (clobber (match_scratch:SI 4 "=&r,&r,&r,&r,&r"))]
  6095.   ""
  6096.   "@
  6097.    xor %4,%1,%2\;{sfi|subfic} %4,%4,0\;{aze|addze} %0,%3
  6098.    {sfi|subfic} %4,%1,0\;{aze|addze} %0,%3
  6099.    {xoril|xori} %4,%1,%b2\;{sfi|subfic} %4,%4,0\;{aze|addze} %0,%3
  6100.    {xoriu|xoris} %4,%1,%u2\;{sfi|subfic} %4,%4,0\;{aze|addze} %0,%3
  6101.    {sfi|subfic} %4,%1,%2\;{sfi|subfic} %4,%4,0\;{aze|addze} %0,%3"
  6102.   [(set_attr "length" "12,8,12,12,12")])
  6103.  
  6104. (define_insn ""
  6105.   [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,x,x,x")
  6106.     (compare:CC
  6107.      (plus:SI
  6108.       (eq:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r")
  6109.          (match_operand:SI 2 "reg_or_cint_operand" "r,O,K,J,I"))
  6110.       (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r,r"))
  6111.      (const_int 0)))
  6112.    (clobber (match_scratch:SI 4 "=&r,&r,&r,&r,&r"))]
  6113.   ""
  6114.   "@
  6115.    xor %4,%1,%2\;{sfi|subfic} %4,%4,0\;{aze.|addze.} %4,%3
  6116.    {sfi|subfic} %4,%1,0\;{aze.|addze.} %0,%3
  6117.    {xoril|xori} %4,%1,%b2\;{sfi|subfic} %4,%4,0\;{aze.|addze.} %4,%3
  6118.    {xoriu|xoris} %4,%1,%u2\;{sfi|subfic} %4,%4,0\;{aze.|addze.} %4,%3
  6119.    {sfi|subfic} %4,%1,%2\;{sfi|subfic} %4,%4,0\;{aze.|addze.} %4,%3"
  6120.   [(set_attr "type" "compare")
  6121.    (set_attr "length" "12,8,12,12,12")])
  6122.  
  6123. (define_insn ""
  6124.   [(set (match_operand:CC 5 "cc_reg_operand" "=x,x,x,x,x")
  6125.     (compare:CC
  6126.      (plus:SI
  6127.       (eq:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r")
  6128.          (match_operand:SI 2 "reg_or_cint_operand" "r,O,K,J,I"))
  6129.       (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r,r"))
  6130.      (const_int 0)))
  6131.    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r,r")
  6132.     (plus:SI (eq:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
  6133.    (clobber (match_scratch:SI 4 "=&r,&r,&r,&r,&r"))]
  6134.   ""
  6135.   "@
  6136.    xor %4,%1,%2\;{sfi|subfic} %4,%4,0\;{aze.|addze.} %0,%3
  6137.    {sfi|subfic} %4,%1,0\;{aze.|addze.} %4,%3
  6138.    {xoril|xori} %4,%1,%b2\;{sfi|subfic} %4,%4,0\;{aze.|addze.} %0,%3
  6139.    {xoriu|xoris} %4,%1,%u2\;{sfi|subfic} %4,%4,0\;{aze.|addze.} %0,%3
  6140.    {sfi|subfic} %4,%1,%2\;{sfi|subfic} %4,%4,0\;{aze.|addze.} %0,%3"
  6141.   [(set_attr "type" "compare")
  6142.    (set_attr "length" "12,8,12,12,12")])
  6143.  
  6144. (define_insn ""
  6145.   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r,r")
  6146.     (neg:SI (eq:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r")
  6147.                (match_operand:SI 2 "reg_or_cint_operand" "r,O,K,J,I"))))]
  6148.   ""
  6149.   "@
  6150.    xor %0,%1,%2\;{ai|addic} %0,%0,-1\;{sfe|subfe} %0,%0,%0
  6151.    {ai|addic} %0,%1,-1\;{sfe|subfe} %0,%0,%0
  6152.    {xoril|xori} %0,%1,%b2\;{ai|addic} %0,%0,-1\;{sfe|subfe} %0,%0,%0
  6153.    {xoriu|xoris} %0,%1,%u2\;{ai|addic} %0,%0,-1\;{sfe|subfe} %0,%0,%0
  6154.    {sfi|subfic} %0,%1,%2\;{ai|addic} %0,%0,-1\;{sfe|subfe} %0,%0,%0"
  6155.    [(set_attr "length" "12,8,12,12,12")])
  6156.  
  6157. ;; Simplify (ne X (const_int 0)) on the PowerPC.  No need to on the Power,
  6158. ;; since it nabs/sr is just as fast.
  6159. (define_insn ""
  6160.   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
  6161.     (lshiftrt:SI (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r")))
  6162.              (const_int 31)))
  6163.    (clobber (match_scratch:SI 2 "=&r"))]
  6164.   "!TARGET_POWER"
  6165.   "{ai|addic} %2,%1,-1\;{sfe|subfe} %0,%2,%1"
  6166.   [(set_attr "length" "8")])
  6167.  
  6168. ;; This is what (plus (ne X (const_int 0)) Y) looks like.
  6169. (define_insn ""
  6170.   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
  6171.     (plus:SI (lshiftrt:SI
  6172.           (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r")))
  6173.           (const_int 31))
  6174.          (match_operand:SI 2 "gpc_reg_operand" "r")))
  6175.    (clobber (match_scratch:SI 3 "=&r"))]
  6176.   ""
  6177.   "{ai|addic} %3,%1,-1\;{aze|addze} %0,%2"
  6178.   [(set_attr "length" "8")])
  6179.  
  6180. (define_insn ""
  6181.   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
  6182.     (compare:CC
  6183.      (plus:SI (lshiftrt:SI
  6184.            (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r")))
  6185.            (const_int 31))
  6186.           (match_operand:SI 2 "gpc_reg_operand" "r"))
  6187.      (const_int 0)))
  6188.    (clobber (match_scratch:SI 3 "=&r"))]
  6189.   ""
  6190.   "{ai|addic} %3,%1,-1\;{aze.|addze.} %3,%2"
  6191.   [(set_attr "type" "compare")
  6192.    (set_attr "length" "8")])
  6193.  
  6194. (define_insn ""
  6195.   [(set (match_operand:CC 4 "cc_reg_operand" "=x")
  6196.     (compare:CC
  6197.      (plus:SI (lshiftrt:SI
  6198.            (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r")))
  6199.            (const_int 31))
  6200.           (match_operand:SI 2 "gpc_reg_operand" "r"))
  6201.      (const_int 0)))
  6202.    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
  6203.     (plus:SI (lshiftrt:SI (neg:SI (abs:SI (match_dup 1))) (const_int 31))
  6204.          (match_dup 2)))
  6205.    (clobber (match_scratch:SI 3 "=&r"))]
  6206.   ""
  6207.   "{ai|addic} %3,%1,-1\;{aze.|addze.} %0,%2"
  6208.   [(set_attr "type" "compare")
  6209.    (set_attr "length" "8")])
  6210.  
  6211. (define_insn ""
  6212.   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
  6213.     (le:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
  6214.            (match_operand:SI 2 "reg_or_short_operand" "r,O")))
  6215.    (clobber (match_scratch:SI 3 "=r,X"))]
  6216.   "TARGET_POWER"
  6217.   "@
  6218.    doz %3,%2,%1\;{sfi|subfic} %0,%3,0\;{ae|adde} %0,%0,%3
  6219.    {ai|addic} %0,%1,-1\;{aze|addze} %0,%0\;{sri|srwi} %0,%0,31"
  6220.   [(set_attr "length" "12")])
  6221.  
  6222. (define_insn ""
  6223.   [(set (match_operand:CC 4 "cc_reg_operand" "=x,x")
  6224.     (compare:CC
  6225.      (le:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
  6226.         (match_operand:SI 2 "reg_or_short_operand" "r,O"))
  6227.      (const_int 0)))
  6228.    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
  6229.     (le:SI (match_dup 1) (match_dup 2)))
  6230.    (clobber (match_scratch:SI 3 "=r,X"))]
  6231.   "TARGET_POWER"
  6232.   "@
  6233.    doz %3,%2,%1\;{sfi|subfic} %0,%3,0\;{ae.|adde.} %0,%0,%3
  6234.    {ai|addic} %0,%1,-1\;{aze|addze} %0,%0\;{sri.|srwi.} %0,%0,31"
  6235.   [(set_attr "type" "compare,delayed_compare")
  6236.    (set_attr "length" "12")])
  6237.  
  6238. (define_insn ""
  6239.   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
  6240.     (plus:SI (le:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
  6241.             (match_operand:SI 2 "reg_or_short_operand" "r,O"))
  6242.          (match_operand:SI 3 "gpc_reg_operand" "r,r")))
  6243.    (clobber (match_scratch:SI 4 "=&r,&r"))]
  6244.   "TARGET_POWER"
  6245.   "@
  6246.    doz %4,%2,%1\;{sfi|subfic} %4,%4,0\;{aze|addze} %0,%3
  6247.    {srai|srawi} %4,%1,31\;{sf|subfc} %4,%1,%4\;{aze|addze} %0,%3"
  6248.   [(set_attr "length" "12")])
  6249.  
  6250. (define_insn ""
  6251.   [(set (match_operand:CC 0 "cc_reg_operand" "=x,x")
  6252.     (compare:CC
  6253.      (plus:SI (le:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
  6254.              (match_operand:SI 2 "reg_or_short_operand" "r,O"))
  6255.           (match_operand:SI 3 "gpc_reg_operand" "r,r"))
  6256.      (const_int 0)))
  6257.    (clobber (match_scratch:SI 4 "=&r,&r"))]
  6258.   "TARGET_POWER"
  6259.   "@
  6260.    doz %4,%2,%1\;{sfi|subfic} %4,%4,0\;{aze.|addze.} %4,%3
  6261.    {srai|srawi} %4,%1,31\;{sf|subfc} %4,%1,%4\;{aze.|addze.} %4,%3"
  6262.   [(set_attr "type" "compare")
  6263.    (set_attr "length" "12")])
  6264.  
  6265. (define_insn ""
  6266.   [(set (match_operand:CC 5 "cc_reg_operand" "=x,x")
  6267.     (compare:CC
  6268.      (plus:SI (le:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
  6269.              (match_operand:SI 2 "reg_or_short_operand" "r,O"))
  6270.           (match_operand:SI 3 "gpc_reg_operand" "r,r"))
  6271.      (const_int 0)))
  6272.    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
  6273.     (plus:SI (le:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
  6274.    (clobber (match_scratch:SI 4 "=&r,&r"))]
  6275.   "TARGET_POWER"
  6276.   "@
  6277.    doz %4,%2,%1\;{sfi|subfic} %4,%4,0\;{aze.|addze.} %0,%3
  6278.    {srai|srawi} %4,%1,31\;{sf|subfc} %4,%1,%4\;{aze.|addze.} %0,%3"
  6279.   [(set_attr "type" "compare")
  6280.    (set_attr "length" "12")])
  6281.  
  6282. (define_insn ""
  6283.   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
  6284.     (neg:SI (le:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
  6285.                (match_operand:SI 2 "reg_or_short_operand" "r,O"))))]
  6286.   "TARGET_POWER"
  6287.   "@
  6288.    doz %0,%2,%1\;{ai|addic} %0,%0,-1\;{sfe|subfe} %0,%0,%0
  6289.    {ai|addic} %0,%1,-1\;{aze|addze} %0,%0\;{srai|srawi} %0,%0,31"
  6290.   [(set_attr "length" "12")])
  6291.  
  6292. (define_insn ""
  6293.   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
  6294.     (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r")
  6295.         (match_operand:SI 2 "reg_or_short_operand" "rI")))]
  6296.   ""
  6297.   "{sf%I2|subf%I2c} %0,%1,%2\;{cal %0,0(0)|li %0,0}\;{ae|adde} %0,%0,%0"
  6298.   [(set_attr "length" "12")])
  6299.  
  6300. (define_insn ""
  6301.   [(set (match_operand:CC 3 "cc_reg_operand" "=x")
  6302.     (compare:CC
  6303.      (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r")
  6304.          (match_operand:SI 2 "reg_or_short_operand" "rI"))
  6305.      (const_int 0)))
  6306.    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
  6307.     (leu:SI (match_dup 1) (match_dup 2)))]
  6308.    ""
  6309.   "{sf%I2|subf%I2c} %0,%1,%2\;{cal %0,0(0)|li %0,0}\;{ae.|adde.} %0,%0,%0"
  6310.   [(set_attr "type" "compare")
  6311.    (set_attr "length" "12")])
  6312.  
  6313. (define_insn ""
  6314.   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
  6315.     (plus:SI (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r")
  6316.              (match_operand:SI 2 "reg_or_short_operand" "rI"))
  6317.          (match_operand:SI 3 "gpc_reg_operand" "r")))
  6318.    (clobber (match_scratch:SI 4 "=&r"))]
  6319.   ""
  6320.   "{sf%I2|subf%I2c} %4,%1,%2\;{aze|addze} %0,%3"
  6321.   [(set_attr "length" "8")])
  6322.  
  6323. (define_insn ""
  6324.   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
  6325.     (compare:CC
  6326.      (plus:SI (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r")
  6327.               (match_operand:SI 2 "reg_or_short_operand" "rI"))
  6328.           (match_operand:SI 3 "gpc_reg_operand" "r"))
  6329.      (const_int 0)))
  6330.    (clobber (match_scratch:SI 4 "=&r"))]
  6331.   ""
  6332.   "{sf%I2|subf%I2c} %4,%1,%2\;{aze.|addze.} %4,%3"
  6333.   [(set_attr "type" "compare")
  6334.    (set_attr "length" "8")])
  6335.  
  6336. (define_insn ""
  6337.   [(set (match_operand:CC 5 "cc_reg_operand" "=x")
  6338.     (compare:CC
  6339.      (plus:SI (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r")
  6340.               (match_operand:SI 2 "reg_or_short_operand" "rI"))
  6341.           (match_operand:SI 3 "gpc_reg_operand" "r"))
  6342.      (const_int 0)))
  6343.    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
  6344.     (plus:SI (leu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
  6345.    (clobber (match_scratch:SI 4 "=&r"))]
  6346.   ""
  6347.   "{sf%I2|subf%I2c} %4,%1,%2\;{aze.|addze.} %0,%3"
  6348.   [(set_attr "type" "compare")
  6349.    (set_attr "length" "8")])
  6350.  
  6351. (define_insn ""
  6352.   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
  6353.     (neg:SI (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r")
  6354.             (match_operand:SI 2 "reg_or_short_operand" "rI"))))]
  6355.   ""
  6356.   "{sf%I2|subf%I2c} %0,%1,%2\;{sfe|subfe} %0,%0,%0\;nand %0,%0,%0"
  6357.    [(set_attr "length" "12")])
  6358.  
  6359. (define_insn ""
  6360.   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
  6361.     (and:SI (neg:SI
  6362.          (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r")
  6363.              (match_operand:SI 2 "reg_or_short_operand" "rI")))
  6364.         (match_operand:SI 3 "gpc_reg_operand" "r")))
  6365.    (clobber (match_scratch:SI 4 "=&r"))]
  6366.   ""
  6367.   "{sf%I2|subf%I2c} %4,%1,%2\;{sfe|subfe} %4,%4,%4\;andc %0,%3,%4"
  6368.   [(set_attr "length" "12")])
  6369.  
  6370. (define_insn ""
  6371.   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
  6372.     (compare:CC
  6373.      (and:SI (neg:SI
  6374.           (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r")
  6375.               (match_operand:SI 2 "reg_or_short_operand" "rI")))
  6376.          (match_operand:SI 3 "gpc_reg_operand" "r"))
  6377.      (const_int 0)))
  6378.    (clobber (match_scratch:SI 4 "=&r"))]
  6379.   ""
  6380.   "{sf%I2|subf%I2c} %4,%1,%2\;{sfe|subfe} %4,%4,%4\;andc. %4,%3,%4"
  6381.   [(set_attr "type" "compare")
  6382.    (set_attr "length" "12")])
  6383.  
  6384. (define_insn ""
  6385.   [(set (match_operand:CC 5 "cc_reg_operand" "=x")
  6386.     (compare:CC
  6387.      (and:SI (neg:SI
  6388.           (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r")
  6389.               (match_operand:SI 2 "reg_or_short_operand" "rI")))
  6390.          (match_operand:SI 3 "gpc_reg_operand" "r"))
  6391.      (const_int 0)))
  6392.    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
  6393.     (and:SI (neg:SI (leu:SI (match_dup 1) (match_dup 2))) (match_dup 3)))
  6394.    (clobber (match_scratch:SI 4 "=&r"))]
  6395.   ""
  6396.   "{sf%I2|subf%I2c} %4,%1,%2\;{sfe|subfe} %4,%4,%4\;andc. %0,%3,%4"
  6397.   [(set_attr "type" "compare")
  6398.    (set_attr "length" "12")])
  6399.  
  6400. (define_insn ""
  6401.   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
  6402.     (lt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
  6403.            (match_operand:SI 2 "reg_or_short_operand" "rI")))]
  6404.   "TARGET_POWER"
  6405.   "doz%I2 %0,%1,%2\;nabs %0,%0\;{sri|srwi} %0,%0,31"
  6406.    [(set_attr "length" "12")])
  6407.  
  6408. (define_insn ""
  6409.   [(set (match_operand:CC 3 "cc_reg_operand" "=x")
  6410.     (compare:CC
  6411.      (lt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
  6412.         (match_operand:SI 2 "reg_or_short_operand" "rI"))
  6413.      (const_int 0)))
  6414.    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
  6415.     (lt:SI (match_dup 1) (match_dup 2)))]
  6416.   "TARGET_POWER"
  6417.   "doz%I2 %0,%1,%2\;nabs %0,%0\;{sri.|srwi.} %0,%0,31"
  6418.   [(set_attr "type" "delayed_compare")
  6419.    (set_attr "length" "12")])
  6420.  
  6421. (define_insn ""
  6422.   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
  6423.     (plus:SI (lt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
  6424.             (match_operand:SI 2 "reg_or_short_operand" "rI"))
  6425.          (match_operand:SI 3 "gpc_reg_operand" "r")))
  6426.    (clobber (match_scratch:SI 4 "=&r"))]
  6427.   "TARGET_POWER"
  6428.   "doz%I2 %4,%1,%2\;{ai|addic} %4,%4,-1\;{aze|addze} %0,%3"
  6429.   [(set_attr "length" "12")])
  6430.  
  6431. (define_insn ""
  6432.   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
  6433.     (compare:CC
  6434.      (plus:SI (lt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
  6435.              (match_operand:SI 2 "reg_or_short_operand" "rI"))
  6436.           (match_operand:SI 3 "gpc_reg_operand" "r"))
  6437.      (const_int 0)))
  6438.    (clobber (match_scratch:SI 4 "=&r"))]
  6439.   "TARGET_POWER"
  6440.   "doz%I2 %4,%1,%2\;{ai|addic} %4,%4,-1\;{aze.|addze.} %4,%3"
  6441.   [(set_attr "type" "compare")
  6442.    (set_attr "length" "12")])
  6443.  
  6444. (define_insn ""
  6445.   [(set (match_operand:CC 5 "cc_reg_operand" "=x")
  6446.     (compare:CC
  6447.      (plus:SI (lt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
  6448.              (match_operand:SI 2 "reg_or_short_operand" "rI"))
  6449.           (match_operand:SI 3 "gpc_reg_operand" "r"))
  6450.      (const_int 0)))
  6451.    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
  6452.     (plus:SI (lt:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
  6453.    (clobber (match_scratch:SI 4 "=&r"))]
  6454.   "TARGET_POWER"
  6455.   "doz%I2 %4,%1,%2\;{ai|addic} %4,%4,-1\;{aze.|addze.} %0,%3"
  6456.   [(set_attr "type" "compare")
  6457.    (set_attr "length" "12")])
  6458.  
  6459. (define_insn ""
  6460.   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
  6461.     (neg:SI (lt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
  6462.                (match_operand:SI 2 "reg_or_short_operand" "rI"))))]
  6463.   "TARGET_POWER"
  6464.   "doz%I2 %0,%1,%2\;nabs %0,%0\;{srai|srawi} %0,%0,31"
  6465.   [(set_attr "length" "12")])
  6466.  
  6467. (define_insn ""
  6468.   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
  6469.     (ltu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
  6470.         (match_operand:SI 2 "reg_or_neg_short_operand" "r,P")))]
  6471.   ""
  6472.   "@
  6473.    {sf|subfc} %0,%2,%1\;{sfe|subfe} %0,%0,%0\;neg %0,%0
  6474.    {ai|addic} %0,%1,%n2\;{sfe|subfe} %0,%0,%0\;neg %0,%0"
  6475.   [(set_attr "length" "12")])
  6476.  
  6477. (define_insn ""
  6478.   [(set (match_operand:CC 3 "cc_reg_operand" "=x,x")
  6479.     (compare:CC
  6480.      (ltu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
  6481.          (match_operand:SI 2 "reg_or_neg_short_operand" "r,P"))
  6482.      (const_int 0)))
  6483.    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
  6484.     (ltu:SI (match_dup 1) (match_dup 2)))]
  6485.   ""
  6486.   "@
  6487.    {sf|subfc} %0,%2,%1\;{sfe|subfe} %0,%0,%0\;neg. %0,%0
  6488.    {ai|addic} %0,%1,%n2\;{sfe|subfe} %0,%0,%0\;neg. %0,%0"
  6489.   [(set_attr "type" "compare")
  6490.    (set_attr "length" "12")])
  6491.  
  6492. (define_insn ""
  6493.   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r")
  6494.     (plus:SI (ltu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
  6495.              (match_operand:SI 2 "reg_or_neg_short_operand" "r,r,P,P"))
  6496.          (match_operand:SI 3 "reg_or_short_operand" "r,I,r,I")))
  6497.    (clobber (match_scratch:SI 4 "=&r,r,&r,r"))]
  6498.   ""
  6499.   "@
  6500.   {sf|subfc} %4,%2,%1\;{sfe|subfe} %4,%4,%4\;{sf%I3|subf%I3c} %0,%4,%3
  6501.   {sf|subfc} %4,%2,%1\;{sfe|subfe} %4,%4,%4\;{sf%I3|subf%I3c} %0,%4,%3
  6502.   {ai|addic} %4,%1,%n2\;{sfe|subfe} %4,%4,%4\;{sf%I3|subf%I3c} %0,%4,%3
  6503.   {ai|addic} %4,%1,%n2\;{sfe|subfe} %4,%4,%4\;{sf%I3|subf%I3c} %0,%4,%3"
  6504.  [(set_attr "length" "12")])
  6505.  
  6506. (define_insn ""
  6507.   [(set (match_operand:CC 0 "cc_reg_operand" "=x,x")
  6508.     (compare:CC
  6509.      (plus:SI (ltu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
  6510.               (match_operand:SI 2 "reg_or_neg_short_operand" "r,P"))
  6511.           (match_operand:SI 3 "gpc_reg_operand" "r,r"))
  6512.      (const_int 0)))
  6513.    (clobber (match_scratch:SI 4 "=&r,&r"))]
  6514.   ""
  6515.   "@
  6516.    {sf|subfc} %4,%2,%1\;{sfe|subfe} %4,%4,%4\;{sf.|subfc.} %4,%4,%3
  6517.    {ai|addic} %4,%1,%n2\;{sfe|subfe} %4,%4,%4\;{sf.|subfc.} %4,%4,%3"
  6518.   [(set_attr "type" "compare")
  6519.    (set_attr "length" "12")])
  6520.  
  6521. (define_insn ""
  6522.   [(set (match_operand:CC 5 "cc_reg_operand" "=x,x")
  6523.     (compare:CC
  6524.      (plus:SI (ltu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
  6525.               (match_operand:SI 2 "reg_or_neg_short_operand" "r,P"))
  6526.           (match_operand:SI 3 "gpc_reg_operand" "r,r"))
  6527.      (const_int 0)))
  6528.    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
  6529.     (plus:SI (ltu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
  6530.    (clobber (match_scratch:SI 4 "=&r,&r"))]
  6531.   ""
  6532.   "@
  6533.    {sf|subfc} %4,%2,%1\;{sfe|subfe} %4,%4,%4\;{sf.|subfc.} %0,%4,%3
  6534.    {ai|addic} %4,%1,%n2\;{sfe|subfe} %4,%4,%4\;{sf.|subfc.} %0,%4,%3"
  6535.   [(set_attr "type" "compare")
  6536.    (set_attr "length" "12")])
  6537.  
  6538. (define_insn ""
  6539.   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
  6540.     (neg:SI (ltu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
  6541.             (match_operand:SI 2 "reg_or_neg_short_operand" "r,P"))))]
  6542.   ""
  6543.   "@
  6544.    {sf|subfc} %0,%2,%1\;{sfe|subfe} %0,%0,%0
  6545.    {ai|addic} %0,%1,%n2\;{sfe|subfe} %0,%0,%0"
  6546.   [(set_attr "length" "8")])
  6547.  
  6548. (define_insn ""
  6549.   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
  6550.     (ge:SI (match_operand:SI 1 "gpc_reg_operand" "r")
  6551.            (match_operand:SI 2 "reg_or_short_operand" "rI")))
  6552.    (clobber (match_scratch:SI 3 "=r"))]
  6553.   "TARGET_POWER"
  6554.   "doz%I2 %3,%1,%2\;{sfi|subfic} %0,%3,0\;{ae|adde} %0,%0,%3"
  6555.    [(set_attr "length" "12")])
  6556.  
  6557. (define_insn ""
  6558.   [(set (match_operand:CC 4 "cc_reg_operand" "=x")
  6559.     (compare:CC
  6560.      (ge:SI (match_operand:SI 1 "gpc_reg_operand" "r")
  6561.         (match_operand:SI 2 "reg_or_short_operand" "rI"))
  6562.      (const_int 0)))
  6563.    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
  6564.     (ge:SI (match_dup 1) (match_dup 2)))
  6565.    (clobber (match_scratch:SI 3 "=r"))]
  6566.   "TARGET_POWER"
  6567.   "doz%I2 %3,%1,%2\;{sfi|subfic} %0,%3,0\;{ae.|adde.} %0,%0,%3"
  6568.   [(set_attr "type" "compare")
  6569.    (set_attr "length" "12")])
  6570.  
  6571. (define_insn ""
  6572.   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
  6573.     (plus:SI (ge:SI (match_operand:SI 1 "gpc_reg_operand" "r")
  6574.             (match_operand:SI 2 "reg_or_short_operand" "rI"))
  6575.          (match_operand:SI 3 "gpc_reg_operand" "r")))
  6576.    (clobber (match_scratch:SI 4 "=&r"))]
  6577.   "TARGET_POWER"
  6578.   "doz%I2 %4,%1,%2\;{sfi|subfic} %4,%4,0\;{aze|addze} %0,%3"
  6579.   [(set_attr "length" "12")])
  6580.  
  6581. (define_insn ""
  6582.   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
  6583.     (compare:CC
  6584.      (plus:SI (ge:SI (match_operand:SI 1 "gpc_reg_operand" "r")
  6585.              (match_operand:SI 2 "reg_or_short_operand" "rI"))
  6586.           (match_operand:SI 3 "gpc_reg_operand" "r"))
  6587.      (const_int 0)))
  6588.    (clobber (match_scratch:SI 4 "=&r"))]
  6589.   "TARGET_POWER"
  6590.   "doz%I2 %4,%1,%2\;{sfi|subfic} %4,%4,0\;{aze.|addze.} %4,%3"
  6591.   [(set_attr "type" "compare")
  6592.    (set_attr "length" "12")])
  6593.  
  6594. (define_insn ""
  6595.   [(set (match_operand:CC 5 "cc_reg_operand" "=x")
  6596.     (compare:CC
  6597.      (plus:SI (ge:SI (match_operand:SI 1 "gpc_reg_operand" "r")
  6598.              (match_operand:SI 2 "reg_or_short_operand" "rI"))
  6599.           (match_operand:SI 3 "gpc_reg_operand" "r"))
  6600.      (const_int 0)))
  6601.    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
  6602.     (plus:SI (ge:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
  6603.    (clobber (match_scratch:SI 4 "=&r"))]
  6604.   "TARGET_POWER"
  6605.   "doz%I2 %4,%1,%2\;{sfi|subfic} %4,%4,0\;{aze.|addze.} %0,%3"
  6606.   [(set_attr "type" "compare")
  6607.    (set_attr "length" "12")])
  6608.  
  6609. (define_insn ""
  6610.   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
  6611.     (neg:SI (ge:SI (match_operand:SI 1 "gpc_reg_operand" "r")
  6612.                (match_operand:SI 2 "reg_or_short_operand" "rI"))))]
  6613.   "TARGET_POWER"
  6614.   "doz%I2 %0,%1,%2\;{ai|addic} %0,%0,-1\;{sfe|subfe} %0,%0,%0"
  6615.   [(set_attr "length" "12")])
  6616.  
  6617. ;; This is (and (neg (ge X (const_int 0))) Y).
  6618. (define_insn ""
  6619.   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
  6620.     (and:SI (neg:SI
  6621.          (lshiftrt:SI
  6622.           (not:SI (match_operand:SI 1 "gpc_reg_operand" "r"))
  6623.           (const_int 31)))
  6624.         (match_operand:SI 2 "gpc_reg_operand" "r")))
  6625.    (clobber (match_scratch:SI 3 "=&r"))]
  6626.   ""
  6627.   "{srai|srawi} %3,%1,31\;andc %0,%2,%3"
  6628.   [(set_attr "length" "8")])
  6629.  
  6630. (define_insn ""
  6631.   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
  6632.     (compare:CC
  6633.      (and:SI (neg:SI
  6634.           (lshiftrt:SI
  6635.            (not:SI (match_operand:SI 1 "gpc_reg_operand" "r"))
  6636.            (const_int 31)))
  6637.          (match_operand:SI 2 "gpc_reg_operand" "r"))
  6638.      (const_int 0)))
  6639.    (clobber (match_scratch:SI 3 "=&r"))]
  6640.   ""
  6641.   "{srai|srawi} %3,%1,31\;andc. %3,%2,%3"
  6642.   [(set_attr "type" "compare")
  6643.    (set_attr "length" "8")])
  6644.  
  6645. (define_insn ""
  6646.   [(set (match_operand:CC 4 "cc_reg_operand" "=x")
  6647.     (compare:CC
  6648.      (and:SI (neg:SI
  6649.           (lshiftrt:SI
  6650.            (not:SI (match_operand:SI 1 "gpc_reg_operand" "r"))
  6651.            (const_int 31)))
  6652.          (match_operand:SI 2 "gpc_reg_operand" "r"))
  6653.      (const_int 0)))
  6654.    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
  6655.     (and:SI (neg:SI (lshiftrt:SI (not:SI (match_dup 1))
  6656.                      (const_int 31)))
  6657.         (match_dup 2)))
  6658.    (clobber (match_scratch:SI 3 "=&r"))]
  6659.   ""
  6660.   "{srai|srawi} %3,%1,31\;andc. %0,%2,%3"
  6661.   [(set_attr "type" "compare")
  6662.    (set_attr "length" "8")])
  6663.  
  6664. (define_insn ""
  6665.   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
  6666.     (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
  6667.         (match_operand:SI 2 "reg_or_neg_short_operand" "r,P")))]
  6668.   ""
  6669.   "@
  6670.    {sf|subfc} %0,%2,%1\;{cal %0,0(0)|li %0,0}\;{ae|adde} %0,%0,%0
  6671.    {ai|addic} %0,%1,%n2\;{cal %0,0(0)|li %0,0}\;{ae|adde} %0,%0,%0"
  6672.   [(set_attr "length" "12")])
  6673.  
  6674. (define_insn ""
  6675.   [(set (match_operand:CC 3 "cc_reg_operand" "=x,x")
  6676.     (compare:CC
  6677.      (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
  6678.          (match_operand:SI 2 "reg_or_neg_short_operand" "r,P"))
  6679.      (const_int 0)))
  6680.    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
  6681.     (geu:SI (match_dup 1) (match_dup 2)))]
  6682.   ""
  6683.   "@
  6684.    {sf|subfc} %0,%2,%1\;{cal %0,0(0)|li %0,0}\;{ae.|adde.} %0,%0,%0
  6685.    {ai|addic} %0,%1,%n2\;{cal %0,0(0)|li %0,0}\;{ae.|adde.} %0,%0,%0"
  6686.   [(set_attr "type" "compare")
  6687.    (set_attr "length" "12")])
  6688.  
  6689. (define_insn ""
  6690.   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
  6691.     (plus:SI (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
  6692.              (match_operand:SI 2 "reg_or_neg_short_operand" "r,P"))
  6693.          (match_operand:SI 3 "gpc_reg_operand" "r,r")))
  6694.    (clobber (match_scratch:SI 4 "=&r,&r"))]
  6695.   ""
  6696.   "@
  6697.    {sf|subfc} %4,%2,%1\;{aze|addze} %0,%3
  6698.    {ai|addic} %4,%1,%n2\;{aze|addze} %0,%3"
  6699.   [(set_attr "length" "8")])
  6700.  
  6701. (define_insn ""
  6702.   [(set (match_operand:CC 0 "cc_reg_operand" "=x,x")
  6703.     (compare:CC
  6704.      (plus:SI (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
  6705.               (match_operand:SI 2 "reg_or_neg_short_operand" "r,P"))
  6706.           (match_operand:SI 3 "gpc_reg_operand" "r,r"))
  6707.      (const_int 0)))
  6708.    (clobber (match_scratch:SI 4 "=&r,&r"))]
  6709.   ""
  6710.   "@
  6711.    {sf|subfc} %4,%2,%1\;{aze.|addze.} %4,%3
  6712.    {ai|addic} %4,%1,%n2\;{aze.|addze.} %4,%3"
  6713.   [(set_attr "type" "compare")
  6714.    (set_attr "length" "8")])
  6715.  
  6716. (define_insn ""
  6717.   [(set (match_operand:CC 5 "cc_reg_operand" "=x,x")
  6718.     (compare:CC
  6719.      (plus:SI (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
  6720.               (match_operand:SI 2 "reg_or_neg_short_operand" "r,P"))
  6721.           (match_operand:SI 3 "gpc_reg_operand" "r,r"))
  6722.      (const_int 0)))
  6723.    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
  6724.     (plus:SI (geu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
  6725.    (clobber (match_scratch:SI 4 "=&r,&r"))]
  6726.   ""
  6727.   "@
  6728.    {sf|subfc} %4,%2,%1\;{aze.|addze.} %0,%3
  6729.    {ai|addic} %4,%1,%n2\;{aze.|addze.} %4,%3"
  6730.   [(set_attr "type" "compare")
  6731.    (set_attr "length" "8")])
  6732.  
  6733. (define_insn ""
  6734.   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
  6735.     (neg:SI (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
  6736.             (match_operand:SI 2 "reg_or_short_operand" "r,I"))))]
  6737.   ""
  6738.   "@
  6739.    {sf|subfc} %0,%2,%1\;{sfe|subfe} %0,%0,%0\;nand %0,%0,%0
  6740.    {sfi|subfic} %0,%1,-1\;a%I2 %0,%0,%2\;{sfe|subfe} %0,%0,%0"
  6741.   [(set_attr "length" "12")])
  6742.  
  6743. (define_insn ""
  6744.   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
  6745.     (and:SI (neg:SI
  6746.          (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
  6747.              (match_operand:SI 2 "reg_or_neg_short_operand" "r,P")))
  6748.         (match_operand:SI 3 "gpc_reg_operand" "r,r")))
  6749.    (clobber (match_scratch:SI 4 "=&r,&r"))]
  6750.   ""
  6751.   "@
  6752.    {sf|subfc} %4,%2,%1\;{sfe|subfe} %4,%4,%4\;andc %0,%3,%4
  6753.    {ai|addic} %4,%1,%n2\;{sfe|subfe} %4,%4,%4\;andc %0,%3,%4"
  6754.   [(set_attr "length" "12")])
  6755.  
  6756. (define_insn ""
  6757.   [(set (match_operand:CC 0 "cc_reg_operand" "=x,x")
  6758.     (compare:CC
  6759.      (and:SI (neg:SI
  6760.           (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
  6761.               (match_operand:SI 2 "reg_or_neg_short_operand" "r,P")))
  6762.          (match_operand:SI 3 "gpc_reg_operand" "r,r"))
  6763.      (const_int 0)))
  6764.    (clobber (match_scratch:SI 4 "=&r,&r"))]
  6765.   ""
  6766.   "@
  6767.    {sf|subfc} %4,%2,%1\;{sfe|subfe} %4,%4,%4\;andc. %4,%3,%4
  6768.    {ai|addic} %4,%1,%n2\;{sfe|subfe} %4,%4,%4\;andc. %4,%3,%4"
  6769.   [(set_attr "type" "compare")
  6770.    (set_attr "length" "12")])
  6771.  
  6772. (define_insn ""
  6773.   [(set (match_operand:CC 5 "cc_reg_operand" "=x,x")
  6774.     (compare:CC
  6775.      (and:SI (neg:SI
  6776.           (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
  6777.               (match_operand:SI 2 "reg_or_neg_short_operand" "r,P")))
  6778.          (match_operand:SI 3 "gpc_reg_operand" "r,r"))
  6779.      (const_int 0)))
  6780.    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
  6781.     (and:SI (neg:SI (geu:SI (match_dup 1) (match_dup 2))) (match_dup 3)))
  6782.    (clobber (match_scratch:SI 4 "=&r,&r"))]
  6783.   ""
  6784.   "@
  6785.    {sf|subfc} %4,%2,%1\;{sfe|subfe} %4,%4,%4\;andc. %0,%3,%4
  6786.    {ai|addic} %4,%1,%n2\;{sfe|subfe} %4,%4,%4\;andc. %0,%3,%4"
  6787.   [(set_attr "type" "compare")
  6788.    (set_attr "length" "12")])
  6789.  
  6790. (define_insn ""
  6791.   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
  6792.     (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
  6793.            (const_int 0)))]
  6794.   ""
  6795.   "{sfi|subfic} %0,%1,0\;{ame|addme} %0,%0\;{sri|srwi} %0,%0,31"
  6796.   [(set_attr "length" "12")])
  6797.  
  6798. (define_insn ""
  6799.   [(set (match_operand:CC 2 "cc_reg_operand" "=x")
  6800.     (compare:CC
  6801.      (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
  6802.         (const_int 0))
  6803.      (const_int 0)))
  6804.    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
  6805.     (gt:SI (match_dup 1) (const_int 0)))]
  6806.   ""
  6807.   "{sfi|subfic} %0,%1,0\;{ame|addme} %0,%0\;{sri.|srwi.} %0,%0,31"
  6808.   [(set_attr "type" "delayed_compare")
  6809.    (set_attr "length" "12")])
  6810.  
  6811. (define_insn ""
  6812.   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
  6813.     (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
  6814.            (match_operand:SI 2 "reg_or_short_operand" "r")))]
  6815.   "TARGET_POWER"
  6816.   "doz %0,%2,%1\;nabs %0,%0\;{sri|srwi} %0,%0,31"
  6817.   [(set_attr "length" "12")])
  6818.  
  6819. (define_insn ""
  6820.   [(set (match_operand:CC 3 "cc_reg_operand" "=x")
  6821.     (compare:CC
  6822.      (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
  6823.         (match_operand:SI 2 "reg_or_short_operand" "r"))
  6824.      (const_int 0)))
  6825.    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
  6826.     (gt:SI (match_dup 1) (match_dup 2)))]
  6827.   "TARGET_POWER"
  6828.   "doz %0,%2,%1\;nabs %0,%0\;{sri.|srwi.} %0,%0,31"
  6829.   [(set_attr "type" "delayed_compare")
  6830.    (set_attr "length" "12")])
  6831.  
  6832. (define_insn ""
  6833.   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
  6834.     (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
  6835.             (const_int 0))
  6836.          (match_operand:SI 2 "gpc_reg_operand" "r")))
  6837.    (clobber (match_scratch:SI 3 "=&r"))]
  6838.   ""
  6839.   "{a|addc} %3,%1,%1\;{sfe|subfe} %3,%1,%3\;{aze|addze} %0,%2"
  6840.   [(set_attr "length" "12")])
  6841.  
  6842. (define_insn ""
  6843.   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
  6844.     (compare:CC
  6845.      (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
  6846.              (const_int 0))
  6847.           (match_operand:SI 2 "gpc_reg_operand" "r"))
  6848.      (const_int 0)))
  6849.    (clobber (match_scratch:SI 3 "=&r"))]
  6850.   ""
  6851.   "{a|addc} %3,%1,%1\;{sfe|subfe} %3,%1,%3\;{aze.|addze.} %0,%2"
  6852.   [(set_attr "type" "compare")
  6853.    (set_attr "length" "12")])
  6854.  
  6855. (define_insn ""
  6856.   [(set (match_operand:CC 4 "cc_reg_operand" "=x")
  6857.     (compare:CC
  6858.      (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
  6859.              (const_int 0))
  6860.           (match_operand:SI 2 "gpc_reg_operand" "r"))
  6861.      (const_int 0)))
  6862.    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
  6863.     (plus:SI (gt:SI (match_dup 1) (const_int 0)) (match_dup 2)))
  6864.    (clobber (match_scratch:SI 3 "=&r"))]
  6865.   ""
  6866.   "{a|addc} %3,%1,%1\;{sfe|subfe} %3,%1,%3\;{aze.|addze.} %3,%2"
  6867.   [(set_attr "type" "compare")
  6868.    (set_attr "length" "12")])
  6869.  
  6870. (define_insn ""
  6871.   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
  6872.     (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
  6873.             (match_operand:SI 2 "reg_or_short_operand" "r"))
  6874.          (match_operand:SI 3 "gpc_reg_operand" "r")))
  6875.    (clobber (match_scratch:SI 4 "=&r"))]
  6876.   "TARGET_POWER"
  6877.   "doz %4,%2,%1\;{ai|addic} %4,%4,-1\;{aze|addze} %0,%3"
  6878.   [(set_attr "length" "12")])
  6879.  
  6880. (define_insn ""
  6881.   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
  6882.     (compare:CC
  6883.      (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
  6884.              (match_operand:SI 2 "reg_or_short_operand" "r"))
  6885.           (match_operand:SI 3 "gpc_reg_operand" "r"))
  6886.      (const_int 0)))
  6887.    (clobber (match_scratch:SI 4 "=&r"))]
  6888.   "TARGET_POWER"
  6889.   "doz %4,%2,%1\;{ai|addic} %4,%4,-1\;{aze.|addze.} %4,%3"
  6890.   [(set_attr "type" "compare")
  6891.    (set_attr "length" "12")])
  6892.  
  6893. (define_insn ""
  6894.   [(set (match_operand:CC 5 "cc_reg_operand" "=x")
  6895.     (compare:CC
  6896.      (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
  6897.              (match_operand:SI 2 "reg_or_short_operand" "r"))
  6898.           (match_operand:SI 3 "gpc_reg_operand" "r"))
  6899.      (const_int 0)))
  6900.    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
  6901.     (plus:SI (gt:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
  6902.    (clobber (match_scratch:SI 4 "=&r"))]
  6903.   "TARGET_POWER"
  6904.   "doz %4,%2,%1\;{ai|addic} %4,%4,-1\;{aze.|addze.} %0,%3"
  6905.   [(set_attr "type" "compare")
  6906.    (set_attr "length" "12")])
  6907.  
  6908. (define_insn ""
  6909.   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
  6910.     (neg:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
  6911.                (const_int 0))))]
  6912.   ""
  6913.   "{sfi|subfic} %0,%1,0\;{ame|addme} %0,%0\;{srai|srawi} %0,%0,31"
  6914.   [(set_attr "length" "12")])
  6915.  
  6916. (define_insn ""
  6917.   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
  6918.     (neg:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
  6919.                (match_operand:SI 2 "reg_or_short_operand" "r"))))]
  6920.   "TARGET_POWER"
  6921.   "doz %0,%2,%1\;nabs %0,%0\;{srai|srawi} %0,%0,31"
  6922.   [(set_attr "length" "12")])
  6923.  
  6924. (define_insn ""
  6925.   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
  6926.     (gtu:SI (match_operand:SI 1 "gpc_reg_operand" "r")
  6927.         (match_operand:SI 2 "reg_or_short_operand" "rI")))]
  6928.   ""
  6929.   "{sf%I2|subf%I2c} %0,%1,%2\;{sfe|subfe} %0,%0,%0\;neg %0,%0"
  6930.   [(set_attr "length" "12")])
  6931.  
  6932. (define_insn ""
  6933.   [(set (match_operand:CC 3 "cc_reg_operand" "=x")
  6934.     (compare:CC
  6935.      (gtu:SI (match_operand:SI 1 "gpc_reg_operand" "r")
  6936.          (match_operand:SI 2 "reg_or_short_operand" "rI"))
  6937.      (const_int 0)))
  6938.    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
  6939.     (gtu:SI (match_dup 1) (match_dup 2)))]
  6940.   ""
  6941.   "{sf%I2|subf%I2c} %0,%1,%2\;{sfe|subfe} %0,%0,%0\;neg. %0,%0"
  6942.   [(set_attr "type" "compare")
  6943.    (set_attr "length" "12")])
  6944.  
  6945. (define_insn ""
  6946.   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r")
  6947.     (plus:SI (gtu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r")
  6948.              (match_operand:SI 2 "reg_or_short_operand" "I,r,rI"))
  6949.          (match_operand:SI 3 "reg_or_short_operand" "r,r,I")))
  6950.    (clobber (match_scratch:SI 4 "=&r,&r,&r"))]
  6951.   ""
  6952.   "@
  6953.    {ai|addic} %4,%1,%k2\;{aze|addze} %0,%3
  6954.    {sf%I2|subf%I2c} %4,%1,%2\;{sfe|subfe} %4,%4,%4\;{sf%I3|subf%I3c} %0,%4,%3
  6955.    {sf%I2|subf%I2c} %4,%1,%2\;{sfe|subfe} %4,%4,%4\;{sf%I3|subf%I3c} %0,%4,%3"
  6956.   [(set_attr "length" "8,12,12")])
  6957.  
  6958. (define_insn ""
  6959.   [(set (match_operand:CC 0 "cc_reg_operand" "=x,x")
  6960.     (compare:CC
  6961.      (plus:SI (gtu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
  6962.               (match_operand:SI 2 "reg_or_short_operand" "I,r"))
  6963.           (match_operand:SI 3 "gpc_reg_operand" "r,r"))
  6964.      (const_int 0)))
  6965.    (clobber (match_scratch:SI 4 "=&r,&r"))]
  6966.   ""
  6967.   "@
  6968.    {ai|addic} %4,%1,%k2\;{aze.|addze.} %0,%3
  6969.    {sf%I2|subf%I2c} %4,%1,%2\;{sfe|subfe} %4,%4,%4\;{sf.|subfc.} %0,%4,%3"
  6970.   [(set_attr "type" "compare")
  6971.    (set_attr "length" "8,12")])
  6972.  
  6973. (define_insn ""
  6974.   [(set (match_operand:CC 5 "cc_reg_operand" "=x,x")
  6975.     (compare:CC
  6976.      (plus:SI (gtu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
  6977.               (match_operand:SI 2 "reg_or_short_operand" "I,r"))
  6978.           (match_operand:SI 3 "gpc_reg_operand" "r,r"))
  6979.      (const_int 0)))
  6980.    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
  6981.     (plus:SI (gtu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
  6982.    (clobber (match_scratch:SI 4 "=&r,&r"))]
  6983.   ""
  6984.   "@
  6985.    {ai|addic} %4,%1,%k2\;{aze.|addze.} %0,%3
  6986.    {sf%I2|subf%I2c} %4,%1,%2\;{sfe|subfe} %4,%4,%4\;{sf.|subfc.} %0,%4,%3"
  6987.   [(set_attr "type" "compare")
  6988.    (set_attr "length" "8,12")])
  6989.  
  6990. (define_insn ""
  6991.   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
  6992.     (neg:SI (gtu:SI (match_operand:SI 1 "gpc_reg_operand" "r")
  6993.             (match_operand:SI 2 "reg_or_short_operand" "rI"))))]
  6994.   ""
  6995.   "{sf%I2|subf%I2c} %0,%1,%2\;{sfe|subfe} %0,%0,%0"
  6996.   [(set_attr "length" "8")])
  6997.  
  6998. ;; Define both directions of branch and return.  If we need a reload
  6999. ;; register, we'd rather use CR0 since it is much easier to copy a
  7000. ;; register CC value to there.
  7001.  
  7002. (define_insn ""
  7003.   [(set (pc)
  7004.     (if_then_else (match_operator 1 "branch_comparison_operator"
  7005.                       [(match_operand 2
  7006.                               "cc_reg_operand" "x,?y")
  7007.                        (const_int 0)])
  7008.               (label_ref (match_operand 0 "" ""))
  7009.               (pc)))]
  7010.   ""
  7011.   "*
  7012. {
  7013.   if (get_attr_length (insn) == 8)
  7014.     return \"%C1bc %t1,%j1,%l0\";
  7015.   else
  7016.     return \"%C1bc %T1,%j1,$+8\;b %l0\";
  7017. }"
  7018.   [(set_attr "type" "branch")])
  7019.  
  7020. (define_insn ""
  7021.   [(set (pc)
  7022.     (if_then_else (match_operator 0 "branch_comparison_operator"
  7023.                       [(match_operand 1
  7024.                               "cc_reg_operand" "x,?y")
  7025.                        (const_int 0)])
  7026.               (return)
  7027.               (pc)))]
  7028.   "direct_return ()"
  7029.   "{%C0bcr|%C0bclr} %t0,%j0"
  7030.   [(set_attr "length" "8")])
  7031.  
  7032. (define_insn ""
  7033.   [(set (pc)
  7034.     (if_then_else (match_operator 1 "branch_comparison_operator"
  7035.                       [(match_operand 2
  7036.                               "cc_reg_operand" "x,?y")
  7037.                        (const_int 0)])
  7038.               (pc)
  7039.               (label_ref (match_operand 0 "" ""))))]
  7040.   ""
  7041.   "*
  7042. {
  7043.   if (get_attr_length (insn) == 8)
  7044.     return \"%C1bc %T1,%j1,%l0\";
  7045.   else
  7046.     return \"%C1bc %t1,%j1,$+8\;b %l0\";
  7047. }"
  7048.   [(set_attr "type" "branch")])
  7049.  
  7050. (define_insn ""
  7051.   [(set (pc)
  7052.     (if_then_else (match_operator 0 "branch_comparison_operator"
  7053.                       [(match_operand 1
  7054.                               "cc_reg_operand" "x,?y")
  7055.                        (const_int 0)])
  7056.               (pc)
  7057.               (return)))]
  7058.   "direct_return ()"
  7059.   "{%C0bcr|%C0bclr} %T0,%j0"
  7060.   [(set_attr "length" "8")])
  7061.  
  7062. ;; Unconditional branch and return.
  7063.  
  7064. (define_insn "jump"
  7065.   [(set (pc)
  7066.     (label_ref (match_operand 0 "" "")))]
  7067.   ""
  7068.   "b %l0")
  7069.  
  7070. (define_insn "return"
  7071.   [(return)]
  7072.   "direct_return ()"
  7073.   "{br|blr}"
  7074.   [(set_attr "type" "jmpreg")])
  7075.  
  7076. (define_insn "indirect_jump"
  7077.   [(set (pc) (match_operand:SI 0 "register_operand" "c,l"))]
  7078.   ""
  7079.   "@
  7080.    bctr
  7081.    {br|blr}"
  7082.   [(set_attr "type" "jmpreg")])
  7083.  
  7084. ;; Table jump for switch statements:
  7085. (define_expand "tablejump"
  7086.   [(set (match_dup 3)
  7087.     (plus:SI (match_operand:SI 0 "" "")
  7088.          (match_dup 2)))
  7089.    (parallel [(set (pc) (match_dup 3))
  7090.           (use (label_ref (match_operand 1 "" "")))])]
  7091.   ""
  7092.   "
  7093. { operands[0] = force_reg (SImode, operands[0]);
  7094.   operands[2] = force_reg (SImode, gen_rtx (LABEL_REF, VOIDmode, operands[1]));
  7095.   operands[3] = gen_reg_rtx (SImode);
  7096. }")
  7097.  
  7098. (define_insn ""
  7099.   [(set (pc)
  7100.     (match_operand:SI 0 "register_operand" "c,l"))
  7101.    (use (label_ref (match_operand 1 "" "")))]
  7102.   ""
  7103.   "@
  7104.    bctr
  7105.    {br|blr}"
  7106.   [(set_attr "type" "jmpreg")])
  7107.  
  7108. (define_insn "nop"
  7109.   [(const_int 0)]
  7110.   ""
  7111.   "{cror 0,0,0|nop}")
  7112.  
  7113. ;; Define the subtract-one-and-jump insns, starting with the template
  7114. ;; so loop.c knows what to generate.
  7115.  
  7116. (define_expand "decrement_and_branchsi"
  7117.   [(parallel [(set (pc) (if_then_else (ne (match_operand:SI 0 "register_operand" "c")
  7118.                       (const_int 1))
  7119.                       (label_ref (match_operand 1 "" ""))
  7120.                       (pc)))
  7121.           (set (match_dup 0) (plus:SI (match_dup 0) (const_int -1)))])]
  7122.   ""
  7123.   "")
  7124.  
  7125. ;; We need to be able to do this for any operand, including MEM, or we
  7126. ;; will cause reload to blow up since we don't allow output reloads on
  7127. ;; JUMP_INSNs.
  7128. (define_insn ""
  7129.   [(set (pc)
  7130.     (if_then_else (ne (match_operand:SI 1 "register_operand" "2,*r,*r")
  7131.               (const_int 1))
  7132.               (label_ref (match_operand 0 "" ""))
  7133.               (pc)))
  7134.    (set (match_operand:SI 2 "register_operand" "=c,*r,m*q*c*l")
  7135.     (plus:SI (match_dup 1) (const_int -1)))
  7136.    (clobber (match_scratch:CC 3 "=X,&x,&x"))
  7137.    (clobber (match_scratch:SI 4 "=X,X,r"))]
  7138.   ""
  7139.   "*
  7140. {
  7141.   if (which_alternative != 0)
  7142.     return \"#\";
  7143.   else if (get_attr_length (insn) == 8)
  7144.     return \"{bdn|bdnz} %l0\";
  7145.   else
  7146.     return \"bdz $+8\;b %l0\";
  7147. }"
  7148.   [(set_attr "type" "branch")
  7149.    (set_attr "length" "*,12,16")])
  7150.  
  7151. ;; Similar, but we can use GE since we have a REG_NONNEG.
  7152. (define_insn ""
  7153.   [(set (pc)
  7154.     (if_then_else (ge (match_operand:SI 1 "register_operand" "2,*r,*r")
  7155.               (const_int 0))
  7156.               (label_ref (match_operand 0 "" ""))
  7157.               (pc)))
  7158.    (set (match_operand:SI 2 "register_operand" "=c,*r,m*q*c*l")
  7159.     (plus:SI (match_dup 1) (const_int -1)))
  7160.    (clobber (match_scratch:CC 3 "=X,&x,&X"))
  7161.    (clobber (match_scratch:SI 4 "=X,X,r"))]
  7162.   "find_reg_note (insn, REG_NONNEG, 0)"
  7163.   "*
  7164. {
  7165.   if (which_alternative != 0)
  7166.     return \"#\";
  7167.   else if (get_attr_length (insn) == 8)
  7168.     return \"{bdn|bdnz} %l0\";
  7169.   else
  7170.     return \"bdz $+8\;b %l0\";
  7171. }"
  7172.   [(set_attr "type" "branch")
  7173.    (set_attr "length" "*,12,16")])
  7174.  
  7175. (define_insn ""
  7176.   [(set (pc)
  7177.     (if_then_else (eq (match_operand:SI 1 "register_operand" "2,*r,*r")
  7178.               (const_int 1))
  7179.               (label_ref (match_operand 0 "" ""))
  7180.               (pc)))
  7181.    (set (match_operand:SI 2 "register_operand" "=c,*r,m*q*c*l")
  7182.     (plus:SI (match_dup 1) (const_int -1)))
  7183.    (clobber (match_scratch:CC 3 "=X,&x,&x"))
  7184.    (clobber (match_scratch:SI 4 "=X,X,r"))]
  7185.   ""
  7186.   "*
  7187. {
  7188.   if (which_alternative != 0)
  7189.     return \"#\";
  7190.   else if (get_attr_length (insn) == 8)
  7191.     return \"bdz %l0\";
  7192.   else
  7193.     return \"{bdn|bdnz} $+8\;b %l0\";
  7194. }"
  7195.   [(set_attr "type" "branch")
  7196.    (set_attr "length" "*,12,16")])
  7197.  
  7198. (define_split
  7199.   [(set (pc)
  7200.     (if_then_else (match_operator 2 "comparison_operator"
  7201.                       [(match_operand:SI 1 "gpc_reg_operand" "")
  7202.                        (const_int 1)])
  7203.               (match_operand 5 "" "")
  7204.               (match_operand 6 "" "")))
  7205.    (set (match_operand:SI 0 "gpc_reg_operand" "")
  7206.     (plus:SI (match_dup 1) (const_int -1)))
  7207.    (clobber (match_scratch:CC 3 ""))
  7208.    (clobber (match_scratch:SI 4 ""))]
  7209.   "reload_completed"
  7210.   [(parallel [(set (match_dup 3)
  7211.            (compare:CC (plus:SI (match_dup 1) (const_int -1))
  7212.                    (const_int 0)))
  7213.           (set (match_dup 0) (plus:SI (match_dup 1) (const_int -1)))])
  7214.    (set (pc) (if_then_else (match_dup 7) (match_dup 5) (match_dup 6)))]
  7215.   "
  7216. { operands[7] = gen_rtx (GET_CODE (operands[2]), VOIDmode, operands[3],
  7217.              const0_rtx); }")
  7218.  
  7219. (define_split
  7220.   [(set (pc)
  7221.     (if_then_else (match_operator 2 "comparison_operator"
  7222.                       [(match_operand:SI 1 "gpc_reg_operand" "")
  7223.                        (const_int 1)])
  7224.               (match_operand 5 "" "")
  7225.               (match_operand 6 "" "")))
  7226.    (set (match_operand:SI 0 "general_operand" "")
  7227.     (plus:SI (match_dup 1) (const_int -1)))
  7228.    (clobber (match_scratch:CC 3 ""))
  7229.    (clobber (match_scratch:SI 4 ""))]
  7230.   "reload_completed && ! gpc_reg_operand (operands[0], SImode)"
  7231.   [(parallel [(set (match_dup 3)
  7232.            (compare:CC (plus:SI (match_dup 1) (const_int -1))
  7233.                    (const_int 0)))
  7234.           (set (match_dup 4) (plus:SI (match_dup 1) (const_int -1)))])
  7235.    (set (match_dup 0) (match_dup 4))
  7236.    (set (pc) (if_then_else (match_dup 7) (match_dup 5) (match_dup 6)))]
  7237.   "
  7238. { operands[7] = gen_rtx (GET_CODE (operands[2]), VOIDmode, operands[3],
  7239.              const0_rtx); }")
  7240.