This is the mail archive of the gcc-bugs@gcc.gnu.org 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]

[Bug rtl-optimization/43226] New: simplify_binary_operation_1 MINUS x const_int issue


On 32-bit HWI host calling
simplify_binary_operation (MINUS, DImode, (reg/v:DI 60 [ x ]), (const_int
-2147483648 [0x80000000]))
returns
(plus:DI (reg/v:DI 60 [ x ])
    (const_int -2147483648 [0x80000000]))
which is wrong.  I guess we need to avoid the INTVAL wrap in that case.
2041      /* Don't let a relocatable value get a negative coeff.  */
2042      if (CONST_INT_P (op1) && GET_MODE (op0) != VOIDmode)
2043        return simplify_gen_binary (PLUS, mode,
2044                                    op0,
2045                                    neg_const_int (mode, op1));
and:
66/* Negate a CONST_INT rtx, truncating (because a conversion from a
67   maximally negative number can overflow).  */
68static rtx
69neg_const_int (enum machine_mode mode, const_rtx i)
70{
71  return gen_int_mode (- INTVAL (i), mode);
72}
if (GET_MODE_BITSIZE (mode) > HOST_BITS_PER_WIDE_INT), I guess we want to avoid
this "optimization" if op1 != const0_rtx && (unsigned HOST_WIDE_INT) INTVAL
(op1) == -(unsigned HOST_WIDE_INT) INTVAL (op1).  Also, I wonder if
neg_const_int we don't need to use - (unsigned HOST_WIDE_INT) INTVAL (i), as
otherwise we e.g. for -ftrapv built gcc we could trap.


-- 
           Summary: simplify_binary_operation_1 MINUS x const_int issue
           Product: gcc
           Version: 4.5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: rtl-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: jakub at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43226


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