On Mon, Aug 22, 2011 at 8:51 PM, Kirill Yukhin <kirill.yuk...@gmail.com> wrote:
> Attached fix for http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50155 > > ChangeLog entry: > 2011-08-22 Kirill Yukhin <kirill.yuk...@intel.com> > > PR target/50155 > * config/i386/sse.md (VI1248_AVX2): New. > (<plusminus_insn><mode>3): Update. > (*<plusminus_insn><mode>3): Likewise. > (<sse2_avx2>_andnot<mode>3): Likewise. > (avx2_pbroadcast<mode>): Likewise. > > testsuite/ChangeLog entry: > 2011-08-22 Kirill Yukhin <kirill.yuk...@intel.com> > > PR target/50155 > * gcc.target/i386/pr50155.c: New test. > > New test fails without fix, passed with it applied. > > Ok for trunk if bootstrap will success? No. - you are disabling andnotps for 256bit integer modes on !TARGET_AVX2 targets. - avx2_pbroadcast change is a no-op. I found two additional problems with the patch: - order of evaluation of cond RTX in mode attribute calculation is wrong for *andnot<mode>3 and *<any_logic:code><mode>3 instructions. - shortmode mode attribute is not used (minor) Attached (lightly tested) patch fixes all problems and adds additional asserts into mentioned logic instructions. Uros.
Index: sse.md =================================================================== --- sse.md (revision 177968) +++ sse.md (working copy) @@ -73,6 +73,12 @@ (V8SI "TARGET_AVX") V4SI (V4DI "TARGET_AVX") V2DI]) +(define_mode_iterator VI_AVX2 + [(V32QI "TARGET_AVX2") V16QI + (V16HI "TARGET_AVX2") V8HI + (V8SI "TARGET_AVX2") V4SI + (V4DI "TARGET_AVX2") V2DI]) + ;; All QImode vector integer modes (define_mode_iterator VI1 [(V32QI "TARGET_AVX") V16QI]) @@ -124,8 +130,8 @@ [V4SI V4DI]) (define_mode_iterator V48_AVX2 - [(V4SF "TARGET_SSE") (V2DF "TARGET_SSE2") - (V8SF "TARGET_AVX") (V4DF "TARGET_AVX") + [V4SF V2DF + V8SF V4DF (V4SI "TARGET_AVX2") (V2DI "TARGET_AVX2") (V8SI "TARGET_AVX2") (V4DI "TARGET_AVX2")]) @@ -170,9 +176,6 @@ (define_mode_attr ssebytemode [(V4DI "V32QI") (V2DI "V16QI")]) -(define_mode_attr shortmode - [(V4DI "v4si") (V2DI "v2si")]) - ;; All 128bit vector integer modes (define_mode_iterator VI_128 [V16QI V8HI V4SI V2DI]) @@ -4641,18 +4644,18 @@ "operands[2] = force_reg (<MODE>mode, CONST0_RTX (<MODE>mode));") (define_expand "<plusminus_insn><mode>3" - [(set (match_operand:VI 0 "register_operand" "") - (plusminus:VI - (match_operand:VI 1 "nonimmediate_operand" "") - (match_operand:VI 2 "nonimmediate_operand" "")))] + [(set (match_operand:VI_AVX2 0 "register_operand" "") + (plusminus:VI_AVX2 + (match_operand:VI_AVX2 1 "nonimmediate_operand" "") + (match_operand:VI_AVX2 2 "nonimmediate_operand" "")))] "TARGET_SSE2" "ix86_fixup_binary_operands_no_copy (<CODE>, <MODE>mode, operands);") (define_insn "*<plusminus_insn><mode>3" - [(set (match_operand:VI 0 "register_operand" "=x,x") - (plusminus:VI - (match_operand:VI 1 "nonimmediate_operand" "<comm>0,x") - (match_operand:VI 2 "nonimmediate_operand" "xm,xm")))] + [(set (match_operand:VI_AVX2 0 "register_operand" "=x,x") + (plusminus:VI_AVX2 + (match_operand:VI_AVX2 1 "nonimmediate_operand" "<comm>0,x") + (match_operand:VI_AVX2 2 "nonimmediate_operand" "xm,xm")))] "TARGET_SSE2 && ix86_binary_operator_ok (<CODE>, <MODE>mode, operands)" "@ p<plusminus_mnemonic><ssemodesuffix>\t{%2, %0|%0, %2} @@ -6176,10 +6179,30 @@ { static char buf[32]; const char *ops; - const char *tmp - = ((get_attr_mode (insn) == MODE_TI) || - (get_attr_mode (insn) == MODE_OI)) ? "pandn" : "andnps"; + const char *tmp; + switch (get_attr_mode (insn)) + { + case MODE_OI: + gcc_assert (TARGET_AVX2); + case MODE_TI: + gcc_assert (TARGET_SSE2); + + tmp = "pandn"; + break; + + case MODE_V8SF: + gcc_assert (TARGET_AVX); + case MODE_V4SF: + gcc_assert (TARGET_SSE); + + tmp = "andnps"; + break; + + default: + gcc_unreachable (); + } + switch (which_alternative) { case 0: @@ -6205,12 +6228,12 @@ (const_string "*"))) (set_attr "prefix" "orig,vex") (set (attr "mode") - (cond [(ne (symbol_ref "GET_MODE_SIZE (<MODE>mode) > 128") (const_int 0)) + (cond [(ne (symbol_ref "TARGET_AVX2") (const_int 0)) + (const_string "OI") + (ne (symbol_ref "GET_MODE_SIZE (<MODE>mode) > 128") (const_int 0)) (const_string "V8SF") (ne (symbol_ref "TARGET_SSE2") (const_int 0)) (const_string "TI") - (ne (symbol_ref "TARGET_AVX2") (const_int 0)) - (const_string "OI") ] (const_string "V4SF")))]) @@ -6232,10 +6255,30 @@ { static char buf[32]; const char *ops; - const char *tmp - = (get_attr_mode (insn) == MODE_TI)|| - (get_attr_mode (insn) == MODE_OI) ? "p<logic>" : "<logic>ps"; + const char *tmp; + switch (get_attr_mode (insn)) + { + case MODE_OI: + gcc_assert (TARGET_AVX2); + case MODE_TI: + gcc_assert (TARGET_SSE2); + + tmp = "p<logic>"; + break; + + case MODE_V8SF: + gcc_assert (TARGET_AVX); + case MODE_V4SF: + gcc_assert (TARGET_SSE); + + tmp = "<logic>ps"; + break; + + default: + gcc_unreachable (); + } + switch (which_alternative) { case 0: @@ -6261,12 +6304,12 @@ (const_string "*"))) (set_attr "prefix" "orig,vex") (set (attr "mode") - (cond [(ne (symbol_ref "GET_MODE_SIZE (<MODE>mode) > 128") (const_int 0)) + (cond [(ne (symbol_ref "TARGET_AVX2") (const_int 0)) + (const_string "OI") + (ne (symbol_ref "GET_MODE_SIZE (<MODE>mode) > 128") (const_int 0)) (const_string "V8SF") (ne (symbol_ref "TARGET_SSE2") (const_int 0)) (const_string "TI") - (ne (symbol_ref "TARGET_AVX2") (const_int 0)) - (const_string "OI") ] (const_string "V4SF")))])