From patchwork Mon Aug 22 19:09:21 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Uros Bizjak X-Patchwork-Id: 110972 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 9ACCFB6F7C for ; Tue, 23 Aug 2011 05:09:41 +1000 (EST) Received: (qmail 10233 invoked by alias); 22 Aug 2011 19:09:40 -0000 Received: (qmail 10224 invoked by uid 22791); 22 Aug 2011 19:09:38 -0000 X-SWARE-Spam-Status: No, hits=-2.3 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, TW_AV X-Spam-Check-By: sourceware.org Received: from mail-pz0-f49.google.com (HELO mail-pz0-f49.google.com) (209.85.210.49) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 22 Aug 2011 19:09:22 +0000 Received: by pzk6 with SMTP id 6so12207794pzk.8 for ; Mon, 22 Aug 2011 12:09:21 -0700 (PDT) MIME-Version: 1.0 Received: by 10.68.71.168 with SMTP id w8mr296196pbu.471.1314040161514; Mon, 22 Aug 2011 12:09:21 -0700 (PDT) Received: by 10.143.13.8 with HTTP; Mon, 22 Aug 2011 12:09:21 -0700 (PDT) In-Reply-To: References: Date: Mon, 22 Aug 2011 21:09:21 +0200 Message-ID: Subject: Re: [PATCH, test, i386] Fix for PR50155 From: Uros Bizjak To: Kirill Yukhin Cc: gcc-patches List , Jakub Jelinek , "H.J. Lu" Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org On Mon, Aug 22, 2011 at 8:51 PM, Kirill Yukhin wrote: > Attached fix for http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50155 > > ChangeLog entry: > 2011-08-22  Kirill Yukhin   > >        PR target/50155 >        * config/i386/sse.md (VI1248_AVX2): New. >        (3): Update. >        (*3): Likewise. >        (_andnot3): Likewise. >        (avx2_pbroadcast): Likewise. > > testsuite/ChangeLog entry: > 2011-08-22  Kirill Yukhin   > >        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 *andnot3 and *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, CONST0_RTX (mode));") (define_expand "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 (, mode, operands);") (define_insn "*3" - [(set (match_operand:VI 0 "register_operand" "=x,x") - (plusminus:VI - (match_operand:VI 1 "nonimmediate_operand" "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" "0,x") + (match_operand:VI_AVX2 2 "nonimmediate_operand" "xm,xm")))] "TARGET_SSE2 && ix86_binary_operator_ok (, mode, operands)" "@ p\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) > 128") (const_int 0)) + (cond [(ne (symbol_ref "TARGET_AVX2") (const_int 0)) + (const_string "OI") + (ne (symbol_ref "GET_MODE_SIZE (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" : "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"; + break; + + case MODE_V8SF: + gcc_assert (TARGET_AVX); + case MODE_V4SF: + gcc_assert (TARGET_SSE); + + tmp = "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) > 128") (const_int 0)) + (cond [(ne (symbol_ref "TARGET_AVX2") (const_int 0)) + (const_string "OI") + (ne (symbol_ref "GET_MODE_SIZE (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")))])