From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by sourceware.org (Postfix) with ESMTPS id A8D38398AC36 for ; Tue, 30 Aug 2022 06:46:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org A8D38398AC36 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 6F7CC222F6; Tue, 30 Aug 2022 06:46:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1661842013; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=0hykG1NSoon6HhyUY5y8Gqg/aW6L0YtiHEMxV7prHD0=; b=fQ6bRi4tfHapqROi8bWaKqKyKHfXD8rSyIc74xsPZQttLL8WOuFkUbKYavoP2w02nPpsZQ S7lYeUcXXlEd5UUwYLkcICVduSxSn+qTDmp8ZYAFc+elubYsKjabjs3TLZJV1iGXzS0Zji SckQCYwPVUQWlaUSsfKQWxVtTgqLT2k= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1661842013; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=0hykG1NSoon6HhyUY5y8Gqg/aW6L0YtiHEMxV7prHD0=; b=8Dyf8ceU+I3vxJB0yC/GH42RgcNcnXf58MWQcP6G4O6XFRZN30822Xqp3oiNkLtmB+SKKp 24vrUs413WDhlOCw== Received: from wotan.suse.de (wotan.suse.de [10.160.0.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 659C82C141; Tue, 30 Aug 2022 06:46:53 +0000 (UTC) Date: Tue, 30 Aug 2022 06:46:53 +0000 (UTC) From: Richard Biener To: Tamar Christina cc: gcc-patches@gcc.gnu.org, nd@arm.com Subject: Re: [PATCH]middle-end: fix min/max phiopts reduction [PR106744] In-Reply-To: Message-ID: References: User-Agent: Alpine 2.22 (LSU 394 2020-01-19) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-10.9 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,KAM_LOTSOFHASH,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Tue, 30 Aug 2022, Tamar Christina wrote: > Hi All, > > This corrects the argument usage to use them in the order that they occur in > the comparisons in gimple. > > This was tested by disabling the pass, adding the runtime checks and re-enabling > the pass and verifying the tests still pass. > > Also tested that the runtime test caught the issue by updating the tests on an > unpatched tree and observing that some fail. > > Bootstrapped Regtested on aarch64-none-linux-gnu and no issues. > > Ok for master? OK. > Thanks, > Tamar > > gcc/ChangeLog: > > PR tree-optimization/106744 > * tree-ssa-phiopt.cc (minmax_replacement): Correct arguments. > > gcc/testsuite/ChangeLog: > > PR tree-optimization/106744 > * gcc.dg/tree-ssa/minmax-10.c: Make runtime test. > * gcc.dg/tree-ssa/minmax-11.c: Likewise. > * gcc.dg/tree-ssa/minmax-12.c: Likewise. > * gcc.dg/tree-ssa/minmax-13.c: Likewise. > * gcc.dg/tree-ssa/minmax-14.c: Likewise. > * gcc.dg/tree-ssa/minmax-15.c: Likewise. > * gcc.dg/tree-ssa/minmax-16.c: Likewise. > * gcc.dg/tree-ssa/minmax-3.c: Likewise. > * gcc.dg/tree-ssa/minmax-4.c: Likewise. > * gcc.dg/tree-ssa/minmax-5.c: Likewise. > * gcc.dg/tree-ssa/minmax-6.c: Likewise. > * gcc.dg/tree-ssa/minmax-7.c: Likewise. > * gcc.dg/tree-ssa/minmax-8.c: Likewise. > * gcc.dg/tree-ssa/minmax-9.c: Likewise. > > --- inline copy of patch -- > diff --git a/gcc/testsuite/gcc.dg/tree-ssa/minmax-10.c b/gcc/testsuite/gcc.dg/tree-ssa/minmax-10.c > index 589953684416a9d263084deb58f6cde7094dd517..c9322a17a4af8e01add2f04176805c812af62e07 100644 > --- a/gcc/testsuite/gcc.dg/tree-ssa/minmax-10.c > +++ b/gcc/testsuite/gcc.dg/tree-ssa/minmax-10.c > @@ -1,8 +1,9 @@ > -/* { dg-do compile } */ > +/* { dg-do run } */ > /* { dg-options "-O -fdump-tree-optimized" } */ > > #include > > +__attribute__ ((noipa, noinline)) > uint8_t three_max (uint8_t xc, uint8_t xm, uint8_t xy) { > uint8_t xk; > xc=~xc; > @@ -16,5 +17,16 @@ uint8_t three_max (uint8_t xc, uint8_t xm, uint8_t xy) { > return xk; > } > > +int > +main (void) > +{ > + volatile uint8_t xy = 255; > + volatile uint8_t xm = 0; > + volatile uint8_t xc = 127; > + if (three_max (xc, xm, xy) != 255) > + __builtin_abort (); > + return 0; > +} > + > /* { dg-final { scan-tree-dump-times "MIN_EXPR" 2 "optimized" } } */ > /* { dg-final { scan-tree-dump-times "= ~" 1 "optimized" } } */ > diff --git a/gcc/testsuite/gcc.dg/tree-ssa/minmax-11.c b/gcc/testsuite/gcc.dg/tree-ssa/minmax-11.c > index 1c2ef01b5d1e639fbf95bb5ca473b63cc98e9df1..b1da41712b342cd7344167a0da91ffd419491391 100644 > --- a/gcc/testsuite/gcc.dg/tree-ssa/minmax-11.c > +++ b/gcc/testsuite/gcc.dg/tree-ssa/minmax-11.c > @@ -1,8 +1,10 @@ > -/* { dg-do compile } */ > +/* { dg-do run } */ > /* { dg-options "-O -fdump-tree-optimized" } */ > > #include > > + > +__attribute__ ((noipa, noinline)) > uint8_t three_minmax1 (uint8_t xc, uint8_t xm, uint8_t xy) { > uint8_t xk; > xc=~xc; > @@ -16,6 +18,17 @@ uint8_t three_minmax1 (uint8_t xc, uint8_t xm, uint8_t xy) { > return xk; > } > > +int > +main (void) > +{ > + volatile uint8_t xy = 255; > + volatile uint8_t xm = 0; > + volatile uint8_t xc = 127; > + if (three_minmax1 (xc, xm, xy) != 0) > + __builtin_abort (); > + return 0; > +} > + > /* { dg-final { scan-tree-dump-times "MIN_EXPR" 1 "optimized" } } */ > /* { dg-final { scan-tree-dump-times "MAX_EXPR" 1 "optimized" } } */ > /* { dg-final { scan-tree-dump-times "= ~" 1 "optimized" } } */ > diff --git a/gcc/testsuite/gcc.dg/tree-ssa/minmax-12.c b/gcc/testsuite/gcc.dg/tree-ssa/minmax-12.c > index 3d0c07d9b57dd689bcb89653937727ab441e7f2b..cb9188f90e8e12c6244d559e63723177102177ee 100644 > --- a/gcc/testsuite/gcc.dg/tree-ssa/minmax-12.c > +++ b/gcc/testsuite/gcc.dg/tree-ssa/minmax-12.c > @@ -1,8 +1,9 @@ > -/* { dg-do compile } */ > +/* { dg-do run } */ > /* { dg-options "-O -fdump-tree-phiopt" } */ > > #include > > +__attribute__ ((noinline, noipa)) > uint8_t three_minmax3 (uint8_t xc, uint8_t xm, uint8_t xy) { > uint8_t xk; > xc=~xc; > @@ -16,5 +17,16 @@ uint8_t three_minmax3 (uint8_t xc, uint8_t xm, uint8_t xy) { > return xk; > } > > +int > +main (void) > +{ > + volatile uint8_t xy = 255; > + volatile uint8_t xm = 0; > + volatile uint8_t xc = 127; > + if (three_minmax3 (xc, xm, xy) != 0) > + __builtin_abort (); > + return 0; > +} > + > /* { dg-final { scan-tree-dump-times "MIN_EXPR" 1 "phiopt1" } } */ > /* { dg-final { scan-tree-dump-times "MAX_EXPR" 1 "phiopt1" } } */ > diff --git a/gcc/testsuite/gcc.dg/tree-ssa/minmax-13.c b/gcc/testsuite/gcc.dg/tree-ssa/minmax-13.c > index c0d0f27c8027ae87654532d1b919cfeccf4413e0..62ba71e8c3f21f1cb33ae2473fd2b30bfdc13c81 100644 > --- a/gcc/testsuite/gcc.dg/tree-ssa/minmax-13.c > +++ b/gcc/testsuite/gcc.dg/tree-ssa/minmax-13.c > @@ -1,8 +1,9 @@ > -/* { dg-do compile } */ > +/* { dg-do run } */ > /* { dg-options "-O -fdump-tree-phiopt" } */ > > #include > > +__attribute__ ((noipa, noinline)) > uint8_t three_minmax2 (uint8_t xc, uint8_t xm, uint8_t xy) { > uint8_t xk; > xc=~xc; > @@ -15,5 +16,17 @@ uint8_t three_minmax2 (uint8_t xc, uint8_t xm, uint8_t xy) { > } > return xk; > } > + > +int > +main (void) > +{ > + volatile uint8_t xy = 255; > + volatile uint8_t xm = 127; > + volatile uint8_t xc = 0; > + if (three_minmax2 (xc, xm, xy) != 255) > + __builtin_abort (); > + return 0; > +} > + > /* { dg-final { scan-tree-dump-times "MIN_EXPR" 1 "phiopt1" } } */ > /* { dg-final { scan-tree-dump-times "MAX_EXPR" 1 "phiopt1" } } */ > diff --git a/gcc/testsuite/gcc.dg/tree-ssa/minmax-14.c b/gcc/testsuite/gcc.dg/tree-ssa/minmax-14.c > index 9c0cadbf7e3119527cb2007d01fe4c7dd772c069..a3ec58460838ebbcfa5451a2471dde07608a38e3 100644 > --- a/gcc/testsuite/gcc.dg/tree-ssa/minmax-14.c > +++ b/gcc/testsuite/gcc.dg/tree-ssa/minmax-14.c > @@ -1,8 +1,9 @@ > -/* { dg-do compile } */ > +/* { dg-do run } */ > /* { dg-options "-O -fdump-tree-optimized" } */ > > #include > > +__attribute__ ((noipa, noinline)) > uint8_t three_minmax11 (uint8_t xc, uint8_t xm, uint8_t xy) { > uint8_t xk; > xc=~xc; > @@ -16,6 +17,17 @@ uint8_t three_minmax11 (uint8_t xc, uint8_t xm, uint8_t xy) { > return xk; > } > > +int > +main (void) > +{ > + volatile uint8_t xy = 255; > + volatile uint8_t xm = 0; > + volatile uint8_t xc = 127; > + if (three_minmax11 (xc, xm, xy) != 128) > + __builtin_abort (); > + return 0; > +} > + > /* { dg-final { scan-tree-dump-times "MIN_EXPR" 1 "optimized" } } */ > /* { dg-final { scan-tree-dump-times "MAX_EXPR" 1 "optimized" } } */ > /* { dg-final { scan-tree-dump-times "= ~" 1 "optimized" } } */ > diff --git a/gcc/testsuite/gcc.dg/tree-ssa/minmax-15.c b/gcc/testsuite/gcc.dg/tree-ssa/minmax-15.c > index 1d97a16564f069b4348ff325c4fd713a224f838a..8a39871c93890b553dc8d4aed494c2f14f8508fe 100644 > --- a/gcc/testsuite/gcc.dg/tree-ssa/minmax-15.c > +++ b/gcc/testsuite/gcc.dg/tree-ssa/minmax-15.c > @@ -1,10 +1,11 @@ > -/* { dg-do compile } */ > +/* { dg-do run } */ > /* { dg-options "-O -fdump-tree-phiopt" } */ > > #include > #include > > -uint8_t three_min (uint8_t xc, uint8_t xm, uint8_t xy, bool m) { > +__attribute__ ((noinline, noipa)) > +uint8_t three_min (uint8_t xc, uint8_t xm, uint8_t xy) { > uint8_t xk; > if (xc) > { > @@ -17,5 +18,17 @@ uint8_t three_min (uint8_t xc, uint8_t xm, uint8_t xy, bool m) { > > return xk; > } > + > +int > +main (void) > +{ > + volatile uint8_t xy = 255; > + volatile uint8_t xm = 0; > + volatile uint8_t xc = 127; > + if (three_min (xc, xm, xy) != 0) > + __builtin_abort (); > + return 0; > +} > + > /* { dg-final { scan-tree-dump-times "MIN_EXPR" 3 "phiopt1" } } */ > /* { dg-final { scan-tree-dump-times "MAX_EXPR" 0 "phiopt1" } } */ > diff --git a/gcc/testsuite/gcc.dg/tree-ssa/minmax-16.c b/gcc/testsuite/gcc.dg/tree-ssa/minmax-16.c > index 89377a2cb341bdafa6ba145c61c1f966af536839..4febd092d837542017438bcc4f8554fdb05c4adf 100644 > --- a/gcc/testsuite/gcc.dg/tree-ssa/minmax-16.c > +++ b/gcc/testsuite/gcc.dg/tree-ssa/minmax-16.c > @@ -1,8 +1,9 @@ > -/* { dg-do compile } */ > +/* { dg-do run } */ > /* { dg-options "-O -fdump-tree-phiopt -g" } */ > > #include > > +__attribute__ ((noipa, noinline)) > uint8_t three_min (uint8_t xc, uint8_t xm, uint8_t xy) { > uint8_t xk; > if (xc < xm) { > @@ -13,5 +14,16 @@ uint8_t three_min (uint8_t xc, uint8_t xm, uint8_t xy) { > return xk; > } > > +int > +main (void) > +{ > + volatile uint8_t xy = 255; > + volatile uint8_t xm = 0; > + volatile uint8_t xc = 127; > + if (three_min (xc, xm, xy) != 0) > + __builtin_abort (); > + return 0; > +} > + > /* { dg-final { scan-tree-dump-times "MIN_EXPR" 3 "phiopt1" } } */ > /* { dg-final { scan-tree-dump-times "MAX_EXPR" 0 "phiopt1" } } */ > diff --git a/gcc/testsuite/gcc.dg/tree-ssa/minmax-3.c b/gcc/testsuite/gcc.dg/tree-ssa/minmax-3.c > index de3b2e946e81701e3b75f580e6a843695a05786e..2af107763469cd16401b618f0e6b556e5ac2b04d 100644 > --- a/gcc/testsuite/gcc.dg/tree-ssa/minmax-3.c > +++ b/gcc/testsuite/gcc.dg/tree-ssa/minmax-3.c > @@ -1,8 +1,9 @@ > -/* { dg-do compile } */ > +/* { dg-do run } */ > /* { dg-options "-O -fdump-tree-phiopt" } */ > > #include > > +__attribute__ ((noipa, noinline)) > uint8_t three_min (uint8_t xc, uint8_t xm, uint8_t xy) { > uint8_t xk; > if (xc < xm) { > @@ -13,5 +14,16 @@ uint8_t three_min (uint8_t xc, uint8_t xm, uint8_t xy) { > return xk; > } > > +int > +main (void) > +{ > + volatile uint8_t xy = 255; > + volatile uint8_t xm = 0; > + volatile uint8_t xc = 127; > + if (three_min (xc, xm, xy) != 0) > + __builtin_abort (); > + return 0; > +} > + > /* { dg-final { scan-tree-dump-times "MIN_EXPR" 3 "phiopt1" } } */ > /* { dg-final { scan-tree-dump-times "MAX_EXPR" 0 "phiopt1" } } */ > diff --git a/gcc/testsuite/gcc.dg/tree-ssa/minmax-4.c b/gcc/testsuite/gcc.dg/tree-ssa/minmax-4.c > index 0b6d667be868c2405eaefd17cb522da44bafa0e2..973f39bfed305d636cd7290ab5dbb726d6d75f12 100644 > --- a/gcc/testsuite/gcc.dg/tree-ssa/minmax-4.c > +++ b/gcc/testsuite/gcc.dg/tree-ssa/minmax-4.c > @@ -1,8 +1,9 @@ > -/* { dg-do compile } */ > +/* { dg-do run } */ > /* { dg-options "-O -fdump-tree-phiopt" } */ > > #include > > +__attribute__ ((noipa, noinline)) > uint8_t three_max (uint8_t xc, uint8_t xm, uint8_t xy) { > uint8_t xk; > if (xc > xm) { > @@ -13,5 +14,16 @@ uint8_t three_max (uint8_t xc, uint8_t xm, uint8_t xy) { > return xk; > } > > +int > +main (void) > +{ > + volatile uint8_t xy = 255; > + volatile uint8_t xm = 0; > + volatile uint8_t xc = 127; > + if (three_max (xc, xm, xy) != 255) > + __builtin_abort (); > + return 0; > +} > + > /* { dg-final { scan-tree-dump-times "MIN_EXPR" 0 "phiopt1" } } */ > /* { dg-final { scan-tree-dump-times "MAX_EXPR" 3 "phiopt1" } } */ > diff --git a/gcc/testsuite/gcc.dg/tree-ssa/minmax-5.c b/gcc/testsuite/gcc.dg/tree-ssa/minmax-5.c > index 650601a3cc75d09a9e6e54a35f5b9993074f8510..34e4e7205111b6c3e28fbe7c8cde85740ac52630 100644 > --- a/gcc/testsuite/gcc.dg/tree-ssa/minmax-5.c > +++ b/gcc/testsuite/gcc.dg/tree-ssa/minmax-5.c > @@ -1,8 +1,9 @@ > -/* { dg-do compile } */ > +/* { dg-do run } */ > /* { dg-options "-O -fdump-tree-phiopt" } */ > > #include > > +__attribute__ ((noipa, noinline)) > uint8_t three_minmax1 (uint8_t xc, uint8_t xm, uint8_t xy) { > uint8_t xk; > if (xc > xm) { > @@ -13,5 +14,16 @@ uint8_t three_minmax1 (uint8_t xc, uint8_t xm, uint8_t xy) { > return xk; > } > > +int > +main (void) > +{ > + volatile uint8_t xy = 255; > + volatile uint8_t xm = 0; > + volatile uint8_t xc = 127; > + if (three_minmax1 (xc, xm, xy) != 127) > + __builtin_abort (); > + return 0; > +} > + > /* { dg-final { scan-tree-dump-times "MIN_EXPR" 2 "phiopt1" } } */ > /* { dg-final { scan-tree-dump-times "MAX_EXPR" 1 "phiopt1" } } */ > diff --git a/gcc/testsuite/gcc.dg/tree-ssa/minmax-6.c b/gcc/testsuite/gcc.dg/tree-ssa/minmax-6.c > index a628f6d99222958cfd8c410f0e85639e3a49dd4b..443d68f826db91118ff8fa4f62333f660fdf5546 100644 > --- a/gcc/testsuite/gcc.dg/tree-ssa/minmax-6.c > +++ b/gcc/testsuite/gcc.dg/tree-ssa/minmax-6.c > @@ -1,8 +1,9 @@ > -/* { dg-do compile } */ > +/* { dg-do run } */ > /* { dg-options "-O -fdump-tree-phiopt" } */ > > #include > > +__attribute__ ((noipa, noinline)) > uint8_t three_minmax3 (uint8_t xc, uint8_t xm, uint8_t xy) { > uint8_t xk; > if (xc > xm) { > @@ -13,5 +14,16 @@ uint8_t three_minmax3 (uint8_t xc, uint8_t xm, uint8_t xy) { > return xk; > } > > +int > +main (void) > +{ > + volatile uint8_t xy = 255; > + volatile uint8_t xm = 0; > + volatile uint8_t xc = 127; > + if (three_minmax3 (xc, xm, xy) != 255) > + __builtin_abort (); > + return 0; > +} > + > /* { dg-final { scan-tree-dump-times "MIN_EXPR" 1 "phiopt1" } } */ > /* { dg-final { scan-tree-dump-times "MAX_EXPR" 1 "phiopt1" } } */ > diff --git a/gcc/testsuite/gcc.dg/tree-ssa/minmax-7.c b/gcc/testsuite/gcc.dg/tree-ssa/minmax-7.c > index cb42412c4ada433b2f59df0a8bef9fa7b1c5e104..7e2a3f08060bc84f33ad416a4c89d0ef74dc9cb3 100644 > --- a/gcc/testsuite/gcc.dg/tree-ssa/minmax-7.c > +++ b/gcc/testsuite/gcc.dg/tree-ssa/minmax-7.c > @@ -1,8 +1,9 @@ > -/* { dg-do compile } */ > +/* { dg-do run } */ > /* { dg-options "-O -fdump-tree-phiopt" } */ > > #include > > +__attribute__ ((noipa, noinline)) > uint8_t three_minmax2 (uint8_t xc, uint8_t xm, uint8_t xy) { > uint8_t xk; > if (xc > xm) { > @@ -12,5 +13,17 @@ uint8_t three_minmax2 (uint8_t xc, uint8_t xm, uint8_t xy) { > } > return xk; > } > + > +int > +main (void) > +{ > + volatile uint8_t xy = 255; > + volatile uint8_t xm = 0; > + volatile uint8_t xc = 127; > + if (three_minmax2 (xc, xm, xy) != 255) > + __builtin_abort (); > + return 0; > +} > + > /* { dg-final { scan-tree-dump-times "MIN_EXPR" 1 "phiopt1" } } */ > /* { dg-final { scan-tree-dump-times "MAX_EXPR" 1 "phiopt1" } } */ > diff --git a/gcc/testsuite/gcc.dg/tree-ssa/minmax-8.c b/gcc/testsuite/gcc.dg/tree-ssa/minmax-8.c > index 9cd050e932376bc50bd6ae60cb654fcab0bfdd1c..0160e573fef8aba106d4f8ef86b5c958ab52cb30 100644 > --- a/gcc/testsuite/gcc.dg/tree-ssa/minmax-8.c > +++ b/gcc/testsuite/gcc.dg/tree-ssa/minmax-8.c > @@ -1,8 +1,9 @@ > -/* { dg-do compile } */ > +/* { dg-do run } */ > /* { dg-options "-O -fdump-tree-phiopt" } */ > > #include > > +__attribute__ ((noinline, noipa)) > uint8_t three_minmax11 (uint8_t xc, uint8_t xm, uint8_t xy) { > uint8_t xk; > if (xc < xm) { > @@ -13,5 +14,16 @@ uint8_t three_minmax11 (uint8_t xc, uint8_t xm, uint8_t xy) { > return xk; > } > > +int > +main (void) > +{ > + volatile uint8_t xy = 255; > + volatile uint8_t xm = 0; > + volatile uint8_t xc = 127; > + if (three_minmax11 (xc, xm, xy) != 255) > + __builtin_abort (); > + return 0; > +} > + > /* { dg-final { scan-tree-dump-times "MIN_EXPR" 1 "phiopt1" } } */ > /* { dg-final { scan-tree-dump-times "MAX_EXPR" 2 "phiopt1" } } */ > diff --git a/gcc/testsuite/gcc.dg/tree-ssa/minmax-9.c b/gcc/testsuite/gcc.dg/tree-ssa/minmax-9.c > index 24f580271c3ac3945860b506d4dc7d178a826093..0cfb65845889af4f25f7c6c57264617a72cda0ad 100644 > --- a/gcc/testsuite/gcc.dg/tree-ssa/minmax-9.c > +++ b/gcc/testsuite/gcc.dg/tree-ssa/minmax-9.c > @@ -1,8 +1,9 @@ > -/* { dg-do compile } */ > +/* { dg-do run } */ > /* { dg-options "-O -fdump-tree-optimized" } */ > > #include > > +__attribute__ ((noipa, noinline)) > uint8_t three_min (uint8_t xc, uint8_t xm, uint8_t xy) { > uint8_t xk; > xc=~xc; > @@ -16,5 +17,16 @@ uint8_t three_min (uint8_t xc, uint8_t xm, uint8_t xy) { > return xk; > } > > +int > +main (void) > +{ > + volatile uint8_t xy = 255; > + volatile uint8_t xm = 0; > + volatile uint8_t xc = 127; > + if (three_min (xc, xm, xy) != 0) > + __builtin_abort (); > + return 0; > +} > + > /* { dg-final { scan-tree-dump-times "= ~" 1 "optimized" } } */ > /* { dg-final { scan-tree-dump-times "MAX_EXPR" 2 "optimized" } } */ > diff --git a/gcc/tree-ssa-phiopt.cc b/gcc/tree-ssa-phiopt.cc > index d5f2ba8be1c33e3ea441a61e9dbf8867aee93a98..925bd7d885357dce114a9b29176d953e30ae3b4d 100644 > --- a/gcc/tree-ssa-phiopt.cc > +++ b/gcc/tree-ssa-phiopt.cc > @@ -2150,9 +2150,9 @@ minmax_replacement (basic_block cond_bb, basic_block middle_bb, basic_block alt_ > gimple_seq stmts = NULL; > tree phi_result = PHI_RESULT (phi); > result = gimple_build (&stmts, locus, minmax, TREE_TYPE (phi_result), > - arg0, bound); > + arg0, arg1); > result = gimple_build (&stmts, locus, ass_code, TREE_TYPE (phi_result), > - result, arg1); > + result, bound); > if (invert) > result = gimple_build (&stmts, locus, BIT_NOT_EXPR, TREE_TYPE (phi_result), > result); > > > > > -- Richard Biener SUSE Software Solutions Germany GmbH, Frankenstrasse 146, 90461 Nuernberg, Germany; GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman; HRB 36809 (AG Nuernberg)