comparison gcc/config/i386/i386.md @ 146:351920fa3827

merge
author anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
date Sun, 01 Mar 2020 16:13:28 +0900
parents d34655255c78 1830386684a0
children
comparison
equal deleted inserted replaced
144:8f4e72ab4e11 146:351920fa3827
1 ;; GCC machine description for IA-32 and x86-64. 1 ;; GCC machine description for IA-32 and x86-64.
2 ;; Copyright (C) 1988-2018 Free Software Foundation, Inc. 2 ;; Copyright (C) 1988-2020 Free Software Foundation, Inc.
3 ;; Mostly by William Schelter. 3 ;; Mostly by William Schelter.
4 ;; x86_64 support added by Jan Hubicka 4 ;; x86_64 support added by Jan Hubicka
5 ;; 5 ;;
6 ;; This file is part of GCC. 6 ;; This file is part of GCC.
7 ;; 7 ;;
122 UNSPEC_RSQRT 122 UNSPEC_RSQRT
123 UNSPEC_PSADBW 123 UNSPEC_PSADBW
124 124
125 ;; Generic math support 125 ;; Generic math support
126 UNSPEC_COPYSIGN 126 UNSPEC_COPYSIGN
127 UNSPEC_XORSIGN
127 UNSPEC_IEEE_MIN ; not commutative 128 UNSPEC_IEEE_MIN ; not commutative
128 UNSPEC_IEEE_MAX ; not commutative 129 UNSPEC_IEEE_MAX ; not commutative
129 130
130 ;; x87 Floating point 131 ;; x87 Floating point
131 UNSPEC_SIN 132 UNSPEC_SIN
138 UNSPEC_F2XM1 139 UNSPEC_F2XM1
139 UNSPEC_TAN 140 UNSPEC_TAN
140 UNSPEC_FXAM 141 UNSPEC_FXAM
141 142
142 ;; x87 Rounding 143 ;; x87 Rounding
144 UNSPEC_FRNDINT_ROUNDEVEN
143 UNSPEC_FRNDINT_FLOOR 145 UNSPEC_FRNDINT_FLOOR
144 UNSPEC_FRNDINT_CEIL 146 UNSPEC_FRNDINT_CEIL
145 UNSPEC_FRNDINT_TRUNC 147 UNSPEC_FRNDINT_TRUNC
146 UNSPEC_FIST_FLOOR 148 UNSPEC_FIST_FLOOR
147 UNSPEC_FIST_CEIL 149 UNSPEC_FIST_CEIL
290 ;; For CLDEMOTE support 292 ;; For CLDEMOTE support
291 UNSPECV_CLDEMOTE 293 UNSPECV_CLDEMOTE
292 294
293 ;; For Speculation Barrier support 295 ;; For Speculation Barrier support
294 UNSPECV_SPECULATION_BARRIER 296 UNSPECV_SPECULATION_BARRIER
297
298 UNSPECV_PTWRITE
299
300 ;; For ENQCMD and ENQCMDS support
301 UNSPECV_ENQCMD
302 UNSPECV_ENQCMDS
295 ]) 303 ])
296 304
297 ;; Constants to represent rounding modes in the ROUND instruction 305 ;; Constants to represent rounding modes in the ROUND instruction
298 (define_constants 306 (define_constants
299 [(ROUND_FLOOR 0x1) 307 [(ROUND_ROUNDEVEN 0x0)
308 (ROUND_FLOOR 0x1)
300 (ROUND_CEIL 0x2) 309 (ROUND_CEIL 0x2)
301 (ROUND_TRUNC 0x3) 310 (ROUND_TRUNC 0x3)
302 (ROUND_MXCSR 0x4) 311 (ROUND_MXCSR 0x4)
303 (ROUND_NO_EXC 0x8) 312 (ROUND_NO_EXC 0x8)
304 ]) 313 ])
428 437
429 438
430 ;; Processor type. 439 ;; Processor type.
431 (define_attr "cpu" "none,pentium,pentiumpro,geode,k6,athlon,k8,core2,nehalem, 440 (define_attr "cpu" "none,pentium,pentiumpro,geode,k6,athlon,k8,core2,nehalem,
432 atom,slm,glm,haswell,generic,amdfam10,bdver1,bdver2,bdver3, 441 atom,slm,glm,haswell,generic,amdfam10,bdver1,bdver2,bdver3,
433 bdver4,btver2,znver1" 442 bdver4,btver2,znver1,znver2"
434 (const (symbol_ref "ix86_schedule"))) 443 (const (symbol_ref "ix86_schedule")))
435 444
436 ;; A basic instruction type. Refinements due to arguments to be 445 ;; A basic instruction type. Refinements due to arguments to be
437 ;; provided in other attributes. 446 ;; provided in other attributes.
438 (define_attr "type" 447 (define_attr "type"
770 (define_attr "fp_int_src" "false,true" 779 (define_attr "fp_int_src" "false,true"
771 (const_string "false")) 780 (const_string "false"))
772 781
773 ;; Defines rounding mode of an FP operation. 782 ;; Defines rounding mode of an FP operation.
774 783
775 (define_attr "i387_cw" "trunc,floor,ceil,uninitialized,any" 784 (define_attr "i387_cw" "roundeven,floor,ceil,trunc,uninitialized,any"
776 (const_string "any")) 785 (const_string "any"))
786
787 ;; Define attribute to indicate AVX insns with partial XMM register update.
788 (define_attr "avx_partial_xmm_update" "false,true"
789 (const_string "false"))
777 790
778 ;; Define attribute to classify add/sub insns that consumes carry flag (CF) 791 ;; Define attribute to classify add/sub insns that consumes carry flag (CF)
779 (define_attr "use_carry" "0,1" (const_string "0")) 792 (define_attr "use_carry" "0,1" (const_string "0"))
780 793
781 ;; Define attribute to indicate unaligned ssemov insns 794 ;; Define attribute to indicate unaligned ssemov insns
782 (define_attr "movu" "0,1" (const_string "0")) 795 (define_attr "movu" "0,1" (const_string "0"))
783 796
784 ;; Used to control the "enabled" attribute on a per-instruction basis. 797 ;; Used to control the "enabled" attribute on a per-instruction basis.
785 (define_attr "isa" "base,x64,x64_sse2,x64_sse4,x64_sse4_noavx,x64_avx,nox64, 798 (define_attr "isa" "base,x64,x64_sse2,x64_sse4,x64_sse4_noavx,x64_avx,nox64,
786 sse2,sse2_noavx,sse3,sse4,sse4_noavx,avx,noavx, 799 sse_noavx,sse2,sse2_noavx,sse3,sse4,sse4_noavx,avx,noavx,
787 avx2,noavx2,bmi,bmi2,fma4,fma,avx512f,noavx512f, 800 avx2,noavx2,bmi,bmi2,fma4,fma,avx512f,noavx512f,
788 avx512bw,noavx512bw,avx512dq,noavx512dq, 801 avx512bw,noavx512bw,avx512dq,noavx512dq,
789 avx512vl,noavx512vl,x64_avx512dq,x64_avx512bw" 802 avx512vl,noavx512vl,x64_avx512dq,x64_avx512bw"
803 (const_string "base"))
804
805 ;; Define instruction set of MMX instructions
806 (define_attr "mmx_isa" "base,native,sse,sse_noavx,avx"
790 (const_string "base")) 807 (const_string "base"))
791 808
792 (define_attr "enabled" "" 809 (define_attr "enabled" ""
793 (cond [(eq_attr "isa" "x64") (symbol_ref "TARGET_64BIT") 810 (cond [(eq_attr "isa" "x64") (symbol_ref "TARGET_64BIT")
794 (eq_attr "isa" "x64_sse2") 811 (eq_attr "isa" "x64_sse2")
803 (symbol_ref "TARGET_64BIT && TARGET_AVX512DQ") 820 (symbol_ref "TARGET_64BIT && TARGET_AVX512DQ")
804 (eq_attr "isa" "x64_avx512bw") 821 (eq_attr "isa" "x64_avx512bw")
805 (symbol_ref "TARGET_64BIT && TARGET_AVX512BW") 822 (symbol_ref "TARGET_64BIT && TARGET_AVX512BW")
806 (eq_attr "isa" "nox64") (symbol_ref "!TARGET_64BIT") 823 (eq_attr "isa" "nox64") (symbol_ref "!TARGET_64BIT")
807 (eq_attr "isa" "sse2") (symbol_ref "TARGET_SSE2") 824 (eq_attr "isa" "sse2") (symbol_ref "TARGET_SSE2")
825 (eq_attr "isa" "sse_noavx")
826 (symbol_ref "TARGET_SSE && !TARGET_AVX")
808 (eq_attr "isa" "sse2_noavx") 827 (eq_attr "isa" "sse2_noavx")
809 (symbol_ref "TARGET_SSE2 && !TARGET_AVX") 828 (symbol_ref "TARGET_SSE2 && !TARGET_AVX")
810 (eq_attr "isa" "sse3") (symbol_ref "TARGET_SSE3") 829 (eq_attr "isa" "sse3") (symbol_ref "TARGET_SSE3")
811 (eq_attr "isa" "sse4") (symbol_ref "TARGET_SSE4_1") 830 (eq_attr "isa" "sse4") (symbol_ref "TARGET_SSE4_1")
812 (eq_attr "isa" "sse4_noavx") 831 (eq_attr "isa" "sse4_noavx")
825 (eq_attr "isa" "noavx512bw") (symbol_ref "!TARGET_AVX512BW") 844 (eq_attr "isa" "noavx512bw") (symbol_ref "!TARGET_AVX512BW")
826 (eq_attr "isa" "avx512dq") (symbol_ref "TARGET_AVX512DQ") 845 (eq_attr "isa" "avx512dq") (symbol_ref "TARGET_AVX512DQ")
827 (eq_attr "isa" "noavx512dq") (symbol_ref "!TARGET_AVX512DQ") 846 (eq_attr "isa" "noavx512dq") (symbol_ref "!TARGET_AVX512DQ")
828 (eq_attr "isa" "avx512vl") (symbol_ref "TARGET_AVX512VL") 847 (eq_attr "isa" "avx512vl") (symbol_ref "TARGET_AVX512VL")
829 (eq_attr "isa" "noavx512vl") (symbol_ref "!TARGET_AVX512VL") 848 (eq_attr "isa" "noavx512vl") (symbol_ref "!TARGET_AVX512VL")
849
850 (eq_attr "mmx_isa" "native")
851 (symbol_ref "!TARGET_MMX_WITH_SSE")
852 (eq_attr "mmx_isa" "sse")
853 (symbol_ref "TARGET_MMX_WITH_SSE")
854 (eq_attr "mmx_isa" "sse_noavx")
855 (symbol_ref "TARGET_MMX_WITH_SSE && !TARGET_AVX")
856 (eq_attr "mmx_isa" "avx")
857 (symbol_ref "TARGET_MMX_WITH_SSE && TARGET_AVX")
830 ] 858 ]
831 (const_int 1))) 859 (const_int 1)))
832 860
833 (define_attr "preferred_for_size" "" (const_int 1)) 861 (define_attr "preferred_for_size" "" (const_int 1))
834 (define_attr "preferred_for_speed" "" (const_int 1)) 862 (define_attr "preferred_for_speed" "" (const_int 1))
924 952
925 ;; Used in signed and unsigned widening multiplications. 953 ;; Used in signed and unsigned widening multiplications.
926 (define_code_iterator any_extend [sign_extend zero_extend]) 954 (define_code_iterator any_extend [sign_extend zero_extend])
927 955
928 ;; Prefix for insn menmonic. 956 ;; Prefix for insn menmonic.
929 (define_code_attr sgnprefix [(sign_extend "i") (zero_extend "")]) 957 (define_code_attr sgnprefix [(sign_extend "i") (zero_extend "")
930 958 (div "i") (udiv "")])
931 ;; Prefix for define_insn 959 ;; Prefix for define_insn
932 (define_code_attr u [(sign_extend "") (zero_extend "u")])
933 (define_code_attr s [(sign_extend "s") (zero_extend "u")]) 960 (define_code_attr s [(sign_extend "s") (zero_extend "u")])
934 (define_code_attr u_bool [(sign_extend "false") (zero_extend "true")]) 961 (define_code_attr u [(sign_extend "") (zero_extend "u")
962 (div "") (udiv "u")])
963 (define_code_attr u_bool [(sign_extend "false") (zero_extend "true")
964 (div "false") (udiv "true")])
935 965
936 ;; Used in signed and unsigned truncations. 966 ;; Used in signed and unsigned truncations.
937 (define_code_iterator any_truncate [ss_truncate truncate us_truncate]) 967 (define_code_iterator any_truncate [ss_truncate truncate us_truncate])
938 ;; Instruction suffix for truncations. 968 ;; Instruction suffix for truncations.
939 (define_code_attr trunsuffix [(ss_truncate "s") (truncate "") (us_truncate "us")]) 969 (define_code_attr trunsuffix [(ss_truncate "s") (truncate "") (us_truncate "us")])
990 ;; Math-dependant integer modes without DImode. 1020 ;; Math-dependant integer modes without DImode.
991 (define_mode_iterator SWIM124 [(QI "TARGET_QIMODE_MATH") 1021 (define_mode_iterator SWIM124 [(QI "TARGET_QIMODE_MATH")
992 (HI "TARGET_HIMODE_MATH") 1022 (HI "TARGET_HIMODE_MATH")
993 SI]) 1023 SI])
994 1024
995 ;; Math-dependant integer modes with DImode. 1025 ;; Math-dependant integer modes with DImode (enabled for 32bit with STV).
996 (define_mode_iterator SWIM1248x [(QI "TARGET_QIMODE_MATH") 1026 (define_mode_iterator SWIM1248s
997 (HI "TARGET_HIMODE_MATH") 1027 [(QI "TARGET_QIMODE_MATH")
998 SI (DI "(TARGET_STV && TARGET_SSE2) || TARGET_64BIT")]) 1028 (HI "TARGET_HIMODE_MATH")
1029 SI (DI "TARGET_64BIT || (TARGET_STV && TARGET_SSE2)")])
999 1030
1000 ;; Math-dependant single word integer modes without QImode. 1031 ;; Math-dependant single word integer modes without QImode.
1001 (define_mode_iterator SWIM248 [(HI "TARGET_HIMODE_MATH") 1032 (define_mode_iterator SWIM248 [(HI "TARGET_HIMODE_MATH")
1002 SI (DI "TARGET_64BIT")]) 1033 SI (DI "TARGET_64BIT")])
1003 1034
1004 ;; Double word integer modes. 1035 ;; Double word integer modes.
1005 (define_mode_iterator DWI [(DI "!TARGET_64BIT") 1036 (define_mode_iterator DWI [(DI "!TARGET_64BIT")
1006 (TI "TARGET_64BIT")]) 1037 (TI "TARGET_64BIT")])
1038
1039 ;; SWI and DWI together.
1040 (define_mode_iterator SWIDWI [QI HI SI DI (TI "TARGET_64BIT")])
1007 1041
1008 ;; GET_MODE_SIZE for selected modes. As GET_MODE_SIZE is not 1042 ;; GET_MODE_SIZE for selected modes. As GET_MODE_SIZE is not
1009 ;; compile time constant, it is faster to use <MODE_SIZE> than 1043 ;; compile time constant, it is faster to use <MODE_SIZE> than
1010 ;; GET_MODE_SIZE (<MODE>mode). For XFmode which depends on 1044 ;; GET_MODE_SIZE (<MODE>mode). For XFmode which depends on
1011 ;; command line options just use GET_MODE_SIZE macro. 1045 ;; command line options just use GET_MODE_SIZE macro.
1018 (V1TI "16") (V2TI "32") (V4TI "64") 1052 (V1TI "16") (V2TI "32") (V4TI "64")
1019 (V2DF "16") (V4DF "32") (V8DF "64") 1053 (V2DF "16") (V4DF "32") (V8DF "64")
1020 (V4SF "16") (V8SF "32") (V16SF "64")]) 1054 (V4SF "16") (V8SF "32") (V16SF "64")])
1021 1055
1022 ;; Double word integer modes as mode attribute. 1056 ;; Double word integer modes as mode attribute.
1023 (define_mode_attr DWI [(QI "HI") (HI "SI") (SI "DI") (DI "TI")]) 1057 (define_mode_attr DWI [(QI "HI") (HI "SI") (SI "DI") (DI "TI") (TI "OI")])
1024 (define_mode_attr dwi [(QI "hi") (HI "si") (SI "di") (DI "ti")]) 1058 (define_mode_attr dwi [(QI "hi") (HI "si") (SI "di") (DI "ti") (TI "oi")])
1025 1059
1026 ;; LEA mode corresponding to an integer mode 1060 ;; LEA mode corresponding to an integer mode
1027 (define_mode_attr LEAMODE [(QI "SI") (HI "SI") (SI "SI") (DI "DI")]) 1061 (define_mode_attr LEAMODE [(QI "SI") (HI "SI") (SI "SI") (DI "DI")])
1028 1062
1029 ;; Half mode for double word integer modes. 1063 ;; Half mode for double word integer modes.
1091 [(QI "general_operand") 1125 [(QI "general_operand")
1092 (HI "general_operand") 1126 (HI "general_operand")
1093 (SI "x86_64_szext_general_operand") 1127 (SI "x86_64_szext_general_operand")
1094 (DI "x86_64_szext_general_operand")]) 1128 (DI "x86_64_szext_general_operand")])
1095 1129
1130 (define_mode_attr nonmemory_szext_operand
1131 [(QI "nonmemory_operand")
1132 (HI "nonmemory_operand")
1133 (SI "x86_64_szext_nonmemory_operand")
1134 (DI "x86_64_szext_nonmemory_operand")])
1135
1096 ;; Immediate operand predicate for integer modes. 1136 ;; Immediate operand predicate for integer modes.
1097 (define_mode_attr immediate_operand 1137 (define_mode_attr immediate_operand
1098 [(QI "immediate_operand") 1138 [(QI "immediate_operand")
1099 (HI "immediate_operand") 1139 (HI "immediate_operand")
1100 (SI "x86_64_immediate_operand") 1140 (SI "x86_64_immediate_operand")
1133 ;; SSE and x87 SFmode and DFmode floating point modes 1173 ;; SSE and x87 SFmode and DFmode floating point modes
1134 (define_mode_iterator MODEF [SF DF]) 1174 (define_mode_iterator MODEF [SF DF])
1135 1175
1136 ;; All x87 floating point modes 1176 ;; All x87 floating point modes
1137 (define_mode_iterator X87MODEF [SF DF XF]) 1177 (define_mode_iterator X87MODEF [SF DF XF])
1178
1179 ;; All SSE floating point modes
1180 (define_mode_iterator SSEMODEF [SF DF TF])
1181 (define_mode_attr ssevecmodef [(SF "V4SF") (DF "V2DF") (TF "TF")])
1138 1182
1139 ;; SSE instruction suffix for various modes 1183 ;; SSE instruction suffix for various modes
1140 (define_mode_attr ssemodesuffix 1184 (define_mode_attr ssemodesuffix
1141 [(SF "ss") (DF "sd") 1185 [(SF "ss") (DF "sd")
1142 (V16SF "ps") (V8DF "pd") 1186 (V16SF "ps") (V8DF "pd")
1158 ;; AVX512F vector mode corresponding to a scalar mode 1202 ;; AVX512F vector mode corresponding to a scalar mode
1159 (define_mode_attr avx512fvecmode 1203 (define_mode_attr avx512fvecmode
1160 [(QI "V64QI") (HI "V32HI") (SI "V16SI") (DI "V8DI") (SF "V16SF") (DF "V8DF")]) 1204 [(QI "V64QI") (HI "V32HI") (SI "V16SI") (DI "V8DI") (SF "V16SF") (DF "V8DF")])
1161 1205
1162 ;; Instruction suffix for REX 64bit operators. 1206 ;; Instruction suffix for REX 64bit operators.
1163 (define_mode_attr rex64suffix [(SI "") (DI "{q}")]) 1207 (define_mode_attr rex64suffix [(SI "{l}") (DI "{q}")])
1164 (define_mode_attr rex64namesuffix [(SI "") (DI "q")]) 1208 (define_mode_attr rex64namesuffix [(SI "") (DI "q")])
1165 1209
1166 ;; This mode iterator allows :P to be used for patterns that operate on 1210 ;; This mode iterator allows :P to be used for patterns that operate on
1167 ;; pointer-sized quantities. Exactly one of the two alternatives will match. 1211 ;; pointer-sized quantities. Exactly one of the two alternatives will match.
1168 (define_mode_iterator P [(SI "Pmode == SImode") (DI "Pmode == DImode")]) 1212 (define_mode_iterator P [(SI "Pmode == SImode") (DI "Pmode == DImode")])
1235 ix86_expand_setcc (operands[0], GET_CODE (operands[1]), 1279 ix86_expand_setcc (operands[0], GET_CODE (operands[1]),
1236 operands[2], operands[3]); 1280 operands[2], operands[3]);
1237 DONE; 1281 DONE;
1238 }) 1282 })
1239 1283
1240 (define_expand "cmp<mode>_1" 1284 (define_expand "@cmp<mode>_1"
1241 [(set (reg:CC FLAGS_REG) 1285 [(set (reg:CC FLAGS_REG)
1242 (compare:CC (match_operand:SWI48 0 "nonimmediate_operand") 1286 (compare:CC (match_operand:SWI48 0 "nonimmediate_operand")
1243 (match_operand:SWI48 1 "<general_operand>")))]) 1287 (match_operand:SWI48 1 "<general_operand>")))])
1244 1288
1245 (define_mode_iterator SWI1248_AVX512BWDQ2_64 1289 (define_mode_iterator SWI1248_AVX512BWDQ_64
1246 [(QI "TARGET_AVX512DQ") (HI "TARGET_AVX512DQ") 1290 [(QI "TARGET_AVX512DQ") HI
1247 (SI "TARGET_AVX512BW") (DI "TARGET_AVX512BW && TARGET_64BIT")]) 1291 (SI "TARGET_AVX512BW") (DI "TARGET_AVX512BW && TARGET_64BIT")])
1248 1292
1249 (define_insn "*cmp<mode>_ccz_1" 1293 (define_insn "*cmp<mode>_ccz_1"
1250 [(set (reg FLAGS_REG) 1294 [(set (reg FLAGS_REG)
1251 (compare (match_operand:SWI1248_AVX512BWDQ2_64 0 1295 (compare (match_operand:SWI1248_AVX512BWDQ_64 0
1252 "nonimmediate_operand" "<r>,?m<r>,$k") 1296 "nonimmediate_operand" "<r>,?m<r>,$k")
1253 (match_operand:SWI1248_AVX512BWDQ2_64 1 "const0_operand")))] 1297 (match_operand:SWI1248_AVX512BWDQ_64 1 "const0_operand")))]
1254 "ix86_match_ccmode (insn, CCZmode)" 1298 "TARGET_AVX512F && ix86_match_ccmode (insn, CCZmode)"
1255 "@ 1299 "@
1256 test{<imodesuffix>}\t%0, %0 1300 test{<imodesuffix>}\t%0, %0
1257 cmp{<imodesuffix>}\t{%1, %0|%0, %1} 1301 cmp{<imodesuffix>}\t{%1, %0|%0, %1}
1258 ktest<mskmodesuffix>\t%0, %0" 1302 kortest<mskmodesuffix>\t%0, %0"
1259 [(set_attr "type" "test,icmp,msklog") 1303 [(set_attr "type" "test,icmp,msklog")
1260 (set_attr "length_immediate" "0,1,*") 1304 (set_attr "length_immediate" "0,1,*")
1261 (set_attr "prefix" "*,*,vex") 1305 (set_attr "prefix" "*,*,vex")
1262 (set_attr "mode" "<MODE>")]) 1306 (set_attr "mode" "<MODE>")])
1263 1307
1642 1686
1643 ;; Convert impossible pushes of immediate to existing instructions. 1687 ;; Convert impossible pushes of immediate to existing instructions.
1644 ;; First try to get scratch register and go through it. In case this 1688 ;; First try to get scratch register and go through it. In case this
1645 ;; fails, push sign extended lower part first and then overwrite 1689 ;; fails, push sign extended lower part first and then overwrite
1646 ;; upper part by 32bit move. 1690 ;; upper part by 32bit move.
1691
1647 (define_peephole2 1692 (define_peephole2
1648 [(match_scratch:DI 2 "r") 1693 [(match_scratch:DI 2 "r")
1649 (set (match_operand:DI 0 "push_operand") 1694 (set (match_operand:DI 0 "push_operand")
1650 (match_operand:DI 1 "immediate_operand"))] 1695 (match_operand:DI 1 "immediate_operand"))]
1651 "TARGET_64BIT && !symbolic_operand (operands[1], DImode) 1696 "TARGET_64BIT
1697 && !symbolic_operand (operands[1], DImode)
1652 && !x86_64_immediate_operand (operands[1], DImode)" 1698 && !x86_64_immediate_operand (operands[1], DImode)"
1653 [(set (match_dup 2) (match_dup 1)) 1699 [(set (match_dup 2) (match_dup 1))
1654 (set (match_dup 0) (match_dup 2))]) 1700 (set (match_dup 0) (match_dup 2))])
1655 1701
1656 ;; We need to define this as both peepholer and splitter for case
1657 ;; peephole2 pass is not run.
1658 ;; "&& 1" is needed to keep it from matching the previous pattern.
1659 (define_peephole2
1660 [(set (match_operand:DI 0 "push_operand")
1661 (match_operand:DI 1 "immediate_operand"))]
1662 "TARGET_64BIT && !symbolic_operand (operands[1], DImode)
1663 && !x86_64_immediate_operand (operands[1], DImode) && 1"
1664 [(set (match_dup 0) (match_dup 1))
1665 (set (match_dup 2) (match_dup 3))]
1666 {
1667 split_double_mode (DImode, &operands[1], 1, &operands[2], &operands[3]);
1668
1669 operands[1] = gen_lowpart (DImode, operands[2]);
1670 operands[2] = gen_rtx_MEM (SImode, gen_rtx_PLUS (Pmode, stack_pointer_rtx,
1671 GEN_INT (4)));
1672 })
1673
1674 (define_split 1702 (define_split
1675 [(set (match_operand:DI 0 "push_operand") 1703 [(set (match_operand:DI 0 "push_operand")
1676 (match_operand:DI 1 "immediate_operand"))] 1704 (match_operand:DI 1 "immediate_operand"))]
1677 "TARGET_64BIT && ((optimize > 0 && flag_peephole2) 1705 "TARGET_64BIT && epilogue_completed
1678 ? epilogue_completed : reload_completed)
1679 && !symbolic_operand (operands[1], DImode) 1706 && !symbolic_operand (operands[1], DImode)
1680 && !x86_64_immediate_operand (operands[1], DImode)" 1707 && !x86_64_immediate_operand (operands[1], DImode)"
1681 [(set (match_dup 0) (match_dup 1)) 1708 [(set (match_dup 0) (match_dup 1))
1682 (set (match_dup 2) (match_dup 3))] 1709 (set (match_dup 2) (match_dup 3))]
1683 { 1710 {
1903 1930
1904 case TYPE_SSEMOV: 1931 case TYPE_SSEMOV:
1905 if (misaligned_operand (operands[0], OImode) 1932 if (misaligned_operand (operands[0], OImode)
1906 || misaligned_operand (operands[1], OImode)) 1933 || misaligned_operand (operands[1], OImode))
1907 { 1934 {
1908 if (get_attr_mode (insn) == MODE_V8SF) 1935 if (get_attr_mode (insn) == MODE_XI)
1909 return "vmovups\t{%1, %0|%0, %1}";
1910 else if (get_attr_mode (insn) == MODE_XI)
1911 return "vmovdqu32\t{%1, %0|%0, %1}"; 1936 return "vmovdqu32\t{%1, %0|%0, %1}";
1912 else 1937 else
1913 return "vmovdqu\t{%1, %0|%0, %1}"; 1938 return "vmovdqu\t{%1, %0|%0, %1}";
1914 } 1939 }
1915 else 1940 else
1916 { 1941 {
1917 if (get_attr_mode (insn) == MODE_V8SF) 1942 if (get_attr_mode (insn) == MODE_XI)
1918 return "vmovaps\t{%1, %0|%0, %1}";
1919 else if (get_attr_mode (insn) == MODE_XI)
1920 return "vmovdqa32\t{%1, %0|%0, %1}"; 1943 return "vmovdqa32\t{%1, %0|%0, %1}";
1921 else 1944 else
1922 return "vmovdqa\t{%1, %0|%0, %1}"; 1945 return "vmovdqa\t{%1, %0|%0, %1}";
1923 } 1946 }
1924 1947
1934 (match_operand 1 "ext_sse_reg_operand")) 1957 (match_operand 1 "ext_sse_reg_operand"))
1935 (const_string "XI") 1958 (const_string "XI")
1936 (and (eq_attr "alternative" "1") 1959 (and (eq_attr "alternative" "1")
1937 (match_test "TARGET_AVX512VL")) 1960 (match_test "TARGET_AVX512VL"))
1938 (const_string "XI") 1961 (const_string "XI")
1939 (ior (match_test "TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL")
1940 (and (eq_attr "alternative" "3")
1941 (match_test "TARGET_SSE_TYPELESS_STORES")))
1942 (const_string "V8SF")
1943 ] 1962 ]
1944 (const_string "OI")))]) 1963 (const_string "OI")))])
1945 1964
1946 (define_insn "*movti_internal" 1965 (define_insn "*movti_internal"
1947 [(set (match_operand:TI 0 "nonimmediate_operand" "=!r ,o ,v,v ,v ,m,?r,?Yd") 1966 [(set (match_operand:TI 0 "nonimmediate_operand" "=!r ,o ,v,v ,v ,m,?r,?Yd")
2013 (match_operand 1 "ext_sse_reg_operand")) 2032 (match_operand 1 "ext_sse_reg_operand"))
2014 (const_string "XI") 2033 (const_string "XI")
2015 (and (eq_attr "alternative" "3") 2034 (and (eq_attr "alternative" "3")
2016 (match_test "TARGET_AVX512VL")) 2035 (match_test "TARGET_AVX512VL"))
2017 (const_string "XI") 2036 (const_string "XI")
2018 (ior (not (match_test "TARGET_SSE2"))
2019 (ior (match_test "TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL")
2020 (and (eq_attr "alternative" "5")
2021 (match_test "TARGET_SSE_TYPELESS_STORES"))))
2022 (const_string "V4SF")
2023 (match_test "TARGET_AVX") 2037 (match_test "TARGET_AVX")
2024 (const_string "TI") 2038 (const_string "TI")
2025 (match_test "optimize_function_for_size_p (cfun)") 2039 (ior (not (match_test "TARGET_SSE2"))
2040 (match_test "optimize_function_for_size_p (cfun)"))
2041 (const_string "V4SF")
2042 (and (eq_attr "alternative" "5")
2043 (match_test "TARGET_SSE_TYPELESS_STORES"))
2026 (const_string "V4SF") 2044 (const_string "V4SF")
2027 ] 2045 ]
2028 (const_string "TI"))) 2046 (const_string "TI")))
2029 (set (attr "preferred_for_speed") 2047 (set (attr "preferred_for_speed")
2030 (cond [(eq_attr "alternative" "6") 2048 (cond [(eq_attr "alternative" "6")
2052 gen_lowpart (DImode, operands[1])); 2070 gen_lowpart (DImode, operands[1]));
2053 }) 2071 })
2054 2072
2055 (define_insn "*movdi_internal" 2073 (define_insn "*movdi_internal"
2056 [(set (match_operand:DI 0 "nonimmediate_operand" 2074 [(set (match_operand:DI 0 "nonimmediate_operand"
2057 "=r ,o ,r,r ,r,m ,*y,*y,?*y,?m,?r,?*y,*v,*v,*v,m ,m,?r ,?*Yd,?r,?*v,?*y,?*x,*k,*k ,*r,*m") 2075 "=r ,o ,r,r ,r,m ,*y,*y,?*y,?m,?r,?*y,*v,*v,*v,m ,m,?r ,?*Yd,?r,?*v,?*y,?*x,*k,*k ,*r,*m,*k")
2058 (match_operand:DI 1 "general_operand" 2076 (match_operand:DI 1 "general_operand"
2059 "riFo,riF,Z,rem,i,re,C ,*y,m ,*y,*y,r ,C ,*v,m ,*v,v,*Yd,r ,*v,r ,*x ,*y ,*r,*km,*k,*k"))] 2077 "riFo,riF,Z,rem,i,re,C ,*y,m ,*y,*y,r ,C ,*v,m ,*v,v,*Yd,r ,*v,r ,*x ,*y ,*r,*km,*k,*k,CBC"))]
2060 "!(MEM_P (operands[0]) && MEM_P (operands[1]))" 2078 "!(MEM_P (operands[0]) && MEM_P (operands[1]))"
2061 { 2079 {
2062 switch (get_attr_type (insn)) 2080 switch (get_attr_type (insn))
2063 { 2081 {
2064 case TYPE_MSKMOV: 2082 case TYPE_MSKMOV:
2065 return "kmovq\t{%1, %0|%0, %1}"; 2083 return "kmovq\t{%1, %0|%0, %1}";
2084
2085 case TYPE_MSKLOG:
2086 if (operands[1] == const0_rtx)
2087 return "kxorq\t%0, %0, %0";
2088 else if (operands[1] == constm1_rtx)
2089 return "kxnorq\t%0, %0, %0";
2090 gcc_unreachable ();
2066 2091
2067 case TYPE_MULTI: 2092 case TYPE_MULTI:
2068 return "#"; 2093 return "#";
2069 2094
2070 case TYPE_MMX: 2095 case TYPE_MMX:
2155 (const_string "ssemov") 2180 (const_string "ssemov")
2156 (eq_attr "alternative" "21,22") 2181 (eq_attr "alternative" "21,22")
2157 (const_string "ssecvt") 2182 (const_string "ssecvt")
2158 (eq_attr "alternative" "23,24,25,26") 2183 (eq_attr "alternative" "23,24,25,26")
2159 (const_string "mskmov") 2184 (const_string "mskmov")
2185 (eq_attr "alternative" "27")
2186 (const_string "msklog")
2160 (and (match_operand 0 "register_operand") 2187 (and (match_operand 0 "register_operand")
2161 (match_operand 1 "pic_32bit_operand")) 2188 (match_operand 1 "pic_32bit_operand"))
2162 (const_string "lea") 2189 (const_string "lea")
2163 ] 2190 ]
2164 (const_string "imov"))) 2191 (const_string "imov")))
2190 (const_string "SI") 2217 (const_string "SI")
2191 (eq_attr "alternative" "12,13") 2218 (eq_attr "alternative" "12,13")
2192 (cond [(ior (match_operand 0 "ext_sse_reg_operand") 2219 (cond [(ior (match_operand 0 "ext_sse_reg_operand")
2193 (match_operand 1 "ext_sse_reg_operand")) 2220 (match_operand 1 "ext_sse_reg_operand"))
2194 (const_string "TI") 2221 (const_string "TI")
2195 (ior (not (match_test "TARGET_SSE2"))
2196 (match_test "TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL"))
2197 (const_string "V4SF")
2198 (match_test "TARGET_AVX") 2222 (match_test "TARGET_AVX")
2199 (const_string "TI") 2223 (const_string "TI")
2200 (match_test "optimize_function_for_size_p (cfun)") 2224 (ior (not (match_test "TARGET_SSE2"))
2225 (match_test "optimize_function_for_size_p (cfun)"))
2201 (const_string "V4SF") 2226 (const_string "V4SF")
2202 ] 2227 ]
2203 (const_string "TI")) 2228 (const_string "TI"))
2204 2229
2205 (and (eq_attr "alternative" "14,15,16") 2230 (and (eq_attr "alternative" "14,15,16")
2292 operands[2] = gen_int_mode (shift, QImode); 2317 operands[2] = gen_int_mode (shift, QImode);
2293 }) 2318 })
2294 2319
2295 (define_insn "*movsi_internal" 2320 (define_insn "*movsi_internal"
2296 [(set (match_operand:SI 0 "nonimmediate_operand" 2321 [(set (match_operand:SI 0 "nonimmediate_operand"
2297 "=r,m ,*y,*y,?*y,?m,?r,?*y,*v,*v,*v,m ,?r,?*v,*k,*k ,*rm") 2322 "=r,m ,*y,*y,?*y,?m,?r,?*y,*v,*v,*v,m ,?r,?*v,*k,*k ,*rm,*k")
2298 (match_operand:SI 1 "general_operand" 2323 (match_operand:SI 1 "general_operand"
2299 "g ,re,C ,*y,m ,*y,*y,r ,C ,*v,m ,*v,*v,r ,*r,*km,*k"))] 2324 "g ,re,C ,*y,m ,*y,*y,r ,C ,*v,m ,*v,*v,r ,*r,*km,*k ,CBC"))]
2300 "!(MEM_P (operands[0]) && MEM_P (operands[1]))" 2325 "!(MEM_P (operands[0]) && MEM_P (operands[1]))"
2301 { 2326 {
2302 switch (get_attr_type (insn)) 2327 switch (get_attr_type (insn))
2303 { 2328 {
2304 case TYPE_SSELOG1: 2329 case TYPE_SSELOG1:
2305 return standard_sse_constant_opcode (insn, operands); 2330 return standard_sse_constant_opcode (insn, operands);
2306 2331
2307 case TYPE_MSKMOV: 2332 case TYPE_MSKMOV:
2308 return "kmovd\t{%1, %0|%0, %1}"; 2333 return "kmovd\t{%1, %0|%0, %1}";
2334
2335 case TYPE_MSKLOG:
2336 if (operands[1] == const0_rtx)
2337 return "kxord\t%0, %0, %0";
2338 else if (operands[1] == constm1_rtx)
2339 return "kxnord\t%0, %0, %0";
2340 gcc_unreachable ();
2309 2341
2310 case TYPE_SSEMOV: 2342 case TYPE_SSEMOV:
2311 switch (get_attr_mode (insn)) 2343 switch (get_attr_mode (insn))
2312 { 2344 {
2313 case MODE_SI: 2345 case MODE_SI:
2371 (const_string "sselog1") 2403 (const_string "sselog1")
2372 (eq_attr "alternative" "9,10,11,12,13") 2404 (eq_attr "alternative" "9,10,11,12,13")
2373 (const_string "ssemov") 2405 (const_string "ssemov")
2374 (eq_attr "alternative" "14,15,16") 2406 (eq_attr "alternative" "14,15,16")
2375 (const_string "mskmov") 2407 (const_string "mskmov")
2408 (eq_attr "alternative" "17")
2409 (const_string "msklog")
2376 (and (match_operand 0 "register_operand") 2410 (and (match_operand 0 "register_operand")
2377 (match_operand 1 "pic_32bit_operand")) 2411 (match_operand 1 "pic_32bit_operand"))
2378 (const_string "lea") 2412 (const_string "lea")
2379 ] 2413 ]
2380 (const_string "imov"))) 2414 (const_string "imov")))
2391 (const_string "DI") 2425 (const_string "DI")
2392 (eq_attr "alternative" "8,9") 2426 (eq_attr "alternative" "8,9")
2393 (cond [(ior (match_operand 0 "ext_sse_reg_operand") 2427 (cond [(ior (match_operand 0 "ext_sse_reg_operand")
2394 (match_operand 1 "ext_sse_reg_operand")) 2428 (match_operand 1 "ext_sse_reg_operand"))
2395 (const_string "XI") 2429 (const_string "XI")
2396 (ior (not (match_test "TARGET_SSE2"))
2397 (match_test "TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL"))
2398 (const_string "V4SF")
2399 (match_test "TARGET_AVX") 2430 (match_test "TARGET_AVX")
2400 (const_string "TI") 2431 (const_string "TI")
2401 (match_test "optimize_function_for_size_p (cfun)") 2432 (ior (not (match_test "TARGET_SSE2"))
2433 (match_test "optimize_function_for_size_p (cfun)"))
2402 (const_string "V4SF") 2434 (const_string "V4SF")
2403 ] 2435 ]
2404 (const_string "TI")) 2436 (const_string "TI"))
2405 2437
2406 (and (eq_attr "alternative" "10,11") 2438 (and (eq_attr "alternative" "10,11")
2415 (symbol_ref "TARGET_INTER_UNIT_MOVES_TO_VEC") 2447 (symbol_ref "TARGET_INTER_UNIT_MOVES_TO_VEC")
2416 ] 2448 ]
2417 (symbol_ref "true")))]) 2449 (symbol_ref "true")))])
2418 2450
2419 (define_insn "*movhi_internal" 2451 (define_insn "*movhi_internal"
2420 [(set (match_operand:HI 0 "nonimmediate_operand" "=r,r ,r ,m ,k,k ,r,m") 2452 [(set (match_operand:HI 0 "nonimmediate_operand" "=r,r ,r ,m ,k,k ,r,m,k")
2421 (match_operand:HI 1 "general_operand" "r ,rn,rm,rn,r,km,k,k"))] 2453 (match_operand:HI 1 "general_operand" "r ,rn,rm,rn,r,km,k,k,CBC"))]
2422 "!(MEM_P (operands[0]) && MEM_P (operands[1]))" 2454 "!(MEM_P (operands[0]) && MEM_P (operands[1]))"
2423 { 2455 {
2424 switch (get_attr_type (insn)) 2456 switch (get_attr_type (insn))
2425 { 2457 {
2426 case TYPE_IMOVX: 2458 case TYPE_IMOVX:
2440 return "kmovw\t{%1, %0|%0, %1}"; 2472 return "kmovw\t{%1, %0|%0, %1}";
2441 default: 2473 default:
2442 gcc_unreachable (); 2474 gcc_unreachable ();
2443 } 2475 }
2444 2476
2477 case TYPE_MSKLOG:
2478 if (operands[1] == const0_rtx)
2479 return "kxorw\t%0, %0, %0";
2480 else if (operands[1] == constm1_rtx)
2481 return "kxnorw\t%0, %0, %0";
2482 gcc_unreachable ();
2483
2445 default: 2484 default:
2446 if (get_attr_mode (insn) == MODE_SI) 2485 if (get_attr_mode (insn) == MODE_SI)
2447 return "mov{l}\t{%k1, %k0|%k0, %k1}"; 2486 return "mov{l}\t{%k1, %k0|%k0, %k1}";
2448 else 2487 else
2449 return "mov{w}\t{%1, %0|%0, %1}"; 2488 return "mov{w}\t{%1, %0|%0, %1}";
2450 } 2489 }
2451 } 2490 }
2452 [(set (attr "type") 2491 [(set (attr "type")
2453 (cond [(eq_attr "alternative" "4,5,6,7") 2492 (cond [(eq_attr "alternative" "4,5,6,7")
2454 (const_string "mskmov") 2493 (const_string "mskmov")
2494 (eq_attr "alternative" "8")
2495 (const_string "msklog")
2455 (match_test "optimize_function_for_size_p (cfun)") 2496 (match_test "optimize_function_for_size_p (cfun)")
2456 (const_string "imov") 2497 (const_string "imov")
2457 (and (eq_attr "alternative" "0") 2498 (and (eq_attr "alternative" "0")
2458 (ior (not (match_test "TARGET_PARTIAL_REG_STALL")) 2499 (ior (not (match_test "TARGET_PARTIAL_REG_STALL"))
2459 (not (match_test "TARGET_HIMODE_MATH")))) 2500 (not (match_test "TARGET_HIMODE_MATH"))))
2465 (eq_attr "alternative" "0,2")) 2506 (eq_attr "alternative" "0,2"))
2466 (const_string "imovx") 2507 (const_string "imovx")
2467 ] 2508 ]
2468 (const_string "imov"))) 2509 (const_string "imov")))
2469 (set (attr "prefix") 2510 (set (attr "prefix")
2470 (if_then_else (eq_attr "alternative" "4,5,6,7") 2511 (if_then_else (eq_attr "alternative" "4,5,6,7,8")
2471 (const_string "vex") 2512 (const_string "vex")
2472 (const_string "orig"))) 2513 (const_string "orig")))
2473 (set (attr "mode") 2514 (set (attr "mode")
2474 (cond [(eq_attr "type" "imovx") 2515 (cond [(eq_attr "type" "imovx")
2475 (const_string "SI") 2516 (const_string "SI")
2494 ;; register stall machines with, where we use QImode instructions, since 2535 ;; register stall machines with, where we use QImode instructions, since
2495 ;; partial register stall can be caused there. Then we use movzx. 2536 ;; partial register stall can be caused there. Then we use movzx.
2496 2537
2497 (define_insn "*movqi_internal" 2538 (define_insn "*movqi_internal"
2498 [(set (match_operand:QI 0 "nonimmediate_operand" 2539 [(set (match_operand:QI 0 "nonimmediate_operand"
2499 "=Q,R,r,q,q,r,r ,?r,m ,k,k,r,m,k") 2540 "=Q,R,r,q,q,r,r ,?r,m ,k,k,r,m,k,k,k")
2500 (match_operand:QI 1 "general_operand" 2541 (match_operand:QI 1 "general_operand"
2501 "Q ,R,r,n,m,q,rn, m,qn,r,k,k,k,m"))] 2542 "Q ,R,r,n,m,q,rn, m,qn,r,k,k,k,m,C,BC"))]
2502 "!(MEM_P (operands[0]) && MEM_P (operands[1]))" 2543 "!(MEM_P (operands[0]) && MEM_P (operands[1]))"
2503 { 2544 {
2504 static char buf[128]; 2545 char buf[128];
2505 const char *ops; 2546 const char *ops;
2506 const char *suffix; 2547 const char *suffix;
2507 2548
2508 switch (get_attr_type (insn)) 2549 switch (get_attr_type (insn))
2509 { 2550 {
2532 } 2573 }
2533 2574
2534 suffix = (get_attr_mode (insn) == MODE_HI) ? "w" : "b"; 2575 suffix = (get_attr_mode (insn) == MODE_HI) ? "w" : "b";
2535 2576
2536 snprintf (buf, sizeof (buf), ops, suffix); 2577 snprintf (buf, sizeof (buf), ops, suffix);
2537 return buf; 2578 output_asm_insn (buf, operands);
2579 return "";
2580
2581 case TYPE_MSKLOG:
2582 if (operands[1] == const0_rtx)
2583 {
2584 if (get_attr_mode (insn) == MODE_HI)
2585 return "kxorw\t%0, %0, %0";
2586 else
2587 return "kxorb\t%0, %0, %0";
2588 }
2589 else if (operands[1] == constm1_rtx)
2590 {
2591 gcc_assert (TARGET_AVX512DQ);
2592 return "kxnorb\t%0, %0, %0";
2593 }
2594 gcc_unreachable ();
2538 2595
2539 default: 2596 default:
2540 if (get_attr_mode (insn) == MODE_SI) 2597 if (get_attr_mode (insn) == MODE_SI)
2541 return "mov{l}\t{%k1, %k0|%k0, %k1}"; 2598 return "mov{l}\t{%k1, %k0|%k0, %k1}";
2542 else 2599 else
2544 } 2601 }
2545 } 2602 }
2546 [(set (attr "isa") 2603 [(set (attr "isa")
2547 (cond [(eq_attr "alternative" "1,2") 2604 (cond [(eq_attr "alternative" "1,2")
2548 (const_string "x64") 2605 (const_string "x64")
2549 (eq_attr "alternative" "12,13") 2606 (eq_attr "alternative" "12,13,15")
2550 (const_string "avx512dq") 2607 (const_string "avx512dq")
2551 ] 2608 ]
2552 (const_string "*"))) 2609 (const_string "*")))
2553 (set (attr "type") 2610 (set (attr "type")
2554 (cond [(eq_attr "alternative" "9,10,11,12,13") 2611 (cond [(eq_attr "alternative" "9,10,11,12,13")
2555 (const_string "mskmov") 2612 (const_string "mskmov")
2613 (eq_attr "alternative" "14,15")
2614 (const_string "msklog")
2556 (and (eq_attr "alternative" "7") 2615 (and (eq_attr "alternative" "7")
2557 (not (match_operand:QI 1 "aligned_operand"))) 2616 (not (match_operand:QI 1 "aligned_operand")))
2558 (const_string "imovx") 2617 (const_string "imovx")
2559 (match_test "optimize_function_for_size_p (cfun)") 2618 (match_test "optimize_function_for_size_p (cfun)")
2560 (const_string "imov") 2619 (const_string "imov")
2568 (eq_attr "alternative" "4")) 2627 (eq_attr "alternative" "4"))
2569 (const_string "imovx") 2628 (const_string "imovx")
2570 ] 2629 ]
2571 (const_string "imov"))) 2630 (const_string "imov")))
2572 (set (attr "prefix") 2631 (set (attr "prefix")
2573 (if_then_else (eq_attr "alternative" "9,10,11") 2632 (if_then_else (eq_attr "alternative" "9,10,11,12,13,14,15")
2574 (const_string "vex") 2633 (const_string "vex")
2575 (const_string "orig"))) 2634 (const_string "orig")))
2576 (set (attr "mode") 2635 (set (attr "mode")
2577 (cond [(eq_attr "alternative" "5,6,7") 2636 (cond [(eq_attr "alternative" "5,6,7")
2578 (const_string "SI") 2637 (const_string "SI")
2579 (eq_attr "alternative" "8") 2638 (eq_attr "alternative" "8")
2580 (const_string "QI") 2639 (const_string "QI")
2581 (and (eq_attr "alternative" "9,10,11") 2640 (and (eq_attr "alternative" "9,10,11,14")
2582 (not (match_test "TARGET_AVX512DQ"))) 2641 (not (match_test "TARGET_AVX512DQ")))
2583 (const_string "HI") 2642 (const_string "HI")
2584 (eq_attr "type" "imovx") 2643 (eq_attr "type" "imovx")
2585 (const_string "SI") 2644 (const_string "SI")
2586 ;; For -Os, 8-bit immediates are always shorter than 32-bit 2645 ;; For -Os, 8-bit immediates are always shorter than 32-bit
2699 (set_attr "pent_pair" "np") 2758 (set_attr "pent_pair" "np")
2700 (set_attr "athlon_decode" "vector") 2759 (set_attr "athlon_decode" "vector")
2701 (set_attr "amdfam10_decode" "double") 2760 (set_attr "amdfam10_decode" "double")
2702 (set_attr "bdver1_decode" "double")]) 2761 (set_attr "bdver1_decode" "double")])
2703 2762
2763 (define_peephole2
2764 [(set (match_operand:SWI 0 "general_reg_operand")
2765 (match_operand:SWI 1 "general_reg_operand"))
2766 (set (match_dup 1)
2767 (match_operand:SWI 2 "general_reg_operand"))
2768 (set (match_dup 2) (match_dup 0))]
2769 "peep2_reg_dead_p (3, operands[0])
2770 && optimize_insn_for_size_p ()"
2771 [(parallel [(set (match_dup 1) (match_dup 2))
2772 (set (match_dup 2) (match_dup 1))])])
2773
2704 (define_expand "movstrict<mode>" 2774 (define_expand "movstrict<mode>"
2705 [(set (strict_low_part (match_operand:SWI12 0 "nonimmediate_operand")) 2775 [(set (strict_low_part (match_operand:SWI12 0 "register_operand"))
2706 (match_operand:SWI12 1 "general_operand"))] 2776 (match_operand:SWI12 1 "general_operand"))]
2707 "" 2777 ""
2708 { 2778 {
2709 if (TARGET_PARTIAL_REG_STALL && optimize_function_for_speed_p (cfun)) 2779 gcc_assert (SUBREG_P (operands[0]));
2780 if ((TARGET_PARTIAL_REG_STALL && optimize_function_for_speed_p (cfun))
2781 || GET_MODE_CLASS (GET_MODE (SUBREG_REG (operands[0]))) != MODE_INT)
2710 FAIL; 2782 FAIL;
2711 if (SUBREG_P (operands[0])
2712 && GET_MODE_CLASS (GET_MODE (SUBREG_REG (operands[0]))) != MODE_INT)
2713 FAIL;
2714 /* Don't generate memory->memory moves, go through a register */
2715 if (MEM_P (operands[0]) && MEM_P (operands[1]))
2716 operands[1] = force_reg (<MODE>mode, operands[1]);
2717 }) 2783 })
2718 2784
2719 (define_insn "*movstrict<mode>_1" 2785 (define_insn "*movstrict<mode>_1"
2720 [(set (strict_low_part 2786 [(set (strict_low_part
2721 (match_operand:SWI12 0 "nonimmediate_operand" "+<r>m,<r>")) 2787 (match_operand:SWI12 0 "register_operand" "+<r>"))
2722 (match_operand:SWI12 1 "general_operand" "<r>n,m"))] 2788 (match_operand:SWI12 1 "general_operand" "<r>mn"))]
2723 "(!TARGET_PARTIAL_REG_STALL || optimize_function_for_size_p (cfun)) 2789 "!TARGET_PARTIAL_REG_STALL || optimize_function_for_size_p (cfun)"
2724 && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
2725 "mov{<imodesuffix>}\t{%1, %0|%0, %1}" 2790 "mov{<imodesuffix>}\t{%1, %0|%0, %1}"
2726 [(set_attr "type" "imov") 2791 [(set_attr "type" "imov")
2727 (set_attr "mode" "<MODE>")]) 2792 (set_attr "mode" "<MODE>")])
2728 2793
2729 (define_insn "*movstrict<mode>_xor" 2794 (define_insn "*movstrict<mode>_xor"
2965 [(set (match_operand:TF 0 "push_operand" "=<,<") 3030 [(set (match_operand:TF 0 "push_operand" "=<,<")
2966 (match_operand:TF 1 "general_no_elim_operand" "v,*roC"))] 3031 (match_operand:TF 1 "general_no_elim_operand" "v,*roC"))]
2967 "TARGET_64BIT || TARGET_SSE" 3032 "TARGET_64BIT || TARGET_SSE"
2968 { 3033 {
2969 /* This insn should be already split before reg-stack. */ 3034 /* This insn should be already split before reg-stack. */
2970 gcc_unreachable (); 3035 return "#";
2971 } 3036 }
2972 [(set_attr "isa" "*,x64") 3037 [(set_attr "isa" "*,x64")
2973 (set_attr "type" "multi") 3038 (set_attr "type" "multi")
2974 (set_attr "unit" "sse,*") 3039 (set_attr "unit" "sse,*")
2975 (set_attr "mode" "TF,DI")]) 3040 (set_attr "mode" "TF,DI")])
3020 [(set (match_operand:XF 0 "push_operand" "=<,<,<,<,<") 3085 [(set (match_operand:XF 0 "push_operand" "=<,<,<,<,<")
3021 (match_operand:XF 1 "general_no_elim_operand" "f,r,*r,oF,oC"))] 3086 (match_operand:XF 1 "general_no_elim_operand" "f,r,*r,oF,oC"))]
3022 "" 3087 ""
3023 { 3088 {
3024 /* This insn should be already split before reg-stack. */ 3089 /* This insn should be already split before reg-stack. */
3025 gcc_unreachable (); 3090 return "#";
3026 } 3091 }
3027 [(set_attr "isa" "*,*,*,nox64,x64") 3092 [(set_attr "isa" "*,*,*,nox64,x64")
3028 (set_attr "type" "multi") 3093 (set_attr "type" "multi")
3029 (set_attr "unit" "i387,*,*,*,*") 3094 (set_attr "unit" "i387,*,*,*,*")
3030 (set (attr "mode") 3095 (set (attr "mode")
3056 [(set (match_operand:DF 0 "push_operand" "=<,<,<,<,<,<") 3121 [(set (match_operand:DF 0 "push_operand" "=<,<,<,<,<,<")
3057 (match_operand:DF 1 "general_no_elim_operand" "f,r,*r,oF,rmC,x"))] 3122 (match_operand:DF 1 "general_no_elim_operand" "f,r,*r,oF,rmC,x"))]
3058 "" 3123 ""
3059 { 3124 {
3060 /* This insn should be already split before reg-stack. */ 3125 /* This insn should be already split before reg-stack. */
3061 gcc_unreachable (); 3126 return "#";
3062 } 3127 }
3063 [(set_attr "isa" "*,nox64,nox64,nox64,x64,sse2") 3128 [(set_attr "isa" "*,nox64,nox64,nox64,x64,sse2")
3064 (set_attr "type" "multi") 3129 (set_attr "type" "multi")
3065 (set_attr "unit" "i387,*,*,*,*,sse") 3130 (set_attr "unit" "i387,*,*,*,*,sse")
3066 (set_attr "mode" "DF,SI,SI,SI,DI,DF") 3131 (set_attr "mode" "DF,SI,SI,SI,DI,DF")
3089 [(set (match_operand:SF 0 "push_operand" "=X,X,X") 3154 [(set (match_operand:SF 0 "push_operand" "=X,X,X")
3090 (match_operand:SF 1 "nonmemory_no_elim_operand" "f,rF,x"))] 3155 (match_operand:SF 1 "nonmemory_no_elim_operand" "f,rF,x"))]
3091 "TARGET_64BIT" 3156 "TARGET_64BIT"
3092 { 3157 {
3093 /* Anything else should be already split before reg-stack. */ 3158 /* Anything else should be already split before reg-stack. */
3094 gcc_assert (which_alternative == 1); 3159 if (which_alternative != 1)
3160 return "#";
3095 return "push{q}\t%q1"; 3161 return "push{q}\t%q1";
3096 } 3162 }
3097 [(set_attr "type" "multi,push,multi") 3163 [(set_attr "type" "multi,push,multi")
3098 (set_attr "unit" "i387,*,*") 3164 (set_attr "unit" "i387,*,*")
3099 (set_attr "mode" "SF,DI,SF")]) 3165 (set_attr "mode" "SF,DI,SF")])
3102 [(set (match_operand:SF 0 "push_operand" "=<,<,<") 3168 [(set (match_operand:SF 0 "push_operand" "=<,<,<")
3103 (match_operand:SF 1 "general_no_elim_operand" "f,rmF,x"))] 3169 (match_operand:SF 1 "general_no_elim_operand" "f,rmF,x"))]
3104 "!TARGET_64BIT" 3170 "!TARGET_64BIT"
3105 { 3171 {
3106 /* Anything else should be already split before reg-stack. */ 3172 /* Anything else should be already split before reg-stack. */
3107 gcc_assert (which_alternative == 1); 3173 if (which_alternative != 1)
3174 return "#";
3108 return "push{l}\t%1"; 3175 return "push{l}\t%1";
3109 } 3176 }
3110 [(set_attr "type" "multi,push,multi") 3177 [(set_attr "type" "multi,push,multi")
3111 (set_attr "unit" "i387,*,*") 3178 (set_attr "unit" "i387,*,*")
3112 (set_attr "mode" "SF,SI,SF")]) 3179 (set_attr "mode" "SF,SI,SF")])
3227 (const_string "maybe_vex") 3294 (const_string "maybe_vex")
3228 (const_string "orig"))) 3295 (const_string "orig")))
3229 (set (attr "mode") 3296 (set (attr "mode")
3230 (cond [(eq_attr "alternative" "3,4") 3297 (cond [(eq_attr "alternative" "3,4")
3231 (const_string "DI") 3298 (const_string "DI")
3299 (match_test "TARGET_AVX")
3300 (const_string "TI")
3301 (ior (not (match_test "TARGET_SSE2"))
3302 (match_test "optimize_function_for_size_p (cfun)"))
3303 (const_string "V4SF")
3232 (match_test "TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL") 3304 (match_test "TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL")
3233 (const_string "V4SF") 3305 (const_string "V4SF")
3234 (and (eq_attr "alternative" "2") 3306 (and (eq_attr "alternative" "2")
3235 (match_test "TARGET_SSE_TYPELESS_STORES")) 3307 (match_test "TARGET_SSE_TYPELESS_STORES"))
3236 (const_string "V4SF")
3237 (match_test "TARGET_AVX")
3238 (const_string "TI")
3239 (ior (not (match_test "TARGET_SSE2"))
3240 (match_test "optimize_function_for_size_p (cfun)"))
3241 (const_string "V4SF") 3308 (const_string "V4SF")
3242 ] 3309 ]
3243 (const_string "TI")))]) 3310 (const_string "TI")))])
3244 3311
3245 (define_split 3312 (define_split
3446 (eq_attr "alternative" "8,9,11,20,21,24,25") 3513 (eq_attr "alternative" "8,9,11,20,21,24,25")
3447 (const_string "DI") 3514 (const_string "DI")
3448 3515
3449 /* xorps is one byte shorter for non-AVX targets. */ 3516 /* xorps is one byte shorter for non-AVX targets. */
3450 (eq_attr "alternative" "12,16") 3517 (eq_attr "alternative" "12,16")
3451 (cond [(not (match_test "TARGET_SSE2")) 3518 (cond [(and (match_test "TARGET_AVX512F")
3452 (const_string "V4SF") 3519 (not (match_test "TARGET_PREFER_AVX256")))
3453 (and (match_test "TARGET_AVX512F")
3454 (not (match_test "TARGET_PREFER_AVX256")))
3455 (const_string "XI") 3520 (const_string "XI")
3456 (match_test "TARGET_AVX") 3521 (match_test "TARGET_AVX")
3457 (const_string "V2DF") 3522 (const_string "V2DF")
3458 (match_test "optimize_function_for_size_p (cfun)") 3523 (ior (not (match_test "TARGET_SSE2"))
3524 (match_test "optimize_function_for_size_p (cfun)"))
3459 (const_string "V4SF") 3525 (const_string "V4SF")
3460 (match_test "TARGET_SSE_LOAD0_BY_PXOR") 3526 (match_test "TARGET_SSE_LOAD0_BY_PXOR")
3461 (const_string "TI") 3527 (const_string "TI")
3462 ] 3528 ]
3463 (const_string "V2DF")) 3529 (const_string "V2DF"))
3471 (cond [(and (ior (not (match_test "TARGET_PREFER_AVX256")) 3537 (cond [(and (ior (not (match_test "TARGET_PREFER_AVX256"))
3472 (not (match_test "TARGET_AVX512VL"))) 3538 (not (match_test "TARGET_AVX512VL")))
3473 (ior (match_operand 0 "ext_sse_reg_operand") 3539 (ior (match_operand 0 "ext_sse_reg_operand")
3474 (match_operand 1 "ext_sse_reg_operand"))) 3540 (match_operand 1 "ext_sse_reg_operand")))
3475 (const_string "V8DF") 3541 (const_string "V8DF")
3542 (match_test "TARGET_AVX")
3543 (const_string "DF")
3476 (ior (not (match_test "TARGET_SSE2")) 3544 (ior (not (match_test "TARGET_SSE2"))
3477 (match_test "TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL")) 3545 (match_test "optimize_function_for_size_p (cfun)"))
3546 (const_string "V4SF")
3547 (match_test "TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL")
3478 (const_string "V4SF") 3548 (const_string "V4SF")
3479 (match_test "TARGET_SSE_PARTIAL_REG_DEPENDENCY") 3549 (match_test "TARGET_SSE_PARTIAL_REG_DEPENDENCY")
3480 (const_string "V2DF") 3550 (const_string "V2DF")
3481 (match_test "TARGET_AVX")
3482 (const_string "DF")
3483 (match_test "optimize_function_for_size_p (cfun)")
3484 (const_string "V4SF")
3485 ] 3551 ]
3486 (const_string "DF")) 3552 (const_string "DF"))
3487 3553
3488 /* For architectures resolving dependencies on register 3554 /* For architectures resolving dependencies on register
3489 parts we may avoid extra work to zero out upper part 3555 parts we may avoid extra work to zero out upper part
3599 default: 3665 default:
3600 gcc_unreachable (); 3666 gcc_unreachable ();
3601 } 3667 }
3602 } 3668 }
3603 [(set (attr "isa") 3669 [(set (attr "isa")
3604 (cond [(eq_attr "alternative" "14,15") 3670 (cond [(eq_attr "alternative" "9,10")
3605 (const_string "sse2") 3671 (const_string "sse2")
3606 ] 3672 ]
3607 (const_string "*"))) 3673 (const_string "*")))
3608 (set (attr "type") 3674 (set (attr "type")
3609 (cond [(eq_attr "alternative" "0,1,2") 3675 (cond [(eq_attr "alternative" "0,1,2")
3628 (cond [(eq_attr "alternative" "3,4,9,10,12,13,14,15,16,17") 3694 (cond [(eq_attr "alternative" "3,4,9,10,12,13,14,15,16,17")
3629 (const_string "SI") 3695 (const_string "SI")
3630 (eq_attr "alternative" "11") 3696 (eq_attr "alternative" "11")
3631 (const_string "DI") 3697 (const_string "DI")
3632 (eq_attr "alternative" "5") 3698 (eq_attr "alternative" "5")
3633 (cond [(not (match_test "TARGET_SSE2")) 3699 (cond [(and (match_test "TARGET_AVX512F")
3634 (const_string "V4SF") 3700 (not (match_test "TARGET_PREFER_AVX256")))
3635 (and (match_test "TARGET_AVX512F")
3636 (not (match_test "TARGET_PREFER_AVX256")))
3637 (const_string "V16SF") 3701 (const_string "V16SF")
3638 (match_test "TARGET_AVX") 3702 (match_test "TARGET_AVX")
3639 (const_string "V4SF") 3703 (const_string "V4SF")
3640 (match_test "optimize_function_for_size_p (cfun)") 3704 (ior (not (match_test "TARGET_SSE2"))
3705 (match_test "optimize_function_for_size_p (cfun)"))
3641 (const_string "V4SF") 3706 (const_string "V4SF")
3642 (match_test "TARGET_SSE_LOAD0_BY_PXOR") 3707 (match_test "TARGET_SSE_LOAD0_BY_PXOR")
3643 (const_string "TI") 3708 (const_string "TI")
3644 ] 3709 ]
3645 (const_string "V4SF")) 3710 (const_string "V4SF"))
3646 3711
3647 /* For architectures resolving dependencies on 3712 /* For architectures resolving dependencies on
3747 [(set (match_operand:DI 0 "nonimmediate_operand") 3812 [(set (match_operand:DI 0 "nonimmediate_operand")
3748 (zero_extend:DI (match_operand:SI 1 "nonimmediate_operand")))]) 3813 (zero_extend:DI (match_operand:SI 1 "nonimmediate_operand")))])
3749 3814
3750 (define_insn "*zero_extendsidi2" 3815 (define_insn "*zero_extendsidi2"
3751 [(set (match_operand:DI 0 "nonimmediate_operand" 3816 [(set (match_operand:DI 0 "nonimmediate_operand"
3752 "=r,?r,?o,r ,o,?*y,?!*y,$r,$v,$x,*x,*v,*r") 3817 "=r,?r,?o,r ,o,?*y,?!*y,$r,$v,$x,*x,*v,*r,*k")
3753 (zero_extend:DI 3818 (zero_extend:DI
3754 (match_operand:SI 1 "x86_64_zext_operand" 3819 (match_operand:SI 1 "x86_64_zext_operand"
3755 "0 ,rm,r ,rmWz,0,r ,m ,v ,r ,m ,*x,*v,*k")))] 3820 "0 ,rm,r ,rmWz,0,r ,m ,v ,r ,m ,*x,*v,*k,*km")))]
3756 "" 3821 ""
3757 { 3822 {
3758 switch (get_attr_type (insn)) 3823 switch (get_attr_type (insn))
3759 { 3824 {
3760 case TYPE_IMOVX: 3825 case TYPE_IMOVX:
3802 (const_string "sse4") 3867 (const_string "sse4")
3803 (eq_attr "alternative" "11") 3868 (eq_attr "alternative" "11")
3804 (const_string "avx512f") 3869 (const_string "avx512f")
3805 (eq_attr "alternative" "12") 3870 (eq_attr "alternative" "12")
3806 (const_string "x64_avx512bw") 3871 (const_string "x64_avx512bw")
3872 (eq_attr "alternative" "13")
3873 (const_string "avx512bw")
3807 ] 3874 ]
3808 (const_string "*"))) 3875 (const_string "*")))
3876 (set (attr "mmx_isa")
3877 (if_then_else (eq_attr "alternative" "5,6")
3878 (const_string "native")
3879 (const_string "*")))
3809 (set (attr "type") 3880 (set (attr "type")
3810 (cond [(eq_attr "alternative" "0,1,2,4") 3881 (cond [(eq_attr "alternative" "0,1,2,4")
3811 (const_string "multi") 3882 (const_string "multi")
3812 (eq_attr "alternative" "5,6") 3883 (eq_attr "alternative" "5,6")
3813 (const_string "mmxmov") 3884 (const_string "mmxmov")
3815 (if_then_else (match_test "TARGET_64BIT") 3886 (if_then_else (match_test "TARGET_64BIT")
3816 (const_string "ssemov") 3887 (const_string "ssemov")
3817 (const_string "multi")) 3888 (const_string "multi"))
3818 (eq_attr "alternative" "8,9,10,11") 3889 (eq_attr "alternative" "8,9,10,11")
3819 (const_string "ssemov") 3890 (const_string "ssemov")
3820 (eq_attr "alternative" "12") 3891 (eq_attr "alternative" "12,13")
3821 (const_string "mskmov") 3892 (const_string "mskmov")
3822 ] 3893 ]
3823 (const_string "imovx"))) 3894 (const_string "imovx")))
3824 (set (attr "prefix_extra") 3895 (set (attr "prefix_extra")
3825 (if_then_else (eq_attr "alternative" "10,11") 3896 (if_then_else (eq_attr "alternative" "10,11")
3877 3948
3878 (define_mode_attr kmov_isa 3949 (define_mode_attr kmov_isa
3879 [(QI "avx512dq") (HI "avx512f") (SI "avx512bw") (DI "avx512bw")]) 3950 [(QI "avx512dq") (HI "avx512f") (SI "avx512bw") (DI "avx512bw")])
3880 3951
3881 (define_insn "zero_extend<mode>di2" 3952 (define_insn "zero_extend<mode>di2"
3882 [(set (match_operand:DI 0 "register_operand" "=r,*r") 3953 [(set (match_operand:DI 0 "register_operand" "=r,*r,*k")
3883 (zero_extend:DI 3954 (zero_extend:DI
3884 (match_operand:SWI12 1 "nonimmediate_operand" "<r>m,*k")))] 3955 (match_operand:SWI12 1 "nonimmediate_operand" "<r>m,*k,*km")))]
3885 "TARGET_64BIT" 3956 "TARGET_64BIT"
3886 "@ 3957 "@
3887 movz{<imodesuffix>l|x}\t{%1, %k0|%k0, %1} 3958 movz{<imodesuffix>l|x}\t{%1, %k0|%k0, %1}
3959 kmov<mskmodesuffix>\t{%1, %k0|%k0, %1}
3888 kmov<mskmodesuffix>\t{%1, %k0|%k0, %1}" 3960 kmov<mskmodesuffix>\t{%1, %k0|%k0, %1}"
3889 [(set_attr "isa" "*,<kmov_isa>") 3961 [(set_attr "isa" "*,<kmov_isa>,<kmov_isa>")
3890 (set_attr "type" "imovx,mskmov") 3962 (set_attr "type" "imovx,mskmov,mskmov")
3891 (set_attr "mode" "SI,<MODE>")]) 3963 (set_attr "mode" "SI,<MODE>,<MODE>")])
3892 3964
3893 (define_expand "zero_extend<mode>si2" 3965 (define_expand "zero_extend<mode>si2"
3894 [(set (match_operand:SI 0 "register_operand") 3966 [(set (match_operand:SI 0 "register_operand")
3895 (zero_extend:SI (match_operand:SWI12 1 "nonimmediate_operand")))] 3967 (zero_extend:SI (match_operand:SWI12 1 "nonimmediate_operand")))]
3896 "" 3968 ""
3918 || REGNO (operands[0]) != REGNO (operands[1])) 3990 || REGNO (operands[0]) != REGNO (operands[1]))
3919 { 3991 {
3920 ix86_expand_clear (operands[0]); 3992 ix86_expand_clear (operands[0]);
3921 3993
3922 gcc_assert (!TARGET_PARTIAL_REG_STALL); 3994 gcc_assert (!TARGET_PARTIAL_REG_STALL);
3923 emit_insn (gen_movstrict<mode> 3995 emit_insn (gen_rtx_SET
3924 (gen_lowpart (<MODE>mode, operands[0]), operands[1])); 3996 (gen_rtx_STRICT_LOW_PART
3997 (VOIDmode, gen_lowpart (<MODE>mode, operands[0])),
3998 operands[1]));
3925 DONE; 3999 DONE;
3926 } 4000 }
3927 4001
3928 operands[2] = GEN_INT (GET_MODE_MASK (<MODE>mode)); 4002 operands[2] = GEN_INT (GET_MODE_MASK (<MODE>mode));
3929 } 4003 }
3930 [(set_attr "type" "alu1") 4004 [(set_attr "type" "alu1")
3931 (set_attr "mode" "SI")]) 4005 (set_attr "mode" "SI")])
3932 4006
3933 (define_insn "*zero_extend<mode>si2" 4007 (define_insn "*zero_extend<mode>si2"
3934 [(set (match_operand:SI 0 "register_operand" "=r,*r") 4008 [(set (match_operand:SI 0 "register_operand" "=r,*r,*k")
3935 (zero_extend:SI 4009 (zero_extend:SI
3936 (match_operand:SWI12 1 "nonimmediate_operand" "<r>m,*k")))] 4010 (match_operand:SWI12 1 "nonimmediate_operand" "<r>m,*k,*km")))]
3937 "!(TARGET_ZERO_EXTEND_WITH_AND && optimize_function_for_speed_p (cfun))" 4011 "!(TARGET_ZERO_EXTEND_WITH_AND && optimize_function_for_speed_p (cfun))"
3938 "@ 4012 "@
3939 movz{<imodesuffix>l|x}\t{%1, %0|%0, %1} 4013 movz{<imodesuffix>l|x}\t{%1, %0|%0, %1}
4014 kmov<mskmodesuffix>\t{%1, %0|%0, %1}
3940 kmov<mskmodesuffix>\t{%1, %0|%0, %1}" 4015 kmov<mskmodesuffix>\t{%1, %0|%0, %1}"
3941 [(set_attr "isa" "*,<kmov_isa>") 4016 [(set_attr "isa" "*,<kmov_isa>,<kmov_isa>")
3942 (set_attr "type" "imovx,mskmov") 4017 (set_attr "type" "imovx,mskmov,mskmov")
3943 (set_attr "mode" "SI,<MODE>")]) 4018 (set_attr "mode" "SI,<MODE>,<MODE>")])
3944 4019
3945 (define_expand "zero_extendqihi2" 4020 (define_expand "zero_extendqihi2"
3946 [(set (match_operand:HI 0 "register_operand") 4021 [(set (match_operand:HI 0 "register_operand")
3947 (zero_extend:HI (match_operand:QI 1 "nonimmediate_operand")))] 4022 (zero_extend:HI (match_operand:QI 1 "nonimmediate_operand")))]
3948 "" 4023 ""
3969 || REGNO (operands[0]) != REGNO (operands[1])) 4044 || REGNO (operands[0]) != REGNO (operands[1]))
3970 { 4045 {
3971 ix86_expand_clear (operands[0]); 4046 ix86_expand_clear (operands[0]);
3972 4047
3973 gcc_assert (!TARGET_PARTIAL_REG_STALL); 4048 gcc_assert (!TARGET_PARTIAL_REG_STALL);
3974 emit_insn (gen_movstrictqi 4049 emit_insn (gen_rtx_SET
3975 (gen_lowpart (QImode, operands[0]), operands[1])); 4050 (gen_rtx_STRICT_LOW_PART
4051 (VOIDmode, gen_lowpart (QImode, operands[0])),
4052 operands[1]));
3976 DONE; 4053 DONE;
3977 } 4054 }
3978 4055
3979 operands[0] = gen_lowpart (SImode, operands[0]); 4056 operands[0] = gen_lowpart (SImode, operands[0]);
3980 } 4057 }
3981 [(set_attr "type" "alu1") 4058 [(set_attr "type" "alu1")
3982 (set_attr "mode" "SI")]) 4059 (set_attr "mode" "SI")])
3983 4060
3984 ; zero extend to SImode to avoid partial register stalls 4061 ; zero extend to SImode to avoid partial register stalls
3985 (define_insn "*zero_extendqihi2" 4062 (define_insn "*zero_extendqihi2"
3986 [(set (match_operand:HI 0 "register_operand" "=r,*r") 4063 [(set (match_operand:HI 0 "register_operand" "=r,*r,*k")
3987 (zero_extend:HI (match_operand:QI 1 "nonimmediate_operand" "qm,*k")))] 4064 (zero_extend:HI (match_operand:QI 1 "nonimmediate_operand" "qm,*k,*km")))]
3988 "!(TARGET_ZERO_EXTEND_WITH_AND && optimize_function_for_speed_p (cfun))" 4065 "!(TARGET_ZERO_EXTEND_WITH_AND && optimize_function_for_speed_p (cfun))"
3989 "@ 4066 "@
3990 movz{bl|x}\t{%1, %k0|%k0, %1} 4067 movz{bl|x}\t{%1, %k0|%k0, %1}
3991 kmovb\t{%1, %k0|%k0, %1}" 4068 kmovb\t{%1, %k0|%k0, %1}
3992 [(set_attr "isa" "*,avx512dq") 4069 kmovb\t{%1, %0|%0, %1}"
3993 (set_attr "type" "imovx,mskmov") 4070 [(set_attr "isa" "*,avx512dq,avx512dq")
3994 (set_attr "mode" "SI,QI")]) 4071 (set_attr "type" "imovx,mskmov,mskmov")
3995 4072 (set_attr "mode" "SI,QI,QI")])
3996 (define_insn_and_split "*zext<mode>_doubleword_and"
3997 [(set (match_operand:DI 0 "register_operand" "=&<r>")
3998 (zero_extend:DI (match_operand:SWI12 1 "nonimmediate_operand" "<r>m")))]
3999 "!TARGET_64BIT && TARGET_STV && TARGET_SSE2
4000 && TARGET_ZERO_EXTEND_WITH_AND && optimize_function_for_speed_p (cfun)"
4001 "#"
4002 "&& reload_completed && GENERAL_REG_P (operands[0])"
4003 [(set (match_dup 2) (const_int 0))]
4004 {
4005 split_double_mode (DImode, &operands[0], 1, &operands[0], &operands[2]);
4006
4007 emit_move_insn (operands[0], const0_rtx);
4008
4009 gcc_assert (!TARGET_PARTIAL_REG_STALL);
4010 emit_insn (gen_movstrict<mode>
4011 (gen_lowpart (<MODE>mode, operands[0]), operands[1]));
4012 })
4013
4014 (define_insn_and_split "*zext<mode>_doubleword"
4015 [(set (match_operand:DI 0 "register_operand" "=r")
4016 (zero_extend:DI (match_operand:SWI12 1 "nonimmediate_operand" "<r>m")))]
4017 "!TARGET_64BIT && TARGET_STV && TARGET_SSE2
4018 && !(TARGET_ZERO_EXTEND_WITH_AND && optimize_function_for_speed_p (cfun))"
4019 "#"
4020 "&& reload_completed && GENERAL_REG_P (operands[0])"
4021 [(set (match_dup 0) (zero_extend:SI (match_dup 1)))
4022 (set (match_dup 2) (const_int 0))]
4023 "split_double_mode (DImode, &operands[0], 1, &operands[0], &operands[2]);")
4024
4025 (define_insn_and_split "*zextsi_doubleword"
4026 [(set (match_operand:DI 0 "register_operand" "=r")
4027 (zero_extend:DI (match_operand:SI 1 "nonimmediate_operand" "rm")))]
4028 "!TARGET_64BIT && TARGET_STV && TARGET_SSE2"
4029 "#"
4030 "&& reload_completed && GENERAL_REG_P (operands[0])"
4031 [(set (match_dup 0) (match_dup 1))
4032 (set (match_dup 2) (const_int 0))]
4033 "split_double_mode (DImode, &operands[0], 1, &operands[0], &operands[2]);")
4034 4073
4035 ;; Sign extension instructions 4074 ;; Sign extension instructions
4036 4075
4037 (define_expand "extendsidi2" 4076 (define_expand "extendsidi2"
4038 [(set (match_operand:DI 0 "register_operand") 4077 [(set (match_operand:DI 0 "register_operand")
4316 operands[1] = validize_mem (force_const_mem (SFmode, operands[1])); 4355 operands[1] = validize_mem (force_const_mem (SFmode, operands[1]));
4317 } 4356 }
4318 }) 4357 })
4319 4358
4320 (define_insn "*extendsfdf2" 4359 (define_insn "*extendsfdf2"
4321 [(set (match_operand:DF 0 "nonimm_ssenomem_operand" "=f,m,v") 4360 [(set (match_operand:DF 0 "nonimm_ssenomem_operand" "=f,m,v,v")
4322 (float_extend:DF 4361 (float_extend:DF
4323 (match_operand:SF 1 "nonimmediate_operand" "fm,f,vm")))] 4362 (match_operand:SF 1 "nonimmediate_operand" "fm,f,v,m")))]
4324 "TARGET_80387 || (TARGET_SSE2 && TARGET_SSE_MATH)" 4363 "TARGET_80387 || (TARGET_SSE2 && TARGET_SSE_MATH)"
4325 { 4364 {
4326 switch (which_alternative) 4365 switch (which_alternative)
4327 { 4366 {
4328 case 0: 4367 case 0:
4329 case 1: 4368 case 1:
4330 return output_387_reg_move (insn, operands); 4369 return output_387_reg_move (insn, operands);
4331 4370
4332 case 2: 4371 case 2:
4372 return "%vcvtss2sd\t{%d1, %0|%0, %d1}";
4373 case 3:
4333 return "%vcvtss2sd\t{%1, %d0|%d0, %1}"; 4374 return "%vcvtss2sd\t{%1, %d0|%d0, %1}";
4334 4375
4335 default: 4376 default:
4336 gcc_unreachable (); 4377 gcc_unreachable ();
4337 } 4378 }
4338 } 4379 }
4339 [(set_attr "type" "fmov,fmov,ssecvt") 4380 [(set_attr "type" "fmov,fmov,ssecvt,ssecvt")
4340 (set_attr "prefix" "orig,orig,maybe_vex") 4381 (set_attr "avx_partial_xmm_update" "false,false,false,true")
4341 (set_attr "mode" "SF,XF,DF") 4382 (set_attr "prefix" "orig,orig,maybe_vex,maybe_vex")
4383 (set_attr "mode" "SF,XF,DF,DF")
4342 (set (attr "enabled") 4384 (set (attr "enabled")
4343 (if_then_else 4385 (if_then_else
4344 (match_test ("TARGET_SSE2 && TARGET_SSE_MATH")) 4386 (match_test ("TARGET_SSE2 && TARGET_SSE_MATH"))
4345 (if_then_else 4387 (if_then_else
4346 (eq_attr "alternative" "0,1") 4388 (eq_attr "alternative" "0,1")
4416 && optimize_insn_for_speed_p ()" 4458 && optimize_insn_for_speed_p ()"
4417 [(set (match_dup 2) (match_dup 1)) 4459 [(set (match_dup 2) (match_dup 1))
4418 (set (match_dup 0) (float_extend:DF (match_dup 2)))] 4460 (set (match_dup 0) (float_extend:DF (match_dup 2)))]
4419 "operands[2] = lowpart_subreg (SFmode, operands[0], DFmode);") 4461 "operands[2] = lowpart_subreg (SFmode, operands[0], DFmode);")
4420 4462
4421 ;; Break partial reg stall for cvtss2sd. This splitter should split 4463 ;; Break partial SSE register dependency stall. This splitter should split
4422 ;; late in the pass sequence (after register rename pass), 4464 ;; late in the pass sequence (after register rename pass), so allocated
4423 ;; so allocated registers won't change anymore. 4465 ;; registers won't change anymore
4424 4466
4425 (define_split 4467 (define_split
4426 [(set (match_operand:DF 0 "sse_reg_operand") 4468 [(set (match_operand:DF 0 "sse_reg_operand")
4427 (float_extend:DF 4469 (float_extend:DF
4428 (match_operand:SF 1 "nonimmediate_operand")))] 4470 (match_operand:SF 1 "nonimmediate_operand")))]
4429 "TARGET_SSE_PARTIAL_REG_DEPENDENCY && epilogue_completed 4471 "!TARGET_AVX
4472 && TARGET_SSE_PARTIAL_REG_DEPENDENCY && epilogue_completed
4430 && optimize_function_for_speed_p (cfun) 4473 && optimize_function_for_speed_p (cfun)
4431 && (!REG_P (operands[1]) 4474 && (!REG_P (operands[1])
4432 || REGNO (operands[0]) != REGNO (operands[1])) 4475 || (!TARGET_AVX && REGNO (operands[0]) != REGNO (operands[1])))
4433 && (!EXT_REX_SSE_REG_P (operands[0]) 4476 && (!EXT_REX_SSE_REG_P (operands[0])
4434 || TARGET_AVX512VL)" 4477 || TARGET_AVX512VL)"
4435 [(set (match_dup 0) 4478 [(set (match_dup 0)
4436 (vec_merge:V2DF 4479 (vec_merge:V2DF
4437 (vec_duplicate:V2DF 4480 (vec_duplicate:V2DF
4480 ;; register preferencing, but we really use a stack slot. 4523 ;; register preferencing, but we really use a stack slot.
4481 4524
4482 ;; Conversion from DFmode to SFmode. 4525 ;; Conversion from DFmode to SFmode.
4483 4526
4484 (define_insn "truncdfsf2" 4527 (define_insn "truncdfsf2"
4485 [(set (match_operand:SF 0 "nonimm_ssenomem_operand" "=m,f,v") 4528 [(set (match_operand:SF 0 "nonimm_ssenomem_operand" "=m,f,v,v")
4486 (float_truncate:SF 4529 (float_truncate:SF
4487 (match_operand:DF 1 "register_ssemem_operand" "f,f,vm")))] 4530 (match_operand:DF 1 "register_ssemem_operand" "f,f,v,m")))]
4488 "TARGET_80387 || (TARGET_SSE2 && TARGET_SSE_MATH)" 4531 "TARGET_80387 || (TARGET_SSE2 && TARGET_SSE_MATH)"
4489 { 4532 {
4490 switch (which_alternative) 4533 switch (which_alternative)
4491 { 4534 {
4492 case 0: 4535 case 0:
4493 case 1: 4536 case 1:
4494 return output_387_reg_move (insn, operands); 4537 return output_387_reg_move (insn, operands);
4495 4538
4496 case 2: 4539 case 2:
4540 return "%vcvtsd2ss\t{%d1, %0|%0, %d1}";
4541 case 3:
4497 return "%vcvtsd2ss\t{%1, %d0|%d0, %1}"; 4542 return "%vcvtsd2ss\t{%1, %d0|%d0, %1}";
4498 4543
4499 default: 4544 default:
4500 gcc_unreachable (); 4545 gcc_unreachable ();
4501 } 4546 }
4502 } 4547 }
4503 [(set_attr "type" "fmov,fmov,ssecvt") 4548 [(set_attr "type" "fmov,fmov,ssecvt,ssecvt")
4549 (set_attr "avx_partial_xmm_update" "false,false,false,true")
4504 (set_attr "mode" "SF") 4550 (set_attr "mode" "SF")
4505 (set (attr "enabled") 4551 (set (attr "enabled")
4506 (if_then_else 4552 (if_then_else
4507 (match_test ("TARGET_SSE2 && TARGET_SSE_MATH")) 4553 (match_test ("TARGET_SSE2 && TARGET_SSE_MATH"))
4508 (cond [(eq_attr "alternative" "0") 4554 (cond [(eq_attr "alternative" "0")
4574 && optimize_insn_for_speed_p ()" 4620 && optimize_insn_for_speed_p ()"
4575 [(set (match_dup 2) (match_dup 1)) 4621 [(set (match_dup 2) (match_dup 1))
4576 (set (match_dup 0) (float_truncate:SF (match_dup 2)))] 4622 (set (match_dup 0) (float_truncate:SF (match_dup 2)))]
4577 "operands[2] = lowpart_subreg (DFmode, operands[0], SFmode);") 4623 "operands[2] = lowpart_subreg (DFmode, operands[0], SFmode);")
4578 4624
4579 ;; Break partial reg stall for cvtsd2ss. This splitter should split 4625 ;; Break partial SSE register dependency stall. This splitter should split
4580 ;; late in the pass sequence (after register rename pass), 4626 ;; late in the pass sequence (after register rename pass), so allocated
4581 ;; so allocated registers won't change anymore. 4627 ;; registers won't change anymore
4582 4628
4583 (define_split 4629 (define_split
4584 [(set (match_operand:SF 0 "sse_reg_operand") 4630 [(set (match_operand:SF 0 "sse_reg_operand")
4585 (float_truncate:SF 4631 (float_truncate:SF
4586 (match_operand:DF 1 "nonimmediate_operand")))] 4632 (match_operand:DF 1 "nonimmediate_operand")))]
4587 "TARGET_SSE_PARTIAL_REG_DEPENDENCY && epilogue_completed 4633 "!TARGET_AVX
4634 && TARGET_SSE_PARTIAL_REG_DEPENDENCY && epilogue_completed
4588 && optimize_function_for_speed_p (cfun) 4635 && optimize_function_for_speed_p (cfun)
4589 && (!REG_P (operands[1]) 4636 && (!REG_P (operands[1])
4590 || REGNO (operands[0]) != REGNO (operands[1])) 4637 || (!TARGET_AVX && REGNO (operands[0]) != REGNO (operands[1])))
4591 && (!EXT_REX_SSE_REG_P (operands[0]) 4638 && (!EXT_REX_SSE_REG_P (operands[0])
4592 || TARGET_AVX512VL)" 4639 || TARGET_AVX512VL)"
4593 [(set (match_dup 0) 4640 [(set (match_dup 0)
4594 (vec_merge:V4SF 4641 (vec_merge:V4SF
4595 (vec_duplicate:V4SF 4642 (vec_duplicate:V4SF
4856 (clobber (reg:CC FLAGS_REG))] 4903 (clobber (reg:CC FLAGS_REG))]
4857 "X87_FLOAT_MODE_P (GET_MODE (operands[1])) 4904 "X87_FLOAT_MODE_P (GET_MODE (operands[1]))
4858 && !TARGET_FISTTP 4905 && !TARGET_FISTTP
4859 && !(SSE_FLOAT_MODE_P (GET_MODE (operands[1])) 4906 && !(SSE_FLOAT_MODE_P (GET_MODE (operands[1]))
4860 && (TARGET_64BIT || <MODE>mode != DImode)) 4907 && (TARGET_64BIT || <MODE>mode != DImode))
4861 && can_create_pseudo_p ()" 4908 && ix86_pre_reload_split ()"
4862 "#" 4909 "#"
4863 "&& 1" 4910 "&& 1"
4864 [(const_int 0)] 4911 [(const_int 0)]
4865 { 4912 {
4866 ix86_optimize_mode_switching[I387_TRUNC] = 1; 4913 ix86_optimize_mode_switching[I387_TRUNC] = 1;
4958 "@ 5005 "@
4959 fild%Z1\t%1 5006 fild%Z1\t%1
4960 %vcvtsi2<MODEF:ssemodesuffix><SWI48:rex64suffix>\t{%1, %d0|%d0, %1} 5007 %vcvtsi2<MODEF:ssemodesuffix><SWI48:rex64suffix>\t{%1, %d0|%d0, %1}
4961 %vcvtsi2<MODEF:ssemodesuffix><SWI48:rex64suffix>\t{%1, %d0|%d0, %1}" 5008 %vcvtsi2<MODEF:ssemodesuffix><SWI48:rex64suffix>\t{%1, %d0|%d0, %1}"
4962 [(set_attr "type" "fmov,sseicvt,sseicvt") 5009 [(set_attr "type" "fmov,sseicvt,sseicvt")
5010 (set_attr "avx_partial_xmm_update" "false,true,true")
4963 (set_attr "prefix" "orig,maybe_vex,maybe_vex") 5011 (set_attr "prefix" "orig,maybe_vex,maybe_vex")
4964 (set_attr "mode" "<MODEF:MODE>") 5012 (set_attr "mode" "<MODEF:MODE>")
4965 (set (attr "prefix_rex") 5013 (set (attr "prefix_rex")
4966 (if_then_else 5014 (if_then_else
4967 (and (eq_attr "prefix" "maybe_vex") 5015 (and (eq_attr "prefix" "maybe_vex")
5049 assign_386_stack_local (DImode, SLOT_TEMP))); 5097 assign_386_stack_local (DImode, SLOT_TEMP)));
5050 DONE; 5098 DONE;
5051 }) 5099 })
5052 5100
5053 (define_insn_and_split "floatdi<X87MODEF:mode>2_i387_with_xmm" 5101 (define_insn_and_split "floatdi<X87MODEF:mode>2_i387_with_xmm"
5054 [(set (match_operand:X87MODEF 0 "register_operand" "=f") 5102 [(set (match_operand:X87MODEF 0 "register_operand" "=f,f")
5055 (float:X87MODEF 5103 (float:X87MODEF
5056 (match_operand:DI 1 "register_operand" "r"))) 5104 (match_operand:DI 1 "register_operand" "r,r")))
5057 (clobber (match_scratch:V4SI 3 "=x")) 5105 (clobber (match_operand:DI 2 "memory_operand" "=m,m"))
5058 (clobber (match_scratch:V4SI 4 "=x")) 5106 (clobber (match_scratch:V4SI 3 "=x,x"))
5059 (clobber (match_operand:DI 2 "memory_operand" "=m"))] 5107 (clobber (match_scratch:V4SI 4 "=X,x"))]
5060 "!TARGET_64BIT && TARGET_INTER_UNIT_MOVES_TO_VEC 5108 "!TARGET_64BIT && TARGET_INTER_UNIT_MOVES_TO_VEC
5061 && TARGET_80387 && X87_ENABLE_FLOAT (<X87MODEF:MODE>mode, DImode) 5109 && TARGET_80387 && X87_ENABLE_FLOAT (<X87MODEF:MODE>mode, DImode)
5062 && TARGET_SSE2 && optimize_function_for_speed_p (cfun)" 5110 && TARGET_SSE2 && optimize_function_for_speed_p (cfun)"
5063 "#" 5111 "#"
5064 "&& reload_completed" 5112 "&& reload_completed"
5067 { 5115 {
5068 /* The DImode arrived in a pair of integral registers (e.g. %edx:%eax). 5116 /* The DImode arrived in a pair of integral registers (e.g. %edx:%eax).
5069 Assemble the 64-bit DImode value in an xmm register. */ 5117 Assemble the 64-bit DImode value in an xmm register. */
5070 emit_insn (gen_sse2_loadld (operands[3], CONST0_RTX (V4SImode), 5118 emit_insn (gen_sse2_loadld (operands[3], CONST0_RTX (V4SImode),
5071 gen_lowpart (SImode, operands[1]))); 5119 gen_lowpart (SImode, operands[1])));
5072 emit_insn (gen_sse2_loadld (operands[4], CONST0_RTX (V4SImode), 5120 if (TARGET_SSE4_1)
5073 gen_highpart (SImode, operands[1]))); 5121 emit_insn (gen_sse4_1_pinsrd (operands[3], operands[3],
5074 emit_insn (gen_vec_interleave_lowv4si (operands[3], operands[3], 5122 gen_highpart (SImode, operands[1]),
5075 operands[4])); 5123 GEN_INT (2)));
5076 5124 else
5125 {
5126 emit_insn (gen_sse2_loadld (operands[4], CONST0_RTX (V4SImode),
5127 gen_highpart (SImode, operands[1])));
5128 emit_insn (gen_vec_interleave_lowv4si (operands[3], operands[3],
5129 operands[4]));
5130 }
5077 operands[3] = gen_lowpart (DImode, operands[3]); 5131 operands[3] = gen_lowpart (DImode, operands[3]);
5078 } 5132 }
5079 [(set_attr "type" "multi") 5133 [(set_attr "isa" "sse4,*")
5134 (set_attr "type" "multi")
5080 (set_attr "mode" "<X87MODEF:MODE>") 5135 (set_attr "mode" "<X87MODEF:MODE>")
5081 (set_attr "unit" "i387") 5136 (set_attr "unit" "i387")
5082 (set_attr "fp_int_src" "true")]) 5137 (set_attr "fp_int_src" "true")])
5083 5138
5084 ;; Avoid partial SSE register dependency stalls. This splitter should split 5139 ;; Break partial SSE register dependency stall. This splitter should split
5085 ;; late in the pass sequence (after register rename pass), so allocated 5140 ;; late in the pass sequence (after register rename pass), so allocated
5086 ;; registers won't change anymore 5141 ;; registers won't change anymore
5087 5142
5088 (define_split 5143 (define_split
5089 [(set (match_operand:MODEF 0 "sse_reg_operand") 5144 [(set (match_operand:MODEF 0 "sse_reg_operand")
5090 (float:MODEF (match_operand:SWI48 1 "nonimmediate_operand")))] 5145 (float:MODEF (match_operand:SWI48 1 "nonimmediate_operand")))]
5091 "TARGET_SSE_PARTIAL_REG_DEPENDENCY && epilogue_completed 5146 "!TARGET_AVX
5147 && TARGET_SSE_PARTIAL_REG_DEPENDENCY && epilogue_completed
5092 && optimize_function_for_speed_p (cfun) 5148 && optimize_function_for_speed_p (cfun)
5093 && (!EXT_REX_SSE_REG_P (operands[0]) 5149 && (!EXT_REX_SSE_REG_P (operands[0])
5094 || TARGET_AVX512VL)" 5150 || TARGET_AVX512VL)"
5095 [(set (match_dup 0) 5151 [(set (match_dup 0)
5096 (vec_merge:<MODEF:ssevecmode> 5152 (vec_merge:<MODEF:ssevecmode>
5123 (unsigned_float:MODEF 5179 (unsigned_float:MODEF
5124 (match_operand:SWI48 1 "nonimmediate_operand" "rm")))] 5180 (match_operand:SWI48 1 "nonimmediate_operand" "rm")))]
5125 "TARGET_AVX512F && TARGET_SSE_MATH" 5181 "TARGET_AVX512F && TARGET_SSE_MATH"
5126 "vcvtusi2<MODEF:ssemodesuffix><SWI48:rex64suffix>\t{%1, %0, %0|%0, %0, %1}" 5182 "vcvtusi2<MODEF:ssemodesuffix><SWI48:rex64suffix>\t{%1, %0, %0|%0, %0, %1}"
5127 [(set_attr "type" "sseicvt") 5183 [(set_attr "type" "sseicvt")
5184 (set_attr "avx_partial_xmm_update" "true")
5128 (set_attr "prefix" "evex") 5185 (set_attr "prefix" "evex")
5129 (set_attr "mode" "<MODEF:MODE>")]) 5186 (set_attr "mode" "<MODEF:MODE>")])
5130 5187
5131 ;; Avoid store forwarding (partial memory) stall penalty by extending 5188 ;; Avoid store forwarding (partial memory) stall penalty by extending
5132 ;; SImode value to DImode through XMM register instead of pushing two 5189 ;; SImode value to DImode through XMM register instead of pushing two
5190 5247
5191 (define_expand "floatunsdidf2" 5248 (define_expand "floatunsdidf2"
5192 [(set (match_operand:DF 0 "register_operand") 5249 [(set (match_operand:DF 0 "register_operand")
5193 (unsigned_float:DF 5250 (unsigned_float:DF
5194 (match_operand:DI 1 "nonimmediate_operand")))] 5251 (match_operand:DI 1 "nonimmediate_operand")))]
5195 "(TARGET_KEEPS_VECTOR_ALIGNED_STACK || TARGET_AVX512F) 5252 "((TARGET_64BIT && TARGET_AVX512F)
5253 || TARGET_KEEPS_VECTOR_ALIGNED_STACK)
5196 && TARGET_SSE2 && TARGET_SSE_MATH" 5254 && TARGET_SSE2 && TARGET_SSE_MATH"
5197 { 5255 {
5198 if (!TARGET_64BIT) 5256 if (!TARGET_64BIT)
5199 { 5257 {
5200 ix86_expand_convert_uns_didf_sse (operands[0], operands[1]); 5258 ix86_expand_convert_uns_didf_sse (operands[0], operands[1]);
5263 (match_operand:SDWIM 2 "<general_hilo_operand>")))] 5321 (match_operand:SDWIM 2 "<general_hilo_operand>")))]
5264 "" 5322 ""
5265 "ix86_expand_binary_operator (PLUS, <MODE>mode, operands); DONE;") 5323 "ix86_expand_binary_operator (PLUS, <MODE>mode, operands); DONE;")
5266 5324
5267 (define_insn_and_split "*add<dwi>3_doubleword" 5325 (define_insn_and_split "*add<dwi>3_doubleword"
5268 [(set (match_operand:<DWI> 0 "nonimmediate_operand" "=r,o") 5326 [(set (match_operand:<DWI> 0 "nonimmediate_operand" "=ro,r")
5269 (plus:<DWI> 5327 (plus:<DWI>
5270 (match_operand:<DWI> 1 "nonimmediate_operand" "%0,0") 5328 (match_operand:<DWI> 1 "nonimmediate_operand" "%0,0")
5271 (match_operand:<DWI> 2 "x86_64_hilo_general_operand" 5329 (match_operand:<DWI> 2 "x86_64_hilo_general_operand" "r<di>,o")))
5272 "ro<di>,r<di>")))
5273 (clobber (reg:CC FLAGS_REG))] 5330 (clobber (reg:CC FLAGS_REG))]
5274 "ix86_binary_operator_ok (PLUS, <DWI>mode, operands)" 5331 "ix86_binary_operator_ok (PLUS, <DWI>mode, operands)"
5275 "#" 5332 "#"
5276 "reload_completed" 5333 "reload_completed"
5277 [(parallel [(set (reg:CCC FLAGS_REG) 5334 [(parallel [(set (reg:CCC FLAGS_REG)
5295 DONE; 5352 DONE;
5296 } 5353 }
5297 }) 5354 })
5298 5355
5299 (define_insn "*add<mode>_1" 5356 (define_insn "*add<mode>_1"
5300 [(set (match_operand:SWI48 0 "nonimmediate_operand" "=r,rm,r,r") 5357 [(set (match_operand:SWI48 0 "nonimmediate_operand" "=rm,r,r,r")
5301 (plus:SWI48 5358 (plus:SWI48
5302 (match_operand:SWI48 1 "nonimmediate_operand" "%0,0,r,r") 5359 (match_operand:SWI48 1 "nonimmediate_operand" "%0,0,r,r")
5303 (match_operand:SWI48 2 "x86_64_general_operand" "rme,re,0,le"))) 5360 (match_operand:SWI48 2 "x86_64_general_operand" "re,m,0,le")))
5304 (clobber (reg:CC FLAGS_REG))] 5361 (clobber (reg:CC FLAGS_REG))]
5305 "ix86_binary_operator_ok (PLUS, <MODE>mode, operands)" 5362 "ix86_binary_operator_ok (PLUS, <MODE>mode, operands)"
5306 { 5363 {
5307 switch (get_attr_type (insn)) 5364 switch (get_attr_type (insn))
5308 { 5365 {
5401 (set_attr "mode" "SI")]) 5458 (set_attr "mode" "SI")])
5402 5459
5403 (define_insn "*addhi_1" 5460 (define_insn "*addhi_1"
5404 [(set (match_operand:HI 0 "nonimmediate_operand" "=rm,r,r,Yp") 5461 [(set (match_operand:HI 0 "nonimmediate_operand" "=rm,r,r,Yp")
5405 (plus:HI (match_operand:HI 1 "nonimmediate_operand" "%0,0,r,Yp") 5462 (plus:HI (match_operand:HI 1 "nonimmediate_operand" "%0,0,r,Yp")
5406 (match_operand:HI 2 "general_operand" "rn,rm,0,ln"))) 5463 (match_operand:HI 2 "general_operand" "rn,m,0,ln")))
5407 (clobber (reg:CC FLAGS_REG))] 5464 (clobber (reg:CC FLAGS_REG))]
5408 "ix86_binary_operator_ok (PLUS, HImode, operands)" 5465 "ix86_binary_operator_ok (PLUS, HImode, operands)"
5409 { 5466 {
5410 switch (get_attr_type (insn)) 5467 switch (get_attr_type (insn))
5411 { 5468 {
5450 (set_attr "mode" "HI,HI,HI,SI")]) 5507 (set_attr "mode" "HI,HI,HI,SI")])
5451 5508
5452 (define_insn "*addqi_1" 5509 (define_insn "*addqi_1"
5453 [(set (match_operand:QI 0 "nonimmediate_operand" "=qm,q,q,r,r,Yp") 5510 [(set (match_operand:QI 0 "nonimmediate_operand" "=qm,q,q,r,r,Yp")
5454 (plus:QI (match_operand:QI 1 "nonimmediate_operand" "%0,0,q,0,r,Yp") 5511 (plus:QI (match_operand:QI 1 "nonimmediate_operand" "%0,0,q,0,r,Yp")
5455 (match_operand:QI 2 "general_operand" "qn,qm,0,rn,0,ln"))) 5512 (match_operand:QI 2 "general_operand" "qn,m,0,rn,0,ln")))
5456 (clobber (reg:CC FLAGS_REG))] 5513 (clobber (reg:CC FLAGS_REG))]
5457 "ix86_binary_operator_ok (PLUS, QImode, operands)" 5514 "ix86_binary_operator_ok (PLUS, QImode, operands)"
5458 { 5515 {
5459 bool widen = (get_attr_mode (insn) != MODE_QI); 5516 bool widen = (get_attr_mode (insn) != MODE_QI);
5460 5517
5510 (set (attr "preferred_for_speed") 5567 (set (attr "preferred_for_speed")
5511 (cond [(eq_attr "alternative" "3,4") 5568 (cond [(eq_attr "alternative" "3,4")
5512 (symbol_ref "!TARGET_PARTIAL_REG_STALL")] 5569 (symbol_ref "!TARGET_PARTIAL_REG_STALL")]
5513 (symbol_ref "true")))]) 5570 (symbol_ref "true")))])
5514 5571
5515 (define_insn "*addqi_1_slp" 5572 (define_insn "*add<mode>_1_slp"
5516 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+qm,q")) 5573 [(set (strict_low_part (match_operand:SWI12 0 "register_operand" "+<r>"))
5517 (plus:QI (match_dup 0) 5574 (plus:SWI12 (match_operand:SWI12 1 "nonimmediate_operand" "%0")
5518 (match_operand:QI 1 "general_operand" "qn,qm"))) 5575 (match_operand:SWI12 2 "general_operand" "<r>mn")))
5519 (clobber (reg:CC FLAGS_REG))] 5576 (clobber (reg:CC FLAGS_REG))]
5520 "(! TARGET_PARTIAL_REG_STALL || optimize_function_for_size_p (cfun)) 5577 "(!TARGET_PARTIAL_REG_STALL || optimize_function_for_size_p (cfun))
5521 && !(MEM_P (operands[0]) && MEM_P (operands[1]))" 5578 /* FIXME: without this LRA can't reload this pattern, see PR82524. */
5579 && (rtx_equal_p (operands[0], operands[1])
5580 || rtx_equal_p (operands[0], operands[2]))"
5522 { 5581 {
5523 switch (get_attr_type (insn)) 5582 switch (get_attr_type (insn))
5524 { 5583 {
5525 case TYPE_INCDEC: 5584 case TYPE_INCDEC:
5526 if (operands[1] == const1_rtx) 5585 if (operands[2] == const1_rtx)
5527 return "inc{b}\t%0"; 5586 return "inc{<imodesuffix>}\t%0";
5528 else 5587 else
5529 { 5588 {
5530 gcc_assert (operands[1] == constm1_rtx); 5589 gcc_assert (operands[2] == constm1_rtx);
5531 return "dec{b}\t%0"; 5590 return "dec{<imodesuffix>}\t%0";
5532 } 5591 }
5533 5592
5534 default: 5593 default:
5535 if (x86_maybe_negate_const_int (&operands[1], QImode)) 5594 if (x86_maybe_negate_const_int (&operands[2], QImode))
5536 return "sub{b}\t{%1, %0|%0, %1}"; 5595 return "sub{<imodesuffix>}\t{%2, %0|%0, %2}";
5537 5596
5538 return "add{b}\t{%1, %0|%0, %1}"; 5597 return "add{<imodesuffix>}\t{%2, %0|%0, %2}";
5539 } 5598 }
5540 } 5599 }
5541 [(set (attr "type") 5600 [(set (attr "type")
5542 (if_then_else (match_operand:QI 1 "incdec_operand") 5601 (if_then_else (match_operand:QI 2 "incdec_operand")
5543 (const_string "incdec") 5602 (const_string "incdec")
5544 (const_string "alu1"))) 5603 (const_string "alu")))
5545 (set (attr "memory") 5604 (set_attr "mode" "<MODE>")])
5546 (if_then_else (match_operand 1 "memory_operand")
5547 (const_string "load")
5548 (const_string "none")))
5549 (set_attr "mode" "QI")])
5550 5605
5551 ;; Split non destructive adds if we cannot use lea. 5606 ;; Split non destructive adds if we cannot use lea.
5552 (define_split 5607 (define_split
5553 [(set (match_operand:SWI48 0 "register_operand") 5608 [(set (match_operand:SWI48 0 "register_operand")
5554 (plus:SWI48 (match_operand:SWI48 1 "register_operand") 5609 (plus:SWI48 (match_operand:SWI48 1 "register_operand")
5606 (define_insn "*add<mode>_2" 5661 (define_insn "*add<mode>_2"
5607 [(set (reg FLAGS_REG) 5662 [(set (reg FLAGS_REG)
5608 (compare 5663 (compare
5609 (plus:SWI 5664 (plus:SWI
5610 (match_operand:SWI 1 "nonimmediate_operand" "%0,0,<r>") 5665 (match_operand:SWI 1 "nonimmediate_operand" "%0,0,<r>")
5611 (match_operand:SWI 2 "<general_operand>" "<g>,<r><i>,0")) 5666 (match_operand:SWI 2 "<general_operand>" "<r><i>,m,0"))
5612 (const_int 0))) 5667 (const_int 0)))
5613 (set (match_operand:SWI 0 "nonimmediate_operand" "=<r>,<r>m,<r>") 5668 (set (match_operand:SWI 0 "nonimmediate_operand" "=<r>m,<r>,<r>")
5614 (plus:SWI (match_dup 1) (match_dup 2)))] 5669 (plus:SWI (match_dup 1) (match_dup 2)))]
5615 "ix86_match_ccmode (insn, CCGOCmode) 5670 "ix86_match_ccmode (insn, CCGOCmode)
5616 && ix86_binary_operator_ok (PLUS, <MODE>mode, operands)" 5671 && ix86_binary_operator_ok (PLUS, <MODE>mode, operands)"
5617 { 5672 {
5618 switch (get_attr_type (insn)) 5673 switch (get_attr_type (insn))
5967 || rtx_equal_p (operands[0], operands[2])" 6022 || rtx_equal_p (operands[0], operands[2])"
5968 "add{b}\t{%h2, %h0|%h0, %h2}" 6023 "add{b}\t{%h2, %h0|%h0, %h2}"
5969 [(set_attr "type" "alu") 6024 [(set_attr "type" "alu")
5970 (set_attr "mode" "QI")]) 6025 (set_attr "mode" "QI")])
5971 6026
6027 ;; Like DWI, but use POImode instead of OImode.
6028 (define_mode_attr DPWI [(QI "HI") (HI "SI") (SI "DI") (DI "TI") (TI "POI")])
6029
5972 ;; Add with jump on overflow. 6030 ;; Add with jump on overflow.
5973 (define_expand "addv<mode>4" 6031 (define_expand "addv<mode>4"
5974 [(parallel [(set (reg:CCO FLAGS_REG) 6032 [(parallel [(set (reg:CCO FLAGS_REG)
5975 (eq:CCO (plus:<DWI> 6033 (eq:CCO
5976 (sign_extend:<DWI> 6034 (plus:<DPWI>
5977 (match_operand:SWI 1 "nonimmediate_operand")) 6035 (sign_extend:<DPWI>
5978 (match_dup 4)) 6036 (match_operand:SWIDWI 1 "nonimmediate_operand"))
5979 (sign_extend:<DWI> 6037 (match_dup 4))
5980 (plus:SWI (match_dup 1) 6038 (sign_extend:<DPWI>
5981 (match_operand:SWI 2 6039 (plus:SWIDWI (match_dup 1)
5982 "<general_operand>"))))) 6040 (match_operand:SWIDWI 2
5983 (set (match_operand:SWI 0 "register_operand") 6041 "<general_hilo_operand>")))))
5984 (plus:SWI (match_dup 1) (match_dup 2)))]) 6042 (set (match_operand:SWIDWI 0 "register_operand")
6043 (plus:SWIDWI (match_dup 1) (match_dup 2)))])
5985 (set (pc) (if_then_else 6044 (set (pc) (if_then_else
5986 (eq (reg:CCO FLAGS_REG) (const_int 0)) 6045 (eq (reg:CCO FLAGS_REG) (const_int 0))
5987 (label_ref (match_operand 3)) 6046 (label_ref (match_operand 3))
5988 (pc)))] 6047 (pc)))]
5989 "" 6048 ""
5990 { 6049 {
5991 ix86_fixup_binary_operands_no_copy (PLUS, <MODE>mode, operands); 6050 ix86_fixup_binary_operands_no_copy (PLUS, <MODE>mode, operands);
5992 if (CONST_INT_P (operands[2])) 6051 if (CONST_SCALAR_INT_P (operands[2]))
5993 operands[4] = operands[2]; 6052 operands[4] = operands[2];
5994 else 6053 else
5995 operands[4] = gen_rtx_SIGN_EXTEND (<DWI>mode, operands[2]); 6054 operands[4] = gen_rtx_SIGN_EXTEND (<DPWI>mode, operands[2]);
5996 }) 6055 })
5997 6056
5998 (define_insn "*addv<mode>4" 6057 (define_insn "*addv<mode>4"
5999 [(set (reg:CCO FLAGS_REG) 6058 [(set (reg:CCO FLAGS_REG)
6000 (eq:CCO (plus:<DWI> 6059 (eq:CCO (plus:<DWI>
6001 (sign_extend:<DWI> 6060 (sign_extend:<DWI>
6002 (match_operand:SWI 1 "nonimmediate_operand" "%0,0")) 6061 (match_operand:SWI 1 "nonimmediate_operand" "%0,0"))
6003 (sign_extend:<DWI> 6062 (sign_extend:<DWI>
6004 (match_operand:SWI 2 "<general_sext_operand>" 6063 (match_operand:SWI 2 "<general_sext_operand>" "<r>We,m")))
6005 "<r>mWe,<r>We")))
6006 (sign_extend:<DWI> 6064 (sign_extend:<DWI>
6007 (plus:SWI (match_dup 1) (match_dup 2))))) 6065 (plus:SWI (match_dup 1) (match_dup 2)))))
6008 (set (match_operand:SWI 0 "nonimmediate_operand" "=<r>,<r>m") 6066 (set (match_operand:SWI 0 "nonimmediate_operand" "=<r>m,<r>")
6009 (plus:SWI (match_dup 1) (match_dup 2)))] 6067 (plus:SWI (match_dup 1) (match_dup 2)))]
6010 "ix86_binary_operator_ok (PLUS, <MODE>mode, operands)" 6068 "ix86_binary_operator_ok (PLUS, <MODE>mode, operands)"
6011 "add{<imodesuffix>}\t{%2, %0|%0, %2}" 6069 "add{<imodesuffix>}\t{%2, %0|%0, %2}"
6012 [(set_attr "type" "alu") 6070 [(set_attr "type" "alu")
6013 (set_attr "mode" "<MODE>")]) 6071 (set_attr "mode" "<MODE>")])
6014 6072
6015 (define_insn "*addv<mode>4_1" 6073 (define_insn "addv<mode>4_1"
6016 [(set (reg:CCO FLAGS_REG) 6074 [(set (reg:CCO FLAGS_REG)
6017 (eq:CCO (plus:<DWI> 6075 (eq:CCO (plus:<DWI>
6018 (sign_extend:<DWI> 6076 (sign_extend:<DWI>
6019 (match_operand:SWI 1 "nonimmediate_operand" "0")) 6077 (match_operand:SWI 1 "nonimmediate_operand" "0"))
6020 (match_operand:<DWI> 3 "const_int_operand" "i")) 6078 (match_operand:<DWI> 3 "const_int_operand" "i"))
6021 (sign_extend:<DWI> 6079 (sign_extend:<DWI>
6022 (plus:SWI (match_dup 1) 6080 (plus:SWI
6023 (match_operand:SWI 2 "x86_64_immediate_operand" 6081 (match_dup 1)
6024 "<i>"))))) 6082 (match_operand:SWI 2 "x86_64_immediate_operand" "<i>")))))
6025 (set (match_operand:SWI 0 "nonimmediate_operand" "=<r>m") 6083 (set (match_operand:SWI 0 "nonimmediate_operand" "=<r>m")
6026 (plus:SWI (match_dup 1) (match_dup 2)))] 6084 (plus:SWI (match_dup 1) (match_dup 2)))]
6027 "ix86_binary_operator_ok (PLUS, <MODE>mode, operands) 6085 "ix86_binary_operator_ok (PLUS, <MODE>mode, operands)
6028 && CONST_INT_P (operands[2]) 6086 && CONST_INT_P (operands[2])
6029 && INTVAL (operands[2]) == INTVAL (operands[3])" 6087 && INTVAL (operands[2]) == INTVAL (operands[3])"
6035 (const_string "1") 6093 (const_string "1")
6036 (match_test "<MODE_SIZE> == 8") 6094 (match_test "<MODE_SIZE> == 8")
6037 (const_string "4")] 6095 (const_string "4")]
6038 (const_string "<MODE_SIZE>")))]) 6096 (const_string "<MODE_SIZE>")))])
6039 6097
6098 ;; Quad word integer modes as mode attribute.
6099 (define_mode_attr QPWI [(SI "TI") (DI "POI")])
6100
6101 (define_insn_and_split "*addv<dwi>4_doubleword"
6102 [(set (reg:CCO FLAGS_REG)
6103 (eq:CCO
6104 (plus:<QPWI>
6105 (sign_extend:<QPWI>
6106 (match_operand:<DWI> 1 "nonimmediate_operand" "%0,0"))
6107 (sign_extend:<QPWI>
6108 (match_operand:<DWI> 2 "nonimmediate_operand" "r,o")))
6109 (sign_extend:<QPWI>
6110 (plus:<DWI> (match_dup 1) (match_dup 2)))))
6111 (set (match_operand:<DWI> 0 "nonimmediate_operand" "=ro,r")
6112 (plus:<DWI> (match_dup 1) (match_dup 2)))]
6113 "ix86_binary_operator_ok (PLUS, <DWI>mode, operands)"
6114 "#"
6115 "reload_completed"
6116 [(parallel [(set (reg:CCC FLAGS_REG)
6117 (compare:CCC
6118 (plus:DWIH (match_dup 1) (match_dup 2))
6119 (match_dup 1)))
6120 (set (match_dup 0)
6121 (plus:DWIH (match_dup 1) (match_dup 2)))])
6122 (parallel [(set (reg:CCO FLAGS_REG)
6123 (eq:CCO
6124 (plus:<DWI>
6125 (plus:<DWI>
6126 (ltu:<DWI> (reg:CC FLAGS_REG) (const_int 0))
6127 (sign_extend:<DWI> (match_dup 4)))
6128 (sign_extend:<DWI> (match_dup 5)))
6129 (sign_extend:<DWI>
6130 (plus:DWIH
6131 (plus:DWIH
6132 (ltu:DWIH (reg:CC FLAGS_REG) (const_int 0))
6133 (match_dup 4))
6134 (match_dup 5)))))
6135 (set (match_dup 3)
6136 (plus:DWIH
6137 (plus:DWIH
6138 (ltu:DWIH (reg:CC FLAGS_REG) (const_int 0))
6139 (match_dup 4))
6140 (match_dup 5)))])]
6141 {
6142 split_double_mode (<DWI>mode, &operands[0], 3, &operands[0], &operands[3]);
6143 })
6144
6145 (define_insn_and_split "*addv<dwi>4_doubleword_1"
6146 [(set (reg:CCO FLAGS_REG)
6147 (eq:CCO
6148 (plus:<QPWI>
6149 (sign_extend:<QPWI>
6150 (match_operand:<DWI> 1 "nonimmediate_operand" "%0"))
6151 (match_operand:<QPWI> 3 "const_scalar_int_operand" ""))
6152 (sign_extend:<QPWI>
6153 (plus:<DWI>
6154 (match_dup 1)
6155 (match_operand:<DWI> 2 "x86_64_hilo_general_operand" "<di>")))))
6156 (set (match_operand:<DWI> 0 "nonimmediate_operand" "=ro")
6157 (plus:<DWI> (match_dup 1) (match_dup 2)))]
6158 "ix86_binary_operator_ok (PLUS, <DWI>mode, operands)
6159 && CONST_SCALAR_INT_P (operands[2])
6160 && rtx_equal_p (operands[2], operands[3])"
6161 "#"
6162 "reload_completed"
6163 [(parallel [(set (reg:CCC FLAGS_REG)
6164 (compare:CCC
6165 (plus:DWIH (match_dup 1) (match_dup 2))
6166 (match_dup 1)))
6167 (set (match_dup 0)
6168 (plus:DWIH (match_dup 1) (match_dup 2)))])
6169 (parallel [(set (reg:CCO FLAGS_REG)
6170 (eq:CCO
6171 (plus:<DWI>
6172 (plus:<DWI>
6173 (ltu:<DWI> (reg:CC FLAGS_REG) (const_int 0))
6174 (sign_extend:<DWI> (match_dup 4)))
6175 (match_dup 5))
6176 (sign_extend:<DWI>
6177 (plus:DWIH
6178 (plus:DWIH
6179 (ltu:DWIH (reg:CC FLAGS_REG) (const_int 0))
6180 (match_dup 4))
6181 (match_dup 5)))))
6182 (set (match_dup 3)
6183 (plus:DWIH
6184 (plus:DWIH
6185 (ltu:DWIH (reg:CC FLAGS_REG) (const_int 0))
6186 (match_dup 4))
6187 (match_dup 5)))])]
6188 {
6189 split_double_mode (<DWI>mode, &operands[0], 3, &operands[0], &operands[3]);
6190 if (operands[2] == const0_rtx)
6191 {
6192 emit_insn (gen_addv<mode>4_1 (operands[3], operands[4], operands[5],
6193 operands[5]));
6194 DONE;
6195 }
6196 })
6197
6198 (define_insn "*addv<mode>4_overflow_1"
6199 [(set (reg:CCO FLAGS_REG)
6200 (eq:CCO
6201 (plus:<DWI>
6202 (plus:<DWI>
6203 (match_operator:<DWI> 4 "ix86_carry_flag_operator"
6204 [(match_operand 3 "flags_reg_operand") (const_int 0)])
6205 (sign_extend:<DWI>
6206 (match_operand:SWI 1 "nonimmediate_operand" "%0,0")))
6207 (sign_extend:<DWI>
6208 (match_operand:SWI 2 "<general_sext_operand>" "rWe,m")))
6209 (sign_extend:<DWI>
6210 (plus:SWI
6211 (plus:SWI
6212 (match_operator:SWI 5 "ix86_carry_flag_operator"
6213 [(match_dup 3) (const_int 0)])
6214 (match_dup 1))
6215 (match_dup 2)))))
6216 (set (match_operand:SWI 0 "nonimmediate_operand" "=rm,r")
6217 (plus:SWI
6218 (plus:SWI
6219 (match_op_dup 5 [(match_dup 3) (const_int 0)])
6220 (match_dup 1))
6221 (match_dup 2)))]
6222 "ix86_binary_operator_ok (PLUS, <MODE>mode, operands)"
6223 "adc{<imodesuffix>}\t{%2, %0|%0, %2}"
6224 [(set_attr "type" "alu")
6225 (set_attr "mode" "<MODE>")])
6226
6227 (define_insn "*addv<mode>4_overflow_2"
6228 [(set (reg:CCO FLAGS_REG)
6229 (eq:CCO
6230 (plus:<DWI>
6231 (plus:<DWI>
6232 (match_operator:<DWI> 4 "ix86_carry_flag_operator"
6233 [(match_operand 3 "flags_reg_operand") (const_int 0)])
6234 (sign_extend:<DWI>
6235 (match_operand:SWI 1 "nonimmediate_operand" "%0")))
6236 (match_operand:<DWI> 6 "const_int_operand" ""))
6237 (sign_extend:<DWI>
6238 (plus:SWI
6239 (plus:SWI
6240 (match_operator:SWI 5 "ix86_carry_flag_operator"
6241 [(match_dup 3) (const_int 0)])
6242 (match_dup 1))
6243 (match_operand:SWI 2 "x86_64_immediate_operand" "e")))))
6244 (set (match_operand:SWI 0 "nonimmediate_operand" "=rm")
6245 (plus:SWI
6246 (plus:SWI
6247 (match_op_dup 5 [(match_dup 3) (const_int 0)])
6248 (match_dup 1))
6249 (match_dup 2)))]
6250 "ix86_binary_operator_ok (PLUS, <MODE>mode, operands)
6251 && CONST_INT_P (operands[2])
6252 && INTVAL (operands[2]) == INTVAL (operands[6])"
6253 "adc{<imodesuffix>}\t{%2, %0|%0, %2}"
6254 [(set_attr "type" "alu")
6255 (set_attr "mode" "<MODE>")
6256 (set (attr "length_immediate")
6257 (if_then_else (match_test "IN_RANGE (INTVAL (operands[2]), -128, 127)")
6258 (const_string "1")
6259 (const_string "4")))])
6260
6040 (define_expand "uaddv<mode>4" 6261 (define_expand "uaddv<mode>4"
6041 [(parallel [(set (reg:CCC FLAGS_REG) 6262 [(parallel [(set (reg:CCC FLAGS_REG)
6042 (compare:CCC 6263 (compare:CCC
6043 (plus:SWI 6264 (plus:SWIDWI
6044 (match_operand:SWI 1 "nonimmediate_operand") 6265 (match_operand:SWIDWI 1 "nonimmediate_operand")
6045 (match_operand:SWI 2 "<general_operand>")) 6266 (match_operand:SWIDWI 2 "<general_hilo_operand>"))
6046 (match_dup 1))) 6267 (match_dup 1)))
6047 (set (match_operand:SWI 0 "register_operand") 6268 (set (match_operand:SWIDWI 0 "register_operand")
6048 (plus:SWI (match_dup 1) (match_dup 2)))]) 6269 (plus:SWIDWI (match_dup 1) (match_dup 2)))])
6049 (set (pc) (if_then_else 6270 (set (pc) (if_then_else
6050 (ltu (reg:CCC FLAGS_REG) (const_int 0)) 6271 (ltu (reg:CCC FLAGS_REG) (const_int 0))
6051 (label_ref (match_operand 3)) 6272 (label_ref (match_operand 3))
6052 (pc)))] 6273 (pc)))]
6053 "" 6274 ""
6223 (match_operand:SDWIM 2 "<general_hilo_operand>")))] 6444 (match_operand:SDWIM 2 "<general_hilo_operand>")))]
6224 "" 6445 ""
6225 "ix86_expand_binary_operator (MINUS, <MODE>mode, operands); DONE;") 6446 "ix86_expand_binary_operator (MINUS, <MODE>mode, operands); DONE;")
6226 6447
6227 (define_insn_and_split "*sub<dwi>3_doubleword" 6448 (define_insn_and_split "*sub<dwi>3_doubleword"
6228 [(set (match_operand:<DWI> 0 "nonimmediate_operand" "=r,o") 6449 [(set (match_operand:<DWI> 0 "nonimmediate_operand" "=ro,r")
6229 (minus:<DWI> 6450 (minus:<DWI>
6230 (match_operand:<DWI> 1 "nonimmediate_operand" "0,0") 6451 (match_operand:<DWI> 1 "nonimmediate_operand" "0,0")
6231 (match_operand:<DWI> 2 "x86_64_hilo_general_operand" 6452 (match_operand:<DWI> 2 "x86_64_hilo_general_operand" "r<di>,o")))
6232 "ro<di>,r<di>")))
6233 (clobber (reg:CC FLAGS_REG))] 6453 (clobber (reg:CC FLAGS_REG))]
6234 "ix86_binary_operator_ok (MINUS, <MODE>mode, operands)" 6454 "ix86_binary_operator_ok (MINUS, <MODE>mode, operands)"
6235 "#" 6455 "#"
6236 "reload_completed" 6456 "reload_completed"
6237 [(parallel [(set (reg:CC FLAGS_REG) 6457 [(parallel [(set (reg:CC FLAGS_REG)
6256 6476
6257 (define_insn "*sub<mode>_1" 6477 (define_insn "*sub<mode>_1"
6258 [(set (match_operand:SWI 0 "nonimmediate_operand" "=<r>m,<r>") 6478 [(set (match_operand:SWI 0 "nonimmediate_operand" "=<r>m,<r>")
6259 (minus:SWI 6479 (minus:SWI
6260 (match_operand:SWI 1 "nonimmediate_operand" "0,0") 6480 (match_operand:SWI 1 "nonimmediate_operand" "0,0")
6261 (match_operand:SWI 2 "<general_operand>" "<r><i>,<r>m"))) 6481 (match_operand:SWI 2 "<general_operand>" "<r><i>,m")))
6262 (clobber (reg:CC FLAGS_REG))] 6482 (clobber (reg:CC FLAGS_REG))]
6263 "ix86_binary_operator_ok (MINUS, <MODE>mode, operands)" 6483 "ix86_binary_operator_ok (MINUS, <MODE>mode, operands)"
6264 "sub{<imodesuffix>}\t{%2, %0|%0, %2}" 6484 "sub{<imodesuffix>}\t{%2, %0|%0, %2}"
6265 [(set_attr "type" "alu") 6485 [(set_attr "type" "alu")
6266 (set_attr "mode" "<MODE>")]) 6486 (set_attr "mode" "<MODE>")])
6274 "TARGET_64BIT && ix86_binary_operator_ok (MINUS, SImode, operands)" 6494 "TARGET_64BIT && ix86_binary_operator_ok (MINUS, SImode, operands)"
6275 "sub{l}\t{%2, %k0|%k0, %2}" 6495 "sub{l}\t{%2, %k0|%k0, %2}"
6276 [(set_attr "type" "alu") 6496 [(set_attr "type" "alu")
6277 (set_attr "mode" "SI")]) 6497 (set_attr "mode" "SI")])
6278 6498
6279 (define_insn "*subqi_1_slp" 6499 (define_insn "*sub<mode>_1_slp"
6280 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+qm,q")) 6500 [(set (strict_low_part (match_operand:SWI12 0 "register_operand" "+<r>"))
6281 (minus:QI (match_dup 0) 6501 (minus:SWI12 (match_operand:SWI12 1 "register_operand" "0")
6282 (match_operand:QI 1 "general_operand" "qn,qm"))) 6502 (match_operand:SWI12 2 "general_operand" "<r>mn")))
6283 (clobber (reg:CC FLAGS_REG))] 6503 (clobber (reg:CC FLAGS_REG))]
6284 "(! TARGET_PARTIAL_REG_STALL || optimize_function_for_size_p (cfun)) 6504 "(!TARGET_PARTIAL_REG_STALL || optimize_function_for_size_p (cfun))
6285 && !(MEM_P (operands[0]) && MEM_P (operands[1]))" 6505 /* FIXME: without this LRA can't reload this pattern, see PR82524. */
6286 "sub{b}\t{%1, %0|%0, %1}" 6506 && rtx_equal_p (operands[0], operands[1])"
6287 [(set_attr "type" "alu1") 6507 "sub{<imodesuffix>}\t{%2, %0|%0, %2}"
6288 (set_attr "mode" "QI")]) 6508 [(set_attr "type" "alu")
6509 (set_attr "mode" "<MODE>")])
6289 6510
6290 (define_insn "*sub<mode>_2" 6511 (define_insn "*sub<mode>_2"
6291 [(set (reg FLAGS_REG) 6512 [(set (reg FLAGS_REG)
6292 (compare 6513 (compare
6293 (minus:SWI 6514 (minus:SWI
6294 (match_operand:SWI 1 "nonimmediate_operand" "0,0") 6515 (match_operand:SWI 1 "nonimmediate_operand" "0,0")
6295 (match_operand:SWI 2 "<general_operand>" "<r><i>,<r>m")) 6516 (match_operand:SWI 2 "<general_operand>" "<r><i>,m"))
6296 (const_int 0))) 6517 (const_int 0)))
6297 (set (match_operand:SWI 0 "nonimmediate_operand" "=<r>m,<r>") 6518 (set (match_operand:SWI 0 "nonimmediate_operand" "=<r>m,<r>")
6298 (minus:SWI (match_dup 1) (match_dup 2)))] 6519 (minus:SWI (match_dup 1) (match_dup 2)))]
6299 "ix86_match_ccmode (insn, CCGOCmode) 6520 "ix86_match_ccmode (insn, CCGOCmode)
6300 && ix86_binary_operator_ok (MINUS, <MODE>mode, operands)" 6521 && ix86_binary_operator_ok (MINUS, <MODE>mode, operands)"
6319 (set_attr "mode" "SI")]) 6540 (set_attr "mode" "SI")])
6320 6541
6321 ;; Subtract with jump on overflow. 6542 ;; Subtract with jump on overflow.
6322 (define_expand "subv<mode>4" 6543 (define_expand "subv<mode>4"
6323 [(parallel [(set (reg:CCO FLAGS_REG) 6544 [(parallel [(set (reg:CCO FLAGS_REG)
6324 (eq:CCO (minus:<DWI> 6545 (eq:CCO
6325 (sign_extend:<DWI> 6546 (minus:<DPWI>
6326 (match_operand:SWI 1 "nonimmediate_operand")) 6547 (sign_extend:<DPWI>
6327 (match_dup 4)) 6548 (match_operand:SWIDWI 1 "nonimmediate_operand"))
6328 (sign_extend:<DWI> 6549 (match_dup 4))
6329 (minus:SWI (match_dup 1) 6550 (sign_extend:<DPWI>
6330 (match_operand:SWI 2 6551 (minus:SWIDWI (match_dup 1)
6331 "<general_operand>"))))) 6552 (match_operand:SWIDWI 2
6332 (set (match_operand:SWI 0 "register_operand") 6553 "<general_hilo_operand>")))))
6333 (minus:SWI (match_dup 1) (match_dup 2)))]) 6554 (set (match_operand:SWIDWI 0 "register_operand")
6555 (minus:SWIDWI (match_dup 1) (match_dup 2)))])
6334 (set (pc) (if_then_else 6556 (set (pc) (if_then_else
6335 (eq (reg:CCO FLAGS_REG) (const_int 0)) 6557 (eq (reg:CCO FLAGS_REG) (const_int 0))
6336 (label_ref (match_operand 3)) 6558 (label_ref (match_operand 3))
6337 (pc)))] 6559 (pc)))]
6338 "" 6560 ""
6339 { 6561 {
6340 ix86_fixup_binary_operands_no_copy (MINUS, <MODE>mode, operands); 6562 ix86_fixup_binary_operands_no_copy (MINUS, <MODE>mode, operands);
6341 if (CONST_INT_P (operands[2])) 6563 if (CONST_SCALAR_INT_P (operands[2]))
6342 operands[4] = operands[2]; 6564 operands[4] = operands[2];
6343 else 6565 else
6344 operands[4] = gen_rtx_SIGN_EXTEND (<DWI>mode, operands[2]); 6566 operands[4] = gen_rtx_SIGN_EXTEND (<DPWI>mode, operands[2]);
6345 }) 6567 })
6346 6568
6347 (define_insn "*subv<mode>4" 6569 (define_insn "*subv<mode>4"
6348 [(set (reg:CCO FLAGS_REG) 6570 [(set (reg:CCO FLAGS_REG)
6349 (eq:CCO (minus:<DWI> 6571 (eq:CCO (minus:<DWI>
6350 (sign_extend:<DWI> 6572 (sign_extend:<DWI>
6351 (match_operand:SWI 1 "nonimmediate_operand" "0,0")) 6573 (match_operand:SWI 1 "nonimmediate_operand" "0,0"))
6352 (sign_extend:<DWI> 6574 (sign_extend:<DWI>
6353 (match_operand:SWI 2 "<general_sext_operand>" 6575 (match_operand:SWI 2 "<general_sext_operand>" "<r>We,m")))
6354 "<r>We,<r>m")))
6355 (sign_extend:<DWI> 6576 (sign_extend:<DWI>
6356 (minus:SWI (match_dup 1) (match_dup 2))))) 6577 (minus:SWI (match_dup 1) (match_dup 2)))))
6357 (set (match_operand:SWI 0 "nonimmediate_operand" "=<r>m,<r>") 6578 (set (match_operand:SWI 0 "nonimmediate_operand" "=<r>m,<r>")
6358 (minus:SWI (match_dup 1) (match_dup 2)))] 6579 (minus:SWI (match_dup 1) (match_dup 2)))]
6359 "ix86_binary_operator_ok (MINUS, <MODE>mode, operands)" 6580 "ix86_binary_operator_ok (MINUS, <MODE>mode, operands)"
6360 "sub{<imodesuffix>}\t{%2, %0|%0, %2}" 6581 "sub{<imodesuffix>}\t{%2, %0|%0, %2}"
6361 [(set_attr "type" "alu") 6582 [(set_attr "type" "alu")
6362 (set_attr "mode" "<MODE>")]) 6583 (set_attr "mode" "<MODE>")])
6363 6584
6364 (define_insn "*subv<mode>4_1" 6585 (define_insn "subv<mode>4_1"
6365 [(set (reg:CCO FLAGS_REG) 6586 [(set (reg:CCO FLAGS_REG)
6366 (eq:CCO (minus:<DWI> 6587 (eq:CCO (minus:<DWI>
6367 (sign_extend:<DWI> 6588 (sign_extend:<DWI>
6368 (match_operand:SWI 1 "nonimmediate_operand" "0")) 6589 (match_operand:SWI 1 "nonimmediate_operand" "0"))
6369 (match_operand:<DWI> 3 "const_int_operand" "i")) 6590 (match_operand:<DWI> 3 "const_int_operand" "i"))
6370 (sign_extend:<DWI> 6591 (sign_extend:<DWI>
6371 (minus:SWI (match_dup 1) 6592 (minus:SWI
6372 (match_operand:SWI 2 "x86_64_immediate_operand" 6593 (match_dup 1)
6373 "<i>"))))) 6594 (match_operand:SWI 2 "x86_64_immediate_operand" "<i>")))))
6374 (set (match_operand:SWI 0 "nonimmediate_operand" "=<r>m") 6595 (set (match_operand:SWI 0 "nonimmediate_operand" "=<r>m")
6375 (minus:SWI (match_dup 1) (match_dup 2)))] 6596 (minus:SWI (match_dup 1) (match_dup 2)))]
6376 "ix86_binary_operator_ok (MINUS, <MODE>mode, operands) 6597 "ix86_binary_operator_ok (MINUS, <MODE>mode, operands)
6377 && CONST_INT_P (operands[2]) 6598 && CONST_INT_P (operands[2])
6378 && INTVAL (operands[2]) == INTVAL (operands[3])" 6599 && INTVAL (operands[2]) == INTVAL (operands[3])"
6384 (const_string "1") 6605 (const_string "1")
6385 (match_test "<MODE_SIZE> == 8") 6606 (match_test "<MODE_SIZE> == 8")
6386 (const_string "4")] 6607 (const_string "4")]
6387 (const_string "<MODE_SIZE>")))]) 6608 (const_string "<MODE_SIZE>")))])
6388 6609
6610 (define_insn_and_split "*subv<dwi>4_doubleword"
6611 [(set (reg:CCO FLAGS_REG)
6612 (eq:CCO
6613 (minus:<QPWI>
6614 (sign_extend:<QPWI>
6615 (match_operand:<DWI> 1 "nonimmediate_operand" "0,0"))
6616 (sign_extend:<QPWI>
6617 (match_operand:<DWI> 2 "nonimmediate_operand" "r,o")))
6618 (sign_extend:<QPWI>
6619 (minus:<DWI> (match_dup 1) (match_dup 2)))))
6620 (set (match_operand:<DWI> 0 "nonimmediate_operand" "=ro,r")
6621 (minus:<DWI> (match_dup 1) (match_dup 2)))]
6622 "ix86_binary_operator_ok (MINUS, <MODE>mode, operands)"
6623 "#"
6624 "reload_completed"
6625 [(parallel [(set (reg:CC FLAGS_REG)
6626 (compare:CC (match_dup 1) (match_dup 2)))
6627 (set (match_dup 0)
6628 (minus:DWIH (match_dup 1) (match_dup 2)))])
6629 (parallel [(set (reg:CCO FLAGS_REG)
6630 (eq:CCO
6631 (minus:<DWI>
6632 (minus:<DWI>
6633 (sign_extend:<DWI> (match_dup 4))
6634 (ltu:<DWI> (reg:CC FLAGS_REG) (const_int 0)))
6635 (sign_extend:<DWI> (match_dup 5)))
6636 (sign_extend:<DWI>
6637 (minus:DWIH
6638 (minus:DWIH
6639 (match_dup 4)
6640 (ltu:DWIH (reg:CC FLAGS_REG) (const_int 0)))
6641 (match_dup 5)))))
6642 (set (match_dup 3)
6643 (minus:DWIH
6644 (minus:DWIH
6645 (match_dup 4)
6646 (ltu:DWIH (reg:CC FLAGS_REG) (const_int 0)))
6647 (match_dup 5)))])]
6648 {
6649 split_double_mode (<DWI>mode, &operands[0], 3, &operands[0], &operands[3]);
6650 })
6651
6652 (define_insn_and_split "*subv<dwi>4_doubleword_1"
6653 [(set (reg:CCO FLAGS_REG)
6654 (eq:CCO
6655 (minus:<QPWI>
6656 (sign_extend:<QPWI>
6657 (match_operand:<DWI> 1 "nonimmediate_operand" "0"))
6658 (match_operand:<QPWI> 3 "const_scalar_int_operand" ""))
6659 (sign_extend:<QPWI>
6660 (minus:<DWI>
6661 (match_dup 1)
6662 (match_operand:<DWI> 2 "x86_64_hilo_general_operand" "<di>")))))
6663 (set (match_operand:<DWI> 0 "nonimmediate_operand" "=ro")
6664 (minus:<DWI> (match_dup 1) (match_dup 2)))]
6665 "ix86_binary_operator_ok (MINUS, <MODE>mode, operands)
6666 && CONST_SCALAR_INT_P (operands[2])
6667 && rtx_equal_p (operands[2], operands[3])"
6668 "#"
6669 "reload_completed"
6670 [(parallel [(set (reg:CC FLAGS_REG)
6671 (compare:CC (match_dup 1) (match_dup 2)))
6672 (set (match_dup 0)
6673 (minus:DWIH (match_dup 1) (match_dup 2)))])
6674 (parallel [(set (reg:CCO FLAGS_REG)
6675 (eq:CCO
6676 (minus:<DWI>
6677 (minus:<DWI>
6678 (sign_extend:<DWI> (match_dup 4))
6679 (ltu:<DWI> (reg:CC FLAGS_REG) (const_int 0)))
6680 (match_dup 5))
6681 (sign_extend:<DWI>
6682 (minus:DWIH
6683 (minus:DWIH
6684 (match_dup 4)
6685 (ltu:DWIH (reg:CC FLAGS_REG) (const_int 0)))
6686 (match_dup 5)))))
6687 (set (match_dup 3)
6688 (minus:DWIH
6689 (minus:DWIH
6690 (match_dup 4)
6691 (ltu:DWIH (reg:CC FLAGS_REG) (const_int 0)))
6692 (match_dup 5)))])]
6693 {
6694 split_double_mode (<DWI>mode, &operands[0], 3, &operands[0], &operands[3]);
6695 if (operands[2] == const0_rtx)
6696 {
6697 emit_insn (gen_subv<mode>4_1 (operands[3], operands[4], operands[5],
6698 operands[5]));
6699 DONE;
6700 }
6701 })
6702
6703 (define_insn "*subv<mode>4_overflow_1"
6704 [(set (reg:CCO FLAGS_REG)
6705 (eq:CCO
6706 (minus:<DWI>
6707 (minus:<DWI>
6708 (sign_extend:<DWI>
6709 (match_operand:SWI 1 "nonimmediate_operand" "%0,0"))
6710 (match_operator:<DWI> 4 "ix86_carry_flag_operator"
6711 [(match_operand 3 "flags_reg_operand") (const_int 0)]))
6712 (sign_extend:<DWI>
6713 (match_operand:SWI 2 "<general_sext_operand>" "rWe,m")))
6714 (sign_extend:<DWI>
6715 (minus:SWI
6716 (minus:SWI
6717 (match_dup 1)
6718 (match_operator:SWI 5 "ix86_carry_flag_operator"
6719 [(match_dup 3) (const_int 0)]))
6720 (match_dup 2)))))
6721 (set (match_operand:SWI 0 "nonimmediate_operand" "=rm,r")
6722 (minus:SWI
6723 (minus:SWI
6724 (match_dup 1)
6725 (match_op_dup 5 [(match_dup 3) (const_int 0)]))
6726 (match_dup 2)))]
6727 "ix86_binary_operator_ok (MINUS, <MODE>mode, operands)"
6728 "sbb{<imodesuffix>}\t{%2, %0|%0, %2}"
6729 [(set_attr "type" "alu")
6730 (set_attr "mode" "<MODE>")])
6731
6732 (define_insn "*subv<mode>4_overflow_2"
6733 [(set (reg:CCO FLAGS_REG)
6734 (eq:CCO
6735 (minus:<DWI>
6736 (minus:<DWI>
6737 (sign_extend:<DWI>
6738 (match_operand:SWI 1 "nonimmediate_operand" "%0"))
6739 (match_operator:<DWI> 4 "ix86_carry_flag_operator"
6740 [(match_operand 3 "flags_reg_operand") (const_int 0)]))
6741 (match_operand:<DWI> 6 "const_int_operand" ""))
6742 (sign_extend:<DWI>
6743 (minus:SWI
6744 (minus:SWI
6745 (match_dup 1)
6746 (match_operator:SWI 5 "ix86_carry_flag_operator"
6747 [(match_dup 3) (const_int 0)]))
6748 (match_operand:SWI 2 "x86_64_immediate_operand" "e")))))
6749 (set (match_operand:SWI 0 "nonimmediate_operand" "=rm")
6750 (minus:SWI
6751 (minus:SWI
6752 (match_dup 1)
6753 (match_op_dup 5 [(match_dup 3) (const_int 0)]))
6754 (match_dup 2)))]
6755 "ix86_binary_operator_ok (MINUS, <MODE>mode, operands)
6756 && CONST_INT_P (operands[2])
6757 && INTVAL (operands[2]) == INTVAL (operands[6])"
6758 "sbb{<imodesuffix>}\t{%2, %0|%0, %2}"
6759 [(set_attr "type" "alu")
6760 (set_attr "mode" "<MODE>")
6761 (set (attr "length_immediate")
6762 (if_then_else (match_test "IN_RANGE (INTVAL (operands[2]), -128, 127)")
6763 (const_string "1")
6764 (const_string "4")))])
6765
6389 (define_expand "usubv<mode>4" 6766 (define_expand "usubv<mode>4"
6390 [(parallel [(set (reg:CC FLAGS_REG) 6767 [(parallel [(set (reg:CC FLAGS_REG)
6391 (compare:CC 6768 (compare:CC
6392 (match_operand:SWI 1 "nonimmediate_operand") 6769 (match_operand:SWI 1 "nonimmediate_operand")
6393 (match_operand:SWI 2 "<general_operand>"))) 6770 (match_operand:SWI 2 "<general_operand>")))
6401 "ix86_fixup_binary_operands_no_copy (MINUS, <MODE>mode, operands);") 6778 "ix86_fixup_binary_operands_no_copy (MINUS, <MODE>mode, operands);")
6402 6779
6403 (define_insn "*sub<mode>_3" 6780 (define_insn "*sub<mode>_3"
6404 [(set (reg FLAGS_REG) 6781 [(set (reg FLAGS_REG)
6405 (compare (match_operand:SWI 1 "nonimmediate_operand" "0,0") 6782 (compare (match_operand:SWI 1 "nonimmediate_operand" "0,0")
6406 (match_operand:SWI 2 "<general_operand>" "<r><i>,<r>m"))) 6783 (match_operand:SWI 2 "<general_operand>" "<r><i>,m")))
6407 (set (match_operand:SWI 0 "nonimmediate_operand" "=<r>m,<r>") 6784 (set (match_operand:SWI 0 "nonimmediate_operand" "=<r>m,<r>")
6408 (minus:SWI (match_dup 1) (match_dup 2)))] 6785 (minus:SWI (match_dup 1) (match_dup 2)))]
6409 "ix86_match_ccmode (insn, CCmode) 6786 "ix86_match_ccmode (insn, CCmode)
6410 && ix86_binary_operator_ok (MINUS, <MODE>mode, operands)" 6787 && ix86_binary_operator_ok (MINUS, <MODE>mode, operands)"
6411 "sub{<imodesuffix>}\t{%2, %0|%0, %2}" 6788 "sub{<imodesuffix>}\t{%2, %0|%0, %2}"
6420 (set (match_dup 0) 6797 (set (match_dup 0)
6421 (minus:SWI (match_dup 0) (match_dup 1)))])] 6798 (minus:SWI (match_dup 0) (match_dup 1)))])]
6422 "find_regno_note (peep2_next_insn (0), REG_UNUSED, REGNO (operands[0])) != 0" 6799 "find_regno_note (peep2_next_insn (0), REG_UNUSED, REGNO (operands[0])) != 0"
6423 [(set (reg:CC FLAGS_REG) 6800 [(set (reg:CC FLAGS_REG)
6424 (compare:CC (match_dup 0) (match_dup 1)))]) 6801 (compare:CC (match_dup 0) (match_dup 1)))])
6802
6803 ;; decl %eax; cmpl $-1, %eax; jne .Lxx; can be optimized into
6804 ;; subl $1, %eax; jnc .Lxx;
6805 (define_peephole2
6806 [(parallel
6807 [(set (match_operand:SWI 0 "general_reg_operand")
6808 (plus:SWI (match_dup 0) (const_int -1)))
6809 (clobber (reg FLAGS_REG))])
6810 (set (reg:CCZ FLAGS_REG)
6811 (compare:CCZ (match_dup 0) (const_int -1)))
6812 (set (pc)
6813 (if_then_else (match_operator 1 "bt_comparison_operator"
6814 [(reg:CCZ FLAGS_REG) (const_int 0)])
6815 (match_operand 2)
6816 (pc)))]
6817 "peep2_regno_dead_p (3, FLAGS_REG)"
6818 [(parallel
6819 [(set (reg:CC FLAGS_REG)
6820 (compare:CC (match_dup 0) (const_int 1)))
6821 (set (match_dup 0)
6822 (minus:SWI (match_dup 0) (const_int 1)))])
6823 (set (pc)
6824 (if_then_else (match_dup 3)
6825 (match_dup 2)
6826 (pc)))]
6827 {
6828 rtx cc = gen_rtx_REG (CCmode, FLAGS_REG);
6829 operands[3] = gen_rtx_fmt_ee (GET_CODE (operands[1]) == NE
6830 ? GEU : LTU, VOIDmode, cc, const0_rtx);
6831 })
6425 6832
6426 (define_insn "*subsi_3_zext" 6833 (define_insn "*subsi_3_zext"
6427 [(set (reg FLAGS_REG) 6834 [(set (reg FLAGS_REG)
6428 (compare (match_operand:SI 1 "register_operand" "0") 6835 (compare (match_operand:SI 1 "register_operand" "0")
6429 (match_operand:SI 2 "x86_64_general_operand" "rme"))) 6836 (match_operand:SI 2 "x86_64_general_operand" "rme")))
6437 [(set_attr "type" "alu") 6844 [(set_attr "type" "alu")
6438 (set_attr "mode" "SI")]) 6845 (set_attr "mode" "SI")])
6439 6846
6440 ;; Add with carry and subtract with borrow 6847 ;; Add with carry and subtract with borrow
6441 6848
6442 (define_insn "add<mode>3_carry" 6849 (define_insn "@add<mode>3_carry"
6443 [(set (match_operand:SWI 0 "nonimmediate_operand" "=<r>m,<r>") 6850 [(set (match_operand:SWI 0 "nonimmediate_operand" "=<r>m,<r>")
6444 (plus:SWI 6851 (plus:SWI
6445 (plus:SWI 6852 (plus:SWI
6446 (match_operator:SWI 4 "ix86_carry_flag_operator" 6853 (match_operator:SWI 4 "ix86_carry_flag_operator"
6447 [(match_operand 3 "flags_reg_operand") (const_int 0)]) 6854 [(match_operand 3 "flags_reg_operand") (const_int 0)])
6448 (match_operand:SWI 1 "nonimmediate_operand" "%0,0")) 6855 (match_operand:SWI 1 "nonimmediate_operand" "%0,0"))
6449 (match_operand:SWI 2 "<general_operand>" "<r><i>,<r>m"))) 6856 (match_operand:SWI 2 "<general_operand>" "<r><i>,m")))
6450 (clobber (reg:CC FLAGS_REG))] 6857 (clobber (reg:CC FLAGS_REG))]
6451 "ix86_binary_operator_ok (PLUS, <MODE>mode, operands)" 6858 "ix86_binary_operator_ok (PLUS, <MODE>mode, operands)"
6452 "adc{<imodesuffix>}\t{%2, %0|%0, %2}" 6859 "adc{<imodesuffix>}\t{%2, %0|%0, %2}"
6453 [(set_attr "type" "alu") 6860 [(set_attr "type" "alu")
6454 (set_attr "use_carry" "1") 6861 (set_attr "use_carry" "1")
6507 (zero_extend:<DWI> 6914 (zero_extend:<DWI>
6508 (plus:SWI48 6915 (plus:SWI48
6509 (plus:SWI48 6916 (plus:SWI48
6510 (match_operator:SWI48 5 "ix86_carry_flag_operator" 6917 (match_operator:SWI48 5 "ix86_carry_flag_operator"
6511 [(match_operand 3 "flags_reg_operand") (const_int 0)]) 6918 [(match_operand 3 "flags_reg_operand") (const_int 0)])
6512 (match_operand:SWI48 1 "nonimmediate_operand" "%0")) 6919 (match_operand:SWI48 1 "nonimmediate_operand" "%0,0"))
6513 (match_operand:SWI48 2 "nonimmediate_operand" "rm"))) 6920 (match_operand:SWI48 2 "nonimmediate_operand" "r,rm")))
6514 (plus:<DWI> 6921 (plus:<DWI>
6515 (zero_extend:<DWI> (match_dup 2)) 6922 (zero_extend:<DWI> (match_dup 2))
6516 (match_operator:<DWI> 4 "ix86_carry_flag_operator" 6923 (match_operator:<DWI> 4 "ix86_carry_flag_operator"
6517 [(match_dup 3) (const_int 0)])))) 6924 [(match_dup 3) (const_int 0)]))))
6518 (set (match_operand:SWI48 0 "register_operand" "=r") 6925 (set (match_operand:SWI48 0 "nonimmediate_operand" "=rm,r")
6519 (plus:SWI48 (plus:SWI48 (match_op_dup 5 6926 (plus:SWI48 (plus:SWI48 (match_op_dup 5
6520 [(match_dup 3) (const_int 0)]) 6927 [(match_dup 3) (const_int 0)])
6521 (match_dup 1)) 6928 (match_dup 1))
6522 (match_dup 2)))] 6929 (match_dup 2)))]
6523 "ix86_binary_operator_ok (PLUS, <MODE>mode, operands)" 6930 "ix86_binary_operator_ok (PLUS, <MODE>mode, operands)"
6533 (compare:CCC 6940 (compare:CCC
6534 (plus:SWI48 6941 (plus:SWI48
6535 (match_operand:SWI48 1 "nonimmediate_operand") 6942 (match_operand:SWI48 1 "nonimmediate_operand")
6536 (match_operand:SWI48 2 "x86_64_general_operand")) 6943 (match_operand:SWI48 2 "x86_64_general_operand"))
6537 (match_dup 1))) 6944 (match_dup 1)))
6538 (set (match_operand:SWI48 0 "register_operand") 6945 (set (match_operand:SWI48 0 "nonimmediate_operand")
6539 (plus:SWI48 (match_dup 1) (match_dup 2)))])] 6946 (plus:SWI48 (match_dup 1) (match_dup 2)))])]
6540 "ix86_binary_operator_ok (PLUS, <MODE>mode, operands)") 6947 "ix86_binary_operator_ok (PLUS, <MODE>mode, operands)")
6541 6948
6542 (define_insn "sub<mode>3_carry" 6949 (define_insn "*addcarry<mode>_1"
6950 [(set (reg:CCC FLAGS_REG)
6951 (compare:CCC
6952 (zero_extend:<DWI>
6953 (plus:SWI48
6954 (plus:SWI48
6955 (match_operator:SWI48 5 "ix86_carry_flag_operator"
6956 [(match_operand 3 "flags_reg_operand") (const_int 0)])
6957 (match_operand:SWI48 1 "nonimmediate_operand" "%0"))
6958 (match_operand:SWI48 2 "x86_64_immediate_operand" "e")))
6959 (plus:<DWI>
6960 (match_operand:<DWI> 6 "const_scalar_int_operand" "")
6961 (match_operator:<DWI> 4 "ix86_carry_flag_operator"
6962 [(match_dup 3) (const_int 0)]))))
6963 (set (match_operand:SWI48 0 "nonimmediate_operand" "=rm")
6964 (plus:SWI48 (plus:SWI48 (match_op_dup 5
6965 [(match_dup 3) (const_int 0)])
6966 (match_dup 1))
6967 (match_dup 2)))]
6968 "ix86_binary_operator_ok (PLUS, <MODE>mode, operands)
6969 && CONST_INT_P (operands[2])
6970 /* Check that operands[6] is operands[2] zero extended from
6971 <MODE>mode to <DWI>mode. */
6972 && ((<MODE>mode == SImode || INTVAL (operands[2]) >= 0)
6973 ? (CONST_INT_P (operands[6])
6974 && UINTVAL (operands[6]) == (UINTVAL (operands[2])
6975 & GET_MODE_MASK (<MODE>mode)))
6976 : (CONST_WIDE_INT_P (operands[6])
6977 && CONST_WIDE_INT_NUNITS (operands[6]) == 2
6978 && ((unsigned HOST_WIDE_INT) CONST_WIDE_INT_ELT (operands[6], 0)
6979 == UINTVAL (operands[2]))
6980 && CONST_WIDE_INT_ELT (operands[6], 1) == 0))"
6981 "adc{<imodesuffix>}\t{%2, %0|%0, %2}"
6982 [(set_attr "type" "alu")
6983 (set_attr "use_carry" "1")
6984 (set_attr "pent_pair" "pu")
6985 (set_attr "mode" "<MODE>")
6986 (set (attr "length_immediate")
6987 (if_then_else (match_test "IN_RANGE (INTVAL (operands[2]), -128, 127)")
6988 (const_string "1")
6989 (const_string "4")))])
6990
6991 (define_insn "@sub<mode>3_carry"
6543 [(set (match_operand:SWI 0 "nonimmediate_operand" "=<r>m,<r>") 6992 [(set (match_operand:SWI 0 "nonimmediate_operand" "=<r>m,<r>")
6544 (minus:SWI 6993 (minus:SWI
6545 (minus:SWI 6994 (minus:SWI
6546 (match_operand:SWI 1 "nonimmediate_operand" "0,0") 6995 (match_operand:SWI 1 "nonimmediate_operand" "0,0")
6547 (match_operator:SWI 4 "ix86_carry_flag_operator" 6996 (match_operator:SWI 4 "ix86_carry_flag_operator"
6548 [(match_operand 3 "flags_reg_operand") (const_int 0)])) 6997 [(match_operand 3 "flags_reg_operand") (const_int 0)]))
6549 (match_operand:SWI 2 "<general_operand>" "<r><i>,<r>m"))) 6998 (match_operand:SWI 2 "<general_operand>" "<r><i>,m")))
6550 (clobber (reg:CC FLAGS_REG))] 6999 (clobber (reg:CC FLAGS_REG))]
6551 "ix86_binary_operator_ok (MINUS, <MODE>mode, operands)" 7000 "ix86_binary_operator_ok (MINUS, <MODE>mode, operands)"
6552 "sbb{<imodesuffix>}\t{%2, %0|%0, %2}" 7001 "sbb{<imodesuffix>}\t{%2, %0|%0, %2}"
6553 [(set_attr "type" "alu") 7002 [(set_attr "type" "alu")
6554 (set_attr "use_carry" "1") 7003 (set_attr "use_carry" "1")
6599 [(set_attr "type" "alu") 7048 [(set_attr "type" "alu")
6600 (set_attr "use_carry" "1") 7049 (set_attr "use_carry" "1")
6601 (set_attr "pent_pair" "pu") 7050 (set_attr "pent_pair" "pu")
6602 (set_attr "mode" "SI")]) 7051 (set_attr "mode" "SI")])
6603 7052
6604 (define_insn "sub<mode>3_carry_ccc" 7053 (define_insn "@sub<mode>3_carry_ccc"
6605 [(set (reg:CCC FLAGS_REG) 7054 [(set (reg:CCC FLAGS_REG)
6606 (compare:CCC 7055 (compare:CCC
6607 (zero_extend:<DWI> (match_operand:DWIH 1 "register_operand" "0")) 7056 (zero_extend:<DWI> (match_operand:DWIH 1 "register_operand" "0"))
6608 (plus:<DWI> 7057 (plus:<DWI>
6609 (ltu:<DWI> (reg:CC FLAGS_REG) (const_int 0)) 7058 (ltu:<DWI> (reg:CC FLAGS_REG) (const_int 0))
6633 7082
6634 ;; The sign flag is set from the 7083 ;; The sign flag is set from the
6635 ;; (compare (match_dup 1) (plus:DWIH (ltu:DWIH ...) (match_dup 2))) 7084 ;; (compare (match_dup 1) (plus:DWIH (ltu:DWIH ...) (match_dup 2)))
6636 ;; result, the overflow flag likewise, but the overflow flag is also 7085 ;; result, the overflow flag likewise, but the overflow flag is also
6637 ;; set if the (plus:DWIH (ltu:DWIH ...) (match_dup 2)) overflows. 7086 ;; set if the (plus:DWIH (ltu:DWIH ...) (match_dup 2)) overflows.
6638 (define_insn "sub<mode>3_carry_ccgz" 7087 (define_insn "@sub<mode>3_carry_ccgz"
6639 [(set (reg:CCGZ FLAGS_REG) 7088 [(set (reg:CCGZ FLAGS_REG)
6640 (unspec:CCGZ [(match_operand:DWIH 1 "register_operand" "0") 7089 (unspec:CCGZ [(match_operand:DWIH 1 "register_operand" "0")
6641 (match_operand:DWIH 2 "x86_64_general_operand" "rme") 7090 (match_operand:DWIH 2 "x86_64_general_operand" "rme")
6642 (ltu:DWIH (reg:CC FLAGS_REG) (const_int 0))] 7091 (ltu:DWIH (reg:CC FLAGS_REG) (const_int 0))]
6643 UNSPEC_SBB)) 7092 UNSPEC_SBB))
6709 (define_insn "*add<mode>3_cc_overflow_1" 7158 (define_insn "*add<mode>3_cc_overflow_1"
6710 [(set (reg:CCC FLAGS_REG) 7159 [(set (reg:CCC FLAGS_REG)
6711 (compare:CCC 7160 (compare:CCC
6712 (plus:SWI 7161 (plus:SWI
6713 (match_operand:SWI 1 "nonimmediate_operand" "%0,0") 7162 (match_operand:SWI 1 "nonimmediate_operand" "%0,0")
6714 (match_operand:SWI 2 "<general_operand>" "<r><i>,<r>m")) 7163 (match_operand:SWI 2 "<general_operand>" "<r><i>,m"))
6715 (match_dup 1))) 7164 (match_dup 1)))
6716 (set (match_operand:SWI 0 "nonimmediate_operand" "=<r>m,<r>") 7165 (set (match_operand:SWI 0 "nonimmediate_operand" "=<r>m,<r>")
6717 (plus:SWI (match_dup 1) (match_dup 2)))] 7166 (plus:SWI (match_dup 1) (match_dup 2)))]
6718 "ix86_binary_operator_ok (PLUS, <MODE>mode, operands)" 7167 "ix86_binary_operator_ok (PLUS, <MODE>mode, operands)"
6719 "add{<imodesuffix>}\t{%2, %0|%0, %2}" 7168 "add{<imodesuffix>}\t{%2, %0|%0, %2}"
6750 (define_insn "*add<mode>3_cc_overflow_2" 7199 (define_insn "*add<mode>3_cc_overflow_2"
6751 [(set (reg:CCC FLAGS_REG) 7200 [(set (reg:CCC FLAGS_REG)
6752 (compare:CCC 7201 (compare:CCC
6753 (plus:SWI 7202 (plus:SWI
6754 (match_operand:SWI 1 "nonimmediate_operand" "%0,0") 7203 (match_operand:SWI 1 "nonimmediate_operand" "%0,0")
6755 (match_operand:SWI 2 "<general_operand>" "<r><i>,<r>m")) 7204 (match_operand:SWI 2 "<general_operand>" "<r><i>,m"))
6756 (match_dup 2))) 7205 (match_dup 2)))
6757 (set (match_operand:SWI 0 "nonimmediate_operand" "=<r>m,<r>") 7206 (set (match_operand:SWI 0 "nonimmediate_operand" "=<r>m,<r>")
6758 (plus:SWI (match_dup 1) (match_dup 2)))] 7207 (plus:SWI (match_dup 1) (match_dup 2)))]
6759 "ix86_binary_operator_ok (PLUS, <MODE>mode, operands)" 7208 "ix86_binary_operator_ok (PLUS, <MODE>mode, operands)"
6760 "add{<imodesuffix>}\t{%2, %0|%0, %2}" 7209 "add{<imodesuffix>}\t{%2, %0|%0, %2}"
6772 (zero_extend:DI (plus:SI (match_dup 1) (match_dup 2))))] 7221 (zero_extend:DI (plus:SI (match_dup 1) (match_dup 2))))]
6773 "TARGET_64BIT && ix86_binary_operator_ok (PLUS, SImode, operands)" 7222 "TARGET_64BIT && ix86_binary_operator_ok (PLUS, SImode, operands)"
6774 "add{l}\t{%2, %k0|%k0, %2}" 7223 "add{l}\t{%2, %k0|%k0, %2}"
6775 [(set_attr "type" "alu") 7224 [(set_attr "type" "alu")
6776 (set_attr "mode" "SI")]) 7225 (set_attr "mode" "SI")])
7226
7227 (define_insn_and_split "*add<dwi>3_doubleword_cc_overflow_1"
7228 [(set (reg:CCC FLAGS_REG)
7229 (compare:CCC
7230 (plus:<DWI>
7231 (match_operand:<DWI> 1 "nonimmediate_operand" "%0,0")
7232 (match_operand:<DWI> 2 "x86_64_hilo_general_operand" "r<di>,o"))
7233 (match_dup 1)))
7234 (set (match_operand:<DWI> 0 "nonimmediate_operand" "=ro,r")
7235 (plus:<DWI> (match_dup 1) (match_dup 2)))]
7236 "ix86_binary_operator_ok (PLUS, <DWI>mode, operands)"
7237 "#"
7238 "reload_completed"
7239 [(parallel [(set (reg:CCC FLAGS_REG)
7240 (compare:CCC
7241 (plus:DWIH (match_dup 1) (match_dup 2))
7242 (match_dup 1)))
7243 (set (match_dup 0)
7244 (plus:DWIH (match_dup 1) (match_dup 2)))])
7245 (parallel [(set (reg:CCC FLAGS_REG)
7246 (compare:CCC
7247 (zero_extend:<DWI>
7248 (plus:DWIH
7249 (plus:DWIH
7250 (ltu:DWIH (reg:CC FLAGS_REG) (const_int 0))
7251 (match_dup 4))
7252 (match_dup 5)))
7253 (plus:<DWI>
7254 (match_dup 6)
7255 (ltu:<DWI> (reg:CC FLAGS_REG) (const_int 0)))))
7256 (set (match_dup 3)
7257 (plus:DWIH
7258 (plus:DWIH (ltu:DWIH (reg:CC FLAGS_REG) (const_int 0))
7259 (match_dup 4))
7260 (match_dup 5)))])]
7261 {
7262 split_double_mode (<DWI>mode, &operands[0], 3, &operands[0], &operands[3]);
7263 if (operands[2] == const0_rtx)
7264 {
7265 emit_insn (gen_addcarry<mode>_0 (operands[3], operands[4], operands[5]));
7266 DONE;
7267 }
7268 if (CONST_INT_P (operands[5]))
7269 operands[6] = simplify_unary_operation (ZERO_EXTEND, <DWI>mode,
7270 operands[5], <MODE>mode);
7271 else
7272 operands[6] = gen_rtx_ZERO_EXTEND (<DWI>mode, operands[5]);
7273 })
7274
7275 ;; x == 0 with zero flag test can be done also as x < 1U with carry flag
7276 ;; test, where the latter is preferrable if we have some carry consuming
7277 ;; instruction.
7278 ;; For x != 0, we need to use x < 1U with negation of carry, i.e.
7279 ;; + (1 - CF).
7280 (define_insn_and_split "*add<mode>3_eq"
7281 [(set (match_operand:SWI 0 "nonimmediate_operand")
7282 (plus:SWI
7283 (plus:SWI
7284 (eq:SWI (match_operand 3 "int_nonimmediate_operand") (const_int 0))
7285 (match_operand:SWI 1 "nonimmediate_operand"))
7286 (match_operand:SWI 2 "<general_operand>")))
7287 (clobber (reg:CC FLAGS_REG))]
7288 "ix86_binary_operator_ok (PLUS, <MODE>mode, operands)
7289 && ix86_pre_reload_split ()"
7290 "#"
7291 "&& 1"
7292 [(set (reg:CC FLAGS_REG)
7293 (compare:CC (match_dup 3) (const_int 1)))
7294 (parallel [(set (match_dup 0)
7295 (plus:SWI
7296 (plus:SWI (ltu:SWI (reg:CC FLAGS_REG) (const_int 0))
7297 (match_dup 1))
7298 (match_dup 2)))
7299 (clobber (reg:CC FLAGS_REG))])])
7300
7301 (define_insn_and_split "*add<mode>3_ne"
7302 [(set (match_operand:SWI 0 "nonimmediate_operand")
7303 (plus:SWI
7304 (plus:SWI
7305 (ne:SWI (match_operand 3 "int_nonimmediate_operand") (const_int 0))
7306 (match_operand:SWI 1 "nonimmediate_operand"))
7307 (match_operand:SWI 2 "<immediate_operand>")))
7308 (clobber (reg:CC FLAGS_REG))]
7309 "CONST_INT_P (operands[2])
7310 && (<MODE>mode != DImode
7311 || INTVAL (operands[2]) != HOST_WIDE_INT_C (-0x80000000))
7312 && ix86_binary_operator_ok (PLUS, <MODE>mode, operands)
7313 && ix86_pre_reload_split ()"
7314 "#"
7315 "&& 1"
7316 [(set (reg:CC FLAGS_REG)
7317 (compare:CC (match_dup 3) (const_int 1)))
7318 (parallel [(set (match_dup 0)
7319 (minus:SWI
7320 (minus:SWI (match_dup 1)
7321 (ltu:SWI (reg:CC FLAGS_REG) (const_int 0)))
7322 (match_dup 2)))
7323 (clobber (reg:CC FLAGS_REG))])]
7324 {
7325 operands[2] = gen_int_mode (~INTVAL (operands[2]),
7326 <MODE>mode == DImode ? SImode : <MODE>mode);
7327 })
7328
7329 (define_insn_and_split "*add<mode>3_eq_0"
7330 [(set (match_operand:SWI 0 "nonimmediate_operand")
7331 (plus:SWI
7332 (eq:SWI (match_operand 2 "int_nonimmediate_operand") (const_int 0))
7333 (match_operand:SWI 1 "<general_operand>")))
7334 (clobber (reg:CC FLAGS_REG))]
7335 "ix86_unary_operator_ok (PLUS, <MODE>mode, operands)
7336 && ix86_pre_reload_split ()"
7337 "#"
7338 "&& 1"
7339 [(set (reg:CC FLAGS_REG)
7340 (compare:CC (match_dup 2) (const_int 1)))
7341 (parallel [(set (match_dup 0)
7342 (plus:SWI (ltu:SWI (reg:CC FLAGS_REG) (const_int 0))
7343 (match_dup 1)))
7344 (clobber (reg:CC FLAGS_REG))])]
7345 {
7346 if (!nonimmediate_operand (operands[1], <MODE>mode))
7347 operands[1] = force_reg (<MODE>mode, operands[1]);
7348 })
7349
7350 (define_insn_and_split "*add<mode>3_ne_0"
7351 [(set (match_operand:SWI 0 "nonimmediate_operand")
7352 (plus:SWI
7353 (ne:SWI (match_operand 2 "int_nonimmediate_operand") (const_int 0))
7354 (match_operand:SWI 1 "<general_operand>")))
7355 (clobber (reg:CC FLAGS_REG))]
7356 "ix86_unary_operator_ok (PLUS, <MODE>mode, operands)
7357 && ix86_pre_reload_split ()"
7358 "#"
7359 "&& 1"
7360 [(set (reg:CC FLAGS_REG)
7361 (compare:CC (match_dup 2) (const_int 1)))
7362 (parallel [(set (match_dup 0)
7363 (minus:SWI (minus:SWI
7364 (match_dup 1)
7365 (ltu:SWI (reg:CC FLAGS_REG) (const_int 0)))
7366 (const_int -1)))
7367 (clobber (reg:CC FLAGS_REG))])]
7368 {
7369 if (!nonimmediate_operand (operands[1], <MODE>mode))
7370 operands[1] = force_reg (<MODE>mode, operands[1]);
7371 })
7372
7373 (define_insn_and_split "*sub<mode>3_eq"
7374 [(set (match_operand:SWI 0 "nonimmediate_operand")
7375 (minus:SWI
7376 (minus:SWI
7377 (match_operand:SWI 1 "nonimmediate_operand")
7378 (eq:SWI (match_operand 3 "int_nonimmediate_operand")
7379 (const_int 0)))
7380 (match_operand:SWI 2 "<general_operand>")))
7381 (clobber (reg:CC FLAGS_REG))]
7382 "ix86_binary_operator_ok (MINUS, <MODE>mode, operands)
7383 && ix86_pre_reload_split ()"
7384 "#"
7385 "&& 1"
7386 [(set (reg:CC FLAGS_REG)
7387 (compare:CC (match_dup 3) (const_int 1)))
7388 (parallel [(set (match_dup 0)
7389 (minus:SWI
7390 (minus:SWI (match_dup 1)
7391 (ltu:SWI (reg:CC FLAGS_REG) (const_int 0)))
7392 (match_dup 2)))
7393 (clobber (reg:CC FLAGS_REG))])])
7394
7395 (define_insn_and_split "*sub<mode>3_ne"
7396 [(set (match_operand:SWI 0 "nonimmediate_operand")
7397 (plus:SWI
7398 (minus:SWI
7399 (match_operand:SWI 1 "nonimmediate_operand")
7400 (ne:SWI (match_operand 3 "int_nonimmediate_operand")
7401 (const_int 0)))
7402 (match_operand:SWI 2 "<immediate_operand>")))
7403 (clobber (reg:CC FLAGS_REG))]
7404 "CONST_INT_P (operands[2])
7405 && (<MODE>mode != DImode
7406 || INTVAL (operands[2]) != HOST_WIDE_INT_C (-0x80000000))
7407 && ix86_binary_operator_ok (MINUS, <MODE>mode, operands)
7408 && ix86_pre_reload_split ()"
7409 "#"
7410 "&& 1"
7411 [(set (reg:CC FLAGS_REG)
7412 (compare:CC (match_dup 3) (const_int 1)))
7413 (parallel [(set (match_dup 0)
7414 (plus:SWI
7415 (plus:SWI (ltu:SWI (reg:CC FLAGS_REG) (const_int 0))
7416 (match_dup 1))
7417 (match_dup 2)))
7418 (clobber (reg:CC FLAGS_REG))])]
7419 {
7420 operands[2] = gen_int_mode (INTVAL (operands[2]) - 1,
7421 <MODE>mode == DImode ? SImode : <MODE>mode);
7422 })
7423
7424 (define_insn_and_split "*sub<mode>3_eq_1"
7425 [(set (match_operand:SWI 0 "nonimmediate_operand")
7426 (plus:SWI
7427 (minus:SWI
7428 (match_operand:SWI 1 "nonimmediate_operand")
7429 (eq:SWI (match_operand 3 "int_nonimmediate_operand")
7430 (const_int 0)))
7431 (match_operand:SWI 2 "<immediate_operand>")))
7432 (clobber (reg:CC FLAGS_REG))]
7433 "CONST_INT_P (operands[2])
7434 && (<MODE>mode != DImode
7435 || INTVAL (operands[2]) != HOST_WIDE_INT_C (-0x80000000))
7436 && ix86_binary_operator_ok (MINUS, <MODE>mode, operands)
7437 && ix86_pre_reload_split ()"
7438 "#"
7439 "&& 1"
7440 [(set (reg:CC FLAGS_REG)
7441 (compare:CC (match_dup 3) (const_int 1)))
7442 (parallel [(set (match_dup 0)
7443 (minus:SWI
7444 (minus:SWI (match_dup 1)
7445 (ltu:SWI (reg:CC FLAGS_REG) (const_int 0)))
7446 (match_dup 2)))
7447 (clobber (reg:CC FLAGS_REG))])]
7448 {
7449 operands[2] = gen_int_mode (-INTVAL (operands[2]),
7450 <MODE>mode == DImode ? SImode : <MODE>mode);
7451 })
7452
7453 (define_insn_and_split "*sub<mode>3_eq_0"
7454 [(set (match_operand:SWI 0 "nonimmediate_operand")
7455 (minus:SWI
7456 (match_operand:SWI 1 "<general_operand>")
7457 (eq:SWI (match_operand 2 "int_nonimmediate_operand") (const_int 0))))
7458 (clobber (reg:CC FLAGS_REG))]
7459 "ix86_unary_operator_ok (MINUS, <MODE>mode, operands)
7460 && ix86_pre_reload_split ()"
7461 "#"
7462 "&& 1"
7463 [(set (reg:CC FLAGS_REG)
7464 (compare:CC (match_dup 2) (const_int 1)))
7465 (parallel [(set (match_dup 0)
7466 (minus:SWI (match_dup 1)
7467 (ltu:SWI (reg:CC FLAGS_REG) (const_int 0))))
7468 (clobber (reg:CC FLAGS_REG))])]
7469 {
7470 if (!nonimmediate_operand (operands[1], <MODE>mode))
7471 operands[1] = force_reg (<MODE>mode, operands[1]);
7472 })
7473
7474 (define_insn_and_split "*sub<mode>3_ne_0"
7475 [(set (match_operand:SWI 0 "nonimmediate_operand")
7476 (minus:SWI
7477 (match_operand:SWI 1 "<general_operand>")
7478 (ne:SWI (match_operand 2 "int_nonimmediate_operand") (const_int 0))))
7479 (clobber (reg:CC FLAGS_REG))]
7480 "ix86_unary_operator_ok (MINUS, <MODE>mode, operands)
7481 && ix86_pre_reload_split ()"
7482 "#"
7483 "&& 1"
7484 [(set (reg:CC FLAGS_REG)
7485 (compare:CC (match_dup 2) (const_int 1)))
7486 (parallel [(set (match_dup 0)
7487 (plus:SWI (plus:SWI
7488 (ltu:SWI (reg:CC FLAGS_REG) (const_int 0))
7489 (match_dup 1))
7490 (const_int -1)))
7491 (clobber (reg:CC FLAGS_REG))])]
7492 {
7493 if (!nonimmediate_operand (operands[1], <MODE>mode))
7494 operands[1] = force_reg (<MODE>mode, operands[1]);
7495 })
6777 7496
6778 ;; The patterns that match these are at the end of this file. 7497 ;; The patterns that match these are at the end of this file.
6779 7498
6780 (define_expand "<plusminus_insn>xf3" 7499 (define_expand "<plusminus_insn>xf3"
6781 [(set (match_operand:XF 0 "register_operand") 7500 [(set (match_operand:XF 0 "register_operand")
7398 } 8117 }
7399 }) 8118 })
7400 8119
7401 ;; Divmod instructions. 8120 ;; Divmod instructions.
7402 8121
7403 (define_expand "divmod<mode>4" 8122 (define_code_iterator any_div [div udiv])
8123 (define_code_attr paired_mod [(div "mod") (udiv "umod")])
8124
8125 (define_expand "<u>divmod<mode>4"
7404 [(parallel [(set (match_operand:SWIM248 0 "register_operand") 8126 [(parallel [(set (match_operand:SWIM248 0 "register_operand")
7405 (div:SWIM248 8127 (any_div:SWIM248
7406 (match_operand:SWIM248 1 "register_operand") 8128 (match_operand:SWIM248 1 "register_operand")
7407 (match_operand:SWIM248 2 "nonimmediate_operand"))) 8129 (match_operand:SWIM248 2 "nonimmediate_operand")))
7408 (set (match_operand:SWIM248 3 "register_operand") 8130 (set (match_operand:SWIM248 3 "register_operand")
7409 (mod:SWIM248 (match_dup 1) (match_dup 2))) 8131 (<paired_mod>:SWIM248 (match_dup 1) (match_dup 2)))
7410 (clobber (reg:CC FLAGS_REG))])]) 8132 (clobber (reg:CC FLAGS_REG))])])
7411 8133
7412 ;; Split with 8bit unsigned divide: 8134 ;; Split with 8bit unsigned divide:
7413 ;; if (dividend an divisor are in [0-255]) 8135 ;; if (dividend an divisor are in [0-255])
7414 ;; use 8bit unsigned integer divide 8136 ;; use 8bit unsigned integer divide
7415 ;; else 8137 ;; else
7416 ;; use original integer divide 8138 ;; use original integer divide
7417 (define_split 8139 (define_split
7418 [(set (match_operand:SWI48 0 "register_operand") 8140 [(set (match_operand:SWI48 0 "register_operand")
7419 (div:SWI48 (match_operand:SWI48 2 "register_operand") 8141 (any_div:SWI48 (match_operand:SWI48 2 "register_operand")
7420 (match_operand:SWI48 3 "nonimmediate_operand"))) 8142 (match_operand:SWI48 3 "nonimmediate_operand")))
7421 (set (match_operand:SWI48 1 "register_operand") 8143 (set (match_operand:SWI48 1 "register_operand")
7422 (mod:SWI48 (match_dup 2) (match_dup 3))) 8144 (<paired_mod>:SWI48 (match_dup 2) (match_dup 3)))
7423 (clobber (reg:CC FLAGS_REG))] 8145 (clobber (reg:CC FLAGS_REG))]
7424 "TARGET_USE_8BIT_IDIV 8146 "TARGET_USE_8BIT_IDIV
7425 && TARGET_QIMODE_MATH 8147 && TARGET_QIMODE_MATH
7426 && can_create_pseudo_p () 8148 && can_create_pseudo_p ()
7427 && !optimize_insn_for_size_p ()" 8149 && !optimize_insn_for_size_p ()"
7428 [(const_int 0)] 8150 [(const_int 0)]
7429 "ix86_split_idivmod (<MODE>mode, operands, true); DONE;") 8151 "ix86_split_idivmod (<MODE>mode, operands, <u_bool>); DONE;")
7430 8152
7431 (define_split 8153 (define_split
7432 [(set (match_operand:DI 0 "register_operand") 8154 [(set (match_operand:DI 0 "register_operand")
7433 (zero_extend:DI 8155 (zero_extend:DI
7434 (div:SI (match_operand:SI 2 "register_operand") 8156 (any_div:SI (match_operand:SI 2 "register_operand")
7435 (match_operand:SI 3 "nonimmediate_operand")))) 8157 (match_operand:SI 3 "nonimmediate_operand"))))
7436 (set (match_operand:SI 1 "register_operand") 8158 (set (match_operand:SI 1 "register_operand")
7437 (mod:SI (match_dup 2) (match_dup 3))) 8159 (<paired_mod>:SI (match_dup 2) (match_dup 3)))
7438 (clobber (reg:CC FLAGS_REG))] 8160 (clobber (reg:CC FLAGS_REG))]
7439 "TARGET_USE_8BIT_IDIV 8161 "TARGET_64BIT
8162 && TARGET_USE_8BIT_IDIV
7440 && TARGET_QIMODE_MATH 8163 && TARGET_QIMODE_MATH
7441 && can_create_pseudo_p () 8164 && can_create_pseudo_p ()
7442 && !optimize_insn_for_size_p ()" 8165 && !optimize_insn_for_size_p ()"
7443 [(const_int 0)] 8166 [(const_int 0)]
7444 "ix86_split_idivmod (SImode, operands, true); DONE;") 8167 "ix86_split_idivmod (SImode, operands, <u_bool>); DONE;")
7445 8168
7446 (define_split 8169 (define_split
7447 [(set (match_operand:DI 1 "register_operand") 8170 [(set (match_operand:DI 1 "register_operand")
7448 (zero_extend:DI 8171 (zero_extend:DI
7449 (mod:SI (match_operand:SI 2 "register_operand") 8172 (<paired_mod>:SI (match_operand:SI 2 "register_operand")
7450 (match_operand:SI 3 "nonimmediate_operand")))) 8173 (match_operand:SI 3 "nonimmediate_operand"))))
7451 (set (match_operand:SI 0 "register_operand") 8174 (set (match_operand:SI 0 "register_operand")
7452 (div:SI (match_dup 2) (match_dup 3))) 8175 (any_div:SI (match_dup 2) (match_dup 3)))
7453 (clobber (reg:CC FLAGS_REG))] 8176 (clobber (reg:CC FLAGS_REG))]
7454 "TARGET_USE_8BIT_IDIV 8177 "TARGET_64BIT
8178 && TARGET_USE_8BIT_IDIV
7455 && TARGET_QIMODE_MATH 8179 && TARGET_QIMODE_MATH
7456 && can_create_pseudo_p () 8180 && can_create_pseudo_p ()
7457 && !optimize_insn_for_size_p ()" 8181 && !optimize_insn_for_size_p ()"
7458 [(const_int 0)] 8182 [(const_int 0)]
7459 "ix86_split_idivmod (SImode, operands, true); DONE;") 8183 "ix86_split_idivmod (SImode, operands, <u_bool>); DONE;")
7460 8184
7461 (define_insn_and_split "divmod<mode>4_1" 8185 (define_insn_and_split "divmod<mode>4_1"
7462 [(set (match_operand:SWI48 0 "register_operand" "=a") 8186 [(set (match_operand:SWI48 0 "register_operand" "=a")
7463 (div:SWI48 (match_operand:SWI48 2 "register_operand" "0") 8187 (div:SWI48 (match_operand:SWI48 2 "register_operand" "0")
7464 (match_operand:SWI48 3 "nonimmediate_operand" "rm"))) 8188 (match_operand:SWI48 3 "nonimmediate_operand" "rm")))
7490 operands[4] = operands[1]; 8214 operands[4] = operands[1];
7491 } 8215 }
7492 } 8216 }
7493 [(set_attr "type" "multi") 8217 [(set_attr "type" "multi")
7494 (set_attr "mode" "<MODE>")]) 8218 (set_attr "mode" "<MODE>")])
7495
7496 (define_insn_and_split "divmodsi4_zext_1"
7497 [(set (match_operand:DI 0 "register_operand" "=a")
7498 (zero_extend:DI
7499 (div:SI (match_operand:SI 2 "register_operand" "0")
7500 (match_operand:SI 3 "nonimmediate_operand" "rm"))))
7501 (set (match_operand:SI 1 "register_operand" "=&d")
7502 (mod:SI (match_dup 2) (match_dup 3)))
7503 (unspec [(const_int 0)] UNSPEC_DIV_ALREADY_SPLIT)
7504 (clobber (reg:CC FLAGS_REG))]
7505 "TARGET_64BIT"
7506 "#"
7507 "reload_completed"
7508 [(parallel [(set (match_dup 1)
7509 (ashiftrt:SI (match_dup 4) (match_dup 5)))
7510 (clobber (reg:CC FLAGS_REG))])
7511 (parallel [(set (match_dup 0)
7512 (zero_extend:DI (div:SI (match_dup 2) (match_dup 3))))
7513 (set (match_dup 1)
7514 (mod:SI (match_dup 2) (match_dup 3)))
7515 (use (match_dup 1))
7516 (clobber (reg:CC FLAGS_REG))])]
7517 {
7518 operands[5] = GEN_INT (GET_MODE_BITSIZE (SImode)-1);
7519
7520 if (optimize_function_for_size_p (cfun) || TARGET_USE_CLTD)
7521 operands[4] = operands[2];
7522 else
7523 {
7524 /* Avoid use of cltd in favor of a mov+shift. */
7525 emit_move_insn (operands[1], operands[2]);
7526 operands[4] = operands[1];
7527 }
7528 }
7529 [(set_attr "type" "multi")
7530 (set_attr "mode" "SI")])
7531
7532 (define_insn_and_split "divmodsi4_zext_2"
7533 [(set (match_operand:DI 1 "register_operand" "=&d")
7534 (zero_extend:DI
7535 (mod:SI (match_operand:SI 2 "register_operand" "0")
7536 (match_operand:SI 3 "nonimmediate_operand" "rm"))))
7537 (set (match_operand:SI 0 "register_operand" "=a")
7538 (div:SI (match_dup 2) (match_dup 3)))
7539 (unspec [(const_int 0)] UNSPEC_DIV_ALREADY_SPLIT)
7540 (clobber (reg:CC FLAGS_REG))]
7541 "TARGET_64BIT"
7542 "#"
7543 "reload_completed"
7544 [(parallel [(set (match_dup 6)
7545 (ashiftrt:SI (match_dup 4) (match_dup 5)))
7546 (clobber (reg:CC FLAGS_REG))])
7547 (parallel [(set (match_dup 1)
7548 (zero_extend:DI (mod:SI (match_dup 2) (match_dup 3))))
7549 (set (match_dup 0)
7550 (div:SI (match_dup 2) (match_dup 3)))
7551 (use (match_dup 6))
7552 (clobber (reg:CC FLAGS_REG))])]
7553 {
7554 operands[5] = GEN_INT (GET_MODE_BITSIZE (SImode)-1);
7555 operands[6] = gen_lowpart (SImode, operands[1]);
7556
7557 if (optimize_function_for_size_p (cfun) || TARGET_USE_CLTD)
7558 operands[4] = operands[2];
7559 else
7560 {
7561 /* Avoid use of cltd in favor of a mov+shift. */
7562 emit_move_insn (operands[6], operands[2]);
7563 operands[4] = operands[6];
7564 }
7565 }
7566 [(set_attr "type" "multi")
7567 (set_attr "mode" "SI")])
7568
7569 (define_insn_and_split "*divmod<mode>4"
7570 [(set (match_operand:SWIM248 0 "register_operand" "=a")
7571 (div:SWIM248 (match_operand:SWIM248 2 "register_operand" "0")
7572 (match_operand:SWIM248 3 "nonimmediate_operand" "rm")))
7573 (set (match_operand:SWIM248 1 "register_operand" "=&d")
7574 (mod:SWIM248 (match_dup 2) (match_dup 3)))
7575 (clobber (reg:CC FLAGS_REG))]
7576 ""
7577 "#"
7578 "reload_completed"
7579 [(parallel [(set (match_dup 1)
7580 (ashiftrt:SWIM248 (match_dup 4) (match_dup 5)))
7581 (clobber (reg:CC FLAGS_REG))])
7582 (parallel [(set (match_dup 0)
7583 (div:SWIM248 (match_dup 2) (match_dup 3)))
7584 (set (match_dup 1)
7585 (mod:SWIM248 (match_dup 2) (match_dup 3)))
7586 (use (match_dup 1))
7587 (clobber (reg:CC FLAGS_REG))])]
7588 {
7589 operands[5] = GEN_INT (GET_MODE_BITSIZE (<MODE>mode)-1);
7590
7591 if (<MODE>mode != HImode
7592 && (optimize_function_for_size_p (cfun) || TARGET_USE_CLTD))
7593 operands[4] = operands[2];
7594 else
7595 {
7596 /* Avoid use of cltd in favor of a mov+shift. */
7597 emit_move_insn (operands[1], operands[2]);
7598 operands[4] = operands[1];
7599 }
7600 }
7601 [(set_attr "type" "multi")
7602 (set_attr "mode" "<MODE>")])
7603
7604 (define_insn_and_split "*divmodsi4_zext_1"
7605 [(set (match_operand:DI 0 "register_operand" "=a")
7606 (zero_extend:DI
7607 (div:SI (match_operand:SI 2 "register_operand" "0")
7608 (match_operand:SI 3 "nonimmediate_operand" "rm"))))
7609 (set (match_operand:SI 1 "register_operand" "=&d")
7610 (mod:SI (match_dup 2) (match_dup 3)))
7611 (clobber (reg:CC FLAGS_REG))]
7612 "TARGET_64BIT"
7613 "#"
7614 "reload_completed"
7615 [(parallel [(set (match_dup 1)
7616 (ashiftrt:SI (match_dup 4) (match_dup 5)))
7617 (clobber (reg:CC FLAGS_REG))])
7618 (parallel [(set (match_dup 0)
7619 (zero_extend:DI (div:SI (match_dup 2) (match_dup 3))))
7620 (set (match_dup 1)
7621 (mod:SI (match_dup 2) (match_dup 3)))
7622 (use (match_dup 1))
7623 (clobber (reg:CC FLAGS_REG))])]
7624 {
7625 operands[5] = GEN_INT (GET_MODE_BITSIZE (SImode)-1);
7626
7627 if (optimize_function_for_size_p (cfun) || TARGET_USE_CLTD)
7628 operands[4] = operands[2];
7629 else
7630 {
7631 /* Avoid use of cltd in favor of a mov+shift. */
7632 emit_move_insn (operands[1], operands[2]);
7633 operands[4] = operands[1];
7634 }
7635 }
7636 [(set_attr "type" "multi")
7637 (set_attr "mode" "SI")])
7638
7639 (define_insn_and_split "*divmodsi4_zext_2"
7640 [(set (match_operand:DI 1 "register_operand" "=&d")
7641 (zero_extend:DI
7642 (mod:SI (match_operand:SI 2 "register_operand" "0")
7643 (match_operand:SI 3 "nonimmediate_operand" "rm"))))
7644 (set (match_operand:SI 0 "register_operand" "=a")
7645 (div:SI (match_dup 2) (match_dup 3)))
7646 (clobber (reg:CC FLAGS_REG))]
7647 "TARGET_64BIT"
7648 "#"
7649 "reload_completed"
7650 [(parallel [(set (match_dup 6)
7651 (ashiftrt:SI (match_dup 4) (match_dup 5)))
7652 (clobber (reg:CC FLAGS_REG))])
7653 (parallel [(set (match_dup 1)
7654 (zero_extend:DI (mod:SI (match_dup 2) (match_dup 3))))
7655 (set (match_dup 0)
7656 (div:SI (match_dup 2) (match_dup 3)))
7657 (use (match_dup 6))
7658 (clobber (reg:CC FLAGS_REG))])]
7659 {
7660 operands[5] = GEN_INT (GET_MODE_BITSIZE (SImode)-1);
7661 operands[6] = gen_lowpart (SImode, operands[1]);
7662
7663 if (optimize_function_for_size_p (cfun) || TARGET_USE_CLTD)
7664 operands[4] = operands[2];
7665 else
7666 {
7667 /* Avoid use of cltd in favor of a mov+shift. */
7668 emit_move_insn (operands[6], operands[2]);
7669 operands[4] = operands[6];
7670 }
7671 }
7672 [(set_attr "type" "multi")
7673 (set_attr "mode" "SI")])
7674
7675 (define_insn "*divmod<mode>4_noext"
7676 [(set (match_operand:SWIM248 0 "register_operand" "=a")
7677 (div:SWIM248 (match_operand:SWIM248 2 "register_operand" "0")
7678 (match_operand:SWIM248 3 "nonimmediate_operand" "rm")))
7679 (set (match_operand:SWIM248 1 "register_operand" "=d")
7680 (mod:SWIM248 (match_dup 2) (match_dup 3)))
7681 (use (match_operand:SWIM248 4 "register_operand" "1"))
7682 (clobber (reg:CC FLAGS_REG))]
7683 ""
7684 "idiv{<imodesuffix>}\t%3"
7685 [(set_attr "type" "idiv")
7686 (set_attr "mode" "<MODE>")])
7687
7688 (define_insn "*divmodsi4_noext_zext_1"
7689 [(set (match_operand:DI 0 "register_operand" "=a")
7690 (zero_extend:DI
7691 (div:SI (match_operand:SI 2 "register_operand" "0")
7692 (match_operand:SI 3 "nonimmediate_operand" "rm"))))
7693 (set (match_operand:SI 1 "register_operand" "=d")
7694 (mod:SI (match_dup 2) (match_dup 3)))
7695 (use (match_operand:SI 4 "register_operand" "1"))
7696 (clobber (reg:CC FLAGS_REG))]
7697 "TARGET_64BIT"
7698 "idiv{l}\t%3"
7699 [(set_attr "type" "idiv")
7700 (set_attr "mode" "SI")])
7701
7702 (define_insn "*divmodsi4_noext_zext_2"
7703 [(set (match_operand:DI 1 "register_operand" "=d")
7704 (zero_extend:DI
7705 (mod:SI (match_operand:SI 2 "register_operand" "0")
7706 (match_operand:SI 3 "nonimmediate_operand" "rm"))))
7707 (set (match_operand:SI 0 "register_operand" "=a")
7708 (div:SI (match_dup 2) (match_dup 3)))
7709 (use (match_operand:SI 4 "register_operand" "1"))
7710 (clobber (reg:CC FLAGS_REG))]
7711 "TARGET_64BIT"
7712 "idiv{l}\t%3"
7713 [(set_attr "type" "idiv")
7714 (set_attr "mode" "SI")])
7715
7716 (define_expand "divmodqi4"
7717 [(parallel [(set (match_operand:QI 0 "register_operand")
7718 (div:QI
7719 (match_operand:QI 1 "register_operand")
7720 (match_operand:QI 2 "nonimmediate_operand")))
7721 (set (match_operand:QI 3 "register_operand")
7722 (mod:QI (match_dup 1) (match_dup 2)))
7723 (clobber (reg:CC FLAGS_REG))])]
7724 "TARGET_QIMODE_MATH"
7725 {
7726 rtx div, mod;
7727 rtx tmp0, tmp1;
7728
7729 tmp0 = gen_reg_rtx (HImode);
7730 tmp1 = gen_reg_rtx (HImode);
7731
7732 /* Extend operands[1] to HImode. Generate 8bit divide. Result is in AX. */
7733 emit_insn (gen_extendqihi2 (tmp1, operands[1]));
7734 emit_insn (gen_divmodhiqi3 (tmp0, tmp1, operands[2]));
7735
7736 /* Extract remainder from AH. */
7737 tmp1 = gen_rtx_ZERO_EXTRACT (SImode, tmp0, GEN_INT (8), GEN_INT (8));
7738 tmp1 = lowpart_subreg (QImode, tmp1, SImode);
7739 rtx_insn *insn = emit_move_insn (operands[3], tmp1);
7740
7741 mod = gen_rtx_MOD (QImode, operands[1], operands[2]);
7742 set_unique_reg_note (insn, REG_EQUAL, mod);
7743
7744 /* Extract quotient from AL. */
7745 insn = emit_move_insn (operands[0], gen_lowpart (QImode, tmp0));
7746
7747 div = gen_rtx_DIV (QImode, operands[1], operands[2]);
7748 set_unique_reg_note (insn, REG_EQUAL, div);
7749
7750 DONE;
7751 })
7752
7753 ;; Divide AX by r/m8, with result stored in
7754 ;; AL <- Quotient
7755 ;; AH <- Remainder
7756 ;; Change div/mod to HImode and extend the second argument to HImode
7757 ;; so that mode of div/mod matches with mode of arguments. Otherwise
7758 ;; combine may fail.
7759 (define_insn "divmodhiqi3"
7760 [(set (match_operand:HI 0 "register_operand" "=a")
7761 (ior:HI
7762 (ashift:HI
7763 (zero_extend:HI
7764 (truncate:QI
7765 (mod:HI (match_operand:HI 1 "register_operand" "0")
7766 (sign_extend:HI
7767 (match_operand:QI 2 "nonimmediate_operand" "qm")))))
7768 (const_int 8))
7769 (zero_extend:HI
7770 (truncate:QI
7771 (div:HI (match_dup 1) (sign_extend:HI (match_dup 2)))))))
7772 (clobber (reg:CC FLAGS_REG))]
7773 "TARGET_QIMODE_MATH"
7774 "idiv{b}\t%2"
7775 [(set_attr "type" "idiv")
7776 (set_attr "mode" "QI")])
7777
7778 (define_expand "udivmod<mode>4"
7779 [(parallel [(set (match_operand:SWIM248 0 "register_operand")
7780 (udiv:SWIM248
7781 (match_operand:SWIM248 1 "register_operand")
7782 (match_operand:SWIM248 2 "nonimmediate_operand")))
7783 (set (match_operand:SWIM248 3 "register_operand")
7784 (umod:SWIM248 (match_dup 1) (match_dup 2)))
7785 (clobber (reg:CC FLAGS_REG))])])
7786
7787 ;; Split with 8bit unsigned divide:
7788 ;; if (dividend an divisor are in [0-255])
7789 ;; use 8bit unsigned integer divide
7790 ;; else
7791 ;; use original integer divide
7792 (define_split
7793 [(set (match_operand:SWI48 0 "register_operand")
7794 (udiv:SWI48 (match_operand:SWI48 2 "register_operand")
7795 (match_operand:SWI48 3 "nonimmediate_operand")))
7796 (set (match_operand:SWI48 1 "register_operand")
7797 (umod:SWI48 (match_dup 2) (match_dup 3)))
7798 (clobber (reg:CC FLAGS_REG))]
7799 "TARGET_USE_8BIT_IDIV
7800 && TARGET_QIMODE_MATH
7801 && can_create_pseudo_p ()
7802 && !optimize_insn_for_size_p ()"
7803 [(const_int 0)]
7804 "ix86_split_idivmod (<MODE>mode, operands, false); DONE;")
7805
7806 (define_split
7807 [(set (match_operand:DI 0 "register_operand")
7808 (zero_extend:DI
7809 (udiv:SI (match_operand:SI 2 "register_operand")
7810 (match_operand:SI 3 "nonimmediate_operand"))))
7811 (set (match_operand:SI 1 "register_operand")
7812 (umod:SI (match_dup 2) (match_dup 3)))
7813 (clobber (reg:CC FLAGS_REG))]
7814 "TARGET_64BIT
7815 && TARGET_USE_8BIT_IDIV
7816 && TARGET_QIMODE_MATH
7817 && can_create_pseudo_p ()
7818 && !optimize_insn_for_size_p ()"
7819 [(const_int 0)]
7820 "ix86_split_idivmod (SImode, operands, false); DONE;")
7821
7822 (define_split
7823 [(set (match_operand:DI 1 "register_operand")
7824 (zero_extend:DI
7825 (umod:SI (match_operand:SI 2 "register_operand")
7826 (match_operand:SI 3 "nonimmediate_operand"))))
7827 (set (match_operand:SI 0 "register_operand")
7828 (udiv:SI (match_dup 2) (match_dup 3)))
7829 (clobber (reg:CC FLAGS_REG))]
7830 "TARGET_64BIT
7831 && TARGET_USE_8BIT_IDIV
7832 && TARGET_QIMODE_MATH
7833 && can_create_pseudo_p ()
7834 && !optimize_insn_for_size_p ()"
7835 [(const_int 0)]
7836 "ix86_split_idivmod (SImode, operands, false); DONE;")
7837 8219
7838 (define_insn_and_split "udivmod<mode>4_1" 8220 (define_insn_and_split "udivmod<mode>4_1"
7839 [(set (match_operand:SWI48 0 "register_operand" "=a") 8221 [(set (match_operand:SWI48 0 "register_operand" "=a")
7840 (udiv:SWI48 (match_operand:SWI48 2 "register_operand" "0") 8222 (udiv:SWI48 (match_operand:SWI48 2 "register_operand" "0")
7841 (match_operand:SWI48 3 "nonimmediate_operand" "rm"))) 8223 (match_operand:SWI48 3 "nonimmediate_operand" "rm")))
7855 (clobber (reg:CC FLAGS_REG))])] 8237 (clobber (reg:CC FLAGS_REG))])]
7856 "" 8238 ""
7857 [(set_attr "type" "multi") 8239 [(set_attr "type" "multi")
7858 (set_attr "mode" "<MODE>")]) 8240 (set_attr "mode" "<MODE>")])
7859 8241
8242 (define_insn_and_split "divmodsi4_zext_1"
8243 [(set (match_operand:DI 0 "register_operand" "=a")
8244 (zero_extend:DI
8245 (div:SI (match_operand:SI 2 "register_operand" "0")
8246 (match_operand:SI 3 "nonimmediate_operand" "rm"))))
8247 (set (match_operand:SI 1 "register_operand" "=&d")
8248 (mod:SI (match_dup 2) (match_dup 3)))
8249 (unspec [(const_int 0)] UNSPEC_DIV_ALREADY_SPLIT)
8250 (clobber (reg:CC FLAGS_REG))]
8251 "TARGET_64BIT"
8252 "#"
8253 "&& reload_completed"
8254 [(parallel [(set (match_dup 1)
8255 (ashiftrt:SI (match_dup 4) (match_dup 5)))
8256 (clobber (reg:CC FLAGS_REG))])
8257 (parallel [(set (match_dup 0)
8258 (zero_extend:DI (div:SI (match_dup 2) (match_dup 3))))
8259 (set (match_dup 1)
8260 (mod:SI (match_dup 2) (match_dup 3)))
8261 (use (match_dup 1))
8262 (clobber (reg:CC FLAGS_REG))])]
8263 {
8264 operands[5] = GEN_INT (GET_MODE_BITSIZE (SImode)-1);
8265
8266 if (optimize_function_for_size_p (cfun) || TARGET_USE_CLTD)
8267 operands[4] = operands[2];
8268 else
8269 {
8270 /* Avoid use of cltd in favor of a mov+shift. */
8271 emit_move_insn (operands[1], operands[2]);
8272 operands[4] = operands[1];
8273 }
8274 }
8275 [(set_attr "type" "multi")
8276 (set_attr "mode" "SI")])
8277
7860 (define_insn_and_split "udivmodsi4_zext_1" 8278 (define_insn_and_split "udivmodsi4_zext_1"
7861 [(set (match_operand:DI 0 "register_operand" "=a") 8279 [(set (match_operand:DI 0 "register_operand" "=a")
7862 (zero_extend:DI 8280 (zero_extend:DI
7863 (udiv:SI (match_operand:SI 2 "register_operand" "0") 8281 (udiv:SI (match_operand:SI 2 "register_operand" "0")
7864 (match_operand:SI 3 "nonimmediate_operand" "rm")))) 8282 (match_operand:SI 3 "nonimmediate_operand" "rm"))))
7866 (umod:SI (match_dup 2) (match_dup 3))) 8284 (umod:SI (match_dup 2) (match_dup 3)))
7867 (unspec [(const_int 0)] UNSPEC_DIV_ALREADY_SPLIT) 8285 (unspec [(const_int 0)] UNSPEC_DIV_ALREADY_SPLIT)
7868 (clobber (reg:CC FLAGS_REG))] 8286 (clobber (reg:CC FLAGS_REG))]
7869 "TARGET_64BIT" 8287 "TARGET_64BIT"
7870 "#" 8288 "#"
7871 "reload_completed" 8289 "&& reload_completed"
7872 [(set (match_dup 1) (const_int 0)) 8290 [(set (match_dup 1) (const_int 0))
7873 (parallel [(set (match_dup 0) 8291 (parallel [(set (match_dup 0)
7874 (zero_extend:DI (udiv:SI (match_dup 2) (match_dup 3)))) 8292 (zero_extend:DI (udiv:SI (match_dup 2) (match_dup 3))))
7875 (set (match_dup 1) 8293 (set (match_dup 1)
7876 (umod:SI (match_dup 2) (match_dup 3))) 8294 (umod:SI (match_dup 2) (match_dup 3)))
7878 (clobber (reg:CC FLAGS_REG))])] 8296 (clobber (reg:CC FLAGS_REG))])]
7879 "" 8297 ""
7880 [(set_attr "type" "multi") 8298 [(set_attr "type" "multi")
7881 (set_attr "mode" "SI")]) 8299 (set_attr "mode" "SI")])
7882 8300
8301 (define_insn_and_split "divmodsi4_zext_2"
8302 [(set (match_operand:DI 1 "register_operand" "=&d")
8303 (zero_extend:DI
8304 (mod:SI (match_operand:SI 2 "register_operand" "0")
8305 (match_operand:SI 3 "nonimmediate_operand" "rm"))))
8306 (set (match_operand:SI 0 "register_operand" "=a")
8307 (div:SI (match_dup 2) (match_dup 3)))
8308 (unspec [(const_int 0)] UNSPEC_DIV_ALREADY_SPLIT)
8309 (clobber (reg:CC FLAGS_REG))]
8310 "TARGET_64BIT"
8311 "#"
8312 "&& reload_completed"
8313 [(parallel [(set (match_dup 6)
8314 (ashiftrt:SI (match_dup 4) (match_dup 5)))
8315 (clobber (reg:CC FLAGS_REG))])
8316 (parallel [(set (match_dup 1)
8317 (zero_extend:DI (mod:SI (match_dup 2) (match_dup 3))))
8318 (set (match_dup 0)
8319 (div:SI (match_dup 2) (match_dup 3)))
8320 (use (match_dup 6))
8321 (clobber (reg:CC FLAGS_REG))])]
8322 {
8323 operands[5] = GEN_INT (GET_MODE_BITSIZE (SImode)-1);
8324 operands[6] = gen_lowpart (SImode, operands[1]);
8325
8326 if (optimize_function_for_size_p (cfun) || TARGET_USE_CLTD)
8327 operands[4] = operands[2];
8328 else
8329 {
8330 /* Avoid use of cltd in favor of a mov+shift. */
8331 emit_move_insn (operands[6], operands[2]);
8332 operands[4] = operands[6];
8333 }
8334 }
8335 [(set_attr "type" "multi")
8336 (set_attr "mode" "SI")])
8337
7883 (define_insn_and_split "udivmodsi4_zext_2" 8338 (define_insn_and_split "udivmodsi4_zext_2"
7884 [(set (match_operand:DI 1 "register_operand" "=&d") 8339 [(set (match_operand:DI 1 "register_operand" "=&d")
7885 (zero_extend:DI 8340 (zero_extend:DI
7886 (umod:SI (match_operand:SI 2 "register_operand" "0") 8341 (umod:SI (match_operand:SI 2 "register_operand" "0")
7887 (match_operand:SI 3 "nonimmediate_operand" "rm")))) 8342 (match_operand:SI 3 "nonimmediate_operand" "rm"))))
7889 (udiv:SI (match_dup 2) (match_dup 3))) 8344 (udiv:SI (match_dup 2) (match_dup 3)))
7890 (unspec [(const_int 0)] UNSPEC_DIV_ALREADY_SPLIT) 8345 (unspec [(const_int 0)] UNSPEC_DIV_ALREADY_SPLIT)
7891 (clobber (reg:CC FLAGS_REG))] 8346 (clobber (reg:CC FLAGS_REG))]
7892 "TARGET_64BIT" 8347 "TARGET_64BIT"
7893 "#" 8348 "#"
7894 "reload_completed" 8349 "&& reload_completed"
7895 [(set (match_dup 4) (const_int 0)) 8350 [(set (match_dup 4) (const_int 0))
7896 (parallel [(set (match_dup 1) 8351 (parallel [(set (match_dup 1)
7897 (zero_extend:DI (umod:SI (match_dup 2) (match_dup 3)))) 8352 (zero_extend:DI (umod:SI (match_dup 2) (match_dup 3))))
7898 (set (match_dup 0) 8353 (set (match_dup 0)
7899 (udiv:SI (match_dup 2) (match_dup 3))) 8354 (udiv:SI (match_dup 2) (match_dup 3)))
7900 (use (match_dup 4)) 8355 (use (match_dup 4))
7901 (clobber (reg:CC FLAGS_REG))])] 8356 (clobber (reg:CC FLAGS_REG))])]
7902 "operands[4] = gen_lowpart (SImode, operands[1]);" 8357 "operands[4] = gen_lowpart (SImode, operands[1]);"
7903 [(set_attr "type" "multi") 8358 [(set_attr "type" "multi")
7904 (set_attr "mode" "SI")]) 8359 (set_attr "mode" "SI")])
8360
8361 (define_insn_and_split "*divmod<mode>4"
8362 [(set (match_operand:SWIM248 0 "register_operand" "=a")
8363 (div:SWIM248 (match_operand:SWIM248 2 "register_operand" "0")
8364 (match_operand:SWIM248 3 "nonimmediate_operand" "rm")))
8365 (set (match_operand:SWIM248 1 "register_operand" "=&d")
8366 (mod:SWIM248 (match_dup 2) (match_dup 3)))
8367 (clobber (reg:CC FLAGS_REG))]
8368 ""
8369 "#"
8370 "reload_completed"
8371 [(parallel [(set (match_dup 1)
8372 (ashiftrt:SWIM248 (match_dup 4) (match_dup 5)))
8373 (clobber (reg:CC FLAGS_REG))])
8374 (parallel [(set (match_dup 0)
8375 (div:SWIM248 (match_dup 2) (match_dup 3)))
8376 (set (match_dup 1)
8377 (mod:SWIM248 (match_dup 2) (match_dup 3)))
8378 (use (match_dup 1))
8379 (clobber (reg:CC FLAGS_REG))])]
8380 {
8381 operands[5] = GEN_INT (GET_MODE_BITSIZE (<MODE>mode)-1);
8382
8383 if (<MODE>mode != HImode
8384 && (optimize_function_for_size_p (cfun) || TARGET_USE_CLTD))
8385 operands[4] = operands[2];
8386 else
8387 {
8388 /* Avoid use of cltd in favor of a mov+shift. */
8389 emit_move_insn (operands[1], operands[2]);
8390 operands[4] = operands[1];
8391 }
8392 }
8393 [(set_attr "type" "multi")
8394 (set_attr "mode" "<MODE>")])
7905 8395
7906 (define_insn_and_split "*udivmod<mode>4" 8396 (define_insn_and_split "*udivmod<mode>4"
7907 [(set (match_operand:SWIM248 0 "register_operand" "=a") 8397 [(set (match_operand:SWIM248 0 "register_operand" "=a")
7908 (udiv:SWIM248 (match_operand:SWIM248 2 "register_operand" "0") 8398 (udiv:SWIM248 (match_operand:SWIM248 2 "register_operand" "0")
7909 (match_operand:SWIM248 3 "nonimmediate_operand" "rm"))) 8399 (match_operand:SWIM248 3 "nonimmediate_operand" "rm")))
7922 (clobber (reg:CC FLAGS_REG))])] 8412 (clobber (reg:CC FLAGS_REG))])]
7923 "" 8413 ""
7924 [(set_attr "type" "multi") 8414 [(set_attr "type" "multi")
7925 (set_attr "mode" "<MODE>")]) 8415 (set_attr "mode" "<MODE>")])
7926 8416
8417 ;; Optimize division or modulo by constant power of 2, if the constant
8418 ;; materializes only after expansion.
8419 (define_insn_and_split "*udivmod<mode>4_pow2"
8420 [(set (match_operand:SWI48 0 "register_operand" "=r")
8421 (udiv:SWI48 (match_operand:SWI48 2 "register_operand" "0")
8422 (match_operand:SWI48 3 "const_int_operand" "n")))
8423 (set (match_operand:SWI48 1 "register_operand" "=r")
8424 (umod:SWI48 (match_dup 2) (match_dup 3)))
8425 (clobber (reg:CC FLAGS_REG))]
8426 "IN_RANGE (exact_log2 (UINTVAL (operands[3])), 1, 31)"
8427 "#"
8428 "&& reload_completed"
8429 [(set (match_dup 1) (match_dup 2))
8430 (parallel [(set (match_dup 0) (lshiftrt:<MODE> (match_dup 2) (match_dup 4)))
8431 (clobber (reg:CC FLAGS_REG))])
8432 (parallel [(set (match_dup 1) (and:<MODE> (match_dup 1) (match_dup 5)))
8433 (clobber (reg:CC FLAGS_REG))])]
8434 {
8435 int v = exact_log2 (UINTVAL (operands[3]));
8436 operands[4] = GEN_INT (v);
8437 operands[5] = GEN_INT ((HOST_WIDE_INT_1U << v) - 1);
8438 }
8439 [(set_attr "type" "multi")
8440 (set_attr "mode" "<MODE>")])
8441
8442 (define_insn_and_split "*divmodsi4_zext_1"
8443 [(set (match_operand:DI 0 "register_operand" "=a")
8444 (zero_extend:DI
8445 (div:SI (match_operand:SI 2 "register_operand" "0")
8446 (match_operand:SI 3 "nonimmediate_operand" "rm"))))
8447 (set (match_operand:SI 1 "register_operand" "=&d")
8448 (mod:SI (match_dup 2) (match_dup 3)))
8449 (clobber (reg:CC FLAGS_REG))]
8450 "TARGET_64BIT"
8451 "#"
8452 "&& reload_completed"
8453 [(parallel [(set (match_dup 1)
8454 (ashiftrt:SI (match_dup 4) (match_dup 5)))
8455 (clobber (reg:CC FLAGS_REG))])
8456 (parallel [(set (match_dup 0)
8457 (zero_extend:DI (div:SI (match_dup 2) (match_dup 3))))
8458 (set (match_dup 1)
8459 (mod:SI (match_dup 2) (match_dup 3)))
8460 (use (match_dup 1))
8461 (clobber (reg:CC FLAGS_REG))])]
8462 {
8463 operands[5] = GEN_INT (GET_MODE_BITSIZE (SImode)-1);
8464
8465 if (optimize_function_for_size_p (cfun) || TARGET_USE_CLTD)
8466 operands[4] = operands[2];
8467 else
8468 {
8469 /* Avoid use of cltd in favor of a mov+shift. */
8470 emit_move_insn (operands[1], operands[2]);
8471 operands[4] = operands[1];
8472 }
8473 }
8474 [(set_attr "type" "multi")
8475 (set_attr "mode" "SI")])
8476
7927 (define_insn_and_split "*udivmodsi4_zext_1" 8477 (define_insn_and_split "*udivmodsi4_zext_1"
7928 [(set (match_operand:DI 0 "register_operand" "=a") 8478 [(set (match_operand:DI 0 "register_operand" "=a")
7929 (zero_extend:DI 8479 (zero_extend:DI
7930 (udiv:SI (match_operand:SI 2 "register_operand" "0") 8480 (udiv:SI (match_operand:SI 2 "register_operand" "0")
7931 (match_operand:SI 3 "nonimmediate_operand" "rm")))) 8481 (match_operand:SI 3 "nonimmediate_operand" "rm"))))
7932 (set (match_operand:SI 1 "register_operand" "=&d") 8482 (set (match_operand:SI 1 "register_operand" "=&d")
7933 (umod:SI (match_dup 2) (match_dup 3))) 8483 (umod:SI (match_dup 2) (match_dup 3)))
7934 (clobber (reg:CC FLAGS_REG))] 8484 (clobber (reg:CC FLAGS_REG))]
7935 "TARGET_64BIT" 8485 "TARGET_64BIT"
7936 "#" 8486 "#"
7937 "reload_completed" 8487 "&& reload_completed"
7938 [(set (match_dup 1) (const_int 0)) 8488 [(set (match_dup 1) (const_int 0))
7939 (parallel [(set (match_dup 0) 8489 (parallel [(set (match_dup 0)
7940 (zero_extend:DI (udiv:SI (match_dup 2) (match_dup 3)))) 8490 (zero_extend:DI (udiv:SI (match_dup 2) (match_dup 3))))
7941 (set (match_dup 1) 8491 (set (match_dup 1)
7942 (umod:SI (match_dup 2) (match_dup 3))) 8492 (umod:SI (match_dup 2) (match_dup 3)))
7944 (clobber (reg:CC FLAGS_REG))])] 8494 (clobber (reg:CC FLAGS_REG))])]
7945 "" 8495 ""
7946 [(set_attr "type" "multi") 8496 [(set_attr "type" "multi")
7947 (set_attr "mode" "SI")]) 8497 (set_attr "mode" "SI")])
7948 8498
8499 (define_insn_and_split "*udivmodsi4_pow2_zext_1"
8500 [(set (match_operand:DI 0 "register_operand" "=r")
8501 (zero_extend:DI
8502 (udiv:SI (match_operand:SI 2 "register_operand" "0")
8503 (match_operand:SI 3 "const_int_operand" "n"))))
8504 (set (match_operand:SI 1 "register_operand" "=r")
8505 (umod:SI (match_dup 2) (match_dup 3)))
8506 (clobber (reg:CC FLAGS_REG))]
8507 "TARGET_64BIT
8508 && exact_log2 (UINTVAL (operands[3])) > 0"
8509 "#"
8510 "&& reload_completed"
8511 [(set (match_dup 1) (match_dup 2))
8512 (parallel [(set (match_dup 0)
8513 (zero_extend:DI (lshiftrt:SI (match_dup 2) (match_dup 4))))
8514 (clobber (reg:CC FLAGS_REG))])
8515 (parallel [(set (match_dup 1) (and:SI (match_dup 1) (match_dup 5)))
8516 (clobber (reg:CC FLAGS_REG))])]
8517 {
8518 int v = exact_log2 (UINTVAL (operands[3]));
8519 operands[4] = GEN_INT (v);
8520 operands[5] = GEN_INT ((HOST_WIDE_INT_1U << v) - 1);
8521 }
8522 [(set_attr "type" "multi")
8523 (set_attr "mode" "SI")])
8524
8525 (define_insn_and_split "*divmodsi4_zext_2"
8526 [(set (match_operand:DI 1 "register_operand" "=&d")
8527 (zero_extend:DI
8528 (mod:SI (match_operand:SI 2 "register_operand" "0")
8529 (match_operand:SI 3 "nonimmediate_operand" "rm"))))
8530 (set (match_operand:SI 0 "register_operand" "=a")
8531 (div:SI (match_dup 2) (match_dup 3)))
8532 (clobber (reg:CC FLAGS_REG))]
8533 "TARGET_64BIT"
8534 "#"
8535 "&& reload_completed"
8536 [(parallel [(set (match_dup 6)
8537 (ashiftrt:SI (match_dup 4) (match_dup 5)))
8538 (clobber (reg:CC FLAGS_REG))])
8539 (parallel [(set (match_dup 1)
8540 (zero_extend:DI (mod:SI (match_dup 2) (match_dup 3))))
8541 (set (match_dup 0)
8542 (div:SI (match_dup 2) (match_dup 3)))
8543 (use (match_dup 6))
8544 (clobber (reg:CC FLAGS_REG))])]
8545 {
8546 operands[5] = GEN_INT (GET_MODE_BITSIZE (SImode)-1);
8547 operands[6] = gen_lowpart (SImode, operands[1]);
8548
8549 if (optimize_function_for_size_p (cfun) || TARGET_USE_CLTD)
8550 operands[4] = operands[2];
8551 else
8552 {
8553 /* Avoid use of cltd in favor of a mov+shift. */
8554 emit_move_insn (operands[6], operands[2]);
8555 operands[4] = operands[6];
8556 }
8557 }
8558 [(set_attr "type" "multi")
8559 (set_attr "mode" "SI")])
8560
7949 (define_insn_and_split "*udivmodsi4_zext_2" 8561 (define_insn_and_split "*udivmodsi4_zext_2"
7950 [(set (match_operand:DI 1 "register_operand" "=&d") 8562 [(set (match_operand:DI 1 "register_operand" "=&d")
7951 (zero_extend:DI 8563 (zero_extend:DI
7952 (umod:SI (match_operand:SI 2 "register_operand" "0") 8564 (umod:SI (match_operand:SI 2 "register_operand" "0")
7953 (match_operand:SI 3 "nonimmediate_operand" "rm")))) 8565 (match_operand:SI 3 "nonimmediate_operand" "rm"))))
7954 (set (match_operand:SI 0 "register_operand" "=a") 8566 (set (match_operand:SI 0 "register_operand" "=a")
7955 (udiv:SI (match_dup 2) (match_dup 3))) 8567 (udiv:SI (match_dup 2) (match_dup 3)))
7956 (clobber (reg:CC FLAGS_REG))] 8568 (clobber (reg:CC FLAGS_REG))]
7957 "TARGET_64BIT" 8569 "TARGET_64BIT"
7958 "#" 8570 "#"
7959 "reload_completed" 8571 "&& reload_completed"
7960 [(set (match_dup 4) (const_int 0)) 8572 [(set (match_dup 4) (const_int 0))
7961 (parallel [(set (match_dup 1) 8573 (parallel [(set (match_dup 1)
7962 (zero_extend:DI (umod:SI (match_dup 2) (match_dup 3)))) 8574 (zero_extend:DI (umod:SI (match_dup 2) (match_dup 3))))
7963 (set (match_dup 0) 8575 (set (match_dup 0)
7964 (udiv:SI (match_dup 2) (match_dup 3))) 8576 (udiv:SI (match_dup 2) (match_dup 3)))
7966 (clobber (reg:CC FLAGS_REG))])] 8578 (clobber (reg:CC FLAGS_REG))])]
7967 "operands[4] = gen_lowpart (SImode, operands[1]);" 8579 "operands[4] = gen_lowpart (SImode, operands[1]);"
7968 [(set_attr "type" "multi") 8580 [(set_attr "type" "multi")
7969 (set_attr "mode" "SI")]) 8581 (set_attr "mode" "SI")])
7970 8582
7971 ;; Optimize division or modulo by constant power of 2, if the constant
7972 ;; materializes only after expansion.
7973 (define_insn_and_split "*udivmod<mode>4_pow2"
7974 [(set (match_operand:SWI48 0 "register_operand" "=r")
7975 (udiv:SWI48 (match_operand:SWI48 2 "register_operand" "0")
7976 (match_operand:SWI48 3 "const_int_operand" "n")))
7977 (set (match_operand:SWI48 1 "register_operand" "=r")
7978 (umod:SWI48 (match_dup 2) (match_dup 3)))
7979 (clobber (reg:CC FLAGS_REG))]
7980 "IN_RANGE (INTVAL (operands[3]), 2, HOST_WIDE_INT_UC (0x80000000))
7981 && (UINTVAL (operands[3]) & (UINTVAL (operands[3]) - 1)) == 0"
7982 "#"
7983 "&& 1"
7984 [(set (match_dup 1) (match_dup 2))
7985 (parallel [(set (match_dup 0) (lshiftrt:<MODE> (match_dup 2) (match_dup 4)))
7986 (clobber (reg:CC FLAGS_REG))])
7987 (parallel [(set (match_dup 1) (and:<MODE> (match_dup 1) (match_dup 5)))
7988 (clobber (reg:CC FLAGS_REG))])]
7989 {
7990 int v = exact_log2 (UINTVAL (operands[3]));
7991 operands[4] = GEN_INT (v);
7992 operands[5] = GEN_INT ((HOST_WIDE_INT_1U << v) - 1);
7993 }
7994 [(set_attr "type" "multi")
7995 (set_attr "mode" "<MODE>")])
7996
7997 (define_insn_and_split "*udivmodsi4_pow2_zext_1"
7998 [(set (match_operand:DI 0 "register_operand" "=r")
7999 (zero_extend:DI
8000 (udiv:SI (match_operand:SI 2 "register_operand" "0")
8001 (match_operand:SI 3 "const_int_operand" "n"))))
8002 (set (match_operand:SI 1 "register_operand" "=r")
8003 (umod:SI (match_dup 2) (match_dup 3)))
8004 (clobber (reg:CC FLAGS_REG))]
8005 "TARGET_64BIT
8006 && IN_RANGE (INTVAL (operands[3]), 2, HOST_WIDE_INT_UC (0x80000000))
8007 && (UINTVAL (operands[3]) & (UINTVAL (operands[3]) - 1)) == 0"
8008 "#"
8009 "&& 1"
8010 [(set (match_dup 1) (match_dup 2))
8011 (parallel [(set (match_dup 0)
8012 (zero_extend:DI (lshiftrt:SI (match_dup 2) (match_dup 4))))
8013 (clobber (reg:CC FLAGS_REG))])
8014 (parallel [(set (match_dup 1) (and:SI (match_dup 1) (match_dup 5)))
8015 (clobber (reg:CC FLAGS_REG))])]
8016 {
8017 int v = exact_log2 (UINTVAL (operands[3]));
8018 operands[4] = GEN_INT (v);
8019 operands[5] = GEN_INT ((HOST_WIDE_INT_1U << v) - 1);
8020 }
8021 [(set_attr "type" "multi")
8022 (set_attr "mode" "SI")])
8023
8024 (define_insn_and_split "*udivmodsi4_pow2_zext_2" 8583 (define_insn_and_split "*udivmodsi4_pow2_zext_2"
8025 [(set (match_operand:DI 1 "register_operand" "=r") 8584 [(set (match_operand:DI 1 "register_operand" "=r")
8026 (zero_extend:DI 8585 (zero_extend:DI
8027 (umod:SI (match_operand:SI 2 "register_operand" "0") 8586 (umod:SI (match_operand:SI 2 "register_operand" "0")
8028 (match_operand:SI 3 "const_int_operand" "n")))) 8587 (match_operand:SI 3 "const_int_operand" "n"))))
8029 (set (match_operand:SI 0 "register_operand" "=r") 8588 (set (match_operand:SI 0 "register_operand" "=r")
8030 (umod:SI (match_dup 2) (match_dup 3))) 8589 (umod:SI (match_dup 2) (match_dup 3)))
8031 (clobber (reg:CC FLAGS_REG))] 8590 (clobber (reg:CC FLAGS_REG))]
8032 "TARGET_64BIT 8591 "TARGET_64BIT
8033 && IN_RANGE (INTVAL (operands[3]), 2, HOST_WIDE_INT_UC (0x80000000)) 8592 && exact_log2 (UINTVAL (operands[3])) > 0"
8034 && (UINTVAL (operands[3]) & (UINTVAL (operands[3]) - 1)) == 0"
8035 "#" 8593 "#"
8036 "&& 1" 8594 "&& reload_completed"
8037 [(set (match_dup 1) (match_dup 2)) 8595 [(set (match_dup 1) (match_dup 2))
8038 (parallel [(set (match_dup 0) (lshiftrt:SI (match_dup 2) (match_dup 4))) 8596 (parallel [(set (match_dup 0) (lshiftrt:SI (match_dup 2) (match_dup 4)))
8039 (clobber (reg:CC FLAGS_REG))]) 8597 (clobber (reg:CC FLAGS_REG))])
8040 (parallel [(set (match_dup 1) 8598 (parallel [(set (match_dup 1)
8041 (zero_extend:DI (and:SI (match_dup 1) (match_dup 5)))) 8599 (zero_extend:DI (and:SI (match_dup 1) (match_dup 5))))
8046 operands[5] = GEN_INT ((HOST_WIDE_INT_1U << v) - 1); 8604 operands[5] = GEN_INT ((HOST_WIDE_INT_1U << v) - 1);
8047 } 8605 }
8048 [(set_attr "type" "multi") 8606 [(set_attr "type" "multi")
8049 (set_attr "mode" "SI")]) 8607 (set_attr "mode" "SI")])
8050 8608
8051 (define_insn "*udivmod<mode>4_noext" 8609 (define_insn "*<u>divmod<mode>4_noext"
8052 [(set (match_operand:SWIM248 0 "register_operand" "=a") 8610 [(set (match_operand:SWIM248 0 "register_operand" "=a")
8053 (udiv:SWIM248 (match_operand:SWIM248 2 "register_operand" "0") 8611 (any_div:SWIM248
8054 (match_operand:SWIM248 3 "nonimmediate_operand" "rm"))) 8612 (match_operand:SWIM248 2 "register_operand" "0")
8613 (match_operand:SWIM248 3 "nonimmediate_operand" "rm")))
8055 (set (match_operand:SWIM248 1 "register_operand" "=d") 8614 (set (match_operand:SWIM248 1 "register_operand" "=d")
8056 (umod:SWIM248 (match_dup 2) (match_dup 3))) 8615 (<paired_mod>:SWIM248 (match_dup 2) (match_dup 3)))
8057 (use (match_operand:SWIM248 4 "register_operand" "1")) 8616 (use (match_operand:SWIM248 4 "register_operand" "1"))
8058 (clobber (reg:CC FLAGS_REG))] 8617 (clobber (reg:CC FLAGS_REG))]
8059 "" 8618 ""
8060 "div{<imodesuffix>}\t%3" 8619 "<sgnprefix>div{<imodesuffix>}\t%3"
8061 [(set_attr "type" "idiv") 8620 [(set_attr "type" "idiv")
8062 (set_attr "mode" "<MODE>")]) 8621 (set_attr "mode" "<MODE>")])
8063 8622
8064 (define_insn "*udivmodsi4_noext_zext_1" 8623 (define_insn "*<u>divmodsi4_noext_zext_1"
8065 [(set (match_operand:DI 0 "register_operand" "=a") 8624 [(set (match_operand:DI 0 "register_operand" "=a")
8066 (zero_extend:DI 8625 (zero_extend:DI
8067 (udiv:SI (match_operand:SI 2 "register_operand" "0") 8626 (any_div:SI (match_operand:SI 2 "register_operand" "0")
8068 (match_operand:SI 3 "nonimmediate_operand" "rm")))) 8627 (match_operand:SI 3 "nonimmediate_operand" "rm"))))
8069 (set (match_operand:SI 1 "register_operand" "=d") 8628 (set (match_operand:SI 1 "register_operand" "=d")
8070 (umod:SI (match_dup 2) (match_dup 3))) 8629 (<paired_mod>:SI (match_dup 2) (match_dup 3)))
8071 (use (match_operand:SI 4 "register_operand" "1")) 8630 (use (match_operand:SI 4 "register_operand" "1"))
8072 (clobber (reg:CC FLAGS_REG))] 8631 (clobber (reg:CC FLAGS_REG))]
8073 "TARGET_64BIT" 8632 "TARGET_64BIT"
8074 "div{l}\t%3" 8633 "<sgnprefix>div{l}\t%3"
8075 [(set_attr "type" "idiv") 8634 [(set_attr "type" "idiv")
8076 (set_attr "mode" "SI")]) 8635 (set_attr "mode" "SI")])
8077 8636
8078 (define_insn "*udivmodsi4_noext_zext_2" 8637 (define_insn "*<u>divmodsi4_noext_zext_2"
8079 [(set (match_operand:DI 1 "register_operand" "=d") 8638 [(set (match_operand:DI 1 "register_operand" "=d")
8080 (zero_extend:DI 8639 (zero_extend:DI
8081 (umod:SI (match_operand:SI 2 "register_operand" "0") 8640 (<paired_mod>:SI (match_operand:SI 2 "register_operand" "0")
8082 (match_operand:SI 3 "nonimmediate_operand" "rm")))) 8641 (match_operand:SI 3 "nonimmediate_operand" "rm"))))
8083 (set (match_operand:SI 0 "register_operand" "=a") 8642 (set (match_operand:SI 0 "register_operand" "=a")
8084 (udiv:SI (match_dup 2) (match_dup 3))) 8643 (any_div:SI (match_dup 2) (match_dup 3)))
8085 (use (match_operand:SI 4 "register_operand" "1")) 8644 (use (match_operand:SI 4 "register_operand" "1"))
8086 (clobber (reg:CC FLAGS_REG))] 8645 (clobber (reg:CC FLAGS_REG))]
8087 "TARGET_64BIT" 8646 "TARGET_64BIT"
8088 "div{l}\t%3" 8647 "<sgnprefix>div{l}\t%3"
8089 [(set_attr "type" "idiv") 8648 [(set_attr "type" "idiv")
8090 (set_attr "mode" "SI")]) 8649 (set_attr "mode" "SI")])
8650
8651 (define_expand "divmodqi4"
8652 [(parallel [(set (match_operand:QI 0 "register_operand")
8653 (div:QI
8654 (match_operand:QI 1 "register_operand")
8655 (match_operand:QI 2 "nonimmediate_operand")))
8656 (set (match_operand:QI 3 "register_operand")
8657 (mod:QI (match_dup 1) (match_dup 2)))
8658 (clobber (reg:CC FLAGS_REG))])]
8659 "TARGET_QIMODE_MATH"
8660 {
8661 rtx div, mod;
8662 rtx tmp0, tmp1;
8663
8664 tmp0 = gen_reg_rtx (HImode);
8665 tmp1 = gen_reg_rtx (HImode);
8666
8667 /* Extend operands[1] to HImode. Generate 8bit divide. Result is in AX. */
8668 emit_insn (gen_extendqihi2 (tmp1, operands[1]));
8669 emit_insn (gen_divmodhiqi3 (tmp0, tmp1, operands[2]));
8670
8671 /* Extract remainder from AH. */
8672 tmp1 = gen_rtx_ZERO_EXTRACT (SImode, tmp0, GEN_INT (8), GEN_INT (8));
8673 tmp1 = lowpart_subreg (QImode, tmp1, SImode);
8674 rtx_insn *insn = emit_move_insn (operands[3], tmp1);
8675
8676 mod = gen_rtx_MOD (QImode, operands[1], operands[2]);
8677 set_unique_reg_note (insn, REG_EQUAL, mod);
8678
8679 /* Extract quotient from AL. */
8680 insn = emit_move_insn (operands[0], gen_lowpart (QImode, tmp0));
8681
8682 div = gen_rtx_DIV (QImode, operands[1], operands[2]);
8683 set_unique_reg_note (insn, REG_EQUAL, div);
8684
8685 DONE;
8686 })
8091 8687
8092 (define_expand "udivmodqi4" 8688 (define_expand "udivmodqi4"
8093 [(parallel [(set (match_operand:QI 0 "register_operand") 8689 [(parallel [(set (match_operand:QI 0 "register_operand")
8094 (udiv:QI 8690 (udiv:QI
8095 (match_operand:QI 1 "register_operand") 8691 (match_operand:QI 1 "register_operand")
8099 (clobber (reg:CC FLAGS_REG))])] 8695 (clobber (reg:CC FLAGS_REG))])]
8100 "TARGET_QIMODE_MATH" 8696 "TARGET_QIMODE_MATH"
8101 { 8697 {
8102 rtx div, mod; 8698 rtx div, mod;
8103 rtx tmp0, tmp1; 8699 rtx tmp0, tmp1;
8104 8700
8105 tmp0 = gen_reg_rtx (HImode); 8701 tmp0 = gen_reg_rtx (HImode);
8106 tmp1 = gen_reg_rtx (HImode); 8702 tmp1 = gen_reg_rtx (HImode);
8107 8703
8108 /* Extend operands[1] to HImode. Generate 8bit divide. Result is in AX. */ 8704 /* Extend operands[1] to HImode. Generate 8bit divide. Result is in AX. */
8109 emit_insn (gen_zero_extendqihi2 (tmp1, operands[1])); 8705 emit_insn (gen_zero_extendqihi2 (tmp1, operands[1]));
8124 set_unique_reg_note (insn, REG_EQUAL, div); 8720 set_unique_reg_note (insn, REG_EQUAL, div);
8125 8721
8126 DONE; 8722 DONE;
8127 }) 8723 })
8128 8724
8129 (define_insn "udivmodhiqi3" 8725 ;; Divide AX by r/m8, with result stored in
8726 ;; AL <- Quotient
8727 ;; AH <- Remainder
8728 ;; Change div/mod to HImode and extend the second argument to HImode
8729 ;; so that mode of div/mod matches with mode of arguments. Otherwise
8730 ;; combine may fail.
8731 (define_insn "<u>divmodhiqi3"
8130 [(set (match_operand:HI 0 "register_operand" "=a") 8732 [(set (match_operand:HI 0 "register_operand" "=a")
8131 (ior:HI 8733 (ior:HI
8132 (ashift:HI 8734 (ashift:HI
8133 (zero_extend:HI 8735 (zero_extend:HI
8134 (truncate:QI 8736 (truncate:QI
8135 (mod:HI (match_operand:HI 1 "register_operand" "0") 8737 (mod:HI (match_operand:HI 1 "register_operand" "0")
8136 (zero_extend:HI 8738 (any_extend:HI
8137 (match_operand:QI 2 "nonimmediate_operand" "qm"))))) 8739 (match_operand:QI 2 "nonimmediate_operand" "qm")))))
8138 (const_int 8)) 8740 (const_int 8))
8139 (zero_extend:HI 8741 (zero_extend:HI
8140 (truncate:QI 8742 (truncate:QI
8141 (div:HI (match_dup 1) (zero_extend:HI (match_dup 2))))))) 8743 (div:HI (match_dup 1) (any_extend:HI (match_dup 2)))))))
8142 (clobber (reg:CC FLAGS_REG))] 8744 (clobber (reg:CC FLAGS_REG))]
8143 "TARGET_QIMODE_MATH" 8745 "TARGET_QIMODE_MATH"
8144 "div{b}\t%2" 8746 "<sgnprefix>div{b}\t%2"
8145 [(set_attr "type" "idiv") 8747 [(set_attr "type" "idiv")
8146 (set_attr "mode" "QI")]) 8748 (set_attr "mode" "QI")])
8147 8749
8148 ;; We cannot use div/idiv for double division, because it causes 8750 ;; We cannot use div/idiv for double division, because it causes
8149 ;; "division by zero" on the overflow and that's not what we expect 8751 ;; "division by zero" on the overflow and that's not what we expect
8167 ;;- Logical AND instructions 8769 ;;- Logical AND instructions
8168 8770
8169 ;; On Pentium, "test imm, reg" is pairable only with eax, ax, and al. 8771 ;; On Pentium, "test imm, reg" is pairable only with eax, ax, and al.
8170 ;; Note that this excludes ah. 8772 ;; Note that this excludes ah.
8171 8773
8172 (define_expand "testsi_ccno_1" 8774 (define_expand "@test<mode>_ccno_1"
8173 [(set (reg:CCNO FLAGS_REG) 8775 [(set (reg:CCNO FLAGS_REG)
8174 (compare:CCNO 8776 (compare:CCNO
8175 (and:SI (match_operand:SI 0 "nonimmediate_operand") 8777 (and:SWI48
8176 (match_operand:SI 1 "x86_64_nonmemory_operand")) 8778 (match_operand:SWI48 0 "nonimmediate_operand")
8779 (match_operand:SWI48 1 "<nonmemory_szext_operand>"))
8177 (const_int 0)))]) 8780 (const_int 0)))])
8178 8781
8179 (define_expand "testqi_ccz_1" 8782 (define_expand "testqi_ccz_1"
8180 [(set (reg:CCZ FLAGS_REG) 8783 [(set (reg:CCZ FLAGS_REG)
8181 (compare:CCZ (and:QI (match_operand:QI 0 "nonimmediate_operand") 8784 (compare:CCZ
8182 (match_operand:QI 1 "nonmemory_operand")) 8785 (and:QI
8183 (const_int 0)))]) 8786 (match_operand:QI 0 "nonimmediate_operand")
8184 8787 (match_operand:QI 1 "nonmemory_operand"))
8185 (define_expand "testdi_ccno_1" 8788 (const_int 0)))])
8186 [(set (reg:CCNO FLAGS_REG)
8187 (compare:CCNO
8188 (and:DI (match_operand:DI 0 "nonimmediate_operand")
8189 (match_operand:DI 1 "x86_64_szext_general_operand"))
8190 (const_int 0)))]
8191 "TARGET_64BIT && !(MEM_P (operands[0]) && MEM_P (operands[1]))")
8192 8789
8193 (define_insn "*testdi_1" 8790 (define_insn "*testdi_1"
8194 [(set (reg FLAGS_REG) 8791 [(set (reg FLAGS_REG)
8195 (compare 8792 (compare
8196 (and:DI 8793 (and:DI
8197 (match_operand:DI 0 "nonimmediate_operand" "%!*a,r,!*a,r,rm") 8794 (match_operand:DI 0 "nonimmediate_operand" "%r,rm")
8198 (match_operand:DI 1 "x86_64_szext_general_operand" "Z,Z,e,e,re")) 8795 (match_operand:DI 1 "x86_64_szext_nonmemory_operand" "Z,re"))
8199 (const_int 0)))] 8796 (const_int 0)))]
8200 "TARGET_64BIT && ix86_match_ccmode (insn, CCNOmode) 8797 "TARGET_64BIT
8201 && !(MEM_P (operands[0]) && MEM_P (operands[1]))" 8798 && ix86_match_ccmode
8799 (insn,
8800 /* If we are going to emit testl instead of testq, and the operands[1]
8801 constant might have the SImode sign bit set, make sure the sign
8802 flag isn't tested, because the instruction will set the sign flag
8803 based on bit 31 rather than bit 63. If it isn't CONST_INT,
8804 conservatively assume it might have bit 31 set. */
8805 (satisfies_constraint_Z (operands[1])
8806 && (!CONST_INT_P (operands[1])
8807 || val_signbit_known_set_p (SImode, INTVAL (operands[1]))))
8808 ? CCZmode : CCNOmode)"
8202 "@ 8809 "@
8203 test{l}\t{%k1, %k0|%k0, %k1} 8810 test{l}\t{%k1, %k0|%k0, %k1}
8204 test{l}\t{%k1, %k0|%k0, %k1}
8205 test{q}\t{%1, %0|%0, %1}
8206 test{q}\t{%1, %0|%0, %1}
8207 test{q}\t{%1, %0|%0, %1}" 8811 test{q}\t{%1, %0|%0, %1}"
8208 [(set_attr "type" "test") 8812 [(set_attr "type" "test")
8209 (set_attr "modrm" "0,1,0,1,1") 8813 (set_attr "mode" "SI,DI")])
8210 (set_attr "mode" "SI,SI,DI,DI,DI")])
8211 8814
8212 (define_insn "*testqi_1_maybe_si" 8815 (define_insn "*testqi_1_maybe_si"
8213 [(set (reg FLAGS_REG) 8816 [(set (reg FLAGS_REG)
8214 (compare 8817 (compare
8215 (and:QI 8818 (and:QI
8216 (match_operand:QI 0 "nonimmediate_operand" "%!*a,q,qm,r") 8819 (match_operand:QI 0 "nonimmediate_operand" "%qm,*a,qm,r")
8217 (match_operand:QI 1 "general_operand" "n,n,qn,n")) 8820 (match_operand:QI 1 "nonmemory_operand" "q,n,n,n"))
8218 (const_int 0)))] 8821 (const_int 0)))]
8219 "!(MEM_P (operands[0]) && MEM_P (operands[1])) 8822 "ix86_match_ccmode (insn,
8220 && ix86_match_ccmode (insn, 8823 CONST_INT_P (operands[1])
8221 CONST_INT_P (operands[1]) 8824 && INTVAL (operands[1]) >= 0 ? CCNOmode : CCZmode)"
8222 && INTVAL (operands[1]) >= 0 ? CCNOmode : CCZmode)"
8223 { 8825 {
8224 if (which_alternative == 3) 8826 if (which_alternative == 3)
8225 { 8827 {
8226 if (CONST_INT_P (operands[1]) && INTVAL (operands[1]) < 0) 8828 if (CONST_INT_P (operands[1]) && INTVAL (operands[1]) < 0)
8227 operands[1] = GEN_INT (INTVAL (operands[1]) & 0xff); 8829 operands[1] = GEN_INT (INTVAL (operands[1]) & 0xff);
8228 return "test{l}\t{%1, %k0|%k0, %1}"; 8830 return "test{l}\t{%1, %k0|%k0, %1}";
8229 } 8831 }
8230 return "test{b}\t{%1, %0|%0, %1}"; 8832 return "test{b}\t{%1, %0|%0, %1}";
8231 } 8833 }
8232 [(set_attr "type" "test") 8834 [(set_attr "type" "test")
8233 (set_attr "modrm" "0,1,1,1")
8234 (set_attr "mode" "QI,QI,QI,SI") 8835 (set_attr "mode" "QI,QI,QI,SI")
8235 (set_attr "pent_pair" "uv,np,uv,np")]) 8836 (set_attr "pent_pair" "uv,uv,np,np")])
8236 8837
8237 (define_insn "*test<mode>_1" 8838 (define_insn "*test<mode>_1"
8238 [(set (reg FLAGS_REG) 8839 [(set (reg FLAGS_REG)
8239 (compare 8840 (compare
8240 (and:SWI124 8841 (and:SWI124
8241 (match_operand:SWI124 0 "nonimmediate_operand" "%!*a,<r>,<r>m") 8842 (match_operand:SWI124 0 "nonimmediate_operand" "%<r>m,*a,<r>m")
8242 (match_operand:SWI124 1 "<general_operand>" "<i>,<i>,<r><i>")) 8843 (match_operand:SWI124 1 "<nonmemory_szext_operand>" "<r>,<i>,<i>"))
8243 (const_int 0)))] 8844 (const_int 0)))]
8244 "ix86_match_ccmode (insn, CCNOmode) 8845 "ix86_match_ccmode (insn, CCNOmode)"
8245 && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
8246 "test{<imodesuffix>}\t{%1, %0|%0, %1}" 8846 "test{<imodesuffix>}\t{%1, %0|%0, %1}"
8247 [(set_attr "type" "test") 8847 [(set_attr "type" "test")
8248 (set_attr "modrm" "0,1,1")
8249 (set_attr "mode" "<MODE>") 8848 (set_attr "mode" "<MODE>")
8250 (set_attr "pent_pair" "uv,np,uv")]) 8849 (set_attr "pent_pair" "uv,uv,np")])
8251 8850
8252 (define_expand "testqi_ext_1_ccno" 8851 (define_expand "testqi_ext_1_ccno"
8253 [(set (reg:CCNO FLAGS_REG) 8852 [(set (reg:CCNO FLAGS_REG)
8254 (compare:CCNO 8853 (compare:CCNO
8255 (and:QI 8854 (and:QI
8407 ;; %%% This used to optimize known byte-wide and operations to memory, 9006 ;; %%% This used to optimize known byte-wide and operations to memory,
8408 ;; and sometimes to QImode registers. If this is considered useful, 9007 ;; and sometimes to QImode registers. If this is considered useful,
8409 ;; it should be done with splitters. 9008 ;; it should be done with splitters.
8410 9009
8411 (define_expand "and<mode>3" 9010 (define_expand "and<mode>3"
8412 [(set (match_operand:SWIM1248x 0 "nonimmediate_operand") 9011 [(set (match_operand:SWIM1248s 0 "nonimmediate_operand")
8413 (and:SWIM1248x (match_operand:SWIM1248x 1 "nonimmediate_operand") 9012 (and:SWIM1248s (match_operand:SWIM1248s 1 "nonimmediate_operand")
8414 (match_operand:SWIM1248x 2 "<general_szext_operand>")))] 9013 (match_operand:SWIM1248s 2 "<general_szext_operand>")))]
8415 "" 9014 ""
8416 { 9015 {
8417 machine_mode mode = <MODE>mode; 9016 machine_mode mode = <MODE>mode;
8418 rtx (*insn) (rtx, rtx); 9017
8419 9018 if (<MODE>mode == DImode && !TARGET_64BIT)
8420 if (CONST_INT_P (operands[2]) && REG_P (operands[0])) 9019 ;
9020 else if (const_int_operand (operands[2], <MODE>mode)
9021 && register_operand (operands[0], <MODE>mode)
9022 && !(TARGET_ZERO_EXTEND_WITH_AND
9023 && optimize_function_for_speed_p (cfun)))
8421 { 9024 {
8422 HOST_WIDE_INT ival = INTVAL (operands[2]); 9025 unsigned HOST_WIDE_INT ival = UINTVAL (operands[2]);
8423 9026
8424 if (ival == (HOST_WIDE_INT) 0xffffffff) 9027 if (ival == GET_MODE_MASK (SImode))
8425 mode = SImode; 9028 mode = SImode;
8426 else if (ival == 0xffff) 9029 else if (ival == GET_MODE_MASK (HImode))
8427 mode = HImode; 9030 mode = HImode;
8428 else if (ival == 0xff) 9031 else if (ival == GET_MODE_MASK (QImode))
8429 mode = QImode; 9032 mode = QImode;
8430 }
8431
8432 if (mode == <MODE>mode)
8433 {
8434 ix86_expand_binary_operator (AND, <MODE>mode, operands);
8435 DONE;
8436 } 9033 }
8437 9034
8438 if (<MODE>mode == DImode) 9035 if (mode != <MODE>mode)
8439 insn = (mode == SImode) 9036 emit_insn (gen_extend_insn
8440 ? gen_zero_extendsidi2 9037 (operands[0], gen_lowpart (mode, operands[1]),
8441 : (mode == HImode) 9038 <MODE>mode, mode, 1));
8442 ? gen_zero_extendhidi2
8443 : gen_zero_extendqidi2;
8444 else if (<MODE>mode == SImode)
8445 insn = (mode == HImode)
8446 ? gen_zero_extendhisi2
8447 : gen_zero_extendqisi2;
8448 else if (<MODE>mode == HImode)
8449 insn = gen_zero_extendqihi2;
8450 else 9039 else
8451 gcc_unreachable (); 9040 ix86_expand_binary_operator (AND, <MODE>mode, operands);
8452 9041
8453 emit_insn (insn (operands[0], gen_lowpart (mode, operands[1])));
8454 DONE; 9042 DONE;
8455 }) 9043 })
8456 9044
8457 (define_insn_and_split "*anddi3_doubleword" 9045 (define_insn_and_split "*anddi3_doubleword"
8458 [(set (match_operand:DI 0 "nonimmediate_operand" "=r,rm,r") 9046 [(set (match_operand:DI 0 "nonimmediate_operand")
8459 (and:DI 9047 (and:DI
8460 (match_operand:DI 1 "nonimmediate_operand" "%0,0,0") 9048 (match_operand:DI 1 "nonimmediate_operand")
8461 (match_operand:DI 2 "x86_64_szext_general_operand" "Z,re,rm"))) 9049 (match_operand:DI 2 "x86_64_szext_general_operand")))
8462 (clobber (reg:CC FLAGS_REG))] 9050 (clobber (reg:CC FLAGS_REG))]
8463 "!TARGET_64BIT && TARGET_STV && TARGET_SSE2 9051 "!TARGET_64BIT && TARGET_STV && TARGET_SSE2
8464 && ix86_binary_operator_ok (AND, DImode, operands)" 9052 && ix86_binary_operator_ok (AND, DImode, operands)
9053 && ix86_pre_reload_split ()"
8465 "#" 9054 "#"
8466 "&& reload_completed" 9055 "&& 1"
8467 [(const_int 0)] 9056 [(const_int 0)]
8468 { 9057 {
8469 split_double_mode (DImode, &operands[0], 3, &operands[0], &operands[3]); 9058 split_double_mode (DImode, &operands[0], 3, &operands[0], &operands[3]);
9059
8470 if (operands[2] == const0_rtx) 9060 if (operands[2] == const0_rtx)
8471 { 9061 emit_move_insn (operands[0], const0_rtx);
8472 operands[1] = const0_rtx; 9062 else if (operands[2] == constm1_rtx)
8473 ix86_expand_move (SImode, &operands[0]); 9063 emit_move_insn (operands[0], operands[1]);
8474 } 9064 else
8475 else if (operands[2] != constm1_rtx) 9065 emit_insn (gen_andsi3 (operands[0], operands[1], operands[2]));
8476 ix86_expand_binary_operator (AND, SImode, &operands[0]); 9066
9067 if (operands[5] == const0_rtx)
9068 emit_move_insn (operands[3], const0_rtx);
8477 else if (operands[5] == constm1_rtx) 9069 else if (operands[5] == constm1_rtx)
8478 emit_note (NOTE_INSN_DELETED); 9070 emit_move_insn (operands[3], operands[4]);
8479 if (operands[5] == const0_rtx) 9071 else
8480 { 9072 emit_insn (gen_andsi3 (operands[3], operands[4], operands[5]));
8481 operands[4] = const0_rtx; 9073
8482 ix86_expand_move (SImode, &operands[3]);
8483 }
8484 else if (operands[5] != constm1_rtx)
8485 ix86_expand_binary_operator (AND, SImode, &operands[3]);
8486 DONE; 9074 DONE;
8487 }) 9075 })
8488 9076
8489 (define_insn "*anddi_1" 9077 (define_insn "*anddi_1"
8490 [(set (match_operand:DI 0 "nonimmediate_operand" "=r,rm,r,r") 9078 [(set (match_operand:DI 0 "nonimmediate_operand" "=r,rm,r,r")
8491 (and:DI 9079 (and:DI
8492 (match_operand:DI 1 "nonimmediate_operand" "%0,0,0,qm") 9080 (match_operand:DI 1 "nonimmediate_operand" "%0,0,0,qm")
8493 (match_operand:DI 2 "x86_64_szext_general_operand" "Z,re,rm,L"))) 9081 (match_operand:DI 2 "x86_64_szext_general_operand" "Z,re,m,L")))
8494 (clobber (reg:CC FLAGS_REG))] 9082 (clobber (reg:CC FLAGS_REG))]
8495 "TARGET_64BIT && ix86_binary_operator_ok (AND, DImode, operands)" 9083 "TARGET_64BIT && ix86_binary_operator_ok (AND, DImode, operands)"
8496 "@ 9084 "@
8497 and{l}\t{%k2, %k0|%k0, %k2} 9085 and{l}\t{%k2, %k0|%k0, %k2}
8498 and{q}\t{%2, %0|%0, %2} 9086 and{q}\t{%2, %0|%0, %2}
8539 (clobber (reg:CC FLAGS_REG))] 9127 (clobber (reg:CC FLAGS_REG))]
8540 "TARGET_64BIT" 9128 "TARGET_64BIT"
8541 [(parallel [(set (match_dup 0) 9129 [(parallel [(set (match_dup 0)
8542 (zero_extend:DI (and:SI (match_dup 1) (match_dup 2)))) 9130 (zero_extend:DI (and:SI (match_dup 1) (match_dup 2))))
8543 (clobber (reg:CC FLAGS_REG))])] 9131 (clobber (reg:CC FLAGS_REG))])]
8544 "operands[2] = gen_lowpart (SImode, operands[2]);") 9132 {
9133 if (GET_CODE (operands[2]) == SYMBOL_REF
9134 || GET_CODE (operands[2]) == LABEL_REF)
9135 {
9136 operands[2] = shallow_copy_rtx (operands[2]);
9137 PUT_MODE (operands[2], SImode);
9138 }
9139 else if (GET_CODE (operands[2]) == CONST)
9140 {
9141 /* (const:DI (plus:DI (symbol_ref:DI ("...")) (const_int N))) */
9142 operands[2] = copy_rtx (operands[2]);
9143 PUT_MODE (operands[2], SImode);
9144 PUT_MODE (XEXP (operands[2], 0), SImode);
9145 PUT_MODE (XEXP (XEXP (operands[2], 0), 0), SImode);
9146 }
9147 else
9148 operands[2] = gen_lowpart (SImode, operands[2]);
9149 })
8545 9150
8546 ;; See comment for addsi_1_zext why we do use nonimmediate_operand 9151 ;; See comment for addsi_1_zext why we do use nonimmediate_operand
8547 (define_insn "*andsi_1_zext" 9152 (define_insn "*andsi_1_zext"
8548 [(set (match_operand:DI 0 "register_operand" "=r") 9153 [(set (match_operand:DI 0 "register_operand" "=r")
8549 (zero_extend:DI 9154 (zero_extend:DI
8556 (set_attr "mode" "SI")]) 9161 (set_attr "mode" "SI")])
8557 9162
8558 (define_insn "*and<mode>_1" 9163 (define_insn "*and<mode>_1"
8559 [(set (match_operand:SWI24 0 "nonimmediate_operand" "=rm,r,Ya") 9164 [(set (match_operand:SWI24 0 "nonimmediate_operand" "=rm,r,Ya")
8560 (and:SWI24 (match_operand:SWI24 1 "nonimmediate_operand" "%0,0,qm") 9165 (and:SWI24 (match_operand:SWI24 1 "nonimmediate_operand" "%0,0,qm")
8561 (match_operand:SWI24 2 "<general_operand>" "r<i>,rm,L"))) 9166 (match_operand:SWI24 2 "<general_operand>" "r<i>,m,L")))
8562 (clobber (reg:CC FLAGS_REG))] 9167 (clobber (reg:CC FLAGS_REG))]
8563 "ix86_binary_operator_ok (AND, <MODE>mode, operands)" 9168 "ix86_binary_operator_ok (AND, <MODE>mode, operands)"
8564 "@ 9169 "@
8565 and{<imodesuffix>}\t{%2, %0|%0, %2} 9170 and{<imodesuffix>}\t{%2, %0|%0, %2}
8566 and{<imodesuffix>}\t{%2, %0|%0, %2} 9171 and{<imodesuffix>}\t{%2, %0|%0, %2}
8577 (set_attr "mode" "<MODE>,<MODE>,SI")]) 9182 (set_attr "mode" "<MODE>,<MODE>,SI")])
8578 9183
8579 (define_insn "*andqi_1" 9184 (define_insn "*andqi_1"
8580 [(set (match_operand:QI 0 "nonimmediate_operand" "=qm,q,r") 9185 [(set (match_operand:QI 0 "nonimmediate_operand" "=qm,q,r")
8581 (and:QI (match_operand:QI 1 "nonimmediate_operand" "%0,0,0") 9186 (and:QI (match_operand:QI 1 "nonimmediate_operand" "%0,0,0")
8582 (match_operand:QI 2 "general_operand" "qn,qmn,rn"))) 9187 (match_operand:QI 2 "general_operand" "qn,m,rn")))
8583 (clobber (reg:CC FLAGS_REG))] 9188 (clobber (reg:CC FLAGS_REG))]
8584 "ix86_binary_operator_ok (AND, QImode, operands)" 9189 "ix86_binary_operator_ok (AND, QImode, operands)"
8585 "@ 9190 "@
8586 and{b}\t{%2, %0|%0, %2} 9191 and{b}\t{%2, %0|%0, %2}
8587 and{b}\t{%2, %0|%0, %2} 9192 and{b}\t{%2, %0|%0, %2}
8592 (set (attr "preferred_for_speed") 9197 (set (attr "preferred_for_speed")
8593 (cond [(eq_attr "alternative" "2") 9198 (cond [(eq_attr "alternative" "2")
8594 (symbol_ref "!TARGET_PARTIAL_REG_STALL")] 9199 (symbol_ref "!TARGET_PARTIAL_REG_STALL")]
8595 (symbol_ref "true")))]) 9200 (symbol_ref "true")))])
8596 9201
8597 (define_insn "*andqi_1_slp" 9202 (define_insn "*and<mode>_1_slp"
8598 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+qm,q")) 9203 [(set (strict_low_part (match_operand:SWI12 0 "register_operand" "+<r>"))
8599 (and:QI (match_dup 0) 9204 (and:SWI12 (match_operand:SWI12 1 "nonimmediate_operand" "%0")
8600 (match_operand:QI 1 "general_operand" "qn,qmn"))) 9205 (match_operand:SWI12 2 "general_operand" "<r>mn")))
8601 (clobber (reg:CC FLAGS_REG))] 9206 (clobber (reg:CC FLAGS_REG))]
8602 "(!TARGET_PARTIAL_REG_STALL || optimize_function_for_size_p (cfun)) 9207 "(!TARGET_PARTIAL_REG_STALL || optimize_function_for_size_p (cfun))
8603 && !(MEM_P (operands[0]) && MEM_P (operands[1]))" 9208 /* FIXME: without this LRA can't reload this pattern, see PR82524. */
8604 "and{b}\t{%1, %0|%0, %1}" 9209 && (rtx_equal_p (operands[0], operands[1])
8605 [(set_attr "type" "alu1") 9210 || rtx_equal_p (operands[0], operands[2]))"
8606 (set_attr "mode" "QI")]) 9211 "and{<imodesuffix>}\t{%2, %0|%0, %2}"
9212 [(set_attr "type" "alu")
9213 (set_attr "mode" "<MODE>")])
8607 9214
8608 (define_split 9215 (define_split
8609 [(set (match_operand:SWI248 0 "register_operand") 9216 [(set (match_operand:SWI248 0 "register_operand")
8610 (and:SWI248 (match_operand:SWI248 1 "nonimmediate_operand") 9217 (and:SWI248 (match_operand:SWI248 1 "nonimmediate_operand")
8611 (match_operand:SWI248 2 "const_int_operand"))) 9218 (match_operand:SWI248 2 "const_int_operand")))
8613 "reload_completed 9220 "reload_completed
8614 && (!REG_P (operands[1]) 9221 && (!REG_P (operands[1])
8615 || REGNO (operands[0]) != REGNO (operands[1]))" 9222 || REGNO (operands[0]) != REGNO (operands[1]))"
8616 [(const_int 0)] 9223 [(const_int 0)]
8617 { 9224 {
8618 HOST_WIDE_INT ival = INTVAL (operands[2]); 9225 unsigned HOST_WIDE_INT ival = UINTVAL (operands[2]);
8619 machine_mode mode; 9226 machine_mode mode;
8620 rtx (*insn) (rtx, rtx); 9227
8621 9228 if (ival == GET_MODE_MASK (SImode))
8622 if (ival == (HOST_WIDE_INT) 0xffffffff)
8623 mode = SImode; 9229 mode = SImode;
8624 else if (ival == 0xffff) 9230 else if (ival == GET_MODE_MASK (HImode))
8625 mode = HImode; 9231 mode = HImode;
9232 else if (ival == GET_MODE_MASK (QImode))
9233 mode = QImode;
8626 else 9234 else
8627 { 9235 gcc_unreachable ();
8628 gcc_assert (ival == 0xff); 9236
8629 mode = QImode; 9237 /* Zero extend to SImode to avoid partial register stalls. */
8630 } 9238 if (<MODE_SIZE> < GET_MODE_SIZE (SImode))
8631 9239 operands[0] = gen_lowpart (SImode, operands[0]);
8632 if (<MODE>mode == DImode) 9240
8633 insn = (mode == SImode) 9241 emit_insn (gen_extend_insn
8634 ? gen_zero_extendsidi2 9242 (operands[0], gen_lowpart (mode, operands[1]),
8635 : (mode == HImode) 9243 GET_MODE (operands[0]), mode, 1));
8636 ? gen_zero_extendhidi2
8637 : gen_zero_extendqidi2;
8638 else
8639 {
8640 if (<MODE>mode != SImode)
8641 /* Zero extend to SImode to avoid partial register stalls. */
8642 operands[0] = gen_lowpart (SImode, operands[0]);
8643
8644 insn = (mode == HImode)
8645 ? gen_zero_extendhisi2
8646 : gen_zero_extendqisi2;
8647 }
8648 emit_insn (insn (operands[0], gen_lowpart (mode, operands[1])));
8649 DONE; 9244 DONE;
8650 }) 9245 })
8651 9246
8652 (define_split 9247 (define_split
8653 [(set (match_operand:SWI48 0 "register_operand") 9248 [(set (match_operand:SWI48 0 "register_operand")
8696 (define_insn "*anddi_2" 9291 (define_insn "*anddi_2"
8697 [(set (reg FLAGS_REG) 9292 [(set (reg FLAGS_REG)
8698 (compare 9293 (compare
8699 (and:DI 9294 (and:DI
8700 (match_operand:DI 1 "nonimmediate_operand" "%0,0,0") 9295 (match_operand:DI 1 "nonimmediate_operand" "%0,0,0")
8701 (match_operand:DI 2 "x86_64_szext_general_operand" "Z,rem,re")) 9296 (match_operand:DI 2 "x86_64_szext_general_operand" "Z,re,m"))
8702 (const_int 0))) 9297 (const_int 0)))
8703 (set (match_operand:DI 0 "nonimmediate_operand" "=r,r,rm") 9298 (set (match_operand:DI 0 "nonimmediate_operand" "=r,rm,r")
8704 (and:DI (match_dup 1) (match_dup 2)))] 9299 (and:DI (match_dup 1) (match_dup 2)))]
8705 "TARGET_64BIT 9300 "TARGET_64BIT
8706 && ix86_match_ccmode 9301 && ix86_match_ccmode
8707 (insn, 9302 (insn,
8708 /* If we are going to emit andl instead of andq, and the operands[2] 9303 /* If we are going to emit andl instead of andq, and the operands[2]
8739 9334
8740 (define_insn "*andqi_2_maybe_si" 9335 (define_insn "*andqi_2_maybe_si"
8741 [(set (reg FLAGS_REG) 9336 [(set (reg FLAGS_REG)
8742 (compare (and:QI 9337 (compare (and:QI
8743 (match_operand:QI 1 "nonimmediate_operand" "%0,0,0") 9338 (match_operand:QI 1 "nonimmediate_operand" "%0,0,0")
8744 (match_operand:QI 2 "general_operand" "qmn,qn,n")) 9339 (match_operand:QI 2 "general_operand" "qn,m,n"))
8745 (const_int 0))) 9340 (const_int 0)))
8746 (set (match_operand:QI 0 "nonimmediate_operand" "=q,qm,*r") 9341 (set (match_operand:QI 0 "nonimmediate_operand" "=qm,q,r")
8747 (and:QI (match_dup 1) (match_dup 2)))] 9342 (and:QI (match_dup 1) (match_dup 2)))]
8748 "ix86_binary_operator_ok (AND, QImode, operands) 9343 "ix86_binary_operator_ok (AND, QImode, operands)
8749 && ix86_match_ccmode (insn, 9344 && ix86_match_ccmode (insn,
8750 CONST_INT_P (operands[2]) 9345 CONST_INT_P (operands[2])
8751 && INTVAL (operands[2]) >= 0 ? CCNOmode : CCZmode)" 9346 && INTVAL (operands[2]) >= 0 ? CCNOmode : CCZmode)"
8757 return "and{l}\t{%2, %k0|%k0, %2}"; 9352 return "and{l}\t{%2, %k0|%k0, %2}";
8758 } 9353 }
8759 return "and{b}\t{%2, %0|%0, %2}"; 9354 return "and{b}\t{%2, %0|%0, %2}";
8760 } 9355 }
8761 [(set_attr "type" "alu") 9356 [(set_attr "type" "alu")
8762 (set_attr "mode" "QI,QI,SI")]) 9357 (set_attr "mode" "QI,QI,SI")
9358 ;; Potential partial reg stall on alternative 2.
9359 (set (attr "preferred_for_speed")
9360 (cond [(eq_attr "alternative" "2")
9361 (symbol_ref "!TARGET_PARTIAL_REG_STALL")]
9362 (symbol_ref "true")))])
8763 9363
8764 (define_insn "*and<mode>_2" 9364 (define_insn "*and<mode>_2"
8765 [(set (reg FLAGS_REG) 9365 [(set (reg FLAGS_REG)
8766 (compare (and:SWI124 9366 (compare (and:SWI124
8767 (match_operand:SWI124 1 "nonimmediate_operand" "%0,0") 9367 (match_operand:SWI124 1 "nonimmediate_operand" "%0,0")
8768 (match_operand:SWI124 2 "<general_operand>" "<g>,<r><i>")) 9368 (match_operand:SWI124 2 "<general_operand>" "<r><i>,m"))
8769 (const_int 0))) 9369 (const_int 0)))
8770 (set (match_operand:SWI124 0 "nonimmediate_operand" "=<r>,<r>m") 9370 (set (match_operand:SWI124 0 "nonimmediate_operand" "=<r>m,<r>")
8771 (and:SWI124 (match_dup 1) (match_dup 2)))] 9371 (and:SWI124 (match_dup 1) (match_dup 2)))]
8772 "ix86_match_ccmode (insn, CCNOmode) 9372 "ix86_match_ccmode (insn, CCNOmode)
8773 && ix86_binary_operator_ok (AND, <MODE>mode, operands)" 9373 && ix86_binary_operator_ok (AND, <MODE>mode, operands)"
8774 "and{<imodesuffix>}\t{%2, %0|%0, %2}" 9374 "and{<imodesuffix>}\t{%2, %0|%0, %2}"
8775 [(set_attr "type" "alu") 9375 [(set_attr "type" "alu")
8776 (set_attr "mode" "<MODE>")]) 9376 (set_attr "mode" "<MODE>")])
8777
8778 (define_insn "*andqi_2_slp"
8779 [(set (reg FLAGS_REG)
8780 (compare (and:QI
8781 (match_operand:QI 0 "nonimmediate_operand" "+q,qm")
8782 (match_operand:QI 1 "nonimmediate_operand" "qmn,qn"))
8783 (const_int 0)))
8784 (set (strict_low_part (match_dup 0))
8785 (and:QI (match_dup 0) (match_dup 1)))]
8786 "(!TARGET_PARTIAL_REG_STALL || optimize_function_for_size_p (cfun))
8787 && ix86_match_ccmode (insn, CCNOmode)
8788 && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
8789 "and{b}\t{%1, %0|%0, %1}"
8790 [(set_attr "type" "alu1")
8791 (set_attr "mode" "QI")])
8792 9377
8793 (define_insn "andqi_ext_1" 9378 (define_insn "andqi_ext_1"
8794 [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "+Q,Q") 9379 [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "+Q,Q")
8795 (const_int 8) 9380 (const_int 8)
8796 (const_int 8)) 9381 (const_int 8))
8912 operands[1] = gen_lowpart (QImode, operands[1]); 9497 operands[1] = gen_lowpart (QImode, operands[1]);
8913 operands[2] = gen_int_mode (INTVAL (operands[2]), QImode); 9498 operands[2] = gen_int_mode (INTVAL (operands[2]), QImode);
8914 }) 9499 })
8915 9500
8916 (define_insn "*andndi3_doubleword" 9501 (define_insn "*andndi3_doubleword"
8917 [(set (match_operand:DI 0 "register_operand" "=&r,r,r,&r") 9502 [(set (match_operand:DI 0 "register_operand")
8918 (and:DI 9503 (and:DI
8919 (not:DI (match_operand:DI 1 "register_operand" "r,0,r,0")) 9504 (not:DI (match_operand:DI 1 "register_operand"))
8920 (match_operand:DI 2 "nonimmediate_operand" "rm,rm,0,rm"))) 9505 (match_operand:DI 2 "nonimmediate_operand")))
8921 (clobber (reg:CC FLAGS_REG))] 9506 (clobber (reg:CC FLAGS_REG))]
8922 "!TARGET_64BIT && TARGET_STV && TARGET_SSE2" 9507 "!TARGET_64BIT && TARGET_STV && TARGET_SSE2
8923 "#" 9508 && ix86_pre_reload_split ()"
8924 [(set_attr "isa" "bmi,bmi,bmi,*")]) 9509 "#")
8925 9510
8926 (define_split 9511 (define_split
8927 [(set (match_operand:DI 0 "register_operand") 9512 [(set (match_operand:DI 0 "register_operand")
8928 (and:DI 9513 (and:DI
8929 (not:DI (match_operand:DI 1 "register_operand")) 9514 (not:DI (match_operand:DI 1 "register_operand"))
8930 (match_operand:DI 2 "nonimmediate_operand"))) 9515 (match_operand:DI 2 "nonimmediate_operand")))
8931 (clobber (reg:CC FLAGS_REG))] 9516 (clobber (reg:CC FLAGS_REG))]
8932 "!TARGET_64BIT && TARGET_BMI && TARGET_STV && TARGET_SSE2 9517 "!TARGET_64BIT && TARGET_BMI && TARGET_STV && TARGET_SSE2
8933 && reload_completed" 9518 && can_create_pseudo_p ()"
8934 [(parallel [(set (match_dup 0) 9519 [(parallel [(set (match_dup 0)
8935 (and:SI (not:SI (match_dup 1)) (match_dup 2))) 9520 (and:SI (not:SI (match_dup 1)) (match_dup 2)))
8936 (clobber (reg:CC FLAGS_REG))]) 9521 (clobber (reg:CC FLAGS_REG))])
8937 (parallel [(set (match_dup 3) 9522 (parallel [(set (match_dup 3)
8938 (and:SI (not:SI (match_dup 4)) (match_dup 5))) 9523 (and:SI (not:SI (match_dup 4)) (match_dup 5)))
8940 "split_double_mode (DImode, &operands[0], 3, &operands[0], &operands[3]);") 9525 "split_double_mode (DImode, &operands[0], 3, &operands[0], &operands[3]);")
8941 9526
8942 (define_split 9527 (define_split
8943 [(set (match_operand:DI 0 "register_operand") 9528 [(set (match_operand:DI 0 "register_operand")
8944 (and:DI 9529 (and:DI
8945 (not:DI (match_dup 0)) 9530 (not:DI (match_operand:DI 1 "register_operand"))
8946 (match_operand:DI 1 "nonimmediate_operand"))) 9531 (match_operand:DI 2 "nonimmediate_operand")))
8947 (clobber (reg:CC FLAGS_REG))] 9532 (clobber (reg:CC FLAGS_REG))]
8948 "!TARGET_64BIT && !TARGET_BMI && TARGET_STV && TARGET_SSE2 9533 "!TARGET_64BIT && !TARGET_BMI && TARGET_STV && TARGET_SSE2
8949 && reload_completed" 9534 && can_create_pseudo_p ()"
8950 [(set (match_dup 0) (not:SI (match_dup 0))) 9535 [(set (match_dup 6) (not:SI (match_dup 1)))
8951 (parallel [(set (match_dup 0) 9536 (parallel [(set (match_dup 0)
8952 (and:SI (match_dup 0) (match_dup 1))) 9537 (and:SI (match_dup 6) (match_dup 2)))
8953 (clobber (reg:CC FLAGS_REG))]) 9538 (clobber (reg:CC FLAGS_REG))])
8954 (set (match_dup 2) (not:SI (match_dup 2))) 9539 (set (match_dup 7) (not:SI (match_dup 4)))
8955 (parallel [(set (match_dup 2) 9540 (parallel [(set (match_dup 3)
8956 (and:SI (match_dup 2) (match_dup 3))) 9541 (and:SI (match_dup 7) (match_dup 5)))
8957 (clobber (reg:CC FLAGS_REG))])] 9542 (clobber (reg:CC FLAGS_REG))])]
8958 "split_double_mode (DImode, &operands[0], 2, &operands[0], &operands[2]);") 9543 {
9544 operands[6] = gen_reg_rtx (SImode);
9545 operands[7] = gen_reg_rtx (SImode);
9546
9547 split_double_mode (DImode, &operands[0], 3, &operands[0], &operands[3]);
9548 })
8959 9549
8960 (define_insn "*andn<mode>_1" 9550 (define_insn "*andn<mode>_1"
8961 [(set (match_operand:SWI48 0 "register_operand" "=r,r") 9551 [(set (match_operand:SWI48 0 "register_operand" "=r,r")
8962 (and:SWI48 9552 (and:SWI48
8963 (not:SWI48 (match_operand:SWI48 1 "register_operand" "r,r")) 9553 (not:SWI48 (match_operand:SWI48 1 "register_operand" "r,r"))
8999 9589
9000 ;; %%% This used to optimize known byte-wide and operations to memory. 9590 ;; %%% This used to optimize known byte-wide and operations to memory.
9001 ;; If this is considered useful, it should be done with splitters. 9591 ;; If this is considered useful, it should be done with splitters.
9002 9592
9003 (define_expand "<code><mode>3" 9593 (define_expand "<code><mode>3"
9004 [(set (match_operand:SWIM1248x 0 "nonimmediate_operand") 9594 [(set (match_operand:SWIM1248s 0 "nonimmediate_operand")
9005 (any_or:SWIM1248x (match_operand:SWIM1248x 1 "nonimmediate_operand") 9595 (any_or:SWIM1248s (match_operand:SWIM1248s 1 "nonimmediate_operand")
9006 (match_operand:SWIM1248x 2 "<general_operand>")))] 9596 (match_operand:SWIM1248s 2 "<general_operand>")))]
9007 "" 9597 ""
9008 "ix86_expand_binary_operator (<CODE>, <MODE>mode, operands); DONE;") 9598 "ix86_expand_binary_operator (<CODE>, <MODE>mode, operands); DONE;")
9009 9599
9010 (define_insn_and_split "*<code>di3_doubleword" 9600 (define_insn_and_split "*<code>di3_doubleword"
9011 [(set (match_operand:DI 0 "nonimmediate_operand" "=r,rm,r") 9601 [(set (match_operand:DI 0 "nonimmediate_operand")
9012 (any_or:DI 9602 (any_or:DI
9013 (match_operand:DI 1 "nonimmediate_operand" "%0,0,0") 9603 (match_operand:DI 1 "nonimmediate_operand")
9014 (match_operand:DI 2 "x86_64_szext_general_operand" "Z,re,rm"))) 9604 (match_operand:DI 2 "x86_64_szext_general_operand")))
9015 (clobber (reg:CC FLAGS_REG))] 9605 (clobber (reg:CC FLAGS_REG))]
9016 "!TARGET_64BIT && TARGET_STV && TARGET_SSE2 9606 "!TARGET_64BIT && TARGET_STV && TARGET_SSE2
9017 && ix86_binary_operator_ok (<CODE>, DImode, operands)" 9607 && ix86_binary_operator_ok (<CODE>, DImode, operands)
9608 && ix86_pre_reload_split ()"
9018 "#" 9609 "#"
9019 "&& reload_completed" 9610 "&& 1"
9020 [(const_int 0)] 9611 [(const_int 0)]
9021 { 9612 {
9022 split_double_mode (DImode, &operands[0], 3, &operands[0], &operands[3]); 9613 split_double_mode (DImode, &operands[0], 3, &operands[0], &operands[3]);
9023 if (operands[2] == constm1_rtx) 9614
9615 if (operands[2] == const0_rtx)
9616 emit_move_insn (operands[0], operands[1]);
9617 else if (operands[2] == constm1_rtx)
9024 { 9618 {
9025 if (<CODE> == IOR) 9619 if (<CODE> == IOR)
9026 { 9620 emit_move_insn (operands[0], constm1_rtx);
9027 operands[1] = constm1_rtx;
9028 ix86_expand_move (SImode, &operands[0]);
9029 }
9030 else 9621 else
9031 ix86_expand_unary_operator (NOT, SImode, &operands[0]); 9622 ix86_expand_unary_operator (NOT, SImode, &operands[0]);
9032 } 9623 }
9033 else if (operands[2] != const0_rtx) 9624 else
9034 ix86_expand_binary_operator (<CODE>, SImode, &operands[0]); 9625 ix86_expand_binary_operator (<CODE>, SImode, &operands[0]);
9035 else if (operands[5] == const0_rtx) 9626
9036 emit_note (NOTE_INSN_DELETED); 9627 if (operands[5] == const0_rtx)
9037 if (operands[5] == constm1_rtx) 9628 emit_move_insn (operands[3], operands[4]);
9629 else if (operands[5] == constm1_rtx)
9038 { 9630 {
9039 if (<CODE> == IOR) 9631 if (<CODE> == IOR)
9040 { 9632 emit_move_insn (operands[3], constm1_rtx);
9041 operands[4] = constm1_rtx;
9042 ix86_expand_move (SImode, &operands[3]);
9043 }
9044 else 9633 else
9045 ix86_expand_unary_operator (NOT, SImode, &operands[3]); 9634 ix86_expand_unary_operator (NOT, SImode, &operands[3]);
9046 } 9635 }
9047 else if (operands[5] != const0_rtx) 9636 else
9048 ix86_expand_binary_operator (<CODE>, SImode, &operands[3]); 9637 ix86_expand_binary_operator (<CODE>, SImode, &operands[3]);
9638
9049 DONE; 9639 DONE;
9050 }) 9640 })
9051 9641
9052 (define_insn "*<code><mode>_1" 9642 (define_insn "*<code><mode>_1"
9053 [(set (match_operand:SWI248 0 "nonimmediate_operand" "=r,rm") 9643 [(set (match_operand:SWI248 0 "nonimmediate_operand" "=rm,r")
9054 (any_or:SWI248 9644 (any_or:SWI248
9055 (match_operand:SWI248 1 "nonimmediate_operand" "%0,0") 9645 (match_operand:SWI248 1 "nonimmediate_operand" "%0,0")
9056 (match_operand:SWI248 2 "<general_operand>" "<g>,r<i>"))) 9646 (match_operand:SWI248 2 "<general_operand>" "r<i>,m")))
9057 (clobber (reg:CC FLAGS_REG))] 9647 (clobber (reg:CC FLAGS_REG))]
9058 "ix86_binary_operator_ok (<CODE>, <MODE>mode, operands)" 9648 "ix86_binary_operator_ok (<CODE>, <MODE>mode, operands)"
9059 "<logic>{<imodesuffix>}\t{%2, %0|%0, %2}" 9649 "<logic>{<imodesuffix>}\t{%2, %0|%0, %2}"
9060 [(set_attr "type" "alu") 9650 [(set_attr "type" "alu")
9061 (set_attr "mode" "<MODE>")]) 9651 (set_attr "mode" "<MODE>")])
9128 "<logic>{l}\t{%2, %k0|%k0, %2}" 9718 "<logic>{l}\t{%2, %k0|%k0, %2}"
9129 [(set_attr "type" "alu") 9719 [(set_attr "type" "alu")
9130 (set_attr "mode" "SI")]) 9720 (set_attr "mode" "SI")])
9131 9721
9132 (define_insn "*<code>qi_1" 9722 (define_insn "*<code>qi_1"
9133 [(set (match_operand:QI 0 "nonimmediate_operand" "=q,m,r") 9723 [(set (match_operand:QI 0 "nonimmediate_operand" "=qm,q,r")
9134 (any_or:QI (match_operand:QI 1 "nonimmediate_operand" "%0,0,0") 9724 (any_or:QI (match_operand:QI 1 "nonimmediate_operand" "%0,0,0")
9135 (match_operand:QI 2 "general_operand" "qmn,qn,rn"))) 9725 (match_operand:QI 2 "general_operand" "qn,m,rn")))
9136 (clobber (reg:CC FLAGS_REG))] 9726 (clobber (reg:CC FLAGS_REG))]
9137 "ix86_binary_operator_ok (<CODE>, QImode, operands)" 9727 "ix86_binary_operator_ok (<CODE>, QImode, operands)"
9138 "@ 9728 "@
9139 <logic>{b}\t{%2, %0|%0, %2} 9729 <logic>{b}\t{%2, %0|%0, %2}
9140 <logic>{b}\t{%2, %0|%0, %2} 9730 <logic>{b}\t{%2, %0|%0, %2}
9145 (set (attr "preferred_for_speed") 9735 (set (attr "preferred_for_speed")
9146 (cond [(eq_attr "alternative" "2") 9736 (cond [(eq_attr "alternative" "2")
9147 (symbol_ref "!TARGET_PARTIAL_REG_STALL")] 9737 (symbol_ref "!TARGET_PARTIAL_REG_STALL")]
9148 (symbol_ref "true")))]) 9738 (symbol_ref "true")))])
9149 9739
9150 (define_insn "*<code>qi_1_slp" 9740 (define_insn "*<code><mode>_1_slp"
9151 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+q,m")) 9741 [(set (strict_low_part (match_operand:SWI12 0 "register_operand" "+<r>"))
9152 (any_or:QI (match_dup 0) 9742 (any_or:SWI12 (match_operand:SWI12 1 "nonimmediate_operand" "%0")
9153 (match_operand:QI 1 "general_operand" "qmn,qn"))) 9743 (match_operand:SWI12 2 "general_operand" "<r>mn")))
9154 (clobber (reg:CC FLAGS_REG))] 9744 (clobber (reg:CC FLAGS_REG))]
9155 "(!TARGET_PARTIAL_REG_STALL || optimize_function_for_size_p (cfun)) 9745 "(!TARGET_PARTIAL_REG_STALL || optimize_function_for_size_p (cfun))
9156 && !(MEM_P (operands[0]) && MEM_P (operands[1]))" 9746 /* FIXME: without this LRA can't reload this pattern, see PR82524. */
9157 "<logic>{b}\t{%1, %0|%0, %1}" 9747 && (rtx_equal_p (operands[0], operands[1])
9158 [(set_attr "type" "alu1") 9748 || rtx_equal_p (operands[0], operands[2]))"
9159 (set_attr "mode" "QI")]) 9749 "<logic>{<imodesuffix>}\t{%2, %0|%0, %2}"
9750 [(set_attr "type" "alu")
9751 (set_attr "mode" "<MODE>")])
9160 9752
9161 (define_insn "*<code><mode>_2" 9753 (define_insn "*<code><mode>_2"
9162 [(set (reg FLAGS_REG) 9754 [(set (reg FLAGS_REG)
9163 (compare (any_or:SWI 9755 (compare (any_or:SWI
9164 (match_operand:SWI 1 "nonimmediate_operand" "%0,0") 9756 (match_operand:SWI 1 "nonimmediate_operand" "%0,0")
9165 (match_operand:SWI 2 "<general_operand>" "<g>,<r><i>")) 9757 (match_operand:SWI 2 "<general_operand>" "<r><i>,m"))
9166 (const_int 0))) 9758 (const_int 0)))
9167 (set (match_operand:SWI 0 "nonimmediate_operand" "=<r>,<r>m") 9759 (set (match_operand:SWI 0 "nonimmediate_operand" "=<r>m,<r>")
9168 (any_or:SWI (match_dup 1) (match_dup 2)))] 9760 (any_or:SWI (match_dup 1) (match_dup 2)))]
9169 "ix86_match_ccmode (insn, CCNOmode) 9761 "ix86_match_ccmode (insn, CCNOmode)
9170 && ix86_binary_operator_ok (<CODE>, <MODE>mode, operands)" 9762 && ix86_binary_operator_ok (<CODE>, <MODE>mode, operands)"
9171 "<logic>{<imodesuffix>}\t{%2, %0|%0, %2}" 9763 "<logic>{<imodesuffix>}\t{%2, %0|%0, %2}"
9172 [(set_attr "type" "alu") 9764 [(set_attr "type" "alu")
9198 "TARGET_64BIT && ix86_match_ccmode (insn, CCNOmode) 9790 "TARGET_64BIT && ix86_match_ccmode (insn, CCNOmode)
9199 && ix86_binary_operator_ok (<CODE>, SImode, operands)" 9791 && ix86_binary_operator_ok (<CODE>, SImode, operands)"
9200 "<logic>{l}\t{%2, %k0|%k0, %2}" 9792 "<logic>{l}\t{%2, %k0|%k0, %2}"
9201 [(set_attr "type" "alu") 9793 [(set_attr "type" "alu")
9202 (set_attr "mode" "SI")]) 9794 (set_attr "mode" "SI")])
9203
9204 (define_insn "*<code>qi_2_slp"
9205 [(set (reg FLAGS_REG)
9206 (compare (any_or:QI (match_operand:QI 0 "nonimmediate_operand" "+q,qm")
9207 (match_operand:QI 1 "general_operand" "qmn,qn"))
9208 (const_int 0)))
9209 (set (strict_low_part (match_dup 0))
9210 (any_or:QI (match_dup 0) (match_dup 1)))]
9211 "(!TARGET_PARTIAL_REG_STALL || optimize_function_for_size_p (cfun))
9212 && ix86_match_ccmode (insn, CCNOmode)
9213 && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
9214 "<logic>{b}\t{%1, %0|%0, %1}"
9215 [(set_attr "type" "alu1")
9216 (set_attr "mode" "QI")])
9217 9795
9218 (define_insn "*<code><mode>_3" 9796 (define_insn "*<code><mode>_3"
9219 [(set (reg FLAGS_REG) 9797 [(set (reg FLAGS_REG)
9220 (compare (any_or:SWI 9798 (compare (any_or:SWI
9221 (match_operand:SWI 1 "nonimmediate_operand" "%0") 9799 (match_operand:SWI 1 "nonimmediate_operand" "%0")
9411 "ix86_unary_operator_ok (NEG, <MODE>mode, operands)" 9989 "ix86_unary_operator_ok (NEG, <MODE>mode, operands)"
9412 "neg{<imodesuffix>}\t%0" 9990 "neg{<imodesuffix>}\t%0"
9413 [(set_attr "type" "negnot") 9991 [(set_attr "type" "negnot")
9414 (set_attr "mode" "<MODE>")]) 9992 (set_attr "mode" "<MODE>")])
9415 9993
9416 ;; Combine is quite creative about this pattern.
9417 (define_insn "*negsi2_1_zext" 9994 (define_insn "*negsi2_1_zext"
9418 [(set (match_operand:DI 0 "register_operand" "=r") 9995 [(set (match_operand:DI 0 "register_operand" "=r")
9419 (lshiftrt:DI 9996 (zero_extend:DI
9420 (neg:DI (ashift:DI (match_operand:DI 1 "register_operand" "0") 9997 (neg:SI (match_operand:SI 1 "register_operand" "0"))))
9421 (const_int 32)))
9422 (const_int 32)))
9423 (clobber (reg:CC FLAGS_REG))] 9998 (clobber (reg:CC FLAGS_REG))]
9424 "TARGET_64BIT && ix86_unary_operator_ok (NEG, SImode, operands)" 9999 "TARGET_64BIT && ix86_unary_operator_ok (NEG, SImode, operands)"
9425 "neg{l}\t%k0" 10000 "neg{l}\t%k0"
9426 [(set_attr "type" "negnot") 10001 [(set_attr "type" "negnot")
9427 (set_attr "mode" "SI")]) 10002 (set_attr "mode" "SI")])
9443 (set_attr "mode" "<MODE>")]) 10018 (set_attr "mode" "<MODE>")])
9444 10019
9445 (define_insn "*negsi2_cmpz_zext" 10020 (define_insn "*negsi2_cmpz_zext"
9446 [(set (reg:CCZ FLAGS_REG) 10021 [(set (reg:CCZ FLAGS_REG)
9447 (compare:CCZ 10022 (compare:CCZ
9448 (lshiftrt:DI 10023 (neg:SI (match_operand:SI 1 "register_operand" "0"))
9449 (neg:DI (ashift:DI
9450 (match_operand:DI 1 "register_operand" "0")
9451 (const_int 32)))
9452 (const_int 32))
9453 (const_int 0))) 10024 (const_int 0)))
9454 (set (match_operand:DI 0 "register_operand" "=r") 10025 (set (match_operand:DI 0 "register_operand" "=r")
9455 (lshiftrt:DI (neg:DI (ashift:DI (match_dup 1) 10026 (zero_extend:DI
9456 (const_int 32))) 10027 (neg:SI (match_dup 1))))]
9457 (const_int 32)))]
9458 "TARGET_64BIT && ix86_unary_operator_ok (NEG, SImode, operands)" 10028 "TARGET_64BIT && ix86_unary_operator_ok (NEG, SImode, operands)"
9459 "neg{l}\t%k0" 10029 "neg{l}\t%k0"
9460 [(set_attr "type" "negnot") 10030 [(set_attr "type" "negnot")
9461 (set_attr "mode" "SI")]) 10031 (set_attr "mode" "SI")])
9462 10032
9488 && mode_signbit_p (<MODE>mode, operands[2])" 10058 && mode_signbit_p (<MODE>mode, operands[2])"
9489 "neg{<imodesuffix>}\t%0" 10059 "neg{<imodesuffix>}\t%0"
9490 [(set_attr "type" "negnot") 10060 [(set_attr "type" "negnot")
9491 (set_attr "mode" "<MODE>")]) 10061 (set_attr "mode" "<MODE>")])
9492 10062
9493 ;; Changing of sign for FP values is doable using integer unit too. 10063 (define_expand "<code>tf2"
10064 [(set (match_operand:TF 0 "register_operand")
10065 (absneg:TF (match_operand:TF 1 "register_operand")))]
10066 "TARGET_SSE"
10067 "ix86_expand_fp_absneg_operator (<CODE>, TFmode, operands); DONE;")
10068
10069 (define_insn "*<code>tf2_1"
10070 [(set (match_operand:TF 0 "register_operand" "=x,x,Yv,Yv")
10071 (absneg:TF
10072 (match_operand:TF 1 "vector_operand" "0,xBm,Yv,m")))
10073 (use (match_operand:TF 2 "vector_operand" "xBm,0,Yvm,Yv"))
10074 (clobber (reg:CC FLAGS_REG))]
10075 "TARGET_SSE"
10076 "#"
10077 [(set_attr "isa" "noavx,noavx,avx,avx")])
10078
10079 (define_insn "*nabstf2_1"
10080 [(set (match_operand:TF 0 "register_operand" "=x,x,Yv,Yv")
10081 (neg:TF
10082 (abs:TF
10083 (match_operand:TF 1 "vector_operand" "0,xBm,Yv,m"))))
10084 (use (match_operand:TF 2 "vector_operand" "xBm,0,Yvm,Yv"))]
10085 "TARGET_SSE"
10086 "#"
10087 [(set_attr "isa" "noavx,noavx,avx,avx")])
10088
10089 ;; Special expand pattern to handle integer mode abs
10090
10091 (define_expand "abs<mode>2"
10092 [(set (match_operand:SWI48x 0 "register_operand")
10093 (abs:SWI48x
10094 (match_operand:SWI48x 1 "register_operand")))]
10095 "TARGET_EXPAND_ABS"
10096 {
10097 machine_mode mode = <MODE>mode;
10098
10099 /* Generate rtx abs using abs (x) = (((signed) x >> (W-1)) ^ x) -
10100 ((signed) x >> (W-1)) */
10101 rtx shift_amount = gen_int_mode (GET_MODE_PRECISION (mode) - 1, QImode);
10102 rtx shift_dst = expand_simple_binop (mode, ASHIFTRT, operands[1],
10103 shift_amount, NULL_RTX,
10104 0, OPTAB_DIRECT);
10105 rtx xor_dst = expand_simple_binop (mode, XOR, shift_dst, operands[1],
10106 operands[0], 0, OPTAB_DIRECT);
10107 rtx minus_dst = expand_simple_binop (mode, MINUS, xor_dst, shift_dst,
10108 operands[0], 0, OPTAB_DIRECT);
10109 if (!rtx_equal_p (minus_dst, operands[0]))
10110 emit_move_insn (operands[0], minus_dst);
10111 DONE;
10112 })
9494 10113
9495 (define_expand "<code><mode>2" 10114 (define_expand "<code><mode>2"
9496 [(set (match_operand:X87MODEF 0 "register_operand") 10115 [(set (match_operand:X87MODEF 0 "register_operand")
9497 (absneg:X87MODEF (match_operand:X87MODEF 1 "register_operand")))] 10116 (absneg:X87MODEF (match_operand:X87MODEF 1 "register_operand")))]
9498 "TARGET_80387 || (SSE_FLOAT_MODE_P (<MODE>mode) && TARGET_SSE_MATH)" 10117 "TARGET_80387 || (SSE_FLOAT_MODE_P (<MODE>mode) && TARGET_SSE_MATH)"
9499 "ix86_expand_fp_absneg_operator (<CODE>, <MODE>mode, operands); DONE;") 10118 "ix86_expand_fp_absneg_operator (<CODE>, <MODE>mode, operands); DONE;")
9500 10119
9501 (define_insn "*absneg<mode>2" 10120 ;; Changing of sign for FP values is doable using integer unit too.
9502 [(set (match_operand:MODEF 0 "register_operand" "=Yv,Yv,f,!r") 10121 (define_insn "*<code><mode>2_i387_1"
9503 (match_operator:MODEF 3 "absneg_operator" 10122 [(set (match_operand:X87MODEF 0 "register_operand" "=f,!r")
9504 [(match_operand:MODEF 1 "register_operand" "0,Yv,0,0")])) 10123 (absneg:X87MODEF
9505 (use (match_operand:<ssevecmode> 2 "nonimmediate_operand" "Yvm,0,X,X")) 10124 (match_operand:X87MODEF 1 "register_operand" "0,0")))
10125 (clobber (reg:CC FLAGS_REG))]
10126 "TARGET_80387"
10127 "#")
10128
10129 (define_split
10130 [(set (match_operand:X87MODEF 0 "fp_register_operand")
10131 (absneg:X87MODEF (match_operand:X87MODEF 1 "fp_register_operand")))
10132 (clobber (reg:CC FLAGS_REG))]
10133 "TARGET_80387 && reload_completed"
10134 [(set (match_dup 0) (absneg:X87MODEF (match_dup 1)))])
10135
10136 (define_split
10137 [(set (match_operand:X87MODEF 0 "general_reg_operand")
10138 (absneg:X87MODEF (match_operand:X87MODEF 1 "general_reg_operand")))
10139 (clobber (reg:CC FLAGS_REG))]
10140 "TARGET_80387 && reload_completed"
10141 [(const_int 0)]
10142 "ix86_split_fp_absneg_operator (<CODE>, <MODE>mode, operands); DONE;")
10143
10144 (define_insn "*<code><mode>2_1"
10145 [(set (match_operand:MODEF 0 "register_operand" "=x,x,Yv,f,!r")
10146 (absneg:MODEF
10147 (match_operand:MODEF 1 "register_operand" "0,x,Yv,0,0")))
10148 (use (match_operand:<ssevecmode> 2 "vector_operand" "xBm,0,Yvm,X,X"))
9506 (clobber (reg:CC FLAGS_REG))] 10149 (clobber (reg:CC FLAGS_REG))]
9507 "TARGET_80387 || (SSE_FLOAT_MODE_P (<MODE>mode) && TARGET_SSE_MATH)" 10150 "TARGET_80387 || (SSE_FLOAT_MODE_P (<MODE>mode) && TARGET_SSE_MATH)"
9508 "#" 10151 "#"
9509 [(set (attr "enabled") 10152 [(set_attr "isa" "noavx,noavx,avx,*,*")
10153 (set (attr "enabled")
9510 (if_then_else 10154 (if_then_else
9511 (match_test ("SSE_FLOAT_MODE_P (<MODE>mode) && TARGET_SSE_MATH")) 10155 (match_test ("SSE_FLOAT_MODE_P (<MODE>mode) && TARGET_SSE_MATH"))
9512 (if_then_else 10156 (if_then_else
9513 (eq_attr "alternative" "2") 10157 (eq_attr "alternative" "3,4")
9514 (symbol_ref "TARGET_MIX_SSE_I387") 10158 (symbol_ref "TARGET_MIX_SSE_I387")
9515 (symbol_ref "true")) 10159 (const_string "*"))
9516 (if_then_else 10160 (if_then_else
9517 (eq_attr "alternative" "2,3") 10161 (eq_attr "alternative" "3,4")
9518 (symbol_ref "true") 10162 (symbol_ref "true")
9519 (symbol_ref "false"))))]) 10163 (symbol_ref "false"))))])
9520 10164
9521 (define_insn "*absnegxf2_i387"
9522 [(set (match_operand:XF 0 "register_operand" "=f,!r")
9523 (match_operator:XF 3 "absneg_operator"
9524 [(match_operand:XF 1 "register_operand" "0,0")]))
9525 (use (match_operand 2))
9526 (clobber (reg:CC FLAGS_REG))]
9527 "TARGET_80387"
9528 "#")
9529
9530 (define_expand "<code>tf2"
9531 [(set (match_operand:TF 0 "register_operand")
9532 (absneg:TF (match_operand:TF 1 "register_operand")))]
9533 "TARGET_SSE"
9534 "ix86_expand_fp_absneg_operator (<CODE>, TFmode, operands); DONE;")
9535
9536 (define_insn "*absnegtf2_sse"
9537 [(set (match_operand:TF 0 "register_operand" "=Yv,Yv")
9538 (match_operator:TF 3 "absneg_operator"
9539 [(match_operand:TF 1 "register_operand" "0,Yv")]))
9540 (use (match_operand:TF 2 "nonimmediate_operand" "Yvm,0"))
9541 (clobber (reg:CC FLAGS_REG))]
9542 "TARGET_SSE"
9543 "#")
9544
9545 ;; Splitters for fp abs and neg.
9546
9547 (define_split 10165 (define_split
9548 [(set (match_operand 0 "fp_register_operand") 10166 [(set (match_operand:SSEMODEF 0 "sse_reg_operand")
9549 (match_operator 1 "absneg_operator" [(match_dup 0)])) 10167 (absneg:SSEMODEF
9550 (use (match_operand 2)) 10168 (match_operand:SSEMODEF 1 "vector_operand")))
9551 (clobber (reg:CC FLAGS_REG))] 10169 (use (match_operand:<ssevecmodef> 2 "vector_operand"))
9552 "reload_completed" 10170 (clobber (reg:CC FLAGS_REG))]
9553 [(set (match_dup 0) (match_op_dup 1 [(match_dup 0)]))]) 10171 "((SSE_FLOAT_MODE_P (<MODE>mode) && TARGET_SSE_MATH)
9554 10172 || (TARGET_SSE && (<MODE>mode == TFmode)))
9555 (define_split 10173 && reload_completed"
9556 [(set (match_operand 0 "sse_reg_operand")
9557 (match_operator 3 "absneg_operator"
9558 [(match_operand 1 "register_operand")]))
9559 (use (match_operand 2 "nonimmediate_operand"))
9560 (clobber (reg:CC FLAGS_REG))]
9561 "reload_completed"
9562 [(set (match_dup 0) (match_dup 3))] 10174 [(set (match_dup 0) (match_dup 3))]
9563 { 10175 {
9564 machine_mode mode = GET_MODE (operands[0]); 10176 machine_mode mode = <MODE>mode;
9565 machine_mode vmode = GET_MODE (operands[2]); 10177 machine_mode vmode = <ssevecmodef>mode;
9566 rtx tmp; 10178 enum rtx_code absneg_op = <CODE> == ABS ? AND : XOR;
9567 10179
9568 operands[0] = lowpart_subreg (vmode, operands[0], mode); 10180 operands[0] = lowpart_subreg (vmode, operands[0], mode);
9569 operands[1] = lowpart_subreg (vmode, operands[1], mode); 10181 operands[1] = lowpart_subreg (vmode, operands[1], mode);
9570 if (operands_match_p (operands[0], operands[2])) 10182
9571 std::swap (operands[1], operands[2]); 10183 if (TARGET_AVX)
9572 if (GET_CODE (operands[3]) == ABS)
9573 tmp = gen_rtx_AND (vmode, operands[1], operands[2]);
9574 else
9575 tmp = gen_rtx_XOR (vmode, operands[1], operands[2]);
9576 operands[3] = tmp;
9577 })
9578
9579 (define_split
9580 [(set (match_operand:SF 0 "general_reg_operand")
9581 (match_operator:SF 1 "absneg_operator" [(match_dup 0)]))
9582 (use (match_operand:V4SF 2))
9583 (clobber (reg:CC FLAGS_REG))]
9584 "reload_completed"
9585 [(parallel [(set (match_dup 0) (match_dup 1))
9586 (clobber (reg:CC FLAGS_REG))])]
9587 {
9588 rtx tmp;
9589 operands[0] = gen_lowpart (SImode, operands[0]);
9590 if (GET_CODE (operands[1]) == ABS)
9591 { 10184 {
9592 tmp = gen_int_mode (0x7fffffff, SImode); 10185 if (MEM_P (operands[1]))
9593 tmp = gen_rtx_AND (SImode, operands[0], tmp); 10186 std::swap (operands[1], operands[2]);
9594 } 10187 }
9595 else 10188 else
10189 {
10190 if (operands_match_p (operands[0], operands[2]))
10191 std::swap (operands[1], operands[2]);
10192 }
10193
10194 operands[3]
10195 = gen_rtx_fmt_ee (absneg_op, vmode, operands[1], operands[2]);
10196 })
10197
10198 (define_split
10199 [(set (match_operand:MODEF 0 "fp_register_operand")
10200 (absneg:MODEF (match_operand:MODEF 1 "fp_register_operand")))
10201 (use (match_operand 2))
10202 (clobber (reg:CC FLAGS_REG))]
10203 "TARGET_80387 && reload_completed"
10204 [(set (match_dup 0) (absneg:MODEF (match_dup 1)))])
10205
10206 (define_split
10207 [(set (match_operand:MODEF 0 "general_reg_operand")
10208 (absneg:MODEF (match_operand:MODEF 1 "general_reg_operand")))
10209 (use (match_operand 2))
10210 (clobber (reg:CC FLAGS_REG))]
10211 "TARGET_80387 && reload_completed"
10212 [(const_int 0)]
10213 "ix86_split_fp_absneg_operator (<CODE>, <MODE>mode, operands); DONE;")
10214
10215 (define_insn "*nabs<mode>2_1"
10216 [(set (match_operand:MODEF 0 "register_operand" "=x,x,Yv")
10217 (neg:MODEF
10218 (abs:MODEF
10219 (match_operand:MODEF 1 "register_operand" "0,x,Yv"))))
10220 (use (match_operand:<ssevecmode> 2 "vector_operand" "xBm,0,Yvm"))]
10221 "SSE_FLOAT_MODE_P (<MODE>mode) && TARGET_SSE_MATH"
10222 "#"
10223 [(set_attr "isa" "noavx,noavx,avx")])
10224
10225 (define_split
10226 [(set (match_operand:SSEMODEF 0 "sse_reg_operand")
10227 (neg:SSEMODEF
10228 (abs:SSEMODEF
10229 (match_operand:SSEMODEF 1 "vector_operand"))))
10230 (use (match_operand:<ssevecmodef> 2 "vector_operand"))]
10231 "((SSE_FLOAT_MODE_P (<MODE>mode) && TARGET_SSE_MATH)
10232 || (TARGET_SSE && (<MODE>mode == TFmode)))
10233 && reload_completed"
10234 [(set (match_dup 0) (match_dup 3))]
10235 {
10236 machine_mode mode = <MODE>mode;
10237 machine_mode vmode = <ssevecmodef>mode;
10238
10239 operands[0] = lowpart_subreg (vmode, operands[0], mode);
10240 operands[1] = lowpart_subreg (vmode, operands[1], mode);
10241
10242 if (TARGET_AVX)
9596 { 10243 {
9597 tmp = gen_int_mode (0x80000000, SImode); 10244 if (MEM_P (operands[1]))
9598 tmp = gen_rtx_XOR (SImode, operands[0], tmp); 10245 std::swap (operands[1], operands[2]);
9599 }
9600 operands[1] = tmp;
9601 })
9602
9603 (define_split
9604 [(set (match_operand:DF 0 "general_reg_operand")
9605 (match_operator:DF 1 "absneg_operator" [(match_dup 0)]))
9606 (use (match_operand 2))
9607 (clobber (reg:CC FLAGS_REG))]
9608 "reload_completed"
9609 [(parallel [(set (match_dup 0) (match_dup 1))
9610 (clobber (reg:CC FLAGS_REG))])]
9611 {
9612 rtx tmp;
9613 if (TARGET_64BIT)
9614 {
9615 tmp = gen_lowpart (DImode, operands[0]);
9616 tmp = gen_rtx_ZERO_EXTRACT (DImode, tmp, const1_rtx, GEN_INT (63));
9617 operands[0] = tmp;
9618
9619 if (GET_CODE (operands[1]) == ABS)
9620 tmp = const0_rtx;
9621 else
9622 tmp = gen_rtx_NOT (DImode, tmp);
9623 } 10246 }
9624 else 10247 else
9625 { 10248 {
9626 operands[0] = gen_highpart (SImode, operands[0]); 10249 if (operands_match_p (operands[0], operands[2]))
9627 if (GET_CODE (operands[1]) == ABS) 10250 std::swap (operands[1], operands[2]);
9628 { 10251 }
9629 tmp = gen_int_mode (0x7fffffff, SImode); 10252
9630 tmp = gen_rtx_AND (SImode, operands[0], tmp); 10253 operands[3]
9631 } 10254 = gen_rtx_fmt_ee (IOR, vmode, operands[1], operands[2]);
9632 else
9633 {
9634 tmp = gen_int_mode (0x80000000, SImode);
9635 tmp = gen_rtx_XOR (SImode, operands[0], tmp);
9636 }
9637 }
9638 operands[1] = tmp;
9639 })
9640
9641 (define_split
9642 [(set (match_operand:XF 0 "general_reg_operand")
9643 (match_operator:XF 1 "absneg_operator" [(match_dup 0)]))
9644 (use (match_operand 2))
9645 (clobber (reg:CC FLAGS_REG))]
9646 "reload_completed"
9647 [(parallel [(set (match_dup 0) (match_dup 1))
9648 (clobber (reg:CC FLAGS_REG))])]
9649 {
9650 rtx tmp;
9651 operands[0] = gen_rtx_REG (SImode,
9652 REGNO (operands[0]) + (TARGET_64BIT ? 1 : 2));
9653 if (GET_CODE (operands[1]) == ABS)
9654 {
9655 tmp = GEN_INT (0x7fff);
9656 tmp = gen_rtx_AND (SImode, operands[0], tmp);
9657 }
9658 else
9659 {
9660 tmp = GEN_INT (0x8000);
9661 tmp = gen_rtx_XOR (SImode, operands[0], tmp);
9662 }
9663 operands[1] = tmp;
9664 }) 10255 })
9665 10256
9666 ;; Conditionalize these after reload. If they match before reload, we 10257 ;; Conditionalize these after reload. If they match before reload, we
9667 ;; lose the clobber and ability to use integer instructions. 10258 ;; lose the clobber and ability to use integer instructions.
9668 10259
9669 (define_insn "*<code><mode>2_1" 10260 (define_insn "*<code><mode>2_i387"
9670 [(set (match_operand:X87MODEF 0 "register_operand" "=f") 10261 [(set (match_operand:X87MODEF 0 "register_operand" "=f")
9671 (absneg:X87MODEF (match_operand:X87MODEF 1 "register_operand" "0")))] 10262 (absneg:X87MODEF (match_operand:X87MODEF 1 "register_operand" "0")))]
9672 "TARGET_80387 10263 "TARGET_80387 && reload_completed"
9673 && (reload_completed
9674 || !(SSE_FLOAT_MODE_P (<MODE>mode) && TARGET_SSE_MATH))"
9675 "<absneg_mnemonic>" 10264 "<absneg_mnemonic>"
9676 [(set_attr "type" "fsgn") 10265 [(set_attr "type" "fsgn")
9677 (set_attr "mode" "<MODE>")]) 10266 (set_attr "mode" "<MODE>")])
9678 10267
9679 ;; Copysign instructions 10268 ;; Copysign instructions
9680 10269
9681 (define_mode_iterator CSGNMODE [SF DF TF])
9682 (define_mode_attr CSGNVMODE [(SF "V4SF") (DF "V2DF") (TF "TF")])
9683
9684 (define_expand "copysign<mode>3" 10270 (define_expand "copysign<mode>3"
9685 [(match_operand:CSGNMODE 0 "register_operand") 10271 [(match_operand:SSEMODEF 0 "register_operand")
9686 (match_operand:CSGNMODE 1 "nonmemory_operand") 10272 (match_operand:SSEMODEF 1 "nonmemory_operand")
9687 (match_operand:CSGNMODE 2 "register_operand")] 10273 (match_operand:SSEMODEF 2 "register_operand")]
9688 "(SSE_FLOAT_MODE_P (<MODE>mode) && TARGET_SSE_MATH) 10274 "(SSE_FLOAT_MODE_P (<MODE>mode) && TARGET_SSE_MATH)
9689 || (TARGET_SSE && (<MODE>mode == TFmode))" 10275 || (TARGET_SSE && (<MODE>mode == TFmode))"
9690 "ix86_expand_copysign (operands); DONE;") 10276 "ix86_expand_copysign (operands); DONE;")
9691 10277
9692 (define_insn_and_split "copysign<mode>3_const" 10278 (define_insn_and_split "@copysign<mode>3_const"
9693 [(set (match_operand:CSGNMODE 0 "register_operand" "=Yv") 10279 [(set (match_operand:SSEMODEF 0 "register_operand" "=Yv")
9694 (unspec:CSGNMODE 10280 (unspec:SSEMODEF
9695 [(match_operand:<CSGNVMODE> 1 "nonimm_or_0_operand" "YvmC") 10281 [(match_operand:<ssevecmodef> 1 "nonimm_or_0_operand" "YvmC")
9696 (match_operand:CSGNMODE 2 "register_operand" "0") 10282 (match_operand:SSEMODEF 2 "register_operand" "0")
9697 (match_operand:<CSGNVMODE> 3 "nonimmediate_operand" "Yvm")] 10283 (match_operand:<ssevecmodef> 3 "nonimmediate_operand" "Yvm")]
9698 UNSPEC_COPYSIGN))] 10284 UNSPEC_COPYSIGN))]
9699 "(SSE_FLOAT_MODE_P (<MODE>mode) && TARGET_SSE_MATH) 10285 "(SSE_FLOAT_MODE_P (<MODE>mode) && TARGET_SSE_MATH)
9700 || (TARGET_SSE && (<MODE>mode == TFmode))" 10286 || (TARGET_SSE && (<MODE>mode == TFmode))"
9701 "#" 10287 "#"
9702 "&& reload_completed" 10288 "&& reload_completed"
9703 [(const_int 0)] 10289 [(const_int 0)]
9704 "ix86_split_copysign_const (operands); DONE;") 10290 "ix86_split_copysign_const (operands); DONE;")
9705 10291
9706 (define_insn "copysign<mode>3_var" 10292 (define_insn "@copysign<mode>3_var"
9707 [(set (match_operand:CSGNMODE 0 "register_operand" "=Yv,Yv,Yv,Yv,Yv") 10293 [(set (match_operand:SSEMODEF 0 "register_operand" "=Yv,Yv,Yv,Yv,Yv")
9708 (unspec:CSGNMODE 10294 (unspec:SSEMODEF
9709 [(match_operand:CSGNMODE 2 "register_operand" "Yv,0,0,Yv,Yv") 10295 [(match_operand:SSEMODEF 2 "register_operand" "Yv,0,0,Yv,Yv")
9710 (match_operand:CSGNMODE 3 "register_operand" "1,1,Yv,1,Yv") 10296 (match_operand:SSEMODEF 3 "register_operand" "1,1,Yv,1,Yv")
9711 (match_operand:<CSGNVMODE> 4 10297 (match_operand:<ssevecmodef> 4
9712 "nonimmediate_operand" "X,Yvm,Yvm,0,0") 10298 "nonimmediate_operand" "X,Yvm,Yvm,0,0")
9713 (match_operand:<CSGNVMODE> 5 10299 (match_operand:<ssevecmodef> 5
9714 "nonimmediate_operand" "0,Yvm,1,Yvm,1")] 10300 "nonimmediate_operand" "0,Yvm,1,Yvm,1")]
9715 UNSPEC_COPYSIGN)) 10301 UNSPEC_COPYSIGN))
9716 (clobber (match_scratch:<CSGNVMODE> 1 "=Yv,Yv,Yv,Yv,Yv"))] 10302 (clobber (match_scratch:<ssevecmodef> 1 "=Yv,Yv,Yv,Yv,Yv"))]
9717 "(SSE_FLOAT_MODE_P (<MODE>mode) && TARGET_SSE_MATH) 10303 "(SSE_FLOAT_MODE_P (<MODE>mode) && TARGET_SSE_MATH)
9718 || (TARGET_SSE && (<MODE>mode == TFmode))" 10304 || (TARGET_SSE && (<MODE>mode == TFmode))"
9719 "#") 10305 "#")
9720 10306
9721 (define_split 10307 (define_split
9722 [(set (match_operand:CSGNMODE 0 "register_operand") 10308 [(set (match_operand:SSEMODEF 0 "register_operand")
9723 (unspec:CSGNMODE 10309 (unspec:SSEMODEF
9724 [(match_operand:CSGNMODE 2 "register_operand") 10310 [(match_operand:SSEMODEF 2 "register_operand")
9725 (match_operand:CSGNMODE 3 "register_operand") 10311 (match_operand:SSEMODEF 3 "register_operand")
9726 (match_operand:<CSGNVMODE> 4) 10312 (match_operand:<ssevecmodef> 4)
9727 (match_operand:<CSGNVMODE> 5)] 10313 (match_operand:<ssevecmodef> 5)]
9728 UNSPEC_COPYSIGN)) 10314 UNSPEC_COPYSIGN))
9729 (clobber (match_scratch:<CSGNVMODE> 1))] 10315 (clobber (match_scratch:<ssevecmodef> 1))]
9730 "((SSE_FLOAT_MODE_P (<MODE>mode) && TARGET_SSE_MATH) 10316 "((SSE_FLOAT_MODE_P (<MODE>mode) && TARGET_SSE_MATH)
9731 || (TARGET_SSE && (<MODE>mode == TFmode))) 10317 || (TARGET_SSE && (<MODE>mode == TFmode)))
9732 && reload_completed" 10318 && reload_completed"
9733 [(const_int 0)] 10319 [(const_int 0)]
9734 "ix86_split_copysign_var (operands); DONE;") 10320 "ix86_split_copysign_var (operands); DONE;")
10321
10322 (define_expand "xorsign<mode>3"
10323 [(match_operand:MODEF 0 "register_operand")
10324 (match_operand:MODEF 1 "register_operand")
10325 (match_operand:MODEF 2 "register_operand")]
10326 "SSE_FLOAT_MODE_P (<MODE>mode) && TARGET_SSE_MATH"
10327 "ix86_expand_xorsign (operands); DONE;")
10328
10329 (define_insn_and_split "@xorsign<mode>3_1"
10330 [(set (match_operand:MODEF 0 "register_operand" "=Yv")
10331 (unspec:MODEF
10332 [(match_operand:MODEF 1 "register_operand" "Yv")
10333 (match_operand:MODEF 2 "register_operand" "0")
10334 (match_operand:<ssevecmode> 3 "nonimmediate_operand" "Yvm")]
10335 UNSPEC_XORSIGN))]
10336 "SSE_FLOAT_MODE_P (<MODE>mode) && TARGET_SSE_MATH"
10337 "#"
10338 "&& reload_completed"
10339 [(const_int 0)]
10340 "ix86_split_xorsign (operands); DONE;")
9735 10341
9736 ;; One complement instructions 10342 ;; One complement instructions
9737 10343
9738 (define_expand "one_cmpl<mode>2" 10344 (define_expand "one_cmpl<mode>2"
9739 [(set (match_operand:SWIM1248x 0 "nonimmediate_operand") 10345 [(set (match_operand:SWIM1248s 0 "nonimmediate_operand")
9740 (not:SWIM1248x (match_operand:SWIM1248x 1 "nonimmediate_operand")))] 10346 (not:SWIM1248s (match_operand:SWIM1248s 1 "nonimmediate_operand")))]
9741 "" 10347 ""
9742 "ix86_expand_unary_operator (NOT, <MODE>mode, operands); DONE;") 10348 "ix86_expand_unary_operator (NOT, <MODE>mode, operands); DONE;")
9743 10349
9744 (define_insn_and_split "*one_cmpldi2_doubleword" 10350 (define_insn_and_split "*one_cmpldi2_doubleword"
9745 [(set (match_operand:DI 0 "nonimmediate_operand" "=rm") 10351 [(set (match_operand:DI 0 "nonimmediate_operand")
9746 (not:DI (match_operand:DI 1 "nonimmediate_operand" "0")))] 10352 (not:DI (match_operand:DI 1 "nonimmediate_operand")))]
9747 "!TARGET_64BIT && TARGET_STV && TARGET_SSE2 10353 "!TARGET_64BIT && TARGET_STV && TARGET_SSE2
9748 && ix86_unary_operator_ok (NOT, DImode, operands)" 10354 && ix86_unary_operator_ok (NOT, DImode, operands)
10355 && ix86_pre_reload_split ()"
9749 "#" 10356 "#"
9750 "&& reload_completed" 10357 "&& 1"
9751 [(set (match_dup 0) 10358 [(set (match_dup 0)
9752 (not:SI (match_dup 1))) 10359 (not:SI (match_dup 1)))
9753 (set (match_dup 2) 10360 (set (match_dup 2)
9754 (not:SI (match_dup 3)))] 10361 (not:SI (match_dup 3)))]
9755 "split_double_mode (DImode, &operands[0], 2, &operands[0], &operands[2]);") 10362 "split_double_mode (DImode, &operands[0], 2, &operands[0], &operands[2]);")
9760 "ix86_unary_operator_ok (NOT, <MODE>mode, operands)" 10367 "ix86_unary_operator_ok (NOT, <MODE>mode, operands)"
9761 "not{<imodesuffix>}\t%0" 10368 "not{<imodesuffix>}\t%0"
9762 [(set_attr "type" "negnot") 10369 [(set_attr "type" "negnot")
9763 (set_attr "mode" "<MODE>")]) 10370 (set_attr "mode" "<MODE>")])
9764 10371
9765 ;; ??? Currently never generated - xor is used instead.
9766 (define_insn "*one_cmplsi2_1_zext" 10372 (define_insn "*one_cmplsi2_1_zext"
9767 [(set (match_operand:DI 0 "register_operand" "=r") 10373 [(set (match_operand:DI 0 "register_operand" "=r")
9768 (zero_extend:DI 10374 (zero_extend:DI
9769 (not:SI (match_operand:SI 1 "register_operand" "0"))))] 10375 (not:SI (match_operand:SI 1 "register_operand" "0"))))]
9770 "TARGET_64BIT && ix86_unary_operator_ok (NOT, SImode, operands)" 10376 "TARGET_64BIT && ix86_unary_operator_ok (NOT, SImode, operands)"
9811 (match_op_dup 2 [(xor:SWI (match_dup 3) (const_int -1)) 10417 (match_op_dup 2 [(xor:SWI (match_dup 3) (const_int -1))
9812 (const_int 0)])) 10418 (const_int 0)]))
9813 (set (match_dup 1) 10419 (set (match_dup 1)
9814 (xor:SWI (match_dup 3) (const_int -1)))])]) 10420 (xor:SWI (match_dup 3) (const_int -1)))])])
9815 10421
9816 ;; ??? Currently never generated - xor is used instead.
9817 (define_insn "*one_cmplsi2_2_zext" 10422 (define_insn "*one_cmplsi2_2_zext"
9818 [(set (reg FLAGS_REG) 10423 [(set (reg FLAGS_REG)
9819 (compare (not:SI (match_operand:SI 1 "register_operand" "0")) 10424 (compare (not:SI (match_operand:SI 1 "register_operand" "0"))
9820 (const_int 0))) 10425 (const_int 0)))
9821 (set (match_operand:DI 0 "register_operand" "=r") 10426 (set (match_operand:DI 0 "register_operand" "=r")
9879 (and:SI 10484 (and:SI
9880 (match_operand:SI 2 "register_operand" "c") 10485 (match_operand:SI 2 "register_operand" "c")
9881 (match_operand:SI 3 "const_int_operand")) 0))) 10486 (match_operand:SI 3 "const_int_operand")) 0)))
9882 (clobber (reg:CC FLAGS_REG))] 10487 (clobber (reg:CC FLAGS_REG))]
9883 "(INTVAL (operands[3]) & (<MODE_SIZE> * BITS_PER_UNIT)) == 0 10488 "(INTVAL (operands[3]) & (<MODE_SIZE> * BITS_PER_UNIT)) == 0
9884 && can_create_pseudo_p ()" 10489 && ix86_pre_reload_split ()"
9885 "#" 10490 "#"
9886 "&& 1" 10491 "&& 1"
9887 [(parallel 10492 [(parallel
9888 [(set (match_dup 6) 10493 [(set (match_dup 6)
9889 (ior:DWIH (ashift:DWIH (match_dup 6) (match_dup 2)) 10494 (ior:DWIH (ashift:DWIH (match_dup 6) (match_dup 2))
9920 (and:QI 10525 (and:QI
9921 (match_operand:QI 2 "register_operand" "c") 10526 (match_operand:QI 2 "register_operand" "c")
9922 (match_operand:QI 3 "const_int_operand")))) 10527 (match_operand:QI 3 "const_int_operand"))))
9923 (clobber (reg:CC FLAGS_REG))] 10528 (clobber (reg:CC FLAGS_REG))]
9924 "(INTVAL (operands[3]) & (<MODE_SIZE> * BITS_PER_UNIT)) == 0 10529 "(INTVAL (operands[3]) & (<MODE_SIZE> * BITS_PER_UNIT)) == 0
9925 && can_create_pseudo_p ()" 10530 && ix86_pre_reload_split ()"
9926 "#" 10531 "#"
9927 "&& 1" 10532 "&& 1"
9928 [(parallel 10533 [(parallel
9929 [(set (match_dup 6) 10534 [(set (match_dup 6)
9930 (ior:DWIH (ashift:DWIH (match_dup 6) (match_dup 2)) 10535 (ior:DWIH (ashift:DWIH (match_dup 6) (match_dup 2))
9964 (define_split 10569 (define_split
9965 [(set (match_operand:DWI 0 "register_operand") 10570 [(set (match_operand:DWI 0 "register_operand")
9966 (ashift:DWI (match_operand:DWI 1 "nonmemory_operand") 10571 (ashift:DWI (match_operand:DWI 1 "nonmemory_operand")
9967 (match_operand:QI 2 "nonmemory_operand"))) 10572 (match_operand:QI 2 "nonmemory_operand")))
9968 (clobber (reg:CC FLAGS_REG))] 10573 (clobber (reg:CC FLAGS_REG))]
9969 "(optimize && flag_peephole2) ? epilogue_completed : reload_completed" 10574 "epilogue_completed"
9970 [(const_int 0)] 10575 [(const_int 0)]
9971 "ix86_split_ashl (operands, NULL_RTX, <MODE>mode); DONE;") 10576 "ix86_split_ashl (operands, NULL_RTX, <MODE>mode); DONE;")
9972 10577
9973 ;; By default we don't ask for a scratch register, because when DWImode 10578 ;; By default we don't ask for a scratch register, because when DWImode
9974 ;; values are manipulated, registers are already at a premium. But if 10579 ;; values are manipulated, registers are already at a premium. But if
10017 (set_attr "pent_pair" "np") 10622 (set_attr "pent_pair" "np")
10018 (set_attr "athlon_decode" "vector") 10623 (set_attr "athlon_decode" "vector")
10019 (set_attr "amdfam10_decode" "vector") 10624 (set_attr "amdfam10_decode" "vector")
10020 (set_attr "bdver1_decode" "vector")]) 10625 (set_attr "bdver1_decode" "vector")])
10021 10626
10022 (define_expand "x86_shift<mode>_adj_1" 10627 (define_expand "@x86_shift<mode>_adj_1"
10023 [(set (reg:CCZ FLAGS_REG) 10628 [(set (reg:CCZ FLAGS_REG)
10024 (compare:CCZ (and:QI (match_operand:QI 2 "register_operand") 10629 (compare:CCZ (and:QI (match_operand:QI 2 "register_operand")
10025 (match_dup 4)) 10630 (match_dup 4))
10026 (const_int 0))) 10631 (const_int 0)))
10027 (set (match_operand:SWI48 0 "register_operand") 10632 (set (match_operand:SWI48 0 "register_operand")
10033 (match_operand:SWI48 3 "register_operand") 10638 (match_operand:SWI48 3 "register_operand")
10034 (match_dup 1)))] 10639 (match_dup 1)))]
10035 "TARGET_CMOVE" 10640 "TARGET_CMOVE"
10036 "operands[4] = GEN_INT (GET_MODE_BITSIZE (<MODE>mode));") 10641 "operands[4] = GEN_INT (GET_MODE_BITSIZE (<MODE>mode));")
10037 10642
10038 (define_expand "x86_shift<mode>_adj_2" 10643 (define_expand "@x86_shift<mode>_adj_2"
10039 [(use (match_operand:SWI48 0 "register_operand")) 10644 [(use (match_operand:SWI48 0 "register_operand"))
10040 (use (match_operand:SWI48 1 "register_operand")) 10645 (use (match_operand:SWI48 1 "register_operand"))
10041 (use (match_operand:QI 2 "register_operand"))] 10646 (use (match_operand:QI 2 "register_operand"))]
10042 "" 10647 ""
10043 { 10648 {
10075 (match_operand:SI 3 "const_int_operand")) 0))) 10680 (match_operand:SI 3 "const_int_operand")) 0)))
10076 (clobber (reg:CC FLAGS_REG))] 10681 (clobber (reg:CC FLAGS_REG))]
10077 "ix86_binary_operator_ok (ASHIFT, <MODE>mode, operands) 10682 "ix86_binary_operator_ok (ASHIFT, <MODE>mode, operands)
10078 && (INTVAL (operands[3]) & (GET_MODE_BITSIZE (<MODE>mode)-1)) 10683 && (INTVAL (operands[3]) & (GET_MODE_BITSIZE (<MODE>mode)-1))
10079 == GET_MODE_BITSIZE (<MODE>mode)-1 10684 == GET_MODE_BITSIZE (<MODE>mode)-1
10080 && can_create_pseudo_p ()" 10685 && ix86_pre_reload_split ()"
10081 "#" 10686 "#"
10082 "&& 1" 10687 "&& 1"
10083 [(parallel 10688 [(parallel
10084 [(set (match_dup 0) 10689 [(set (match_dup 0)
10085 (ashift:SWI48 (match_dup 1) 10690 (ashift:SWI48 (match_dup 1)
10097 (match_operand:QI 3 "const_int_operand")))) 10702 (match_operand:QI 3 "const_int_operand"))))
10098 (clobber (reg:CC FLAGS_REG))] 10703 (clobber (reg:CC FLAGS_REG))]
10099 "ix86_binary_operator_ok (ASHIFT, <MODE>mode, operands) 10704 "ix86_binary_operator_ok (ASHIFT, <MODE>mode, operands)
10100 && (INTVAL (operands[3]) & (GET_MODE_BITSIZE (<MODE>mode)-1)) 10705 && (INTVAL (operands[3]) & (GET_MODE_BITSIZE (<MODE>mode)-1))
10101 == GET_MODE_BITSIZE (<MODE>mode)-1 10706 == GET_MODE_BITSIZE (<MODE>mode)-1
10102 && can_create_pseudo_p ()" 10707 && ix86_pre_reload_split ()"
10103 "#" 10708 "#"
10104 "&& 1" 10709 "&& 1"
10105 [(parallel 10710 [(parallel
10106 [(set (match_dup 0) 10711 [(set (match_dup 0)
10107 (ashift:SWI48 (match_dup 1) 10712 (ashift:SWI48 (match_dup 1)
10353 (set (attr "preferred_for_speed") 10958 (set (attr "preferred_for_speed")
10354 (cond [(eq_attr "alternative" "1") 10959 (cond [(eq_attr "alternative" "1")
10355 (symbol_ref "!TARGET_PARTIAL_REG_STALL")] 10960 (symbol_ref "!TARGET_PARTIAL_REG_STALL")]
10356 (symbol_ref "true")))]) 10961 (symbol_ref "true")))])
10357 10962
10358 (define_insn "*ashlqi3_1_slp" 10963 (define_insn "*ashl<mode>3_1_slp"
10359 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+qm")) 10964 [(set (strict_low_part (match_operand:SWI12 0 "register_operand" "+<r>"))
10360 (ashift:QI (match_dup 0) 10965 (ashift:SWI12 (match_operand:SWI12 1 "register_operand" "0")
10361 (match_operand:QI 1 "nonmemory_operand" "cI"))) 10966 (match_operand:QI 2 "nonmemory_operand" "cI")))
10362 (clobber (reg:CC FLAGS_REG))] 10967 (clobber (reg:CC FLAGS_REG))]
10363 "(optimize_function_for_size_p (cfun) 10968 "(!TARGET_PARTIAL_REG_STALL || optimize_function_for_size_p (cfun))
10364 || !TARGET_PARTIAL_FLAG_REG_STALL 10969 /* FIXME: without this LRA can't reload this pattern, see PR82524. */
10365 || (operands[1] == const1_rtx 10970 && rtx_equal_p (operands[0], operands[1])"
10366 && (TARGET_SHIFT1
10367 || (TARGET_DOUBLE_WITH_ADD && REG_P (operands[0])))))"
10368 { 10971 {
10369 switch (get_attr_type (insn)) 10972 switch (get_attr_type (insn))
10370 { 10973 {
10371 case TYPE_ALU1: 10974 case TYPE_ALU:
10372 gcc_assert (operands[1] == const1_rtx); 10975 gcc_assert (operands[2] == const1_rtx);
10373 return "add{b}\t%0, %0"; 10976 return "add{<imodesuffix>}\t%0, %0";
10374 10977
10375 default: 10978 default:
10376 if (operands[1] == const1_rtx 10979 if (operands[2] == const1_rtx
10377 && (TARGET_SHIFT1 || optimize_function_for_size_p (cfun))) 10980 && (TARGET_SHIFT1 || optimize_function_for_size_p (cfun)))
10378 return "sal{b}\t%0"; 10981 return "sal{<imodesuffix>}\t%0";
10379 else 10982 else
10380 return "sal{b}\t{%1, %0|%0, %1}"; 10983 return "sal{<imodesuffix>}\t{%2, %0|%0, %2}";
10381 } 10984 }
10382 } 10985 }
10383 [(set (attr "type") 10986 [(set (attr "type")
10384 (cond [(and (and (match_test "TARGET_DOUBLE_WITH_ADD") 10987 (cond [(and (match_test "TARGET_DOUBLE_WITH_ADD")
10385 (match_operand 0 "register_operand")) 10988 (match_operand 2 "const1_operand"))
10386 (match_operand 1 "const1_operand")) 10989 (const_string "alu")
10387 (const_string "alu1")
10388 ] 10990 ]
10389 (const_string "ishift1"))) 10991 (const_string "ishift")))
10390 (set (attr "length_immediate") 10992 (set (attr "length_immediate")
10391 (if_then_else 10993 (if_then_else
10392 (ior (eq_attr "type" "alu1") 10994 (ior (eq_attr "type" "alu")
10393 (and (eq_attr "type" "ishift1") 10995 (and (eq_attr "type" "ishift")
10394 (and (match_operand 1 "const1_operand") 10996 (and (match_operand 2 "const1_operand")
10395 (ior (match_test "TARGET_SHIFT1") 10997 (ior (match_test "TARGET_SHIFT1")
10396 (match_test "optimize_function_for_size_p (cfun)"))))) 10998 (match_test "optimize_function_for_size_p (cfun)")))))
10397 (const_string "0") 10999 (const_string "0")
10398 (const_string "*"))) 11000 (const_string "*")))
10399 (set_attr "mode" "QI")]) 11001 (set_attr "mode" "<MODE>")])
10400 11002
10401 ;; Convert ashift to the lea pattern to avoid flags dependency. 11003 ;; Convert ashift to the lea pattern to avoid flags dependency.
10402 (define_split 11004 (define_split
10403 [(set (match_operand:SWI 0 "register_operand") 11005 [(set (match_operand:SWI 0 "register_operand")
10404 (ashift:SWI (match_operand:SWI 1 "index_register_operand") 11006 (ashift:SWI (match_operand:SWI 1 "index_register_operand")
10598 (match_operand:SI 3 "const_int_operand")) 0))) 11200 (match_operand:SI 3 "const_int_operand")) 0)))
10599 (clobber (reg:CC FLAGS_REG))] 11201 (clobber (reg:CC FLAGS_REG))]
10600 "ix86_binary_operator_ok (<CODE>, <MODE>mode, operands) 11202 "ix86_binary_operator_ok (<CODE>, <MODE>mode, operands)
10601 && (INTVAL (operands[3]) & (GET_MODE_BITSIZE (<MODE>mode)-1)) 11203 && (INTVAL (operands[3]) & (GET_MODE_BITSIZE (<MODE>mode)-1))
10602 == GET_MODE_BITSIZE (<MODE>mode)-1 11204 == GET_MODE_BITSIZE (<MODE>mode)-1
10603 && can_create_pseudo_p ()" 11205 && ix86_pre_reload_split ()"
10604 "#" 11206 "#"
10605 "&& 1" 11207 "&& 1"
10606 [(parallel 11208 [(parallel
10607 [(set (match_dup 0) 11209 [(set (match_dup 0)
10608 (any_shiftrt:SWI48 (match_dup 1) 11210 (any_shiftrt:SWI48 (match_dup 1)
10620 (match_operand:QI 3 "const_int_operand")))) 11222 (match_operand:QI 3 "const_int_operand"))))
10621 (clobber (reg:CC FLAGS_REG))] 11223 (clobber (reg:CC FLAGS_REG))]
10622 "ix86_binary_operator_ok (<CODE>, <MODE>mode, operands) 11224 "ix86_binary_operator_ok (<CODE>, <MODE>mode, operands)
10623 && (INTVAL (operands[3]) & (GET_MODE_BITSIZE (<MODE>mode)-1)) 11225 && (INTVAL (operands[3]) & (GET_MODE_BITSIZE (<MODE>mode)-1))
10624 == GET_MODE_BITSIZE (<MODE>mode)-1 11226 == GET_MODE_BITSIZE (<MODE>mode)-1
10625 && can_create_pseudo_p ()" 11227 && ix86_pre_reload_split ()"
10626 "#" 11228 "#"
10627 "&& 1" 11229 "&& 1"
10628 [(parallel 11230 [(parallel
10629 [(set (match_dup 0) 11231 [(set (match_dup 0)
10630 (any_shiftrt:SWI48 (match_dup 1) 11232 (any_shiftrt:SWI48 (match_dup 1)
10641 (and:SI 11243 (and:SI
10642 (match_operand:SI 2 "register_operand" "c") 11244 (match_operand:SI 2 "register_operand" "c")
10643 (match_operand:SI 3 "const_int_operand")) 0))) 11245 (match_operand:SI 3 "const_int_operand")) 0)))
10644 (clobber (reg:CC FLAGS_REG))] 11246 (clobber (reg:CC FLAGS_REG))]
10645 "(INTVAL (operands[3]) & (<MODE_SIZE> * BITS_PER_UNIT)) == 0 11247 "(INTVAL (operands[3]) & (<MODE_SIZE> * BITS_PER_UNIT)) == 0
10646 && can_create_pseudo_p ()" 11248 && ix86_pre_reload_split ()"
10647 "#" 11249 "#"
10648 "&& 1" 11250 "&& 1"
10649 [(parallel 11251 [(parallel
10650 [(set (match_dup 4) 11252 [(set (match_dup 4)
10651 (ior:DWIH (lshiftrt:DWIH (match_dup 4) (match_dup 2)) 11253 (ior:DWIH (lshiftrt:DWIH (match_dup 4) (match_dup 2))
10682 (and:QI 11284 (and:QI
10683 (match_operand:QI 2 "register_operand" "c") 11285 (match_operand:QI 2 "register_operand" "c")
10684 (match_operand:QI 3 "const_int_operand")))) 11286 (match_operand:QI 3 "const_int_operand"))))
10685 (clobber (reg:CC FLAGS_REG))] 11287 (clobber (reg:CC FLAGS_REG))]
10686 "(INTVAL (operands[3]) & (<MODE_SIZE> * BITS_PER_UNIT)) == 0 11288 "(INTVAL (operands[3]) & (<MODE_SIZE> * BITS_PER_UNIT)) == 0
10687 && can_create_pseudo_p ()" 11289 && ix86_pre_reload_split ()"
10688 "#" 11290 "#"
10689 "&& 1" 11291 "&& 1"
10690 [(parallel 11292 [(parallel
10691 [(set (match_dup 4) 11293 [(set (match_dup 4)
10692 (ior:DWIH (lshiftrt:DWIH (match_dup 4) (match_dup 2)) 11294 (ior:DWIH (lshiftrt:DWIH (match_dup 4) (match_dup 2))
10719 (any_shiftrt:DWI (match_operand:DWI 1 "register_operand" "0") 11321 (any_shiftrt:DWI (match_operand:DWI 1 "register_operand" "0")
10720 (match_operand:QI 2 "nonmemory_operand" "<S>c"))) 11322 (match_operand:QI 2 "nonmemory_operand" "<S>c")))
10721 (clobber (reg:CC FLAGS_REG))] 11323 (clobber (reg:CC FLAGS_REG))]
10722 "" 11324 ""
10723 "#" 11325 "#"
10724 "(optimize && flag_peephole2) ? epilogue_completed : reload_completed" 11326 "epilogue_completed"
10725 [(const_int 0)] 11327 [(const_int 0)]
10726 "ix86_split_<shift_insn> (operands, NULL_RTX, <MODE>mode); DONE;" 11328 "ix86_split_<shift_insn> (operands, NULL_RTX, <MODE>mode); DONE;"
10727 [(set_attr "type" "multi")]) 11329 [(set_attr "type" "multi")])
10728 11330
10729 ;; By default we don't ask for a scratch register, because when DWImode 11331 ;; By default we don't ask for a scratch register, because when DWImode
10773 (set_attr "pent_pair" "np") 11375 (set_attr "pent_pair" "np")
10774 (set_attr "athlon_decode" "vector") 11376 (set_attr "athlon_decode" "vector")
10775 (set_attr "amdfam10_decode" "vector") 11377 (set_attr "amdfam10_decode" "vector")
10776 (set_attr "bdver1_decode" "vector")]) 11378 (set_attr "bdver1_decode" "vector")])
10777 11379
10778 (define_insn "ashrdi3_cvt" 11380 ;; Base name for insn mnemonic.
10779 [(set (match_operand:DI 0 "nonimmediate_operand" "=*d,rm") 11381 (define_mode_attr cvt_mnemonic
10780 (ashiftrt:DI (match_operand:DI 1 "nonimmediate_operand" "*a,0") 11382 [(SI "{cltd|cdq}") (DI "{cqto|cqo}")])
10781 (match_operand:QI 2 "const_int_operand"))) 11383
10782 (clobber (reg:CC FLAGS_REG))] 11384 (define_insn "ashr<mode>3_cvt"
10783 "TARGET_64BIT && INTVAL (operands[2]) == 63 11385 [(set (match_operand:SWI48 0 "nonimmediate_operand" "=*d,rm")
11386 (ashiftrt:SWI48
11387 (match_operand:SWI48 1 "nonimmediate_operand" "*a,0")
11388 (match_operand:QI 2 "const_int_operand")))
11389 (clobber (reg:CC FLAGS_REG))]
11390 "INTVAL (operands[2]) == GET_MODE_BITSIZE (<MODE>mode)-1
10784 && (TARGET_USE_CLTD || optimize_function_for_size_p (cfun)) 11391 && (TARGET_USE_CLTD || optimize_function_for_size_p (cfun))
10785 && ix86_binary_operator_ok (ASHIFTRT, DImode, operands)" 11392 && ix86_binary_operator_ok (ASHIFTRT, <MODE>mode, operands)"
10786 "@ 11393 "@
10787 {cqto|cqo} 11394 <cvt_mnemonic>
10788 sar{q}\t{%2, %0|%0, %2}" 11395 sar{<imodesuffix>}\t{%2, %0|%0, %2}"
10789 [(set_attr "type" "imovx,ishift") 11396 [(set_attr "type" "imovx,ishift")
10790 (set_attr "prefix_0f" "0,*") 11397 (set_attr "prefix_0f" "0,*")
10791 (set_attr "length_immediate" "0,*") 11398 (set_attr "length_immediate" "0,*")
10792 (set_attr "modrm" "0,1") 11399 (set_attr "modrm" "0,1")
10793 (set_attr "mode" "DI")]) 11400 (set_attr "mode" "<MODE>")])
10794 11401
10795 (define_insn "*ashrsi3_cvt_zext" 11402 (define_insn "*ashrsi3_cvt_zext"
10796 [(set (match_operand:DI 0 "register_operand" "=*d,r") 11403 [(set (match_operand:DI 0 "register_operand" "=*d,r")
10797 (zero_extend:DI 11404 (zero_extend:DI
10798 (ashiftrt:SI (match_operand:SI 1 "register_operand" "*a,0") 11405 (ashiftrt:SI (match_operand:SI 1 "register_operand" "*a,0")
10808 (set_attr "prefix_0f" "0,*") 11415 (set_attr "prefix_0f" "0,*")
10809 (set_attr "length_immediate" "0,*") 11416 (set_attr "length_immediate" "0,*")
10810 (set_attr "modrm" "0,1") 11417 (set_attr "modrm" "0,1")
10811 (set_attr "mode" "SI")]) 11418 (set_attr "mode" "SI")])
10812 11419
10813 (define_insn "ashrsi3_cvt" 11420 (define_expand "@x86_shift<mode>_adj_3"
10814 [(set (match_operand:SI 0 "nonimmediate_operand" "=*d,rm")
10815 (ashiftrt:SI (match_operand:SI 1 "nonimmediate_operand" "*a,0")
10816 (match_operand:QI 2 "const_int_operand")))
10817 (clobber (reg:CC FLAGS_REG))]
10818 "INTVAL (operands[2]) == 31
10819 && (TARGET_USE_CLTD || optimize_function_for_size_p (cfun))
10820 && ix86_binary_operator_ok (ASHIFTRT, SImode, operands)"
10821 "@
10822 {cltd|cdq}
10823 sar{l}\t{%2, %0|%0, %2}"
10824 [(set_attr "type" "imovx,ishift")
10825 (set_attr "prefix_0f" "0,*")
10826 (set_attr "length_immediate" "0,*")
10827 (set_attr "modrm" "0,1")
10828 (set_attr "mode" "SI")])
10829
10830 (define_expand "x86_shift<mode>_adj_3"
10831 [(use (match_operand:SWI48 0 "register_operand")) 11421 [(use (match_operand:SWI48 0 "register_operand"))
10832 (use (match_operand:SWI48 1 "register_operand")) 11422 (use (match_operand:SWI48 1 "register_operand"))
10833 (use (match_operand:QI 2 "register_operand"))] 11423 (use (match_operand:QI 2 "register_operand"))]
10834 "" 11424 ""
10835 { 11425 {
10984 (match_test "optimize_function_for_size_p (cfun)"))) 11574 (match_test "optimize_function_for_size_p (cfun)")))
10985 (const_string "0") 11575 (const_string "0")
10986 (const_string "*"))) 11576 (const_string "*")))
10987 (set_attr "mode" "<MODE>")]) 11577 (set_attr "mode" "<MODE>")])
10988 11578
10989 (define_insn "*<shift_insn>qi3_1_slp" 11579 (define_insn "*<shift_insn><mode>3_1_slp"
10990 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+qm")) 11580 [(set (strict_low_part (match_operand:SWI12 0 "register_operand" "+<r>"))
10991 (any_shiftrt:QI (match_dup 0) 11581 (any_shiftrt:SWI12 (match_operand:SWI12 1 "register_operand" "0")
10992 (match_operand:QI 1 "nonmemory_operand" "cI"))) 11582 (match_operand:QI 2 "nonmemory_operand" "cI")))
10993 (clobber (reg:CC FLAGS_REG))] 11583 (clobber (reg:CC FLAGS_REG))]
10994 "(optimize_function_for_size_p (cfun) 11584 "(!TARGET_PARTIAL_REG_STALL || optimize_function_for_size_p (cfun))
10995 || !TARGET_PARTIAL_REG_STALL 11585 /* FIXME: without this LRA can't reload this pattern, see PR82524. */
10996 || (operands[1] == const1_rtx 11586 && rtx_equal_p (operands[0], operands[1])"
10997 && TARGET_SHIFT1))" 11587 {
10998 { 11588 if (operands[2] == const1_rtx
10999 if (operands[1] == const1_rtx
11000 && (TARGET_SHIFT1 || optimize_function_for_size_p (cfun))) 11589 && (TARGET_SHIFT1 || optimize_function_for_size_p (cfun)))
11001 return "<shift>{b}\t%0"; 11590 return "<shift>{<imodesuffix>}\t%0";
11002 else 11591 else
11003 return "<shift>{b}\t{%1, %0|%0, %1}"; 11592 return "<shift>{<imodesuffix>}\t{%2, %0|%0, %2}";
11004 } 11593 }
11005 [(set_attr "type" "ishift1") 11594 [(set_attr "type" "ishift")
11006 (set (attr "length_immediate") 11595 (set (attr "length_immediate")
11007 (if_then_else 11596 (if_then_else
11008 (and (match_operand 1 "const1_operand") 11597 (and (match_operand 2 "const1_operand")
11009 (ior (match_test "TARGET_SHIFT1") 11598 (ior (match_test "TARGET_SHIFT1")
11010 (match_test "optimize_function_for_size_p (cfun)"))) 11599 (match_test "optimize_function_for_size_p (cfun)")))
11011 (const_string "0") 11600 (const_string "0")
11012 (const_string "*"))) 11601 (const_string "*")))
11013 (set_attr "mode" "QI")]) 11602 (set_attr "mode" "<MODE>")])
11014 11603
11015 ;; This pattern can't accept a variable shift count, since shifts by 11604 ;; This pattern can't accept a variable shift count, since shifts by
11016 ;; zero don't affect the flags. We assume that shifts by constant 11605 ;; zero don't affect the flags. We assume that shifts by constant
11017 ;; zero are optimized away. 11606 ;; zero are optimized away.
11018 (define_insn "*<shift_insn><mode>3_cmp" 11607 (define_insn "*<shift_insn><mode>3_cmp"
11161 (match_operand:SI 3 "const_int_operand")) 0))) 11750 (match_operand:SI 3 "const_int_operand")) 0)))
11162 (clobber (reg:CC FLAGS_REG))] 11751 (clobber (reg:CC FLAGS_REG))]
11163 "ix86_binary_operator_ok (<CODE>, <MODE>mode, operands) 11752 "ix86_binary_operator_ok (<CODE>, <MODE>mode, operands)
11164 && (INTVAL (operands[3]) & (GET_MODE_BITSIZE (<MODE>mode)-1)) 11753 && (INTVAL (operands[3]) & (GET_MODE_BITSIZE (<MODE>mode)-1))
11165 == GET_MODE_BITSIZE (<MODE>mode)-1 11754 == GET_MODE_BITSIZE (<MODE>mode)-1
11166 && can_create_pseudo_p ()" 11755 && ix86_pre_reload_split ()"
11167 "#" 11756 "#"
11168 "&& 1" 11757 "&& 1"
11169 [(parallel 11758 [(parallel
11170 [(set (match_dup 0) 11759 [(set (match_dup 0)
11171 (any_rotate:SWI48 (match_dup 1) 11760 (any_rotate:SWI48 (match_dup 1)
11182 (match_operand:QI 3 "const_int_operand")))) 11771 (match_operand:QI 3 "const_int_operand"))))
11183 (clobber (reg:CC FLAGS_REG))] 11772 (clobber (reg:CC FLAGS_REG))]
11184 "ix86_binary_operator_ok (<CODE>, <MODE>mode, operands) 11773 "ix86_binary_operator_ok (<CODE>, <MODE>mode, operands)
11185 && (INTVAL (operands[3]) & (GET_MODE_BITSIZE (<MODE>mode)-1)) 11774 && (INTVAL (operands[3]) & (GET_MODE_BITSIZE (<MODE>mode)-1))
11186 == GET_MODE_BITSIZE (<MODE>mode)-1 11775 == GET_MODE_BITSIZE (<MODE>mode)-1
11187 && can_create_pseudo_p ()" 11776 && ix86_pre_reload_split ()"
11188 "#" 11777 "#"
11189 "&& 1" 11778 "&& 1"
11190 [(parallel 11779 [(parallel
11191 [(set (match_dup 0) 11780 [(set (match_dup 0)
11192 (any_rotate:SWI48 (match_dup 1) 11781 (any_rotate:SWI48 (match_dup 1)
11413 (match_test "optimize_function_for_size_p (cfun)"))) 12002 (match_test "optimize_function_for_size_p (cfun)")))
11414 (const_string "0") 12003 (const_string "0")
11415 (const_string "*"))) 12004 (const_string "*")))
11416 (set_attr "mode" "<MODE>")]) 12005 (set_attr "mode" "<MODE>")])
11417 12006
11418 (define_insn "*<rotate_insn>qi3_1_slp" 12007 (define_insn "*<rotate_insn><mode>3_1_slp"
11419 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+qm")) 12008 [(set (strict_low_part (match_operand:SWI12 0 "register_operand" "+<r>"))
11420 (any_rotate:QI (match_dup 0) 12009 (any_rotate:SWI12 (match_operand:SWI12 1 "register_operand" "0")
11421 (match_operand:QI 1 "nonmemory_operand" "cI"))) 12010 (match_operand:QI 2 "nonmemory_operand" "cI")))
11422 (clobber (reg:CC FLAGS_REG))] 12011 (clobber (reg:CC FLAGS_REG))]
11423 "(optimize_function_for_size_p (cfun) 12012 "(!TARGET_PARTIAL_REG_STALL || optimize_function_for_size_p (cfun))
11424 || !TARGET_PARTIAL_REG_STALL 12013 /* FIXME: without this LRA can't reload this pattern, see PR82524. */
11425 || (operands[1] == const1_rtx 12014 && rtx_equal_p (operands[0], operands[1])"
11426 && TARGET_SHIFT1))" 12015 {
11427 { 12016 if (operands[2] == const1_rtx
11428 if (operands[1] == const1_rtx
11429 && (TARGET_SHIFT1 || optimize_function_for_size_p (cfun))) 12017 && (TARGET_SHIFT1 || optimize_function_for_size_p (cfun)))
11430 return "<rotate>{b}\t%0"; 12018 return "<rotate>{<imodesuffix>}\t%0";
11431 else 12019 else
11432 return "<rotate>{b}\t{%1, %0|%0, %1}"; 12020 return "<rotate>{<imodesuffix>}\t{%2, %0|%0, %2}";
11433 } 12021 }
11434 [(set_attr "type" "rotate1") 12022 [(set_attr "type" "rotate")
11435 (set (attr "length_immediate") 12023 (set (attr "length_immediate")
11436 (if_then_else 12024 (if_then_else
11437 (and (match_operand 1 "const1_operand") 12025 (and (match_operand 2 "const1_operand")
11438 (ior (match_test "TARGET_SHIFT1") 12026 (ior (match_test "TARGET_SHIFT1")
11439 (match_test "optimize_function_for_size_p (cfun)"))) 12027 (match_test "optimize_function_for_size_p (cfun)")))
11440 (const_string "0") 12028 (const_string "0")
11441 (const_string "*"))) 12029 (const_string "*")))
11442 (set_attr "mode" "QI")]) 12030 (set_attr "mode" "<MODE>")])
11443 12031
11444 (define_split 12032 (define_split
11445 [(set (match_operand:HI 0 "QIreg_operand") 12033 [(set (match_operand:HI 0 "QIreg_operand")
11446 (any_rotate:HI (match_dup 0) (const_int 8))) 12034 (any_rotate:HI (match_dup 0) (const_int 8)))
11447 (clobber (reg:CC FLAGS_REG))] 12035 (clobber (reg:CC FLAGS_REG))]
11486 (match_operand:SWI48 3 "register_operand"))) 12074 (match_operand:SWI48 3 "register_operand")))
11487 (clobber (reg:CC FLAGS_REG))] 12075 (clobber (reg:CC FLAGS_REG))]
11488 "TARGET_USE_BT 12076 "TARGET_USE_BT
11489 && (INTVAL (operands[2]) & (GET_MODE_BITSIZE (<MODE>mode)-1)) 12077 && (INTVAL (operands[2]) & (GET_MODE_BITSIZE (<MODE>mode)-1))
11490 == GET_MODE_BITSIZE (<MODE>mode)-1 12078 == GET_MODE_BITSIZE (<MODE>mode)-1
11491 && can_create_pseudo_p ()" 12079 && ix86_pre_reload_split ()"
11492 "#" 12080 "#"
11493 "&& 1" 12081 "&& 1"
11494 [(parallel 12082 [(parallel
11495 [(set (match_dup 0) 12083 [(set (match_dup 0)
11496 (any_or:SWI48 12084 (any_or:SWI48
11511 (match_operand:SWI48 3 "register_operand"))) 12099 (match_operand:SWI48 3 "register_operand")))
11512 (clobber (reg:CC FLAGS_REG))] 12100 (clobber (reg:CC FLAGS_REG))]
11513 "TARGET_USE_BT 12101 "TARGET_USE_BT
11514 && (INTVAL (operands[2]) & (GET_MODE_BITSIZE (<MODE>mode)-1)) 12102 && (INTVAL (operands[2]) & (GET_MODE_BITSIZE (<MODE>mode)-1))
11515 == GET_MODE_BITSIZE (<MODE>mode)-1 12103 == GET_MODE_BITSIZE (<MODE>mode)-1
11516 && can_create_pseudo_p ()" 12104 && ix86_pre_reload_split ()"
11517 "#" 12105 "#"
11518 "&& 1" 12106 "&& 1"
11519 [(parallel 12107 [(parallel
11520 [(set (match_dup 0) 12108 [(set (match_dup 0)
11521 (any_or:SWI48 12109 (any_or:SWI48
11551 (match_operand:SWI48 3 "register_operand"))) 12139 (match_operand:SWI48 3 "register_operand")))
11552 (clobber (reg:CC FLAGS_REG))] 12140 (clobber (reg:CC FLAGS_REG))]
11553 "TARGET_USE_BT 12141 "TARGET_USE_BT
11554 && (INTVAL (operands[2]) & (GET_MODE_BITSIZE (<MODE>mode)-1)) 12142 && (INTVAL (operands[2]) & (GET_MODE_BITSIZE (<MODE>mode)-1))
11555 == GET_MODE_BITSIZE (<MODE>mode)-1 12143 == GET_MODE_BITSIZE (<MODE>mode)-1
11556 && can_create_pseudo_p ()" 12144 && ix86_pre_reload_split ()"
11557 "#" 12145 "#"
11558 "&& 1" 12146 "&& 1"
11559 [(parallel 12147 [(parallel
11560 [(set (match_dup 0) 12148 [(set (match_dup 0)
11561 (and:SWI48 12149 (and:SWI48
11576 (match_operand:SWI48 3 "register_operand"))) 12164 (match_operand:SWI48 3 "register_operand")))
11577 (clobber (reg:CC FLAGS_REG))] 12165 (clobber (reg:CC FLAGS_REG))]
11578 "TARGET_USE_BT 12166 "TARGET_USE_BT
11579 && (INTVAL (operands[2]) & (GET_MODE_BITSIZE (<MODE>mode)-1)) 12167 && (INTVAL (operands[2]) & (GET_MODE_BITSIZE (<MODE>mode)-1))
11580 == GET_MODE_BITSIZE (<MODE>mode)-1 12168 == GET_MODE_BITSIZE (<MODE>mode)-1
11581 && can_create_pseudo_p ()" 12169 && ix86_pre_reload_split ()"
11582 "#" 12170 "#"
11583 "&& 1" 12171 "&& 1"
11584 [(parallel 12172 [(parallel
11585 [(set (match_dup 0) 12173 [(set (match_dup 0)
11586 (and:SWI48 12174 (and:SWI48
11761 && (CONST_INT_P (operands[2]) 12349 && (CONST_INT_P (operands[2])
11762 ? (INTVAL (operands[2]) < GET_MODE_BITSIZE (<MODE>mode) 12350 ? (INTVAL (operands[2]) < GET_MODE_BITSIZE (<MODE>mode)
11763 && INTVAL (operands[2]) 12351 && INTVAL (operands[2])
11764 >= (optimize_function_for_size_p (cfun) ? 8 : 32)) 12352 >= (optimize_function_for_size_p (cfun) ? 8 : 32))
11765 : !memory_operand (operands[1], <MODE>mode)) 12353 : !memory_operand (operands[1], <MODE>mode))
11766 && can_create_pseudo_p ()" 12354 && ix86_pre_reload_split ()"
11767 "#" 12355 "#"
11768 "&& 1" 12356 "&& 1"
11769 [(set (reg:CCC FLAGS_REG) 12357 [(set (reg:CCC FLAGS_REG)
11770 (compare:CCC 12358 (compare:CCC
11771 (zero_extract:SWI48 12359 (zero_extract:SWI48
11793 (const_int 0)]) 12381 (const_int 0)])
11794 (label_ref (match_operand 3)) 12382 (label_ref (match_operand 3))
11795 (pc))) 12383 (pc)))
11796 (clobber (reg:CC FLAGS_REG))] 12384 (clobber (reg:CC FLAGS_REG))]
11797 "(TARGET_USE_BT || optimize_function_for_size_p (cfun)) 12385 "(TARGET_USE_BT || optimize_function_for_size_p (cfun))
11798 && can_create_pseudo_p ()" 12386 && ix86_pre_reload_split ()"
11799 "#" 12387 "#"
11800 "&& 1" 12388 "&& 1"
11801 [(set (reg:CCC FLAGS_REG) 12389 [(set (reg:CCC FLAGS_REG)
11802 (compare:CCC 12390 (compare:CCC
11803 (zero_extract:SWI48 12391 (zero_extract:SWI48
11829 (pc))) 12417 (pc)))
11830 (clobber (reg:CC FLAGS_REG))] 12418 (clobber (reg:CC FLAGS_REG))]
11831 "(TARGET_USE_BT || optimize_function_for_size_p (cfun)) 12419 "(TARGET_USE_BT || optimize_function_for_size_p (cfun))
11832 && (INTVAL (operands[3]) & (GET_MODE_BITSIZE (<MODE>mode)-1)) 12420 && (INTVAL (operands[3]) & (GET_MODE_BITSIZE (<MODE>mode)-1))
11833 == GET_MODE_BITSIZE (<MODE>mode)-1 12421 == GET_MODE_BITSIZE (<MODE>mode)-1
11834 && can_create_pseudo_p ()" 12422 && ix86_pre_reload_split ()"
11835 "#" 12423 "#"
11836 "&& 1" 12424 "&& 1"
11837 [(set (reg:CCC FLAGS_REG) 12425 [(set (reg:CCC FLAGS_REG)
11838 (compare:CCC 12426 (compare:CCC
11839 (zero_extract:SWI48 12427 (zero_extract:SWI48
11912 "set%C1\t%0" 12500 "set%C1\t%0"
11913 [(set_attr "type" "setcc") 12501 [(set_attr "type" "setcc")
11914 (set_attr "mode" "QI")]) 12502 (set_attr "mode" "QI")])
11915 12503
11916 (define_insn "*setcc_qi_slp" 12504 (define_insn "*setcc_qi_slp"
11917 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+qm")) 12505 [(set (strict_low_part (match_operand:QI 0 "register_operand" "+q"))
11918 (match_operator:QI 1 "ix86_comparison_operator" 12506 (match_operator:QI 1 "ix86_comparison_operator"
11919 [(reg FLAGS_REG) (const_int 0)]))] 12507 [(reg FLAGS_REG) (const_int 0)]))]
11920 "" 12508 ""
11921 "set%C1\t%0" 12509 "set%C1\t%0"
11922 [(set_attr "type" "setcc") 12510 [(set_attr "type" "setcc")
11941 operands[1] = shallow_copy_rtx (operands[1]); 12529 operands[1] = shallow_copy_rtx (operands[1]);
11942 PUT_MODE (operands[1], QImode); 12530 PUT_MODE (operands[1], QImode);
11943 }) 12531 })
11944 12532
11945 (define_split 12533 (define_split
11946 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand")) 12534 [(set (strict_low_part (match_operand:QI 0 "register_operand"))
11947 (ne:QI (match_operator 1 "ix86_comparison_operator" 12535 (ne:QI (match_operator 1 "ix86_comparison_operator"
11948 [(reg FLAGS_REG) (const_int 0)]) 12536 [(reg FLAGS_REG) (const_int 0)])
11949 (const_int 0)))] 12537 (const_int 0)))]
11950 "" 12538 ""
11951 [(set (match_dup 0) (match_dup 1))] 12539 [(set (match_dup 0) (match_dup 1))]
11973 if (! ix86_comparison_operator (operands[1], VOIDmode)) 12561 if (! ix86_comparison_operator (operands[1], VOIDmode))
11974 FAIL; 12562 FAIL;
11975 }) 12563 })
11976 12564
11977 (define_split 12565 (define_split
11978 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand")) 12566 [(set (strict_low_part (match_operand:QI 0 "register_operand"))
11979 (eq:QI (match_operator 1 "ix86_comparison_operator" 12567 (eq:QI (match_operator 1 "ix86_comparison_operator"
11980 [(reg FLAGS_REG) (const_int 0)]) 12568 [(reg FLAGS_REG) (const_int 0)])
11981 (const_int 0)))] 12569 (const_int 0)))]
11982 "" 12570 ""
11983 [(set (match_dup 0) (match_dup 1))] 12571 [(set (match_dup 0) (match_dup 1))]
13108 "#" 13696 "#"
13109 "epilogue_completed" 13697 "epilogue_completed"
13110 [(const_int 0)] 13698 [(const_int 0)]
13111 "ix86_expand_epilogue (2); DONE;") 13699 "ix86_expand_epilogue (2); DONE;")
13112 13700
13113 (define_insn "leave" 13701 (define_expand "@leave_<mode>"
13702 [(parallel
13703 [(set (reg:W SP_REG) (plus:W (reg:W BP_REG) (match_dup 0)))
13704 (set (reg:W BP_REG) (mem:W (reg:W BP_REG)))
13705 (clobber (mem:BLK (scratch)))])]
13706 ""
13707 "operands[0] = GEN_INT (<MODE_SIZE>);")
13708
13709 (define_insn "*leave"
13114 [(set (reg:SI SP_REG) (plus:SI (reg:SI BP_REG) (const_int 4))) 13710 [(set (reg:SI SP_REG) (plus:SI (reg:SI BP_REG) (const_int 4)))
13115 (set (reg:SI BP_REG) (mem:SI (reg:SI BP_REG))) 13711 (set (reg:SI BP_REG) (mem:SI (reg:SI BP_REG)))
13116 (clobber (mem:BLK (scratch)))] 13712 (clobber (mem:BLK (scratch)))]
13117 "!TARGET_64BIT" 13713 "!TARGET_64BIT"
13118 "leave" 13714 "leave"
13119 [(set_attr "type" "leave")]) 13715 [(set_attr "type" "leave")])
13120 13716
13121 (define_insn "leave_rex64" 13717 (define_insn "*leave_rex64"
13122 [(set (reg:DI SP_REG) (plus:DI (reg:DI BP_REG) (const_int 8))) 13718 [(set (reg:DI SP_REG) (plus:DI (reg:DI BP_REG) (const_int 8)))
13123 (set (reg:DI BP_REG) (mem:DI (reg:DI BP_REG))) 13719 (set (reg:DI BP_REG) (mem:DI (reg:DI BP_REG)))
13124 (clobber (mem:BLK (scratch)))] 13720 (clobber (mem:BLK (scratch)))]
13125 "TARGET_64BIT" 13721 "TARGET_64BIT"
13126 "leave" 13722 "leave"
13625 14221
13626 ;; BMI2 instructions. 14222 ;; BMI2 instructions.
13627 (define_expand "bmi2_bzhi_<mode>3" 14223 (define_expand "bmi2_bzhi_<mode>3"
13628 [(parallel 14224 [(parallel
13629 [(set (match_operand:SWI48 0 "register_operand") 14225 [(set (match_operand:SWI48 0 "register_operand")
13630 (zero_extract:SWI48 14226 (if_then_else:SWI48
13631 (match_operand:SWI48 1 "nonimmediate_operand") 14227 (ne:QI (and:SWI48 (match_operand:SWI48 2 "register_operand")
13632 (umin:SWI48 14228 (const_int 255))
13633 (and:SWI48 (match_operand:SWI48 2 "register_operand") 14229 (const_int 0))
13634 (const_int 255)) 14230 (zero_extract:SWI48
13635 (match_dup 3)) 14231 (match_operand:SWI48 1 "nonimmediate_operand")
14232 (umin:SWI48 (and:SWI48 (match_dup 2) (const_int 255))
14233 (match_dup 3))
14234 (const_int 0))
13636 (const_int 0))) 14235 (const_int 0)))
13637 (clobber (reg:CC FLAGS_REG))])] 14236 (clobber (reg:CC FLAGS_REG))])]
13638 "TARGET_BMI2" 14237 "TARGET_BMI2"
13639 "operands[3] = GEN_INT (<MODE_SIZE> * BITS_PER_UNIT);") 14238 "operands[3] = GEN_INT (<MODE_SIZE> * BITS_PER_UNIT);")
13640 14239
13641 (define_insn "*bmi2_bzhi_<mode>3" 14240 (define_insn "*bmi2_bzhi_<mode>3"
13642 [(set (match_operand:SWI48 0 "register_operand" "=r") 14241 [(set (match_operand:SWI48 0 "register_operand" "=r")
13643 (zero_extract:SWI48 14242 (if_then_else:SWI48
13644 (match_operand:SWI48 1 "nonimmediate_operand" "rm") 14243 (ne:QI (and:SWI48 (match_operand:SWI48 2 "register_operand" "r")
13645 (umin:SWI48 14244 (const_int 255))
13646 (and:SWI48 (match_operand:SWI48 2 "register_operand" "r") 14245 (const_int 0))
13647 (const_int 255)) 14246 (zero_extract:SWI48
13648 (match_operand:SWI48 3 "const_int_operand" "n")) 14247 (match_operand:SWI48 1 "nonimmediate_operand" "rm")
14248 (umin:SWI48 (and:SWI48 (match_dup 2) (const_int 255))
14249 (match_operand:SWI48 3 "const_int_operand" "n"))
14250 (const_int 0))
13649 (const_int 0))) 14251 (const_int 0)))
13650 (clobber (reg:CC FLAGS_REG))] 14252 (clobber (reg:CC FLAGS_REG))]
13651 "TARGET_BMI2 && INTVAL (operands[3]) == <MODE_SIZE> * BITS_PER_UNIT" 14253 "TARGET_BMI2 && INTVAL (operands[3]) == <MODE_SIZE> * BITS_PER_UNIT"
13652 "bzhi\t{%2, %1, %0|%0, %1, %2}" 14254 "bzhi\t{%2, %1, %0|%0, %1, %2}"
13653 [(set_attr "type" "bitmanip") 14255 [(set_attr "type" "bitmanip")
13654 (set_attr "prefix" "vex") 14256 (set_attr "prefix" "vex")
13655 (set_attr "mode" "<MODE>")]) 14257 (set_attr "mode" "<MODE>")])
13656 14258
13657 (define_insn "*bmi2_bzhi_<mode>3_1" 14259 (define_insn "*bmi2_bzhi_<mode>3_1"
13658 [(set (match_operand:SWI48 0 "register_operand" "=r") 14260 [(set (match_operand:SWI48 0 "register_operand" "=r")
13659 (zero_extract:SWI48 14261 (if_then_else:SWI48
13660 (match_operand:SWI48 1 "nonimmediate_operand" "rm") 14262 (ne:QI (match_operand:QI 2 "register_operand" "r") (const_int 0))
13661 (umin:SWI48 14263 (zero_extract:SWI48
13662 (zero_extend:SWI48 (match_operand:QI 2 "register_operand" "r")) 14264 (match_operand:SWI48 1 "nonimmediate_operand" "rm")
13663 (match_operand:SWI48 3 "const_int_operand" "n")) 14265 (umin:SWI48 (zero_extend:SWI48 (match_dup 2))
14266 (match_operand:SWI48 3 "const_int_operand" "n"))
14267 (const_int 0))
13664 (const_int 0))) 14268 (const_int 0)))
13665 (clobber (reg:CC FLAGS_REG))] 14269 (clobber (reg:CC FLAGS_REG))]
13666 "TARGET_BMI2 && INTVAL (operands[3]) == <MODE_SIZE> * BITS_PER_UNIT" 14270 "TARGET_BMI2 && INTVAL (operands[3]) == <MODE_SIZE> * BITS_PER_UNIT"
13667 "bzhi\t{%<k>2, %1, %0|%0, %1, %<k>2}" 14271 "bzhi\t{%<k>2, %1, %0|%0, %1, %<k>2}"
13668 [(set_attr "type" "bitmanip") 14272 [(set_attr "type" "bitmanip")
13670 (set_attr "mode" "<MODE>")]) 14274 (set_attr "mode" "<MODE>")])
13671 14275
13672 (define_insn "*bmi2_bzhi_<mode>3_1_ccz" 14276 (define_insn "*bmi2_bzhi_<mode>3_1_ccz"
13673 [(set (reg:CCZ FLAGS_REG) 14277 [(set (reg:CCZ FLAGS_REG)
13674 (compare:CCZ 14278 (compare:CCZ
13675 (zero_extract:SWI48 14279 (if_then_else:SWI48
13676 (match_operand:SWI48 1 "nonimmediate_operand" "rm") 14280 (ne:QI (match_operand:QI 2 "register_operand" "r") (const_int 0))
13677 (umin:SWI48 14281 (zero_extract:SWI48
13678 (zero_extend:SWI48 (match_operand:QI 2 "register_operand" "r")) 14282 (match_operand:SWI48 1 "nonimmediate_operand" "rm")
13679 (match_operand:SWI48 3 "const_int_operand" "n")) 14283 (umin:SWI48 (zero_extend:SWI48 (match_dup 2))
14284 (match_operand:SWI48 3 "const_int_operand" "n"))
14285 (const_int 0))
13680 (const_int 0)) 14286 (const_int 0))
13681 (const_int 0))) 14287 (const_int 0)))
13682 (clobber (match_scratch:SWI48 0 "=r"))] 14288 (clobber (match_scratch:SWI48 0 "=r"))]
13683 "TARGET_BMI2 && INTVAL (operands[3]) == <MODE_SIZE> * BITS_PER_UNIT" 14289 "TARGET_BMI2 && INTVAL (operands[3]) == <MODE_SIZE> * BITS_PER_UNIT"
14290 "bzhi\t{%<k>2, %1, %0|%0, %1, %<k>2}"
14291 [(set_attr "type" "bitmanip")
14292 (set_attr "prefix" "vex")
14293 (set_attr "mode" "<MODE>")])
14294
14295 (define_insn "*bmi2_bzhi_<mode>3_2"
14296 [(set (match_operand:SWI48 0 "register_operand" "=r")
14297 (and:SWI48
14298 (plus:SWI48
14299 (ashift:SWI48 (const_int 1)
14300 (match_operand:QI 2 "register_operand" "r"))
14301 (const_int -1))
14302 (match_operand:SWI48 1 "nonimmediate_operand" "rm")))
14303 (clobber (reg:CC FLAGS_REG))]
14304 "TARGET_BMI2"
14305 "bzhi\t{%<k>2, %1, %0|%0, %1, %<k>2}"
14306 [(set_attr "type" "bitmanip")
14307 (set_attr "prefix" "vex")
14308 (set_attr "mode" "<MODE>")])
14309
14310 (define_insn "*bmi2_bzhi_<mode>3_3"
14311 [(set (match_operand:SWI48 0 "register_operand" "=r")
14312 (and:SWI48
14313 (not:SWI48
14314 (ashift:SWI48 (const_int -1)
14315 (match_operand:QI 2 "register_operand" "r")))
14316 (match_operand:SWI48 1 "nonimmediate_operand" "rm")))
14317 (clobber (reg:CC FLAGS_REG))]
14318 "TARGET_BMI2"
13684 "bzhi\t{%<k>2, %1, %0|%0, %1, %<k>2}" 14319 "bzhi\t{%<k>2, %1, %0|%0, %1, %<k>2}"
13685 [(set_attr "type" "bitmanip") 14320 [(set_attr "type" "bitmanip")
13686 (set_attr "prefix" "vex") 14321 (set_attr "prefix" "vex")
13687 (set_attr "mode" "<MODE>")]) 14322 (set_attr "mode" "<MODE>")])
13688 14323
13707 [(set_attr "type" "bitmanip") 14342 [(set_attr "type" "bitmanip")
13708 (set_attr "prefix" "vex") 14343 (set_attr "prefix" "vex")
13709 (set_attr "mode" "<MODE>")]) 14344 (set_attr "mode" "<MODE>")])
13710 14345
13711 ;; TBM instructions. 14346 ;; TBM instructions.
13712 (define_insn "tbm_bextri_<mode>" 14347 (define_expand "tbm_bextri_<mode>"
14348 [(parallel
14349 [(set (match_operand:SWI48 0 "register_operand")
14350 (zero_extract:SWI48
14351 (match_operand:SWI48 1 "nonimmediate_operand")
14352 (match_operand 2 "const_0_to_255_operand" "N")
14353 (match_operand 3 "const_0_to_255_operand" "N")))
14354 (clobber (reg:CC FLAGS_REG))])]
14355 "TARGET_TBM"
14356 {
14357 if (operands[2] == const0_rtx
14358 || INTVAL (operands[3]) >= <MODE_SIZE> * BITS_PER_UNIT)
14359 {
14360 emit_move_insn (operands[0], const0_rtx);
14361 DONE;
14362 }
14363 if (INTVAL (operands[2]) + INTVAL (operands[3])
14364 > <MODE_SIZE> * BITS_PER_UNIT)
14365 operands[2] = GEN_INT (<MODE_SIZE> * BITS_PER_UNIT - INTVAL (operands[3]));
14366 })
14367
14368 (define_insn "*tbm_bextri_<mode>"
13713 [(set (match_operand:SWI48 0 "register_operand" "=r") 14369 [(set (match_operand:SWI48 0 "register_operand" "=r")
13714 (zero_extract:SWI48 14370 (zero_extract:SWI48
13715 (match_operand:SWI48 1 "nonimmediate_operand" "rm") 14371 (match_operand:SWI48 1 "nonimmediate_operand" "rm")
13716 (match_operand 2 "const_0_to_255_operand" "N") 14372 (match_operand 2 "const_0_to_255_operand" "N")
13717 (match_operand 3 "const_0_to_255_operand" "N"))) 14373 (match_operand 3 "const_0_to_255_operand" "N")))
13892 } 14548 }
13893 [(set_attr "prefix_rep" "1") 14549 [(set_attr "prefix_rep" "1")
13894 (set_attr "type" "bitmanip") 14550 (set_attr "type" "bitmanip")
13895 (set_attr "mode" "<MODE>")]) 14551 (set_attr "mode" "<MODE>")])
13896 14552
14553 (define_insn_and_split "*popcountsi2_zext"
14554 [(set (match_operand:DI 0 "register_operand" "=r")
14555 (and:DI
14556 (subreg:DI
14557 (popcount:SI
14558 (match_operand:SI 1 "nonimmediate_operand" "rm")) 0)
14559 (const_int 63)))
14560 (clobber (reg:CC FLAGS_REG))]
14561 "TARGET_POPCNT && TARGET_64BIT"
14562 {
14563 #if TARGET_MACHO
14564 return "popcnt\t{%1, %k0|%k0, %1}";
14565 #else
14566 return "popcnt{l}\t{%1, %k0|%k0, %1}";
14567 #endif
14568 }
14569 "&& TARGET_AVOID_FALSE_DEP_FOR_BMI && epilogue_completed
14570 && optimize_function_for_speed_p (cfun)
14571 && !reg_mentioned_p (operands[0], operands[1])"
14572 [(parallel
14573 [(set (match_dup 0)
14574 (and:DI (subreg:DI (popcount:SI (match_dup 1)) 0) (const_int 63)))
14575 (unspec [(match_dup 0)] UNSPEC_INSN_FALSE_DEP)
14576 (clobber (reg:CC FLAGS_REG))])]
14577 "ix86_expand_clear (operands[0]);"
14578 [(set_attr "prefix_rep" "1")
14579 (set_attr "type" "bitmanip")
14580 (set_attr "mode" "SI")])
14581
14582 ; False dependency happens when destination is only updated by tzcnt,
14583 ; lzcnt or popcnt. There is no false dependency when destination is
14584 ; also used in source.
14585 (define_insn "*popcountsi2_zext_falsedep"
14586 [(set (match_operand:DI 0 "register_operand" "=r")
14587 (and:DI
14588 (subreg:DI
14589 (popcount:SI
14590 (match_operand:SI 1 "nonimmediate_operand" "rm")) 0)
14591 (const_int 63)))
14592 (unspec [(match_operand:DI 2 "register_operand" "0")]
14593 UNSPEC_INSN_FALSE_DEP)
14594 (clobber (reg:CC FLAGS_REG))]
14595 "TARGET_POPCNT && TARGET_64BIT"
14596 {
14597 #if TARGET_MACHO
14598 return "popcnt\t{%1, %k0|%k0, %1}";
14599 #else
14600 return "popcnt{l}\t{%1, %k0|%k0, %1}";
14601 #endif
14602 }
14603 [(set_attr "prefix_rep" "1")
14604 (set_attr "type" "bitmanip")
14605 (set_attr "mode" "SI")])
14606
13897 (define_insn_and_split "*popcounthi2_1" 14607 (define_insn_and_split "*popcounthi2_1"
13898 [(set (match_operand:SI 0 "register_operand") 14608 [(set (match_operand:SI 0 "register_operand")
13899 (popcount:SI 14609 (popcount:SI
13900 (zero_extend:SI (match_operand:HI 1 "nonimmediate_operand")))) 14610 (zero_extend:SI (match_operand:HI 1 "nonimmediate_operand"))))
13901 (clobber (reg:CC FLAGS_REG))] 14611 (clobber (reg:CC FLAGS_REG))]
13902 "TARGET_POPCNT 14612 "TARGET_POPCNT
13903 && can_create_pseudo_p ()" 14613 && ix86_pre_reload_split ()"
13904 "#" 14614 "#"
13905 "&& 1" 14615 "&& 1"
13906 [(const_int 0)] 14616 [(const_int 0)]
13907 { 14617 {
13908 rtx tmp = gen_reg_rtx (HImode); 14618 rtx tmp = gen_reg_rtx (HImode);
14254 return "call\t{*%%rax|rax}"; 14964 return "call\t{*%%rax|rax}";
14255 } 14965 }
14256 [(set_attr "type" "multi") 14966 [(set_attr "type" "multi")
14257 (set_attr "length" "22")]) 14967 (set_attr "length" "22")])
14258 14968
14259 (define_expand "tls_global_dynamic_64_<mode>" 14969 (define_expand "@tls_global_dynamic_64_<mode>"
14260 [(parallel 14970 [(parallel
14261 [(set (match_operand:P 0 "register_operand") 14971 [(set (match_operand:P 0 "register_operand")
14262 (call:P 14972 (call:P
14263 (mem:QI (match_operand 2)) 14973 (mem:QI (match_operand 2))
14264 (const_int 0))) 14974 (const_int 0)))
14348 return "call\t{*%%rax|rax}"; 15058 return "call\t{*%%rax|rax}";
14349 } 15059 }
14350 [(set_attr "type" "multi") 15060 [(set_attr "type" "multi")
14351 (set_attr "length" "22")]) 15061 (set_attr "length" "22")])
14352 15062
14353 (define_expand "tls_local_dynamic_base_64_<mode>" 15063 (define_expand "@tls_local_dynamic_base_64_<mode>"
14354 [(parallel 15064 [(parallel
14355 [(set (match_operand:P 0 "register_operand") 15065 [(set (match_operand:P 0 "register_operand")
14356 (call:P 15066 (call:P
14357 (mem:QI (match_operand 1)) 15067 (mem:QI (match_operand 1))
14358 (const_int 0))) 15068 (const_int 0)))
14544 { 15254 {
14545 operands[5] = can_create_pseudo_p () ? gen_reg_rtx (Pmode) : operands[0]; 15255 operands[5] = can_create_pseudo_p () ? gen_reg_rtx (Pmode) : operands[0];
14546 emit_insn (gen_tls_dynamic_gnu2_32 (operands[5], operands[1], operands[2])); 15256 emit_insn (gen_tls_dynamic_gnu2_32 (operands[5], operands[1], operands[2]));
14547 }) 15257 })
14548 15258
14549 (define_expand "tls_dynamic_gnu2_64" 15259 (define_expand "@tls_dynamic_gnu2_64_<mode>"
14550 [(set (match_dup 2) 15260 [(set (match_dup 2)
14551 (unspec:DI [(match_operand 1 "tls_symbolic_operand")] 15261 (unspec:PTR [(match_operand 1 "tls_symbolic_operand")]
14552 UNSPEC_TLSDESC)) 15262 UNSPEC_TLSDESC))
14553 (parallel 15263 (parallel
14554 [(set (match_operand:DI 0 "register_operand") 15264 [(set (match_operand:PTR 0 "register_operand")
14555 (unspec:DI [(match_dup 1) (match_dup 2) (reg:DI SP_REG)] 15265 (unspec:PTR [(match_dup 1) (match_dup 2) (reg:PTR SP_REG)]
14556 UNSPEC_TLSDESC)) 15266 UNSPEC_TLSDESC))
14557 (clobber (reg:CC FLAGS_REG))])] 15267 (clobber (reg:CC FLAGS_REG))])]
14558 "TARGET_64BIT && TARGET_GNU2_TLS" 15268 "TARGET_64BIT && TARGET_GNU2_TLS"
14559 { 15269 {
14560 operands[2] = can_create_pseudo_p () ? gen_reg_rtx (Pmode) : operands[0]; 15270 operands[2] = can_create_pseudo_p () ? gen_reg_rtx (ptr_mode) : operands[0];
14561 ix86_tls_descriptor_calls_expanded_in_cfun = true; 15271 ix86_tls_descriptor_calls_expanded_in_cfun = true;
14562 }) 15272 })
14563 15273
14564 (define_insn "*tls_dynamic_gnu2_lea_64" 15274 (define_insn "*tls_dynamic_gnu2_lea_64_<mode>"
14565 [(set (match_operand:DI 0 "register_operand" "=r") 15275 [(set (match_operand:PTR 0 "register_operand" "=r")
14566 (unspec:DI [(match_operand 1 "tls_symbolic_operand")] 15276 (unspec:PTR [(match_operand 1 "tls_symbolic_operand")]
14567 UNSPEC_TLSDESC))] 15277 UNSPEC_TLSDESC))]
14568 "TARGET_64BIT && TARGET_GNU2_TLS" 15278 "TARGET_64BIT && TARGET_GNU2_TLS"
14569 "lea{q}\t{%E1@TLSDESC(%%rip), %0|%0, %E1@TLSDESC[rip]}" 15279 "lea%z0\t{%E1@TLSDESC(%%rip), %0|%0, %E1@TLSDESC[rip]}"
14570 [(set_attr "type" "lea") 15280 [(set_attr "type" "lea")
14571 (set_attr "mode" "DI") 15281 (set_attr "mode" "<MODE>")
14572 (set_attr "length" "7") 15282 (set_attr "length" "7")
14573 (set_attr "length_address" "4")]) 15283 (set_attr "length_address" "4")])
14574 15284
14575 (define_insn "*tls_dynamic_gnu2_call_64" 15285 (define_insn "*tls_dynamic_gnu2_call_64_<mode>"
14576 [(set (match_operand:DI 0 "register_operand" "=a") 15286 [(set (match_operand:PTR 0 "register_operand" "=a")
14577 (unspec:DI [(match_operand 1 "tls_symbolic_operand") 15287 (unspec:PTR [(match_operand 1 "tls_symbolic_operand")
14578 (match_operand:DI 2 "register_operand" "0") 15288 (match_operand:PTR 2 "register_operand" "0")
14579 (reg:DI SP_REG)] 15289 (reg:PTR SP_REG)]
14580 UNSPEC_TLSDESC)) 15290 UNSPEC_TLSDESC))
14581 (clobber (reg:CC FLAGS_REG))] 15291 (clobber (reg:CC FLAGS_REG))]
14582 "TARGET_64BIT && TARGET_GNU2_TLS" 15292 "TARGET_64BIT && TARGET_GNU2_TLS"
14583 "call\t{*%a1@TLSCALL(%2)|[QWORD PTR [%2+%a1@TLSCALL]]}" 15293 "call\t{*%a1@TLSCALL(%2)|[QWORD PTR [%2+%a1@TLSCALL]]}"
14584 [(set_attr "type" "call") 15294 [(set_attr "type" "call")
14585 (set_attr "length" "2") 15295 (set_attr "length" "2")
14586 (set_attr "length_address" "0")]) 15296 (set_attr "length_address" "0")])
14587 15297
14588 (define_insn_and_split "*tls_dynamic_gnu2_combine_64" 15298 (define_insn_and_split "*tls_dynamic_gnu2_combine_64_<mode>"
14589 [(set (match_operand:DI 0 "register_operand" "=&a") 15299 [(set (match_operand:PTR 0 "register_operand" "=&a")
14590 (plus:DI 15300 (plus:PTR
14591 (unspec:DI [(match_operand 2 "tls_modbase_operand") 15301 (unspec:PTR [(match_operand 2 "tls_modbase_operand")
14592 (match_operand:DI 3) 15302 (match_operand:PTR 3)
14593 (reg:DI SP_REG)] 15303 (reg:PTR SP_REG)]
14594 UNSPEC_TLSDESC) 15304 UNSPEC_TLSDESC)
14595 (const:DI (unspec:DI 15305 (const:PTR (unspec:PTR
14596 [(match_operand 1 "tls_symbolic_operand")] 15306 [(match_operand 1 "tls_symbolic_operand")]
14597 UNSPEC_DTPOFF)))) 15307 UNSPEC_DTPOFF))))
14598 (clobber (reg:CC FLAGS_REG))] 15308 (clobber (reg:CC FLAGS_REG))]
14599 "TARGET_64BIT && TARGET_GNU2_TLS" 15309 "TARGET_64BIT && TARGET_GNU2_TLS"
14600 "#" 15310 "#"
14601 "" 15311 ""
14602 [(set (match_dup 0) (match_dup 4))] 15312 [(set (match_dup 0) (match_dup 4))]
14603 { 15313 {
14604 operands[4] = can_create_pseudo_p () ? gen_reg_rtx (Pmode) : operands[0]; 15314 operands[4] = can_create_pseudo_p () ? gen_reg_rtx (ptr_mode) : operands[0];
14605 emit_insn (gen_tls_dynamic_gnu2_64 (operands[4], operands[1])); 15315 emit_insn (gen_tls_dynamic_gnu2_64 (ptr_mode, operands[4], operands[1]));
14606 }) 15316 })
14607 15317
14608 (define_split 15318 (define_split
14609 [(match_operand 0 "tls_address_pattern")] 15319 [(match_operand 0 "tls_address_pattern")]
14610 "TARGET_TLS_DIRECT_SEG_REFS" 15320 "TARGET_TLS_DIRECT_SEG_REFS"
14670 (eq_attr "alternative" "0") 15380 (eq_attr "alternative" "0")
14671 (symbol_ref "true") 15381 (symbol_ref "true")
14672 (symbol_ref "false"))))]) 15382 (symbol_ref "false"))))])
14673 15383
14674 (define_insn "*rcpsf2_sse" 15384 (define_insn "*rcpsf2_sse"
14675 [(set (match_operand:SF 0 "register_operand" "=x,x") 15385 [(set (match_operand:SF 0 "register_operand" "=x,x,x")
14676 (unspec:SF [(match_operand:SF 1 "nonimmediate_operand" "x,m")] 15386 (unspec:SF [(match_operand:SF 1 "nonimmediate_operand" "0,x,m")]
14677 UNSPEC_RCP))] 15387 UNSPEC_RCP))]
14678 "TARGET_SSE && TARGET_SSE_MATH" 15388 "TARGET_SSE && TARGET_SSE_MATH"
14679 "@ 15389 "@
15390 %vrcpss\t{%d1, %0|%0, %d1}
14680 %vrcpss\t{%d1, %0|%0, %d1} 15391 %vrcpss\t{%d1, %0|%0, %d1}
14681 %vrcpss\t{%1, %d0|%d0, %1}" 15392 %vrcpss\t{%1, %d0|%d0, %1}"
14682 [(set_attr "type" "sse") 15393 [(set_attr "type" "sse")
14683 (set_attr "atom_sse_attr" "rcp") 15394 (set_attr "atom_sse_attr" "rcp")
14684 (set_attr "btver2_sse_attr" "rcp") 15395 (set_attr "btver2_sse_attr" "rcp")
14685 (set_attr "prefix" "maybe_vex") 15396 (set_attr "prefix" "maybe_vex")
14686 (set_attr "mode" "SF")]) 15397 (set_attr "mode" "SF")
15398 (set_attr "avx_partial_xmm_update" "false,false,true")
15399 (set (attr "preferred_for_speed")
15400 (cond [(match_test "TARGET_AVX")
15401 (symbol_ref "true")
15402 (eq_attr "alternative" "1,2")
15403 (symbol_ref "!TARGET_SSE_PARTIAL_REG_DEPENDENCY")
15404 ]
15405 (symbol_ref "true")))])
14687 15406
14688 (define_insn "*fop_xf_1_i387" 15407 (define_insn "*fop_xf_1_i387"
14689 [(set (match_operand:XF 0 "register_operand" "=f,f") 15408 [(set (match_operand:XF 0 "register_operand" "=f,f")
14690 (match_operator:XF 3 "binary_fp_operator" 15409 (match_operator:XF 3 "binary_fp_operator"
14691 [(match_operand:XF 1 "register_operand" "0,f") 15410 [(match_operand:XF 1 "register_operand" "0,f")
14773 (match_operand:X87MODEF 3 "div_operator") 15492 (match_operand:X87MODEF 3 "div_operator")
14774 (const_string "fdiv") 15493 (const_string "fdiv")
14775 ] 15494 ]
14776 (const_string "fop"))) 15495 (const_string "fop")))
14777 (set_attr "fp_int_src" "true") 15496 (set_attr "fp_int_src" "true")
14778 (set_attr "mode" "<MODE>")]) 15497 (set_attr "mode" "<SWI24:MODE>")])
14779 15498
14780 (define_insn "*fop_xf_4_i387" 15499 (define_insn "*fop_xf_4_i387"
14781 [(set (match_operand:XF 0 "register_operand" "=f,f") 15500 [(set (match_operand:XF 0 "register_operand" "=f,f")
14782 (match_operator:XF 3 "binary_fp_operator" 15501 (match_operator:XF 3 "binary_fp_operator"
14783 [(float_extend:XF 15502 [(float_extend:XF
14908 (set_attr "athlon_decode" "direct") 15627 (set_attr "athlon_decode" "direct")
14909 (set_attr "amdfam10_decode" "direct") 15628 (set_attr "amdfam10_decode" "direct")
14910 (set_attr "bdver1_decode" "direct")]) 15629 (set_attr "bdver1_decode" "direct")])
14911 15630
14912 (define_insn "*rsqrtsf2_sse" 15631 (define_insn "*rsqrtsf2_sse"
14913 [(set (match_operand:SF 0 "register_operand" "=x,x") 15632 [(set (match_operand:SF 0 "register_operand" "=x,x,x")
14914 (unspec:SF [(match_operand:SF 1 "nonimmediate_operand" "x,m")] 15633 (unspec:SF [(match_operand:SF 1 "nonimmediate_operand" "0,x,m")]
14915 UNSPEC_RSQRT))] 15634 UNSPEC_RSQRT))]
14916 "TARGET_SSE && TARGET_SSE_MATH" 15635 "TARGET_SSE && TARGET_SSE_MATH"
14917 "@ 15636 "@
15637 %vrsqrtss\t{%d1, %0|%0, %d1}
14918 %vrsqrtss\t{%d1, %0|%0, %d1} 15638 %vrsqrtss\t{%d1, %0|%0, %d1}
14919 %vrsqrtss\t{%1, %d0|%d0, %1}" 15639 %vrsqrtss\t{%1, %d0|%d0, %1}"
14920 [(set_attr "type" "sse") 15640 [(set_attr "type" "sse")
14921 (set_attr "atom_sse_attr" "rcp") 15641 (set_attr "atom_sse_attr" "rcp")
14922 (set_attr "btver2_sse_attr" "rcp") 15642 (set_attr "btver2_sse_attr" "rcp")
14923 (set_attr "prefix" "maybe_vex") 15643 (set_attr "prefix" "maybe_vex")
14924 (set_attr "mode" "SF")]) 15644 (set_attr "mode" "SF")
15645 (set_attr "avx_partial_xmm_update" "false,false,true")
15646 (set (attr "preferred_for_speed")
15647 (cond [(match_test "TARGET_AVX")
15648 (symbol_ref "true")
15649 (eq_attr "alternative" "1,2")
15650 (symbol_ref "!TARGET_SSE_PARTIAL_REG_DEPENDENCY")
15651 ]
15652 (symbol_ref "true")))])
14925 15653
14926 (define_expand "rsqrtsf2" 15654 (define_expand "rsqrtsf2"
14927 [(set (match_operand:SF 0 "register_operand") 15655 [(set (match_operand:SF 0 "register_operand")
14928 (unspec:SF [(match_operand:SF 1 "nonimmediate_operand")] 15656 (unspec:SF [(match_operand:SF 1 "nonimmediate_operand")]
14929 UNSPEC_RSQRT))] 15657 UNSPEC_RSQRT))]
14932 ix86_emit_swsqrtsf (operands[0], operands[1], SFmode, 1); 15660 ix86_emit_swsqrtsf (operands[0], operands[1], SFmode, 1);
14933 DONE; 15661 DONE;
14934 }) 15662 })
14935 15663
14936 (define_insn "*sqrt<mode>2_sse" 15664 (define_insn "*sqrt<mode>2_sse"
14937 [(set (match_operand:MODEF 0 "register_operand" "=v,v") 15665 [(set (match_operand:MODEF 0 "register_operand" "=v,v,v")
14938 (sqrt:MODEF 15666 (sqrt:MODEF
14939 (match_operand:MODEF 1 "nonimmediate_operand" "v,m")))] 15667 (match_operand:MODEF 1 "nonimmediate_operand" "0,v,m")))]
14940 "SSE_FLOAT_MODE_P (<MODE>mode) && TARGET_SSE_MATH" 15668 "SSE_FLOAT_MODE_P (<MODE>mode) && TARGET_SSE_MATH"
14941 "@ 15669 "@
15670 %vsqrt<ssemodesuffix>\t{%d1, %0|%0, %d1}
14942 %vsqrt<ssemodesuffix>\t{%d1, %0|%0, %d1} 15671 %vsqrt<ssemodesuffix>\t{%d1, %0|%0, %d1}
14943 %vsqrt<ssemodesuffix>\t{%1, %d0|%d0, %1}" 15672 %vsqrt<ssemodesuffix>\t{%1, %d0|%d0, %1}"
14944 [(set_attr "type" "sse") 15673 [(set_attr "type" "sse")
14945 (set_attr "atom_sse_attr" "sqrt") 15674 (set_attr "atom_sse_attr" "sqrt")
14946 (set_attr "btver2_sse_attr" "sqrt") 15675 (set_attr "btver2_sse_attr" "sqrt")
14947 (set_attr "prefix" "maybe_vex") 15676 (set_attr "prefix" "maybe_vex")
15677 (set_attr "avx_partial_xmm_update" "false,false,true")
14948 (set_attr "mode" "<MODE>") 15678 (set_attr "mode" "<MODE>")
14949 (set_attr "athlon_decode" "*") 15679 (set (attr "preferred_for_speed")
14950 (set_attr "amdfam10_decode" "*") 15680 (cond [(match_test "TARGET_AVX")
14951 (set_attr "bdver1_decode" "*")]) 15681 (symbol_ref "true")
15682 (eq_attr "alternative" "1,2")
15683 (symbol_ref "!TARGET_SSE_PARTIAL_REG_DEPENDENCY")
15684 ]
15685 (symbol_ref "true")))])
14952 15686
14953 (define_expand "sqrt<mode>2" 15687 (define_expand "sqrt<mode>2"
14954 [(set (match_operand:MODEF 0 "register_operand") 15688 [(set (match_operand:MODEF 0 "register_operand")
14955 (sqrt:MODEF 15689 (sqrt:MODEF
14956 (match_operand:MODEF 1 "nonimmediate_operand")))] 15690 (match_operand:MODEF 1 "nonimmediate_operand")))]
14976 emit_insn (gen_extend<mode>xf2 (op1, operands[1])); 15710 emit_insn (gen_extend<mode>xf2 (op1, operands[1]));
14977 emit_insn (gen_sqrtxf2 (op0, op1)); 15711 emit_insn (gen_sqrtxf2 (op0, op1));
14978 emit_insn (gen_truncxf<mode>2_i387_noop_unspec (operands[0], op0)); 15712 emit_insn (gen_truncxf<mode>2_i387_noop_unspec (operands[0], op0));
14979 DONE; 15713 DONE;
14980 } 15714 }
15715 })
15716
15717 (define_expand "hypot<mode>3"
15718 [(use (match_operand:MODEF 0 "register_operand"))
15719 (use (match_operand:MODEF 1 "general_operand"))
15720 (use (match_operand:MODEF 2 "general_operand"))]
15721 "TARGET_USE_FANCY_MATH_387
15722 && (!(SSE_FLOAT_MODE_P (<MODE>mode) && TARGET_SSE_MATH)
15723 || TARGET_MIX_SSE_I387)
15724 && flag_finite_math_only
15725 && flag_unsafe_math_optimizations"
15726 {
15727 rtx op0 = gen_reg_rtx (XFmode);
15728 rtx op1 = gen_reg_rtx (XFmode);
15729 rtx op2 = gen_reg_rtx (XFmode);
15730
15731 emit_insn (gen_extend<mode>xf2 (op2, operands[2]));
15732 emit_insn (gen_extend<mode>xf2 (op1, operands[1]));
15733
15734 emit_insn (gen_mulxf3 (op1, op1, op1));
15735 emit_insn (gen_mulxf3 (op2, op2, op2));
15736 emit_insn (gen_addxf3 (op0, op2, op1));
15737 emit_insn (gen_sqrtxf2 (op0, op0));
15738
15739 emit_insn (gen_truncxf<mode>2 (operands[0], op0));
15740 DONE;
14981 }) 15741 })
14982 15742
14983 (define_insn "x86_fnstsw_1" 15743 (define_insn "x86_fnstsw_1"
14984 [(set (match_operand:HI 0 "register_operand" "=a") 15744 [(set (match_operand:HI 0 "register_operand" "=a")
14985 (unspec:HI [(reg:CCFP FPSR_REG)] UNSPEC_FNSTSW))] 15745 (unspec:HI [(reg:CCFP FPSR_REG)] UNSPEC_FNSTSW))]
15383 rtx op0 = gen_reg_rtx (XFmode); 16143 rtx op0 = gen_reg_rtx (XFmode);
15384 rtx op1 = gen_reg_rtx (XFmode); 16144 rtx op1 = gen_reg_rtx (XFmode);
15385 16145
15386 emit_insn (gen_extend<mode>xf2 (op1, operands[1])); 16146 emit_insn (gen_extend<mode>xf2 (op1, operands[1]));
15387 emit_insn (gen_acosxf2 (op0, op1)); 16147 emit_insn (gen_acosxf2 (op0, op1));
16148 emit_insn (gen_truncxf<mode>2 (operands[0], op0));
16149 DONE;
16150 })
16151
16152 (define_expand "sinhxf2"
16153 [(use (match_operand:XF 0 "register_operand"))
16154 (use (match_operand:XF 1 "register_operand"))]
16155 "TARGET_USE_FANCY_MATH_387
16156 && flag_finite_math_only
16157 && flag_unsafe_math_optimizations"
16158 {
16159 ix86_emit_i387_sinh (operands[0], operands[1]);
16160 DONE;
16161 })
16162
16163 (define_expand "sinh<mode>2"
16164 [(use (match_operand:MODEF 0 "register_operand"))
16165 (use (match_operand:MODEF 1 "general_operand"))]
16166 "TARGET_USE_FANCY_MATH_387
16167 && (!(SSE_FLOAT_MODE_P (<MODE>mode) && TARGET_SSE_MATH)
16168 || TARGET_MIX_SSE_I387)
16169 && flag_finite_math_only
16170 && flag_unsafe_math_optimizations"
16171 {
16172 rtx op0 = gen_reg_rtx (XFmode);
16173 rtx op1 = gen_reg_rtx (XFmode);
16174
16175 emit_insn (gen_extend<mode>xf2 (op1, operands[1]));
16176 emit_insn (gen_sinhxf2 (op0, op1));
16177 emit_insn (gen_truncxf<mode>2 (operands[0], op0));
16178 DONE;
16179 })
16180
16181 (define_expand "coshxf2"
16182 [(use (match_operand:XF 0 "register_operand"))
16183 (use (match_operand:XF 1 "register_operand"))]
16184 "TARGET_USE_FANCY_MATH_387
16185 && flag_unsafe_math_optimizations"
16186 {
16187 ix86_emit_i387_cosh (operands[0], operands[1]);
16188 DONE;
16189 })
16190
16191 (define_expand "cosh<mode>2"
16192 [(use (match_operand:MODEF 0 "register_operand"))
16193 (use (match_operand:MODEF 1 "general_operand"))]
16194 "TARGET_USE_FANCY_MATH_387
16195 && (!(SSE_FLOAT_MODE_P (<MODE>mode) && TARGET_SSE_MATH)
16196 || TARGET_MIX_SSE_I387)
16197 && flag_unsafe_math_optimizations"
16198 {
16199 rtx op0 = gen_reg_rtx (XFmode);
16200 rtx op1 = gen_reg_rtx (XFmode);
16201
16202 emit_insn (gen_extend<mode>xf2 (op1, operands[1]));
16203 emit_insn (gen_coshxf2 (op0, op1));
16204 emit_insn (gen_truncxf<mode>2 (operands[0], op0));
16205 DONE;
16206 })
16207
16208 (define_expand "tanhxf2"
16209 [(use (match_operand:XF 0 "register_operand"))
16210 (use (match_operand:XF 1 "register_operand"))]
16211 "TARGET_USE_FANCY_MATH_387
16212 && flag_unsafe_math_optimizations"
16213 {
16214 ix86_emit_i387_tanh (operands[0], operands[1]);
16215 DONE;
16216 })
16217
16218 (define_expand "tanh<mode>2"
16219 [(use (match_operand:MODEF 0 "register_operand"))
16220 (use (match_operand:MODEF 1 "general_operand"))]
16221 "TARGET_USE_FANCY_MATH_387
16222 && (!(SSE_FLOAT_MODE_P (<MODE>mode) && TARGET_SSE_MATH)
16223 || TARGET_MIX_SSE_I387)
16224 && flag_unsafe_math_optimizations"
16225 {
16226 rtx op0 = gen_reg_rtx (XFmode);
16227 rtx op1 = gen_reg_rtx (XFmode);
16228
16229 emit_insn (gen_extend<mode>xf2 (op1, operands[1]));
16230 emit_insn (gen_tanhxf2 (op0, op1));
16231 emit_insn (gen_truncxf<mode>2 (operands[0], op0));
16232 DONE;
16233 })
16234
16235 (define_expand "asinhxf2"
16236 [(use (match_operand:XF 0 "register_operand"))
16237 (use (match_operand:XF 1 "register_operand"))]
16238 "TARGET_USE_FANCY_MATH_387
16239 && flag_finite_math_only
16240 && flag_unsafe_math_optimizations"
16241 {
16242 ix86_emit_i387_asinh (operands[0], operands[1]);
16243 DONE;
16244 })
16245
16246 (define_expand "asinh<mode>2"
16247 [(use (match_operand:MODEF 0 "register_operand"))
16248 (use (match_operand:MODEF 1 "general_operand"))]
16249 "TARGET_USE_FANCY_MATH_387
16250 && (!(SSE_FLOAT_MODE_P (<MODE>mode) && TARGET_SSE_MATH)
16251 || TARGET_MIX_SSE_I387)
16252 && flag_finite_math_only
16253 && flag_unsafe_math_optimizations"
16254 {
16255 rtx op0 = gen_reg_rtx (XFmode);
16256 rtx op1 = gen_reg_rtx (XFmode);
16257
16258 emit_insn (gen_extend<mode>xf2 (op1, operands[1]));
16259 emit_insn (gen_asinhxf2 (op0, op1));
16260 emit_insn (gen_truncxf<mode>2 (operands[0], op0));
16261 DONE;
16262 })
16263
16264 (define_expand "acoshxf2"
16265 [(use (match_operand:XF 0 "register_operand"))
16266 (use (match_operand:XF 1 "register_operand"))]
16267 "TARGET_USE_FANCY_MATH_387
16268 && flag_unsafe_math_optimizations"
16269 {
16270 ix86_emit_i387_acosh (operands[0], operands[1]);
16271 DONE;
16272 })
16273
16274 (define_expand "acosh<mode>2"
16275 [(use (match_operand:MODEF 0 "register_operand"))
16276 (use (match_operand:MODEF 1 "general_operand"))]
16277 "TARGET_USE_FANCY_MATH_387
16278 && (!(SSE_FLOAT_MODE_P (<MODE>mode) && TARGET_SSE_MATH)
16279 || TARGET_MIX_SSE_I387)
16280 && flag_unsafe_math_optimizations"
16281 {
16282 rtx op0 = gen_reg_rtx (XFmode);
16283 rtx op1 = gen_reg_rtx (XFmode);
16284
16285 emit_insn (gen_extend<mode>xf2 (op1, operands[1]));
16286 emit_insn (gen_acoshxf2 (op0, op1));
16287 emit_insn (gen_truncxf<mode>2 (operands[0], op0));
16288 DONE;
16289 })
16290
16291 (define_expand "atanhxf2"
16292 [(use (match_operand:XF 0 "register_operand"))
16293 (use (match_operand:XF 1 "register_operand"))]
16294 "TARGET_USE_FANCY_MATH_387
16295 && flag_unsafe_math_optimizations"
16296 {
16297 ix86_emit_i387_atanh (operands[0], operands[1]);
16298 DONE;
16299 })
16300
16301 (define_expand "atanh<mode>2"
16302 [(use (match_operand:MODEF 0 "register_operand"))
16303 (use (match_operand:MODEF 1 "general_operand"))]
16304 "TARGET_USE_FANCY_MATH_387
16305 && (!(SSE_FLOAT_MODE_P (<MODE>mode) && TARGET_SSE_MATH)
16306 || TARGET_MIX_SSE_I387)
16307 && flag_unsafe_math_optimizations"
16308 {
16309 rtx op0 = gen_reg_rtx (XFmode);
16310 rtx op1 = gen_reg_rtx (XFmode);
16311
16312 emit_insn (gen_extend<mode>xf2 (op1, operands[1]));
16313 emit_insn (gen_atanhxf2 (op0, op1));
15388 emit_insn (gen_truncxf<mode>2 (operands[0], op0)); 16314 emit_insn (gen_truncxf<mode>2 (operands[0], op0));
15389 DONE; 16315 DONE;
15390 }) 16316 })
15391 16317
15392 (define_insn "fyl2xxf3_i387" 16318 (define_insn "fyl2xxf3_i387"
15888 DONE; 16814 DONE;
15889 }) 16815 })
15890 16816
15891 16817
15892 (define_insn "sse4_1_round<mode>2" 16818 (define_insn "sse4_1_round<mode>2"
15893 [(set (match_operand:MODEF 0 "register_operand" "=x,v") 16819 [(set (match_operand:MODEF 0 "register_operand" "=x,x,x,v,v")
15894 (unspec:MODEF [(match_operand:MODEF 1 "nonimmediate_operand" "xm,vm") 16820 (unspec:MODEF
15895 (match_operand:SI 2 "const_0_to_15_operand" "n,n")] 16821 [(match_operand:MODEF 1 "nonimmediate_operand" "0,x,m,v,m")
15896 UNSPEC_ROUND))] 16822 (match_operand:SI 2 "const_0_to_15_operand" "n,n,n,n,n")]
16823 UNSPEC_ROUND))]
15897 "TARGET_SSE4_1" 16824 "TARGET_SSE4_1"
15898 "@ 16825 "@
16826 %vround<ssemodesuffix>\t{%2, %d1, %0|%0, %d1, %2}
16827 %vround<ssemodesuffix>\t{%2, %d1, %0|%0, %d1, %2}
15899 %vround<ssemodesuffix>\t{%2, %1, %d0|%d0, %1, %2} 16828 %vround<ssemodesuffix>\t{%2, %1, %d0|%d0, %1, %2}
16829 vrndscale<ssemodesuffix>\t{%2, %d1, %0|%0, %d1, %2}
15900 vrndscale<ssemodesuffix>\t{%2, %1, %d0|%d0, %1, %2}" 16830 vrndscale<ssemodesuffix>\t{%2, %1, %d0|%d0, %1, %2}"
15901 [(set_attr "type" "ssecvt") 16831 [(set_attr "type" "ssecvt")
15902 (set_attr "prefix_extra" "1,*") 16832 (set_attr "prefix_extra" "1,1,1,*,*")
15903 (set_attr "length_immediate" "*,1") 16833 (set_attr "length_immediate" "*,*,*,1,1")
15904 (set_attr "prefix" "maybe_vex,evex") 16834 (set_attr "prefix" "maybe_vex,maybe_vex,maybe_vex,evex,evex")
15905 (set_attr "isa" "noavx512f,avx512f") 16835 (set_attr "isa" "noavx512f,noavx512f,noavx512f,avx512f,avx512f")
15906 (set_attr "mode" "<MODE>")]) 16836 (set_attr "avx_partial_xmm_update" "false,false,true,false,true")
16837 (set_attr "mode" "<MODE>")
16838 (set (attr "preferred_for_speed")
16839 (cond [(match_test "TARGET_AVX")
16840 (symbol_ref "true")
16841 (eq_attr "alternative" "1,2")
16842 (symbol_ref "!TARGET_SSE_PARTIAL_REG_DEPENDENCY")
16843 ]
16844 (symbol_ref "true")))])
15907 16845
15908 (define_insn "rintxf2" 16846 (define_insn "rintxf2"
15909 [(set (match_operand:XF 0 "register_operand" "=f") 16847 [(set (match_operand:XF 0 "register_operand" "=f")
15910 (unspec:XF [(match_operand:XF 1 "register_operand" "0")] 16848 (unspec:XF [(match_operand:XF 1 "register_operand" "0")]
15911 UNSPEC_FRNDINT))] 16849 UNSPEC_FRNDINT))]
16054 ix86_emit_i387_round (operands[0], operands[1]); 16992 ix86_emit_i387_round (operands[0], operands[1]);
16055 DONE; 16993 DONE;
16056 }) 16994 })
16057 16995
16058 (define_int_iterator FRNDINT_ROUNDING 16996 (define_int_iterator FRNDINT_ROUNDING
16059 [UNSPEC_FRNDINT_FLOOR 16997 [UNSPEC_FRNDINT_ROUNDEVEN
16998 UNSPEC_FRNDINT_FLOOR
16060 UNSPEC_FRNDINT_CEIL 16999 UNSPEC_FRNDINT_CEIL
16061 UNSPEC_FRNDINT_TRUNC]) 17000 UNSPEC_FRNDINT_TRUNC])
16062 17001
16063 (define_int_iterator FIST_ROUNDING 17002 (define_int_iterator FIST_ROUNDING
16064 [UNSPEC_FIST_FLOOR 17003 [UNSPEC_FIST_FLOOR
16065 UNSPEC_FIST_CEIL]) 17004 UNSPEC_FIST_CEIL])
16066 17005
16067 ;; Base name for define_insn 17006 ;; Base name for define_insn
16068 (define_int_attr rounding_insn 17007 (define_int_attr rounding_insn
16069 [(UNSPEC_FRNDINT_FLOOR "floor") 17008 [(UNSPEC_FRNDINT_ROUNDEVEN "roundeven")
17009 (UNSPEC_FRNDINT_FLOOR "floor")
16070 (UNSPEC_FRNDINT_CEIL "ceil") 17010 (UNSPEC_FRNDINT_CEIL "ceil")
16071 (UNSPEC_FRNDINT_TRUNC "btrunc") 17011 (UNSPEC_FRNDINT_TRUNC "btrunc")
16072 (UNSPEC_FIST_FLOOR "floor") 17012 (UNSPEC_FIST_FLOOR "floor")
16073 (UNSPEC_FIST_CEIL "ceil")]) 17013 (UNSPEC_FIST_CEIL "ceil")])
16074 17014
16075 (define_int_attr rounding 17015 (define_int_attr rounding
16076 [(UNSPEC_FRNDINT_FLOOR "floor") 17016 [(UNSPEC_FRNDINT_ROUNDEVEN "roundeven")
17017 (UNSPEC_FRNDINT_FLOOR "floor")
16077 (UNSPEC_FRNDINT_CEIL "ceil") 17018 (UNSPEC_FRNDINT_CEIL "ceil")
16078 (UNSPEC_FRNDINT_TRUNC "trunc") 17019 (UNSPEC_FRNDINT_TRUNC "trunc")
16079 (UNSPEC_FIST_FLOOR "floor") 17020 (UNSPEC_FIST_FLOOR "floor")
16080 (UNSPEC_FIST_CEIL "ceil")]) 17021 (UNSPEC_FIST_CEIL "ceil")])
16081 17022
16082 (define_int_attr ROUNDING 17023 (define_int_attr ROUNDING
16083 [(UNSPEC_FRNDINT_FLOOR "FLOOR") 17024 [(UNSPEC_FRNDINT_ROUNDEVEN "ROUNDEVEN")
17025 (UNSPEC_FRNDINT_FLOOR "FLOOR")
16084 (UNSPEC_FRNDINT_CEIL "CEIL") 17026 (UNSPEC_FRNDINT_CEIL "CEIL")
16085 (UNSPEC_FRNDINT_TRUNC "TRUNC") 17027 (UNSPEC_FRNDINT_TRUNC "TRUNC")
16086 (UNSPEC_FIST_FLOOR "FLOOR") 17028 (UNSPEC_FIST_FLOOR "FLOOR")
16087 (UNSPEC_FIST_CEIL "CEIL")]) 17029 (UNSPEC_FIST_CEIL "CEIL")])
16088 17030
16092 (unspec:XF [(match_operand:XF 1 "register_operand")] 17034 (unspec:XF [(match_operand:XF 1 "register_operand")]
16093 FRNDINT_ROUNDING)) 17035 FRNDINT_ROUNDING))
16094 (clobber (reg:CC FLAGS_REG))] 17036 (clobber (reg:CC FLAGS_REG))]
16095 "TARGET_USE_FANCY_MATH_387 17037 "TARGET_USE_FANCY_MATH_387
16096 && (flag_fp_int_builtin_inexact || !flag_trapping_math) 17038 && (flag_fp_int_builtin_inexact || !flag_trapping_math)
16097 && can_create_pseudo_p ()" 17039 && ix86_pre_reload_split ()"
16098 "#" 17040 "#"
16099 "&& 1" 17041 "&& 1"
16100 [(const_int 0)] 17042 [(const_int 0)]
16101 { 17043 {
16102 ix86_optimize_mode_switching[I387_<ROUNDING>] = 1; 17044 ix86_optimize_mode_switching[I387_<ROUNDING>] = 1;
16141 "(TARGET_USE_FANCY_MATH_387 17083 "(TARGET_USE_FANCY_MATH_387
16142 && (!(SSE_FLOAT_MODE_P (<MODE>mode) && TARGET_SSE_MATH) 17084 && (!(SSE_FLOAT_MODE_P (<MODE>mode) && TARGET_SSE_MATH)
16143 || TARGET_MIX_SSE_I387) 17085 || TARGET_MIX_SSE_I387)
16144 && (flag_fp_int_builtin_inexact || !flag_trapping_math)) 17086 && (flag_fp_int_builtin_inexact || !flag_trapping_math))
16145 || (SSE_FLOAT_MODE_P (<MODE>mode) && TARGET_SSE_MATH 17087 || (SSE_FLOAT_MODE_P (<MODE>mode) && TARGET_SSE_MATH
16146 && (TARGET_SSE4_1 || flag_fp_int_builtin_inexact 17088 && (TARGET_SSE4_1
16147 || !flag_trapping_math))" 17089 || (ROUND_<ROUNDING> != ROUND_ROUNDEVEN
17090 && (flag_fp_int_builtin_inexact || !flag_trapping_math))))"
16148 { 17091 {
16149 if (SSE_FLOAT_MODE_P (<MODE>mode) && TARGET_SSE_MATH 17092 if (SSE_FLOAT_MODE_P (<MODE>mode) && TARGET_SSE_MATH
16150 && (TARGET_SSE4_1 || flag_fp_int_builtin_inexact || !flag_trapping_math)) 17093 && (TARGET_SSE4_1 || flag_fp_int_builtin_inexact || !flag_trapping_math))
16151 { 17094 {
16152 if (TARGET_SSE4_1) 17095 if (TARGET_SSE4_1)
16194 (unspec:SWI248x [(match_operand:XF 1 "register_operand")] 17137 (unspec:SWI248x [(match_operand:XF 1 "register_operand")]
16195 FIST_ROUNDING)) 17138 FIST_ROUNDING))
16196 (clobber (reg:CC FLAGS_REG))] 17139 (clobber (reg:CC FLAGS_REG))]
16197 "TARGET_USE_FANCY_MATH_387 17140 "TARGET_USE_FANCY_MATH_387
16198 && flag_unsafe_math_optimizations 17141 && flag_unsafe_math_optimizations
16199 && can_create_pseudo_p ()" 17142 && ix86_pre_reload_split ()"
16200 "#" 17143 "#"
16201 "&& 1" 17144 "&& 1"
16202 [(const_int 0)] 17145 [(const_int 0)]
16203 { 17146 {
16204 ix86_optimize_mode_switching[I387_<ROUNDING>] = 1; 17147 ix86_optimize_mode_switching[I387_<ROUNDING>] = 1;
16260 { 17203 {
16261 if (TARGET_SSE4_1) 17204 if (TARGET_SSE4_1)
16262 { 17205 {
16263 rtx tmp = gen_reg_rtx (<MODEF:MODE>mode); 17206 rtx tmp = gen_reg_rtx (<MODEF:MODE>mode);
16264 17207
16265 emit_insn (gen_sse4_1_round<mode>2 17208 emit_insn (gen_sse4_1_round<MODEF:mode>2
16266 (tmp, operands[1], GEN_INT (ROUND_<ROUNDING> 17209 (tmp, operands[1], GEN_INT (ROUND_<ROUNDING>
16267 | ROUND_NO_EXC))); 17210 | ROUND_NO_EXC)));
16268 emit_insn (gen_fix_trunc<MODEF:mode><SWI48:mode>2 17211 emit_insn (gen_fix_trunc<MODEF:mode><SWI48:mode>2
16269 (operands[0], tmp)); 17212 (operands[0], tmp));
16270 } 17213 }
16385 "cld" 17328 "cld"
16386 [(set_attr "length" "1") 17329 [(set_attr "length" "1")
16387 (set_attr "length_immediate" "0") 17330 (set_attr "length_immediate" "0")
16388 (set_attr "modrm" "0")]) 17331 (set_attr "modrm" "0")])
16389 17332
16390 (define_expand "movmem<mode>" 17333 (define_expand "cpymem<mode>"
16391 [(use (match_operand:BLK 0 "memory_operand")) 17334 [(use (match_operand:BLK 0 "memory_operand"))
16392 (use (match_operand:BLK 1 "memory_operand")) 17335 (use (match_operand:BLK 1 "memory_operand"))
16393 (use (match_operand:SWI48 2 "nonmemory_operand")) 17336 (use (match_operand:SWI48 2 "nonmemory_operand"))
16394 (use (match_operand:SWI48 3 "const_int_operand")) 17337 (use (match_operand:SWI48 3 "const_int_operand"))
16395 (use (match_operand:SI 4 "const_int_operand")) 17338 (use (match_operand:SI 4 "const_int_operand"))
16397 (use (match_operand:SI 6 "")) 17340 (use (match_operand:SI 6 ""))
16398 (use (match_operand:SI 7 "")) 17341 (use (match_operand:SI 7 ""))
16399 (use (match_operand:SI 8 ""))] 17342 (use (match_operand:SI 8 ""))]
16400 "" 17343 ""
16401 { 17344 {
16402 if (ix86_expand_set_or_movmem (operands[0], operands[1], 17345 if (ix86_expand_set_or_cpymem (operands[0], operands[1],
16403 operands[2], NULL, operands[3], 17346 operands[2], NULL, operands[3],
16404 operands[4], operands[5], 17347 operands[4], operands[5],
16405 operands[6], operands[7], 17348 operands[6], operands[7],
16406 operands[8], false)) 17349 operands[8], false))
16407 DONE; 17350 DONE;
16612 (use (match_operand:SI 6 "")) 17555 (use (match_operand:SI 6 ""))
16613 (use (match_operand:SI 7 "")) 17556 (use (match_operand:SI 7 ""))
16614 (use (match_operand:SI 8 ""))] 17557 (use (match_operand:SI 8 ""))]
16615 "" 17558 ""
16616 { 17559 {
16617 if (ix86_expand_set_or_movmem (operands[0], NULL, 17560 if (ix86_expand_set_or_cpymem (operands[0], NULL,
16618 operands[1], operands[2], 17561 operands[1], operands[2],
16619 operands[3], operands[4], 17562 operands[3], operands[4],
16620 operands[5], operands[6], 17563 operands[5], operands[6],
16621 operands[7], operands[8], true)) 17564 operands[7], operands[8], true))
16622 DONE; 17565 DONE;
16809 (match_operand:BLK 2 "general_operand"))) 17752 (match_operand:BLK 2 "general_operand")))
16810 (use (match_operand 3 "general_operand")) 17753 (use (match_operand 3 "general_operand"))
16811 (use (match_operand 4 "immediate_operand"))] 17754 (use (match_operand 4 "immediate_operand"))]
16812 "" 17755 ""
16813 { 17756 {
16814 rtx addr1, addr2, out, outlow, count, countreg, align; 17757 rtx addr1, addr2, countreg, align, out;
16815 17758
16816 if (optimize_insn_for_size_p () && !TARGET_INLINE_ALL_STRINGOPS) 17759 if (optimize_insn_for_size_p () && !TARGET_INLINE_ALL_STRINGOPS)
16817 FAIL; 17760 FAIL;
16818 17761
16819 /* Can't use this if the user has appropriated ecx, esi or edi. */ 17762 /* Can't use this if the user has appropriated ecx, esi or edi. */
16833 || (t2 && TREE_CODE (t2) == MEM_REF 17776 || (t2 && TREE_CODE (t2) == MEM_REF
16834 && TREE_CODE (TREE_OPERAND (t2, 0)) == ADDR_EXPR 17777 && TREE_CODE (TREE_OPERAND (t2, 0)) == ADDR_EXPR
16835 && TREE_CODE (TREE_OPERAND (TREE_OPERAND (t2, 0), 0)) == STRING_CST))) 17778 && TREE_CODE (TREE_OPERAND (TREE_OPERAND (t2, 0), 0)) == STRING_CST)))
16836 FAIL; 17779 FAIL;
16837 17780
16838 out = operands[0];
16839 if (!REG_P (out))
16840 out = gen_reg_rtx (SImode);
16841
16842 addr1 = copy_addr_to_reg (XEXP (operands[1], 0)); 17781 addr1 = copy_addr_to_reg (XEXP (operands[1], 0));
16843 addr2 = copy_addr_to_reg (XEXP (operands[2], 0)); 17782 addr2 = copy_addr_to_reg (XEXP (operands[2], 0));
16844 if (addr1 != XEXP (operands[1], 0)) 17783 if (addr1 != XEXP (operands[1], 0))
16845 operands[1] = replace_equiv_address_nv (operands[1], addr1); 17784 operands[1] = replace_equiv_address_nv (operands[1], addr1);
16846 if (addr2 != XEXP (operands[2], 0)) 17785 if (addr2 != XEXP (operands[2], 0))
16847 operands[2] = replace_equiv_address_nv (operands[2], addr2); 17786 operands[2] = replace_equiv_address_nv (operands[2], addr2);
16848 17787
16849 count = operands[3]; 17788 countreg = ix86_zero_extend_to_Pmode (operands[3]);
16850 countreg = ix86_zero_extend_to_Pmode (count);
16851 17789
16852 /* %%% Iff we are testing strict equality, we can use known alignment 17790 /* %%% Iff we are testing strict equality, we can use known alignment
16853 to good advantage. This may be possible with combine, particularly 17791 to good advantage. This may be possible with combine, particularly
16854 once cc0 is dead. */ 17792 once cc0 is dead. */
16855 align = operands[4]; 17793 align = operands[4];
16856 17794
16857 if (CONST_INT_P (count)) 17795 if (CONST_INT_P (operands[3]))
16858 { 17796 {
16859 if (INTVAL (count) == 0) 17797 if (operands[3] == const0_rtx)
16860 { 17798 {
16861 emit_move_insn (operands[0], const0_rtx); 17799 emit_move_insn (operands[0], const0_rtx);
16862 DONE; 17800 DONE;
16863 } 17801 }
16864 emit_insn (gen_cmpstrnqi_nz_1 (addr1, addr2, countreg, align, 17802 emit_insn (gen_cmpstrnqi_nz_1 (addr1, addr2, countreg, align,
16865 operands[1], operands[2])); 17803 operands[1], operands[2]));
16866 } 17804 }
16867 else 17805 else
16868 { 17806 {
16869 rtx (*gen_cmp) (rtx, rtx); 17807 emit_insn (gen_cmp_1 (Pmode, countreg, countreg));
16870
16871 gen_cmp = (TARGET_64BIT
16872 ? gen_cmpdi_1 : gen_cmpsi_1);
16873
16874 emit_insn (gen_cmp (countreg, countreg));
16875 emit_insn (gen_cmpstrnqi_1 (addr1, addr2, countreg, align, 17808 emit_insn (gen_cmpstrnqi_1 (addr1, addr2, countreg, align,
16876 operands[1], operands[2])); 17809 operands[1], operands[2]));
16877 } 17810 }
16878 17811
16879 outlow = gen_lowpart (QImode, out); 17812 out = gen_lowpart (QImode, operands[0]);
16880 emit_insn (gen_cmpintqi (outlow)); 17813 emit_insn (gen_cmpintqi (out));
16881 emit_move_insn (out, gen_rtx_SIGN_EXTEND (SImode, outlow)); 17814 emit_move_insn (operands[0], gen_rtx_SIGN_EXTEND (SImode, out));
16882
16883 if (operands[0] != out)
16884 emit_move_insn (operands[0], out);
16885 17815
16886 DONE; 17816 DONE;
16887 }) 17817 })
16888 17818
16889 ;; Produce a tri-state integer (-1, 0, 1) from condition codes. 17819 ;; Produce a tri-state integer (-1, 0, 1) from condition codes.
17174 (set_attr "use_carry" "1") 18104 (set_attr "use_carry" "1")
17175 (set_attr "pent_pair" "pu") 18105 (set_attr "pent_pair" "pu")
17176 (set_attr "mode" "<MODE>") 18106 (set_attr "mode" "<MODE>")
17177 (set_attr "length_immediate" "0")]) 18107 (set_attr "length_immediate" "0")])
17178 18108
18109 (define_insn_and_split "*x86_mov<SWI48:mode>cc_0_m1_neg_leu<SWI:mode>"
18110 [(set (match_operand:SWI48 0 "register_operand" "=r")
18111 (neg:SWI48
18112 (leu:SWI48
18113 (match_operand:SWI 1 "nonimmediate_operand" "<SWI:r>m")
18114 (match_operand:SWI 2 "<SWI:immediate_operand>" "<SWI:i>"))))
18115 (clobber (reg:CC FLAGS_REG))]
18116 "CONST_INT_P (operands[2])
18117 && INTVAL (operands[2]) != -1
18118 && INTVAL (operands[2]) != 2147483647"
18119 "#"
18120 ""
18121 [(set (reg:CC FLAGS_REG) (compare:CC (match_dup 1) (match_dup 2)))
18122 (parallel [(set (match_dup 0)
18123 (neg:SWI48 (ltu:SWI48 (reg:CC FLAGS_REG) (const_int 0))))
18124 (clobber (reg:CC FLAGS_REG))])]
18125 "operands[2] = GEN_INT (INTVAL (operands[2]) + 1);")
18126
17179 (define_insn "*mov<mode>cc_noc" 18127 (define_insn "*mov<mode>cc_noc"
17180 [(set (match_operand:SWI248 0 "register_operand" "=r,r") 18128 [(set (match_operand:SWI248 0 "register_operand" "=r,r")
17181 (if_then_else:SWI248 (match_operator 1 "ix86_comparison_operator" 18129 (if_then_else:SWI248 (match_operator 1 "ix86_comparison_operator"
17182 [(reg FLAGS_REG) (const_int 0)]) 18130 [(reg FLAGS_REG) (const_int 0)])
17183 (match_operand:SWI248 2 "nonimmediate_operand" "rm,0") 18131 (match_operand:SWI248 2 "nonimmediate_operand" "rm,0")
17556 (match_operand 1 "ordered_comparison_operator") 18504 (match_operand 1 "ordered_comparison_operator")
17557 (match_operand:SWI 2 "register_operand") 18505 (match_operand:SWI 2 "register_operand")
17558 (match_operand:SWI 3 "const_int_operand")] 18506 (match_operand:SWI 3 "const_int_operand")]
17559 "" 18507 ""
17560 "if (ix86_expand_int_addcc (operands)) DONE; else FAIL;") 18508 "if (ix86_expand_int_addcc (operands)) DONE; else FAIL;")
18509
18510 ;; min/max patterns
18511
18512 (define_mode_iterator MAXMIN_IMODE
18513 [(SI "TARGET_SSE4_1") (DI "TARGET_AVX512VL")])
18514 (define_code_attr maxmin_rel
18515 [(smax "GE") (smin "LE") (umax "GEU") (umin "LEU")])
18516
18517 (define_expand "<code><mode>3"
18518 [(parallel
18519 [(set (match_operand:MAXMIN_IMODE 0 "register_operand")
18520 (maxmin:MAXMIN_IMODE
18521 (match_operand:MAXMIN_IMODE 1 "register_operand")
18522 (match_operand:MAXMIN_IMODE 2 "nonimmediate_operand")))
18523 (clobber (reg:CC FLAGS_REG))])]
18524 "TARGET_STV")
18525
18526 (define_insn_and_split "*<code><mode>3_1"
18527 [(set (match_operand:MAXMIN_IMODE 0 "register_operand")
18528 (maxmin:MAXMIN_IMODE
18529 (match_operand:MAXMIN_IMODE 1 "register_operand")
18530 (match_operand:MAXMIN_IMODE 2 "nonimmediate_operand")))
18531 (clobber (reg:CC FLAGS_REG))]
18532 "(TARGET_64BIT || <MODE>mode != DImode) && TARGET_STV
18533 && ix86_pre_reload_split ()"
18534 "#"
18535 "&& 1"
18536 [(set (match_dup 0)
18537 (if_then_else:MAXMIN_IMODE (match_dup 3)
18538 (match_dup 1)
18539 (match_dup 2)))]
18540 {
18541 machine_mode mode = <MODE>mode;
18542
18543 if (!register_operand (operands[2], mode))
18544 operands[2] = force_reg (mode, operands[2]);
18545
18546 enum rtx_code code = <maxmin_rel>;
18547 machine_mode cmpmode = SELECT_CC_MODE (code, operands[1], operands[2]);
18548 rtx flags = gen_rtx_REG (cmpmode, FLAGS_REG);
18549
18550 rtx tmp = gen_rtx_COMPARE (cmpmode, operands[1], operands[2]);
18551 emit_insn (gen_rtx_SET (flags, tmp));
18552
18553 operands[3] = gen_rtx_fmt_ee (code, VOIDmode, flags, const0_rtx);
18554 })
18555
18556 (define_insn_and_split "*<code>di3_doubleword"
18557 [(set (match_operand:DI 0 "register_operand")
18558 (maxmin:DI (match_operand:DI 1 "register_operand")
18559 (match_operand:DI 2 "nonimmediate_operand")))
18560 (clobber (reg:CC FLAGS_REG))]
18561 "!TARGET_64BIT && TARGET_STV && TARGET_AVX512VL
18562 && ix86_pre_reload_split ()"
18563 "#"
18564 "&& 1"
18565 [(set (match_dup 0)
18566 (if_then_else:SI (match_dup 6)
18567 (match_dup 1)
18568 (match_dup 2)))
18569 (set (match_dup 3)
18570 (if_then_else:SI (match_dup 6)
18571 (match_dup 4)
18572 (match_dup 5)))]
18573 {
18574 if (!register_operand (operands[2], DImode))
18575 operands[2] = force_reg (DImode, operands[2]);
18576
18577 split_double_mode (DImode, &operands[0], 3, &operands[0], &operands[3]);
18578
18579 rtx cmplo[2] = { operands[1], operands[2] };
18580 rtx cmphi[2] = { operands[4], operands[5] };
18581
18582 enum rtx_code code = <maxmin_rel>;
18583
18584 switch (code)
18585 {
18586 case LE: case LEU:
18587 std::swap (cmplo[0], cmplo[1]);
18588 std::swap (cmphi[0], cmphi[1]);
18589 code = swap_condition (code);
18590 /* FALLTHRU */
18591
18592 case GE: case GEU:
18593 {
18594 bool uns = (code == GEU);
18595 rtx (*sbb_insn) (machine_mode, rtx, rtx, rtx)
18596 = uns ? gen_sub3_carry_ccc : gen_sub3_carry_ccgz;
18597
18598 emit_insn (gen_cmp_1 (SImode, cmplo[0], cmplo[1]));
18599
18600 rtx tmp = gen_rtx_SCRATCH (SImode);
18601 emit_insn (sbb_insn (SImode, tmp, cmphi[0], cmphi[1]));
18602
18603 rtx flags = gen_rtx_REG (uns ? CCCmode : CCGZmode, FLAGS_REG);
18604 operands[6] = gen_rtx_fmt_ee (code, VOIDmode, flags, const0_rtx);
18605
18606 break;
18607 }
18608
18609 default:
18610 gcc_unreachable ();
18611 }
18612 })
17561 18613
17562 ;; Misc patterns (?) 18614 ;; Misc patterns (?)
17563 18615
17564 ;; This pattern exists to put a dependency on all ebp-based memory accesses. 18616 ;; This pattern exists to put a dependency on all ebp-based memory accesses.
17565 ;; Otherwise there will be nothing to keep 18617 ;; Otherwise there will be nothing to keep
17569 ;; (clobber (eflags)] 18621 ;; (clobber (eflags)]
17570 ;; [(set (mem (plus (reg ebp) (const_int -160000))) (const_int 0))] 18622 ;; [(set (mem (plus (reg ebp) (const_int -160000))) (const_int 0))]
17571 ;; 18623 ;;
17572 ;; in proper program order. 18624 ;; in proper program order.
17573 18625
17574 (define_insn "pro_epilogue_adjust_stack_<mode>_add" 18626 (define_insn "@pro_epilogue_adjust_stack_add_<mode>"
17575 [(set (match_operand:P 0 "register_operand" "=r,r") 18627 [(set (match_operand:P 0 "register_operand" "=r,r")
17576 (plus:P (match_operand:P 1 "register_operand" "0,r") 18628 (plus:P (match_operand:P 1 "register_operand" "0,r")
17577 (match_operand:P 2 "<nonmemory_operand>" "r<i>,l<i>"))) 18629 (match_operand:P 2 "<nonmemory_operand>" "r<i>,l<i>")))
17578 (clobber (reg:CC FLAGS_REG)) 18630 (clobber (reg:CC FLAGS_REG))
17579 (clobber (mem:BLK (scratch)))] 18631 (clobber (mem:BLK (scratch)))]
17612 (const_string "1") 18664 (const_string "1")
17613 ] 18665 ]
17614 (const_string "*"))) 18666 (const_string "*")))
17615 (set_attr "mode" "<MODE>")]) 18667 (set_attr "mode" "<MODE>")])
17616 18668
17617 (define_insn "pro_epilogue_adjust_stack_<mode>_sub" 18669 (define_insn "@pro_epilogue_adjust_stack_sub_<mode>"
17618 [(set (match_operand:P 0 "register_operand" "=r") 18670 [(set (match_operand:P 0 "register_operand" "=r")
17619 (minus:P (match_operand:P 1 "register_operand" "0") 18671 (minus:P (match_operand:P 1 "register_operand" "0")
17620 (match_operand:P 2 "register_operand" "r"))) 18672 (match_operand:P 2 "register_operand" "r")))
17621 (clobber (reg:CC FLAGS_REG)) 18673 (clobber (reg:CC FLAGS_REG))
17622 (clobber (mem:BLK (scratch)))] 18674 (clobber (mem:BLK (scratch)))]
17623 "" 18675 ""
17624 "sub{<imodesuffix>}\t{%2, %0|%0, %2}" 18676 "sub{<imodesuffix>}\t{%2, %0|%0, %2}"
17625 [(set_attr "type" "alu") 18677 [(set_attr "type" "alu")
17626 (set_attr "mode" "<MODE>")]) 18678 (set_attr "mode" "<MODE>")])
17627 18679
17628 (define_insn "allocate_stack_worker_probe_<mode>" 18680 (define_insn "@allocate_stack_worker_probe_<mode>"
17629 [(set (match_operand:P 0 "register_operand" "=a") 18681 [(set (match_operand:P 0 "register_operand" "=a")
17630 (unspec_volatile:P [(match_operand:P 1 "register_operand" "0")] 18682 (unspec_volatile:P [(match_operand:P 1 "register_operand" "0")]
17631 UNSPECV_STACK_PROBE)) 18683 UNSPECV_STACK_PROBE))
17632 (clobber (reg:CC FLAGS_REG))] 18684 (clobber (reg:CC FLAGS_REG))]
17633 "ix86_target_stack_probe ()" 18685 "ix86_target_stack_probe ()"
17649 if (CHECK_STACK_LIMIT && CONST_INT_P (operands[1]) 18701 if (CHECK_STACK_LIMIT && CONST_INT_P (operands[1])
17650 && INTVAL (operands[1]) < CHECK_STACK_LIMIT) 18702 && INTVAL (operands[1]) < CHECK_STACK_LIMIT)
17651 x = operands[1]; 18703 x = operands[1];
17652 else 18704 else
17653 { 18705 {
17654 rtx (*insn) (rtx, rtx);
17655
17656 x = copy_to_mode_reg (Pmode, operands[1]); 18706 x = copy_to_mode_reg (Pmode, operands[1]);
17657 18707
17658 insn = (TARGET_64BIT 18708 emit_insn (gen_allocate_stack_worker_probe (Pmode, x, x));
17659 ? gen_allocate_stack_worker_probe_di
17660 : gen_allocate_stack_worker_probe_si);
17661
17662 emit_insn (insn (x, x));
17663 } 18709 }
17664 18710
17665 x = expand_simple_binop (Pmode, MINUS, stack_pointer_rtx, x, 18711 x = expand_simple_binop (Pmode, MINUS, stack_pointer_rtx, x,
17666 stack_pointer_rtx, 0, OPTAB_DIRECT); 18712 stack_pointer_rtx, 0, OPTAB_DIRECT);
17667 18713
17674 18720
17675 (define_expand "probe_stack" 18721 (define_expand "probe_stack"
17676 [(match_operand 0 "memory_operand")] 18722 [(match_operand 0 "memory_operand")]
17677 "" 18723 ""
17678 { 18724 {
17679 rtx (*insn) (rtx, rtx) 18725 emit_insn (gen_probe_stack_1
17680 = (GET_MODE (operands[0]) == DImode 18726 (word_mode, operands[0], const0_rtx));
17681 ? gen_probe_stack_di : gen_probe_stack_si);
17682
17683 emit_insn (insn (operands[0], const0_rtx));
17684 DONE; 18727 DONE;
17685 }) 18728 })
17686 18729
17687 ;; Use OR for stack probes, this is shorter. 18730 ;; Use OR for stack probes, this is shorter.
17688 (define_insn "probe_stack_<mode>" 18731 (define_insn "@probe_stack_1_<mode>"
17689 [(set (match_operand:W 0 "memory_operand" "=m") 18732 [(set (match_operand:W 0 "memory_operand" "=m")
17690 (unspec:W [(match_operand:W 1 "const0_operand")] 18733 (unspec:W [(match_operand:W 1 "const0_operand")]
17691 UNSPEC_PROBE_STACK)) 18734 UNSPEC_PROBE_STACK))
17692 (clobber (reg:CC FLAGS_REG))] 18735 (clobber (reg:CC FLAGS_REG))]
17693 "" 18736 ""
17694 "or{<imodesuffix>}\t{%1, %0|%0, %1}" 18737 "or{<imodesuffix>}\t{%1, %0|%0, %1}"
17695 [(set_attr "type" "alu1") 18738 [(set_attr "type" "alu1")
17696 (set_attr "mode" "<MODE>") 18739 (set_attr "mode" "<MODE>")
17697 (set_attr "length_immediate" "1")]) 18740 (set_attr "length_immediate" "1")])
17698 18741
17699 (define_insn "adjust_stack_and_probe<mode>" 18742 (define_insn "@adjust_stack_and_probe_<mode>"
17700 [(set (match_operand:P 0 "register_operand" "=r") 18743 [(set (match_operand:P 0 "register_operand" "=r")
17701 (unspec_volatile:P [(match_operand:P 1 "register_operand" "0")] 18744 (unspec_volatile:P [(match_operand:P 1 "register_operand" "0")]
17702 UNSPECV_PROBE_STACK_RANGE)) 18745 UNSPECV_PROBE_STACK_RANGE))
17703 (set (reg:P SP_REG) 18746 (set (reg:P SP_REG)
17704 (minus:P (reg:P SP_REG) (match_operand:P 2 "const_int_operand" "n"))) 18747 (minus:P (reg:P SP_REG) (match_operand:P 2 "const_int_operand" "n")))
17706 (clobber (mem:BLK (scratch)))] 18749 (clobber (mem:BLK (scratch)))]
17707 "" 18750 ""
17708 "* return output_adjust_stack_and_probe (operands[0]);" 18751 "* return output_adjust_stack_and_probe (operands[0]);"
17709 [(set_attr "type" "multi")]) 18752 [(set_attr "type" "multi")])
17710 18753
17711 (define_insn "probe_stack_range<mode>" 18754 (define_insn "@probe_stack_range_<mode>"
17712 [(set (match_operand:P 0 "register_operand" "=r") 18755 [(set (match_operand:P 0 "register_operand" "=r")
17713 (unspec_volatile:P [(match_operand:P 1 "register_operand" "0") 18756 (unspec_volatile:P [(match_operand:P 1 "register_operand" "0")
17714 (match_operand:P 2 "const_int_operand" "n")] 18757 (match_operand:P 2 "const_int_operand" "n")]
17715 UNSPECV_PROBE_STACK_RANGE)) 18758 UNSPECV_PROBE_STACK_RANGE))
17716 (clobber (reg:CC FLAGS_REG))] 18759 (clobber (reg:CC FLAGS_REG))]
18337 19380
18338 ;; Likewise for instances where we have a lea pattern. 19381 ;; Likewise for instances where we have a lea pattern.
18339 (define_peephole2 19382 (define_peephole2
18340 [(set (match_operand:SWI 0 "register_operand") 19383 [(set (match_operand:SWI 0 "register_operand")
18341 (match_operand:SWI 1 "memory_operand")) 19384 (match_operand:SWI 1 "memory_operand"))
18342 (set (match_operand:SWI 3 "register_operand") 19385 (set (match_operand:<LEAMODE> 3 "register_operand")
18343 (plus:SWI (match_dup 0) 19386 (plus:<LEAMODE> (match_operand:<LEAMODE> 4 "register_operand")
18344 (match_operand:SWI 2 "<nonmemory_operand>"))) 19387 (match_operand:<LEAMODE> 2 "<nonmemory_operand>")))
18345 (set (match_dup 1) (match_dup 3)) 19388 (set (match_dup 1) (match_operand:SWI 5 "register_operand"))
18346 (set (reg FLAGS_REG) (compare (match_dup 3) (const_int 0)))] 19389 (set (reg FLAGS_REG) (compare (match_dup 5) (const_int 0)))]
18347 "(TARGET_READ_MODIFY_WRITE || optimize_insn_for_size_p ()) 19390 "(TARGET_READ_MODIFY_WRITE || optimize_insn_for_size_p ())
19391 && REGNO (operands[4]) == REGNO (operands[0])
19392 && REGNO (operands[5]) == REGNO (operands[3])
18348 && peep2_reg_dead_p (4, operands[3]) 19393 && peep2_reg_dead_p (4, operands[3])
18349 && (rtx_equal_p (operands[0], operands[3]) 19394 && ((REGNO (operands[0]) == REGNO (operands[3]))
18350 || peep2_reg_dead_p (2, operands[0])) 19395 || peep2_reg_dead_p (2, operands[0]))
18351 && !reg_overlap_mentioned_p (operands[0], operands[1]) 19396 && !reg_overlap_mentioned_p (operands[0], operands[1])
18352 && !reg_overlap_mentioned_p (operands[3], operands[1]) 19397 && !reg_overlap_mentioned_p (operands[3], operands[1])
18353 && !reg_overlap_mentioned_p (operands[0], operands[2]) 19398 && !reg_overlap_mentioned_p (operands[0], operands[2])
18354 && (<MODE>mode != QImode 19399 && (<MODE>mode != QImode
18355 || immediate_operand (operands[2], QImode) 19400 || immediate_operand (operands[2], QImode)
18356 || any_QIreg_operand (operands[2], QImode)) 19401 || any_QIreg_operand (operands[2], QImode))
18357 && ix86_match_ccmode (peep2_next_insn (3), CCGOCmode)" 19402 && ix86_match_ccmode (peep2_next_insn (3), CCGOCmode)"
18358 [(parallel [(set (match_dup 4) (match_dup 6)) 19403 [(parallel [(set (match_dup 6) (match_dup 8))
18359 (set (match_dup 1) (match_dup 5))])] 19404 (set (match_dup 1) (match_dup 7))])]
18360 { 19405 {
18361 operands[4] = SET_DEST (PATTERN (peep2_next_insn (3))); 19406 operands[6] = SET_DEST (PATTERN (peep2_next_insn (3)));
18362 operands[5] 19407 operands[7]
18363 = gen_rtx_PLUS (<MODE>mode, 19408 = gen_rtx_PLUS (<MODE>mode,
18364 copy_rtx (operands[1]), 19409 copy_rtx (operands[1]),
18365 operands[2]); 19410 gen_lowpart (<MODE>mode, operands[2]));
18366 operands[6] 19411 operands[8]
18367 = gen_rtx_COMPARE (GET_MODE (operands[4]), 19412 = gen_rtx_COMPARE (GET_MODE (operands[6]),
18368 copy_rtx (operands[5]), 19413 copy_rtx (operands[7]),
18369 const0_rtx); 19414 const0_rtx);
18370 }) 19415 })
18371 19416
18372 (define_peephole2 19417 (define_peephole2
18373 [(parallel [(set (match_operand:SWI 0 "register_operand") 19418 [(parallel [(set (match_operand:SWI 0 "register_operand")
18446 && !reg_overlap_mentioned_p (operands[0], operands[2]) 19491 && !reg_overlap_mentioned_p (operands[0], operands[2])
18447 && ix86_match_ccmode (peep2_next_insn (3), 19492 && ix86_match_ccmode (peep2_next_insn (3),
18448 (GET_CODE (operands[3]) == PLUS 19493 (GET_CODE (operands[3]) == PLUS
18449 || GET_CODE (operands[3]) == MINUS) 19494 || GET_CODE (operands[3]) == MINUS)
18450 ? CCGOCmode : CCNOmode)" 19495 ? CCGOCmode : CCNOmode)"
18451 [(parallel [(set (match_dup 4) (match_dup 6)) 19496 [(parallel [(set (match_dup 5) (match_dup 7))
18452 (set (match_dup 1) (match_dup 5))])] 19497 (set (match_dup 1) (match_dup 6))])]
18453 { 19498 {
18454 operands[4] = SET_DEST (PATTERN (peep2_next_insn (3))); 19499 operands[5] = SET_DEST (PATTERN (peep2_next_insn (3)));
18455 operands[5] 19500 operands[6]
18456 = gen_rtx_fmt_ee (GET_CODE (operands[3]), <MODE>mode, 19501 = gen_rtx_fmt_ee (GET_CODE (operands[3]), <MODE>mode,
18457 copy_rtx (operands[1]), 19502 copy_rtx (operands[1]),
18458 gen_lowpart (<MODE>mode, operands[2])); 19503 gen_lowpart (<MODE>mode, operands[2]));
19504 operands[7]
19505 = gen_rtx_COMPARE (GET_MODE (operands[5]),
19506 copy_rtx (operands[6]),
19507 const0_rtx);
19508 })
19509
19510 ;; peephole2 comes before regcprop, so deal also with a case that
19511 ;; would be cleaned up by regcprop.
19512 (define_peephole2
19513 [(set (match_operand:SWI 0 "register_operand")
19514 (match_operand:SWI 1 "memory_operand"))
19515 (parallel [(set (match_dup 0)
19516 (match_operator:SWI 3 "plusminuslogic_operator"
19517 [(match_dup 0)
19518 (match_operand:SWI 2 "<nonmemory_operand>")]))
19519 (clobber (reg:CC FLAGS_REG))])
19520 (set (match_operand:SWI 4 "register_operand") (match_dup 0))
19521 (set (match_dup 1) (match_dup 4))
19522 (set (reg FLAGS_REG) (compare (match_dup 4) (const_int 0)))]
19523 "(TARGET_READ_MODIFY_WRITE || optimize_insn_for_size_p ())
19524 && peep2_reg_dead_p (3, operands[0])
19525 && peep2_reg_dead_p (5, operands[4])
19526 && !reg_overlap_mentioned_p (operands[0], operands[1])
19527 && !reg_overlap_mentioned_p (operands[0], operands[2])
19528 && !reg_overlap_mentioned_p (operands[4], operands[1])
19529 && (<MODE>mode != QImode
19530 || immediate_operand (operands[2], QImode)
19531 || any_QIreg_operand (operands[2], QImode))
19532 && ix86_match_ccmode (peep2_next_insn (4),
19533 (GET_CODE (operands[3]) == PLUS
19534 || GET_CODE (operands[3]) == MINUS)
19535 ? CCGOCmode : CCNOmode)"
19536 [(parallel [(set (match_dup 5) (match_dup 7))
19537 (set (match_dup 1) (match_dup 6))])]
19538 {
19539 operands[5] = SET_DEST (PATTERN (peep2_next_insn (4)));
18459 operands[6] 19540 operands[6]
18460 = gen_rtx_COMPARE (GET_MODE (operands[4]), 19541 = gen_rtx_fmt_ee (GET_CODE (operands[3]), GET_MODE (operands[3]),
18461 copy_rtx (operands[5]), 19542 copy_rtx (operands[1]),
19543 operands[2]);
19544 operands[7]
19545 = gen_rtx_COMPARE (GET_MODE (operands[5]),
19546 copy_rtx (operands[6]),
18462 const0_rtx); 19547 const0_rtx);
18463 }) 19548 })
19549
19550 (define_peephole2
19551 [(set (match_operand:SWI12 0 "register_operand")
19552 (match_operand:SWI12 1 "memory_operand"))
19553 (parallel [(set (match_operand:SI 4 "register_operand")
19554 (match_operator:SI 3 "plusminuslogic_operator"
19555 [(match_dup 4)
19556 (match_operand:SI 2 "nonmemory_operand")]))
19557 (clobber (reg:CC FLAGS_REG))])
19558 (set (match_operand:SWI12 5 "register_operand") (match_dup 0))
19559 (set (match_dup 1) (match_dup 5))
19560 (set (reg FLAGS_REG) (compare (match_dup 5) (const_int 0)))]
19561 "(TARGET_READ_MODIFY_WRITE || optimize_insn_for_size_p ())
19562 && REGNO (operands[0]) == REGNO (operands[4])
19563 && peep2_reg_dead_p (3, operands[0])
19564 && peep2_reg_dead_p (5, operands[5])
19565 && (<MODE>mode != QImode
19566 || immediate_operand (operands[2], SImode)
19567 || any_QIreg_operand (operands[2], SImode))
19568 && !reg_overlap_mentioned_p (operands[0], operands[1])
19569 && !reg_overlap_mentioned_p (operands[0], operands[2])
19570 && !reg_overlap_mentioned_p (operands[5], operands[1])
19571 && ix86_match_ccmode (peep2_next_insn (4),
19572 (GET_CODE (operands[3]) == PLUS
19573 || GET_CODE (operands[3]) == MINUS)
19574 ? CCGOCmode : CCNOmode)"
19575 [(parallel [(set (match_dup 6) (match_dup 8))
19576 (set (match_dup 1) (match_dup 7))])]
19577 {
19578 operands[6] = SET_DEST (PATTERN (peep2_next_insn (4)));
19579 operands[7]
19580 = gen_rtx_fmt_ee (GET_CODE (operands[3]), <MODE>mode,
19581 copy_rtx (operands[1]),
19582 gen_lowpart (<MODE>mode, operands[2]));
19583 operands[8]
19584 = gen_rtx_COMPARE (GET_MODE (operands[6]),
19585 copy_rtx (operands[7]),
19586 const0_rtx);
19587 })
19588
19589 ;; Likewise for cmpelim optimized pattern.
19590 (define_peephole2
19591 [(set (match_operand:SWI 0 "register_operand")
19592 (match_operand:SWI 1 "memory_operand"))
19593 (parallel [(set (reg FLAGS_REG)
19594 (compare (match_operator:SWI 3 "plusminuslogic_operator"
19595 [(match_dup 0)
19596 (match_operand:SWI 2 "<nonmemory_operand>")])
19597 (const_int 0)))
19598 (set (match_dup 0) (match_dup 3))])
19599 (set (match_operand:SWI 4 "register_operand") (match_dup 0))
19600 (set (match_dup 1) (match_dup 4))]
19601 "(TARGET_READ_MODIFY_WRITE || optimize_insn_for_size_p ())
19602 && peep2_reg_dead_p (3, operands[0])
19603 && peep2_reg_dead_p (4, operands[4])
19604 && !reg_overlap_mentioned_p (operands[0], operands[1])
19605 && !reg_overlap_mentioned_p (operands[0], operands[2])
19606 && !reg_overlap_mentioned_p (operands[4], operands[1])
19607 && ix86_match_ccmode (peep2_next_insn (1),
19608 (GET_CODE (operands[3]) == PLUS
19609 || GET_CODE (operands[3]) == MINUS)
19610 ? CCGOCmode : CCNOmode)"
19611 [(parallel [(set (match_dup 5) (match_dup 7))
19612 (set (match_dup 1) (match_dup 6))])]
19613 {
19614 operands[5] = SET_DEST (XVECEXP (PATTERN (peep2_next_insn (1)), 0, 0));
19615 operands[6]
19616 = gen_rtx_fmt_ee (GET_CODE (operands[3]), GET_MODE (operands[3]),
19617 copy_rtx (operands[1]), operands[2]);
19618 operands[7]
19619 = gen_rtx_COMPARE (GET_MODE (operands[5]), copy_rtx (operands[6]),
19620 const0_rtx);
19621 })
19622
19623 ;; Special cases for xor, where (x ^= y) != 0 is (misoptimized)
19624 ;; into x = z; x ^= y; x != z
19625 (define_peephole2
19626 [(set (match_operand:SWI 0 "register_operand")
19627 (match_operand:SWI 1 "memory_operand"))
19628 (set (match_operand:SWI 3 "register_operand") (match_dup 0))
19629 (parallel [(set (match_operand:SWI 4 "register_operand")
19630 (xor:SWI (match_dup 4)
19631 (match_operand:SWI 2 "<nonmemory_operand>")))
19632 (clobber (reg:CC FLAGS_REG))])
19633 (set (match_dup 1) (match_dup 4))
19634 (set (reg:CCZ FLAGS_REG)
19635 (compare:CCZ (match_operand:SWI 5 "register_operand")
19636 (match_operand:SWI 6 "<nonmemory_operand>")))]
19637 "(TARGET_READ_MODIFY_WRITE || optimize_insn_for_size_p ())
19638 && (REGNO (operands[4]) == REGNO (operands[0])
19639 || REGNO (operands[4]) == REGNO (operands[3]))
19640 && (rtx_equal_p (operands[REGNO (operands[4]) == REGNO (operands[0])
19641 ? 3 : 0], operands[5])
19642 ? rtx_equal_p (operands[2], operands[6])
19643 : rtx_equal_p (operands[2], operands[5])
19644 && rtx_equal_p (operands[REGNO (operands[4]) == REGNO (operands[0])
19645 ? 3 : 0], operands[6]))
19646 && peep2_reg_dead_p (4, operands[4])
19647 && peep2_reg_dead_p (5, operands[REGNO (operands[4]) == REGNO (operands[0])
19648 ? 3 : 0])
19649 && !reg_overlap_mentioned_p (operands[0], operands[1])
19650 && !reg_overlap_mentioned_p (operands[0], operands[2])
19651 && !reg_overlap_mentioned_p (operands[3], operands[0])
19652 && !reg_overlap_mentioned_p (operands[3], operands[1])
19653 && !reg_overlap_mentioned_p (operands[3], operands[2])
19654 && (<MODE>mode != QImode
19655 || immediate_operand (operands[2], QImode)
19656 || any_QIreg_operand (operands[2], QImode))"
19657 [(parallel [(set (match_dup 7) (match_dup 9))
19658 (set (match_dup 1) (match_dup 8))])]
19659 {
19660 operands[7] = SET_DEST (PATTERN (peep2_next_insn (4)));
19661 operands[8] = gen_rtx_XOR (<MODE>mode, copy_rtx (operands[1]),
19662 operands[2]);
19663 operands[9]
19664 = gen_rtx_COMPARE (GET_MODE (operands[7]),
19665 copy_rtx (operands[8]),
19666 const0_rtx);
19667 })
19668
19669 (define_peephole2
19670 [(set (match_operand:SWI12 0 "register_operand")
19671 (match_operand:SWI12 1 "memory_operand"))
19672 (set (match_operand:SWI12 3 "register_operand") (match_dup 0))
19673 (parallel [(set (match_operand:SI 4 "register_operand")
19674 (xor:SI (match_dup 4)
19675 (match_operand:SI 2 "<nonmemory_operand>")))
19676 (clobber (reg:CC FLAGS_REG))])
19677 (set (match_dup 1) (match_operand:SWI12 5 "register_operand"))
19678 (set (reg:CCZ FLAGS_REG)
19679 (compare:CCZ (match_operand:SWI12 6 "register_operand")
19680 (match_operand:SWI12 7 "<nonmemory_operand>")))]
19681 "(TARGET_READ_MODIFY_WRITE || optimize_insn_for_size_p ())
19682 && (REGNO (operands[5]) == REGNO (operands[0])
19683 || REGNO (operands[5]) == REGNO (operands[3]))
19684 && REGNO (operands[5]) == REGNO (operands[4])
19685 && (rtx_equal_p (operands[REGNO (operands[5]) == REGNO (operands[0])
19686 ? 3 : 0], operands[6])
19687 ? (REG_P (operands[2])
19688 ? REG_P (operands[7]) && REGNO (operands[2]) == REGNO (operands[7])
19689 : rtx_equal_p (operands[2], operands[7]))
19690 : (rtx_equal_p (operands[REGNO (operands[5]) == REGNO (operands[0])
19691 ? 3 : 0], operands[7])
19692 && REG_P (operands[2])
19693 && REGNO (operands[2]) == REGNO (operands[6])))
19694 && peep2_reg_dead_p (4, operands[5])
19695 && peep2_reg_dead_p (5, operands[REGNO (operands[5]) == REGNO (operands[0])
19696 ? 3 : 0])
19697 && !reg_overlap_mentioned_p (operands[0], operands[1])
19698 && !reg_overlap_mentioned_p (operands[0], operands[2])
19699 && !reg_overlap_mentioned_p (operands[3], operands[0])
19700 && !reg_overlap_mentioned_p (operands[3], operands[1])
19701 && !reg_overlap_mentioned_p (operands[3], operands[2])
19702 && (<MODE>mode != QImode
19703 || immediate_operand (operands[2], SImode)
19704 || any_QIreg_operand (operands[2], SImode))"
19705 [(parallel [(set (match_dup 8) (match_dup 10))
19706 (set (match_dup 1) (match_dup 9))])]
19707 {
19708 operands[8] = SET_DEST (PATTERN (peep2_next_insn (4)));
19709 operands[9] = gen_rtx_XOR (<MODE>mode, copy_rtx (operands[1]),
19710 gen_lowpart (<MODE>mode, operands[2]));
19711 operands[10]
19712 = gen_rtx_COMPARE (GET_MODE (operands[8]),
19713 copy_rtx (operands[9]),
19714 const0_rtx);
19715 })
19716
19717 ;; Attempt to optimize away memory stores of values the memory already
19718 ;; has. See PR79593.
19719 (define_peephole2
19720 [(set (match_operand 0 "register_operand")
19721 (match_operand 1 "memory_operand"))
19722 (set (match_operand 2 "memory_operand") (match_dup 0))]
19723 "!MEM_VOLATILE_P (operands[1])
19724 && !MEM_VOLATILE_P (operands[2])
19725 && rtx_equal_p (operands[1], operands[2])
19726 && !reg_overlap_mentioned_p (operands[0], operands[2])"
19727 [(set (match_dup 0) (match_dup 1))])
18464 19728
18465 ;; Attempt to always use XOR for zeroing registers (including FP modes). 19729 ;; Attempt to always use XOR for zeroing registers (including FP modes).
18466 (define_peephole2 19730 (define_peephole2
18467 [(set (match_operand 0 "general_reg_operand") 19731 [(set (match_operand 0 "general_reg_operand")
18468 (match_operand 1 "const0_operand"))] 19732 (match_operand 1 "const0_operand"))]
18900 [(prefetch (match_operand 0 "address_operand") 20164 [(prefetch (match_operand 0 "address_operand")
18901 (match_operand:SI 1 "const_int_operand") 20165 (match_operand:SI 1 "const_int_operand")
18902 (match_operand:SI 2 "const_int_operand"))] 20166 (match_operand:SI 2 "const_int_operand"))]
18903 "TARGET_3DNOW || TARGET_PREFETCH_SSE || TARGET_PRFCHW || TARGET_PREFETCHWT1" 20167 "TARGET_3DNOW || TARGET_PREFETCH_SSE || TARGET_PRFCHW || TARGET_PREFETCHWT1"
18904 { 20168 {
18905 bool write = INTVAL (operands[1]) != 0; 20169 bool write = operands[1] != const0_rtx;
18906 int locality = INTVAL (operands[2]); 20170 int locality = INTVAL (operands[2]);
18907 20171
18908 gcc_assert (IN_RANGE (locality, 0, 3)); 20172 gcc_assert (IN_RANGE (locality, 0, 3));
18909 20173
18910 /* Use 3dNOW prefetch in case we are asking for write prefetch not 20174 /* Use 3dNOW prefetch in case we are asking for write prefetch not
18965 [(prefetch (match_operand 0 "address_operand" "p") 20229 [(prefetch (match_operand 0 "address_operand" "p")
18966 (match_operand:SI 1 "const_int_operand" "n") 20230 (match_operand:SI 1 "const_int_operand" "n")
18967 (const_int 3))] 20231 (const_int 3))]
18968 "TARGET_3DNOW || TARGET_PRFCHW || TARGET_PREFETCHWT1" 20232 "TARGET_3DNOW || TARGET_PRFCHW || TARGET_PREFETCHWT1"
18969 { 20233 {
18970 if (INTVAL (operands[1]) == 0) 20234 if (operands[1] == const0_rtx)
18971 return "prefetch\t%a0"; 20235 return "prefetch\t%a0";
18972 else 20236 else
18973 return "prefetchw\t%a0"; 20237 return "prefetchw\t%a0";
18974 } 20238 }
18975 [(set_attr "type" "mmx") 20239 [(set_attr "type" "mmx")
18989 (set_attr "memory" "none")]) 20253 (set_attr "memory" "none")])
18990 20254
18991 (define_expand "stack_protect_set" 20255 (define_expand "stack_protect_set"
18992 [(match_operand 0 "memory_operand") 20256 [(match_operand 0 "memory_operand")
18993 (match_operand 1 "memory_operand")] 20257 (match_operand 1 "memory_operand")]
18994 "TARGET_SSP_TLS_GUARD" 20258 ""
18995 { 20259 {
18996 rtx (*insn)(rtx, rtx); 20260 emit_insn (gen_stack_protect_set_1
18997 20261 (ptr_mode, operands[0], operands[1]));
18998 insn = (TARGET_LP64
18999 ? gen_stack_protect_set_di
19000 : gen_stack_protect_set_si);
19001
19002 emit_insn (insn (operands[0], operands[1]));
19003 DONE; 20262 DONE;
19004 }) 20263 })
19005 20264
19006 (define_insn "stack_protect_set_<mode>" 20265 (define_insn "@stack_protect_set_1_<mode>"
19007 [(set (match_operand:PTR 0 "memory_operand" "=m") 20266 [(set (match_operand:PTR 0 "memory_operand" "=m")
19008 (unspec:PTR [(match_operand:PTR 1 "memory_operand" "m")] 20267 (unspec:PTR [(match_operand:PTR 1 "memory_operand" "m")]
19009 UNSPEC_SP_SET)) 20268 UNSPEC_SP_SET))
19010 (set (match_scratch:PTR 2 "=&r") (const_int 0)) 20269 (set (match_scratch:PTR 2 "=&r") (const_int 0))
19011 (clobber (reg:CC FLAGS_REG))] 20270 (clobber (reg:CC FLAGS_REG))]
19012 "TARGET_SSP_TLS_GUARD" 20271 ""
19013 "mov{<imodesuffix>}\t{%1, %2|%2, %1}\;mov{<imodesuffix>}\t{%2, %0|%0, %2}\;xor{l}\t%k2, %k2" 20272 {
20273 output_asm_insn ("mov{<imodesuffix>}\t{%1, %2|%2, %1}", operands);
20274 output_asm_insn ("mov{<imodesuffix>}\t{%2, %0|%0, %2}", operands);
20275 return "xor{l}\t%k2, %k2";
20276 }
19014 [(set_attr "type" "multi")]) 20277 [(set_attr "type" "multi")])
20278
20279 ;; Patterns and peephole2s to optimize stack_protect_set_1_<mode>
20280 ;; immediately followed by *mov{s,d}i_internal to the same register,
20281 ;; where we can avoid the xor{l} above. We don't split this, so that
20282 ;; scheduling or anything else doesn't separate the *stack_protect_set*
20283 ;; pattern from the set of the register that overwrites the register
20284 ;; with a new value.
20285 (define_insn "*stack_protect_set_2_<mode>"
20286 [(set (match_operand:PTR 0 "memory_operand" "=m")
20287 (unspec:PTR [(match_operand:PTR 3 "memory_operand" "m")]
20288 UNSPEC_SP_SET))
20289 (set (match_operand:SI 1 "register_operand" "=&r")
20290 (match_operand:SI 2 "general_operand" "g"))
20291 (clobber (reg:CC FLAGS_REG))]
20292 "reload_completed
20293 && !reg_overlap_mentioned_p (operands[1], operands[2])"
20294 {
20295 output_asm_insn ("mov{<imodesuffix>}\t{%3, %<k>1|%<k>1, %3}", operands);
20296 output_asm_insn ("mov{<imodesuffix>}\t{%<k>1, %0|%0, %<k>1}", operands);
20297 if (pic_32bit_operand (operands[2], SImode)
20298 || ix86_use_lea_for_mov (insn, operands + 1))
20299 return "lea{l}\t{%E2, %1|%1, %E2}";
20300 else
20301 return "mov{l}\t{%2, %1|%1, %2}";
20302 }
20303 [(set_attr "type" "multi")
20304 (set_attr "length" "24")])
20305
20306 (define_peephole2
20307 [(parallel [(set (match_operand:PTR 0 "memory_operand")
20308 (unspec:PTR [(match_operand:PTR 1 "memory_operand")]
20309 UNSPEC_SP_SET))
20310 (set (match_operand:PTR 2 "general_reg_operand") (const_int 0))
20311 (clobber (reg:CC FLAGS_REG))])
20312 (set (match_operand:SI 3 "general_reg_operand")
20313 (match_operand:SI 4))]
20314 "REGNO (operands[2]) == REGNO (operands[3])
20315 && general_operand (operands[4], SImode)
20316 && (general_reg_operand (operands[4], SImode)
20317 || memory_operand (operands[4], SImode)
20318 || immediate_operand (operands[4], SImode))
20319 && !reg_overlap_mentioned_p (operands[3], operands[4])"
20320 [(parallel [(set (match_dup 0)
20321 (unspec:PTR [(match_dup 1)] UNSPEC_SP_SET))
20322 (set (match_dup 3) (match_dup 4))
20323 (clobber (reg:CC FLAGS_REG))])])
20324
20325 (define_insn "*stack_protect_set_3"
20326 [(set (match_operand:DI 0 "memory_operand" "=m,m,m")
20327 (unspec:DI [(match_operand:DI 3 "memory_operand" "m,m,m")]
20328 UNSPEC_SP_SET))
20329 (set (match_operand:DI 1 "register_operand" "=&r,r,r")
20330 (match_operand:DI 2 "general_operand" "Z,rem,i"))
20331 (clobber (reg:CC FLAGS_REG))]
20332 "TARGET_64BIT
20333 && reload_completed
20334 && !reg_overlap_mentioned_p (operands[1], operands[2])"
20335 {
20336 output_asm_insn ("mov{q}\t{%3, %1|%1, %3}", operands);
20337 output_asm_insn ("mov{q}\t{%1, %0|%0, %1}", operands);
20338 if (pic_32bit_operand (operands[2], DImode))
20339 return "lea{q}\t{%E2, %1|%1, %E2}";
20340 else if (which_alternative == 0)
20341 return "mov{l}\t{%k2, %k1|%k1, %k2}";
20342 else if (which_alternative == 2)
20343 return "movabs{q}\t{%2, %1|%1, %2}";
20344 else if (ix86_use_lea_for_mov (insn, operands + 1))
20345 return "lea{q}\t{%E2, %1|%1, %E2}";
20346 else
20347 return "mov{q}\t{%2, %1|%1, %2}";
20348 }
20349 [(set_attr "type" "multi")
20350 (set_attr "length" "24")])
20351
20352 (define_peephole2
20353 [(parallel [(set (match_operand:DI 0 "memory_operand")
20354 (unspec:DI [(match_operand:DI 1 "memory_operand")]
20355 UNSPEC_SP_SET))
20356 (set (match_operand:DI 2 "general_reg_operand") (const_int 0))
20357 (clobber (reg:CC FLAGS_REG))])
20358 (set (match_dup 2) (match_operand:DI 3))]
20359 "TARGET_64BIT
20360 && general_operand (operands[3], DImode)
20361 && (general_reg_operand (operands[3], DImode)
20362 || memory_operand (operands[3], DImode)
20363 || x86_64_zext_immediate_operand (operands[3], DImode)
20364 || x86_64_immediate_operand (operands[3], DImode)
20365 || (CONSTANT_P (operands[3])
20366 && (!flag_pic || LEGITIMATE_PIC_OPERAND_P (operands[3]))))
20367 && !reg_overlap_mentioned_p (operands[2], operands[3])"
20368 [(parallel [(set (match_dup 0)
20369 (unspec:PTR [(match_dup 1)] UNSPEC_SP_SET))
20370 (set (match_dup 2) (match_dup 3))
20371 (clobber (reg:CC FLAGS_REG))])])
19015 20372
19016 (define_expand "stack_protect_test" 20373 (define_expand "stack_protect_test"
19017 [(match_operand 0 "memory_operand") 20374 [(match_operand 0 "memory_operand")
19018 (match_operand 1 "memory_operand") 20375 (match_operand 1 "memory_operand")
19019 (match_operand 2)] 20376 (match_operand 2)]
19020 "TARGET_SSP_TLS_GUARD" 20377 ""
19021 { 20378 {
19022 rtx flags = gen_rtx_REG (CCZmode, FLAGS_REG); 20379 rtx flags = gen_rtx_REG (CCZmode, FLAGS_REG);
19023 20380
19024 rtx (*insn)(rtx, rtx, rtx); 20381 emit_insn (gen_stack_protect_test_1
19025 20382 (ptr_mode, flags, operands[0], operands[1]));
19026 insn = (TARGET_LP64
19027 ? gen_stack_protect_test_di
19028 : gen_stack_protect_test_si);
19029
19030 emit_insn (insn (flags, operands[0], operands[1]));
19031 20383
19032 emit_jump_insn (gen_cbranchcc4 (gen_rtx_EQ (VOIDmode, flags, const0_rtx), 20384 emit_jump_insn (gen_cbranchcc4 (gen_rtx_EQ (VOIDmode, flags, const0_rtx),
19033 flags, const0_rtx, operands[2])); 20385 flags, const0_rtx, operands[2]));
19034 DONE; 20386 DONE;
19035 }) 20387 })
19036 20388
19037 (define_insn "stack_protect_test_<mode>" 20389 (define_insn "@stack_protect_test_1_<mode>"
19038 [(set (match_operand:CCZ 0 "flags_reg_operand") 20390 [(set (match_operand:CCZ 0 "flags_reg_operand")
19039 (unspec:CCZ [(match_operand:PTR 1 "memory_operand" "m") 20391 (unspec:CCZ [(match_operand:PTR 1 "memory_operand" "m")
19040 (match_operand:PTR 2 "memory_operand" "m")] 20392 (match_operand:PTR 2 "memory_operand" "m")]
19041 UNSPEC_SP_TEST)) 20393 UNSPEC_SP_TEST))
19042 (clobber (match_scratch:PTR 3 "=&r"))] 20394 (clobber (match_scratch:PTR 3 "=&r"))]
19043 "TARGET_SSP_TLS_GUARD" 20395 ""
19044 "mov{<imodesuffix>}\t{%1, %3|%3, %1}\;xor{<imodesuffix>}\t{%2, %3|%3, %2}" 20396 {
20397 output_asm_insn ("mov{<imodesuffix>}\t{%1, %3|%3, %1}", operands);
20398 return "sub{<imodesuffix>}\t{%2, %3|%3, %2}";
20399 }
19045 [(set_attr "type" "multi")]) 20400 [(set_attr "type" "multi")])
19046 20401
19047 (define_insn "sse4_2_crc32<mode>" 20402 (define_insn "sse4_2_crc32<mode>"
19048 [(set (match_operand:SI 0 "register_operand" "=r") 20403 [(set (match_operand:SI 0 "register_operand" "=r")
19049 (unspec:SI 20404 (unspec:SI
19404 (define_expand "lwp_llwpcb" 20759 (define_expand "lwp_llwpcb"
19405 [(unspec_volatile [(match_operand 0 "register_operand")] 20760 [(unspec_volatile [(match_operand 0 "register_operand")]
19406 UNSPECV_LLWP_INTRINSIC)] 20761 UNSPECV_LLWP_INTRINSIC)]
19407 "TARGET_LWP") 20762 "TARGET_LWP")
19408 20763
19409 (define_insn "*lwp_llwpcb<mode>1" 20764 (define_insn "*lwp_llwpcb<mode>_1"
19410 [(unspec_volatile [(match_operand:P 0 "register_operand" "r")] 20765 [(unspec_volatile [(match_operand:P 0 "register_operand" "r")]
19411 UNSPECV_LLWP_INTRINSIC)] 20766 UNSPECV_LLWP_INTRINSIC)]
19412 "TARGET_LWP" 20767 "TARGET_LWP"
19413 "llwpcb\t%0" 20768 "llwpcb\t%0"
19414 [(set_attr "type" "lwp") 20769 [(set_attr "type" "lwp")
19417 20772
19418 (define_expand "lwp_slwpcb" 20773 (define_expand "lwp_slwpcb"
19419 [(set (match_operand 0 "register_operand") 20774 [(set (match_operand 0 "register_operand")
19420 (unspec_volatile [(const_int 0)] UNSPECV_SLWP_INTRINSIC))] 20775 (unspec_volatile [(const_int 0)] UNSPECV_SLWP_INTRINSIC))]
19421 "TARGET_LWP" 20776 "TARGET_LWP"
19422 { 20777 "emit_insn (gen_lwp_slwpcb_1 (Pmode, operands[0])); DONE;")
19423 rtx (*insn)(rtx); 20778
19424 20779 (define_insn "@lwp_slwpcb<mode>_1"
19425 insn = (Pmode == DImode
19426 ? gen_lwp_slwpcbdi
19427 : gen_lwp_slwpcbsi);
19428
19429 emit_insn (insn (operands[0]));
19430 DONE;
19431 })
19432
19433 (define_insn "lwp_slwpcb<mode>"
19434 [(set (match_operand:P 0 "register_operand" "=r") 20780 [(set (match_operand:P 0 "register_operand" "=r")
19435 (unspec_volatile:P [(const_int 0)] UNSPECV_SLWP_INTRINSIC))] 20781 (unspec_volatile:P [(const_int 0)] UNSPECV_SLWP_INTRINSIC))]
19436 "TARGET_LWP" 20782 "TARGET_LWP"
19437 "slwpcb\t%0" 20783 "slwpcb\t%0"
19438 [(set_attr "type" "lwp") 20784 [(set_attr "type" "lwp")
19511 "TARGET_64BIT && TARGET_FSGSBASE" 20857 "TARGET_64BIT && TARGET_FSGSBASE"
19512 "wr<fsgs>base\t%0" 20858 "wr<fsgs>base\t%0"
19513 [(set_attr "type" "other") 20859 [(set_attr "type" "other")
19514 (set_attr "prefix_extra" "2")]) 20860 (set_attr "prefix_extra" "2")])
19515 20861
20862 (define_insn "ptwrite<mode>"
20863 [(unspec_volatile [(match_operand:SWI48 0 "nonimmediate_operand" "rm")]
20864 UNSPECV_PTWRITE)]
20865 "TARGET_PTWRITE"
20866 "ptwrite\t%0"
20867 [(set_attr "type" "other")
20868 (set_attr "prefix_extra" "2")])
20869
19516 (define_insn "rdrand<mode>_1" 20870 (define_insn "rdrand<mode>_1"
19517 [(set (match_operand:SWI248 0 "register_operand" "=r") 20871 [(set (match_operand:SWI248 0 "register_operand" "=r")
19518 (unspec_volatile:SWI248 [(const_int 0)] UNSPECV_RDRAND)) 20872 (unspec_volatile:SWI248 [(const_int 0)] UNSPECV_RDRAND))
19519 (set (reg:CCC FLAGS_REG) 20873 (set (reg:CCC FLAGS_REG)
19520 (unspec_volatile:CCC [(const_int 0)] UNSPECV_RDRAND))] 20874 (unspec_volatile:CCC [(const_int 0)] UNSPECV_RDRAND))]
19737 ;; Since 32bit register operands are implicitly zero extended to 64bit, 21091 ;; Since 32bit register operands are implicitly zero extended to 64bit,
19738 ;; we only need to set up 32bit registers. 21092 ;; we only need to set up 32bit registers.
19739 "mwaitx" 21093 "mwaitx"
19740 [(set_attr "length" "3")]) 21094 [(set_attr "length" "3")])
19741 21095
19742 (define_insn "monitorx_<mode>" 21096 (define_insn "@monitorx_<mode>"
19743 [(unspec_volatile [(match_operand:P 0 "register_operand" "a") 21097 [(unspec_volatile [(match_operand:P 0 "register_operand" "a")
19744 (match_operand:SI 1 "register_operand" "c") 21098 (match_operand:SI 1 "register_operand" "c")
19745 (match_operand:SI 2 "register_operand" "d")] 21099 (match_operand:SI 2 "register_operand" "d")]
19746 UNSPECV_MONITORX)] 21100 UNSPECV_MONITORX)]
19747 "TARGET_MWAITX" 21101 "TARGET_MWAITX"
19751 "%^monitorx" 21105 "%^monitorx"
19752 [(set (attr "length") 21106 [(set (attr "length")
19753 (symbol_ref ("(Pmode != word_mode) + 3")))]) 21107 (symbol_ref ("(Pmode != word_mode) + 3")))])
19754 21108
19755 ;; CLZERO 21109 ;; CLZERO
19756 (define_insn "clzero_<mode>" 21110 (define_insn "@clzero_<mode>"
19757 [(unspec_volatile [(match_operand: P 0 "register_operand" "a")] 21111 [(unspec_volatile [(match_operand: P 0 "register_operand" "a")]
19758 UNSPECV_CLZERO)] 21112 UNSPECV_CLZERO)]
19759 "TARGET_CLZERO" 21113 "TARGET_CLZERO"
19760 "clzero" 21114 "clzero"
19761 [(set_attr "length" "3") 21115 [(set_attr "length" "3")
19839 UNSPECV_MOVDIRI)] 21193 UNSPECV_MOVDIRI)]
19840 "TARGET_MOVDIRI" 21194 "TARGET_MOVDIRI"
19841 "movdiri\t{%1, %0|%0, %1}" 21195 "movdiri\t{%1, %0|%0, %1}"
19842 [(set_attr "type" "other")]) 21196 [(set_attr "type" "other")])
19843 21197
19844 (define_insn "movdir64b_<mode>" 21198 (define_insn "@movdir64b_<mode>"
19845 [(unspec_volatile:XI [(match_operand:P 0 "register_operand" "r") 21199 [(unspec_volatile:XI [(match_operand:P 0 "register_operand" "r")
19846 (match_operand:XI 1 "memory_operand")] 21200 (match_operand:XI 1 "memory_operand")]
19847 UNSPECV_MOVDIR64B)] 21201 UNSPECV_MOVDIR64B)]
19848 "TARGET_MOVDIR64B" 21202 "TARGET_MOVDIR64B"
19849 "movdir64b\t{%1, %0|%0, %1}" 21203 "movdir64b\t{%1, %0|%0, %1}"
21204 [(set_attr "type" "other")])
21205
21206 ;; ENQCMD and ENQCMDS
21207
21208 (define_int_iterator ENQCMD [UNSPECV_ENQCMD UNSPECV_ENQCMDS])
21209 (define_int_attr enqcmd_sfx [(UNSPECV_ENQCMD "") (UNSPECV_ENQCMDS "s")])
21210
21211 (define_insn "@enqcmd<enqcmd_sfx>_<mode>"
21212 [(set (reg:CCZ FLAGS_REG)
21213 (unspec_volatile:CCZ [(match_operand:P 0 "register_operand" "r")
21214 (match_operand:XI 1 "memory_operand" "m")]
21215 ENQCMD))]
21216 "TARGET_ENQCMD"
21217 "enqcmd<enqcmd_sfx>\t{%1, %0|%0, %1}"
19850 [(set_attr "type" "other")]) 21218 [(set_attr "type" "other")])
19851 21219
19852 ;; WAITPKG 21220 ;; WAITPKG
19853 21221
19854 (define_insn "umwait" 21222 (define_insn "umwait"
19868 UNSPECV_UMWAIT))] 21236 UNSPECV_UMWAIT))]
19869 "TARGET_64BIT && TARGET_WAITPKG" 21237 "TARGET_64BIT && TARGET_WAITPKG"
19870 "umwait\t%0" 21238 "umwait\t%0"
19871 [(set_attr "length" "3")]) 21239 [(set_attr "length" "3")])
19872 21240
19873 (define_insn "umonitor_<mode>" 21241 (define_insn "@umonitor_<mode>"
19874 [(unspec_volatile [(match_operand:P 0 "register_operand" "r")] 21242 [(unspec_volatile [(match_operand:P 0 "register_operand" "r")]
19875 UNSPECV_UMONITOR)] 21243 UNSPECV_UMONITOR)]
19876 "TARGET_WAITPKG" 21244 "TARGET_WAITPKG"
19877 "umonitor\t%0" 21245 "umonitor\t%0"
19878 [(set (attr "length") 21246 [(set (attr "length")