This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: RFA: fix PR66726 regression for min/max/conversion combo from PR71016 patch

[Apologies if this is a duplicate, I'm unsure if my previous mail was delivered]
On 01/07/19 12:38, Richard Biener wrote:
On Mon, Jul 1, 2019 at 1:22 PM Joern Wolfgang Rennecke
<> wrote:
The heuristic introduced for PR71016 prevents recognizing a max / min
combo like it is used for
saturation when followed by a conversion.
The attached patch refines the heuristic to allow this case. Regression
tested on x86_64-pc-linux-gnu .
Few style nits:


also please check that 'lhs' is equal to gimple_assing_rhs1 (arg0_def_stmt)
otherwise you'd also allow MIN/MAX unrelated to the conversion detected.

Like the attached patch?

On x86 I see the MIN_EXPR is already detected by GENERIC folding,
I wonder if that is required or if we can handle the case without in one
phiopt pass invocation as well.

tree_ssa_phiopt_worker is supposed to handle this by handling nested COND_EXPRs
from the inside out:

   /* Search every basic block for COND_EXPR we may be able to optimize.

     We walk the blocks in order that guarantees that a block with
     a single predecessor is processed before the predecessor.
     This ensures that we collapse inner ifs before visiting the
     outer ones, and also that we do not try to visit a removed
     block.  */
  bb_order = single_pred_before_succ_order ();

However, I have no idea how to construct a testcase for this with the gimple folding in place.

#define SAT(x) (x < 0 ? 0 : (x > 255 ? 255 : x))

foo (unsigned char *p, int i, int m)
  *p = (m > SAT (i) ? m : SAT (i));

or the equivalent for MIN_EXPR, *.c.004.original already has only one conditional left.

Attachment: pr66726-sat-uchar-patch-2.txt
Description: Text document

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]