From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 95863 invoked by alias); 31 Mar 2017 21:40:43 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 95847 invoked by uid 89); 31 Mar 2017 21:40:43 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-23.7 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,KAM_LAZY_DOMAIN_SECURITY,RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy= X-HELO: gcc1-power7.osuosl.org Received: from gcc1-power7.osuosl.org (HELO gcc1-power7.osuosl.org) (140.211.15.137) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 31 Mar 2017 21:40:42 +0000 Received: by gcc1-power7.osuosl.org (Postfix, from userid 10019) id 88DD41C00A3; Fri, 31 Mar 2017 21:40:39 +0000 (UTC) From: Segher Boessenkool To: gcc-patches@gcc.gnu.org Cc: Segher Boessenkool Subject: [PATCH] simplify-rtx: Fix compare of comparisons (PR60818) Date: Fri, 31 Mar 2017 22:50:00 -0000 Message-Id: X-IsSubscribed: yes X-SW-Source: 2017-03/txt/msg01595.txt.bz2 The function simplify_binary_operation_1 has code that does /* Convert (compare (gt (flags) 0) (lt (flags) 0)) to (flags). */ but this transformation is only valid if "flags" has the same machine mode as the outer compare. This fixes it. Bootstrapped and tested on powerpc64-linux {-m32,-m64} (and tested the new testcase with {-m32,-m64}{,-misel}). Is this okay for trunk? Segher 2017-03-31 Segher Boessenkool PR rtl-optimization/60818 * simplify-rtx.c (simplify_binary_operation_1): Do not replace a compare of comparisons with the thing compared if this results in a different machine mode. gcc/testsuite/ PR rtl-optimization/60818 * gcc.c-torture/compile/pr60818.c: New testcase. --- gcc/simplify-rtx.c | 6 +++--- gcc/testsuite/gcc.c-torture/compile/pr60818.c | 5 +++++ 2 files changed, 8 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/gcc.c-torture/compile/pr60818.c diff --git a/gcc/simplify-rtx.c b/gcc/simplify-rtx.c index 3022779..10c2800 100644 --- a/gcc/simplify-rtx.c +++ b/gcc/simplify-rtx.c @@ -2367,10 +2367,10 @@ return xop00; if (REG_P (xop00) && REG_P (xop10) - && GET_MODE (xop00) == GET_MODE (xop10) && REGNO (xop00) == REGNO (xop10) - && GET_MODE_CLASS (GET_MODE (xop00)) == MODE_CC - && GET_MODE_CLASS (GET_MODE (xop10)) == MODE_CC) + && GET_MODE (xop00) == mode + && GET_MODE (xop10) == mode + && GET_MODE_CLASS (mode) == MODE_CC) return xop00; } break; diff --git a/gcc/testsuite/gcc.c-torture/compile/pr60818.c b/gcc/testsuite/gcc.c-torture/compile/pr60818.c new file mode 100644 index 0000000..b6171bb --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr60818.c @@ -0,0 +1,5 @@ +int +lx (int oi, int mb) +{ + return (oi < mb) < (mb < oi); +} -- 1.9.3