> Which is wrong when TRULY_NOOP_TRUNCATION_MODES_P is false which is
> what happens on MIPS.
>
> This patches fixes the problem by change the place where the call to
> gen_lowpart should have been gen_lowpart_or_truncate in
> simplify_comparison.

There is a similar transformation in the same function:

          /* If this AND operation is really a ZERO_EXTEND from a narrower
             mode, the constant fits within that mode, and this is either an
             equality or unsigned comparison, try to do this comparison in
             the narrower mode.

             Note that in:

             (ne:DI (and:DI (reg:DI 4) (const_int 0xffffffff)) (const_int 0))
             -> (ne:DI (reg:SI 4) (const_int 0))

             unless TRULY_NOOP_TRUNCATION allows it or the register is
             known to hold a value of the required mode the
             transformation is invalid.  */
          if ((equality_comparison_p || unsigned_comparison_p)
              && CONST_INT_P (XEXP (op0, 1))
              && (i = exact_log2 ((UINTVAL (XEXP (op0, 1))
                                   & GET_MODE_MASK (mode))
                                  + 1)) >= 0
              && const_op >> i == 0
              && (tmode = mode_for_size (i, MODE_INT, 1)) != BLKmode
              && (TRULY_NOOP_TRUNCATION_MODES_P (tmode, GET_MODE (op0))
                  || (REG_P (XEXP (op0, 0))
                      && reg_truncated_to_mode (tmode, XEXP (op0, 0)))))
            {
              op0 = gen_lowpart (tmode, XEXP (op0, 0));
              continue;
            }

and, in this case, it is simply not done if !TRULY_NOOP_TRUNCATION_MODES_P.
I think that both transformations are equally profitable, so can we make them 
agree, one way or the other?

> * gcc.c-torture/execute/20110418-1.c: New testcase.

This needs to be updated a little bit. :-)

-- 
Eric Botcazou

Reply via email to