https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66489

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
For floating point, tree-ssa-math-opts.c  handles the FMA and then expand is
supposed to handle the neg inside the FMA_EXPR but for some reason on this
testcase it is not. 
        def0 = get_def_for_expr (treeop0, NEGATE_EXPR);
        /* The multiplication is commutative - look at its 2nd operand
           if the first isn't fed by a negate.  */
        if (!def0)
          {
            def0 = get_def_for_expr (treeop1, NEGATE_EXPR);
            /* Swap operands if the 2nd operand is fed by a negate.  */
            if (def0)
              {
                tree tem = treeop0;
                treeop0 = treeop1;
                treeop1 = tem;
              }
          }
        def2 = get_def_for_expr (treeop2, NEGATE_EXPR);

        op0 = op2 = NULL;

        if (def0 && def2
            && optab_handler (fnms_optab, mode) != CODE_FOR_nothing)
          {
            opt = fnms_optab;
            op0 = expand_normal (gimple_assign_rhs1 (def0));
            op2 = expand_normal (gimple_assign_rhs1 (def2));
          }
        else if (def0
                 && optab_handler (fnma_optab, mode) != CODE_FOR_nothing)
          {
            opt = fnma_optab;
            op0 = expand_normal (gimple_assign_rhs1 (def0));
          }
        else if (def2
                 && optab_handler (fms_optab, mode) != CODE_FOR_nothing)
          {
            opt = fms_optab;
            op2 = expand_normal (gimple_assign_rhs1 (def2));
          }

So you are going to need to debug why expr.c is not handling this case for
floating point.

Again for integer, it is a different story.  And I doubt for integer it shows
up that often and if it did, the neg could most likely schedule with some other
instruction.

Reply via email to