On Thu, Feb 23, 2017 at 03:07:14PM +0100, Jakub Jelinek wrote: > On Thu, Feb 23, 2017 at 02:47:11PM +0100, Bernd Schmidt wrote: > > On 02/23/2017 02:36 PM, Jakub Jelinek wrote: > > > and both UNLT and GE can be reversed. But if the arguments of the > > > condition > > > are canonicalized, we run into: > > > /* Test for an integer condition, or a floating-point comparison > > > in which NaNs can be ignored. */ > > > if (CONST_INT_P (arg0) > > > || (GET_MODE (arg0) != VOIDmode > > > && GET_MODE_CLASS (mode) != MODE_CC > > > && !HONOR_NANS (mode))) > > > return reverse_condition (code); > > > and thus always return UNKNOWN. > > > > So... do you think we could add (in gcc-8, probably, although if it fixes > > this regression...) > > > > else if (GET_MODE (arg0) != VOIDmode > > && GET_MODE_CLASS (mode) != MODE_CC > > && HONOR_NANS (mode)) > > return reverse_condition_maybe_unordered (code); > > > > to make this work? > > Maybe, though I'd feel safer about trying it only in gcc 8. I can certainly > test such a change on a couple of targets. It would not be sufficient, we'd > either need to also reverse_condition_maybe_unordered for the UN* codes > we don't handle yet, or break so that we perhaps reach this spot. > > Updated (not yet tested) version of the patch is below.
Now successfully bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? > 2017-02-23 Jakub Jelinek <ja...@redhat.com> > > PR tree-optimization/79389 > * ifcvt.c (struct noce_if_info): Add rev_cond field. > (noce_reversed_cond_code): New function. > (noce_emit_store_flag): Use rev_cond if non-NULL instead of > reversed_comparison_code. Formatting fix. > (noce_try_store_flag): Test rev_cond != NULL in addition to > reversed_comparison_code. > (noce_try_store_flag_constants): Likewise. > (noce_try_store_flag_mask): Likewise. > (noce_try_addcc): Use rev_cond if non-NULL instead of > reversed_comparison_code. > (noce_try_cmove_arith): Likewise. Formatting fixes. > (noce_try_minmax, noce_try_abs): Clear rev_cond. > (noce_find_if_block): Initialize rev_cond. > (find_cond_trap): Call noce_get_condition with then_bb == trap_bb > instead of false as last argument never attempt to reverse it > afterwards. Jakub