Message ID | CAEwic4Zz0OnrFxuxCFeV2Qych_zwJBzCoOEXFQExfMJfjVQ2yA@mail.gmail.com |
---|---|
State | New |
Headers | show |
On 08/31/2015 03:08 PM, Kai Tietz wrote: > I will need to verify that this patch doesn't introduce regressions. > The wacky thing here is the encapsulation of overflowed-arguments in > maybe_constant_value function by nop-expr. Do we need to worry about that? If one of the operands is overflowed, we don't care whether the result is overflowed. Jason
2015-08-31 21:29 GMT+02:00 Jason Merrill <jason@redhat.com>: > On 08/31/2015 03:08 PM, Kai Tietz wrote: >> >> I will need to verify that this patch doesn't introduce regressions. >> The wacky thing here is the encapsulation of overflowed-arguments in >> maybe_constant_value function by nop-expr. > > > Do we need to worry about that? If one of the operands is overflowed, we > don't care whether the result is overflowed. Well, we would introduce, if we don't see in condition that operand already overflowed, double overflow-warning, which seems to be something we avoided until now. So I would say, it matters. Kai
On 08/31/2015 03:43 PM, Kai Tietz wrote: > 2015-08-31 21:29 GMT+02:00 Jason Merrill <jason@redhat.com>: >> On 08/31/2015 03:08 PM, Kai Tietz wrote: >>> >>> I will need to verify that this patch doesn't introduce regressions. >>> The wacky thing here is the encapsulation of overflowed-arguments in >>> maybe_constant_value function by nop-expr. >> >> >> Do we need to worry about that? If one of the operands is overflowed, we >> don't care whether the result is overflowed. > > Well, we would introduce, if we don't see in condition that operand > already overflowed, double overflow-warning, which seems to be > something we avoided until now. So I would say, it matters. I would rather handle this by checking whether the folded operands are constant before even building the folded result. Jason
2015-09-01 16:47 GMT+02:00 Jason Merrill <jason@redhat.com>: > On 08/31/2015 03:43 PM, Kai Tietz wrote: >> >> 2015-08-31 21:29 GMT+02:00 Jason Merrill <jason@redhat.com>: >>> >>> On 08/31/2015 03:08 PM, Kai Tietz wrote: >>>> >>>> >>>> I will need to verify that this patch doesn't introduce regressions. >>>> The wacky thing here is the encapsulation of overflowed-arguments in >>>> maybe_constant_value function by nop-expr. >>> >>> >>> >>> Do we need to worry about that? If one of the operands is overflowed, we >>> don't care whether the result is overflowed. >> >> >> Well, we would introduce, if we don't see in condition that operand >> already overflowed, double overflow-warning, which seems to be >> something we avoided until now. So I would say, it matters. > > > I would rather handle this by checking whether the folded operands are > constant before even building the folded result. I rewrote binary/unary overflow-check logic so, that we avoid double checking-s. I think this address things as you intend, beside the checking for constant value. We would need to check for *_CST tree-codes. Is there a macro we could use, which is just checking for those? > Jason > Kai
On 09/01/2015 11:27 AM, Kai Tietz wrote: > I rewrote binary/unary overflow-check logic so, that we avoid double > checking-s. I think this address things as you intend, beside the > checking for constant value. We would need to check for *_CST > tree-codes. Is there a macro we could use, which is just checking for > those? Yes, CONSTANT_CLASS_P. Jason
2015-09-01 17:31 GMT+02:00 Jason Merrill <jason@redhat.com>: > On 09/01/2015 11:27 AM, Kai Tietz wrote: >> >> I rewrote binary/unary overflow-check logic so, that we avoid double >> checking-s. I think this address things as you intend, beside the >> checking for constant value. We would need to check for *_CST >> tree-codes. Is there a macro we could use, which is just checking for >> those? > > > Yes, CONSTANT_CLASS_P. > > Jason Thanks, I found it too :] I applied a patch short-cutting check for cases that operands aren't of constant-class. Kai
Index: typeck.c =================================================================== --- typeck.c (Revision 227339) +++ typeck.c (Arbeitskopie) @@ -5070,8 +5070,12 @@ cp_build_binary_op (location_t location, result = build2 (resultcode, build_type, op0, op1); if (final_type != 0) result = cp_convert (final_type, result, complain); - op0 = fold_simple (op0); - op1 = fold_simple (op1); + op0 = maybe_constant_value (op0); + op1 = maybe_constant_value (op1); + /* Strip added nop-expression for overflow-operand introduced by + maybe_constant_value. */ + STRIP_NOPS (op0); + STRIP_NOPS (op1); result_ovl = fold_build2 (resultcode, build_type, op0, op1); if (TREE_OVERFLOW_P (result_ovl) && !TREE_OVERFLOW_P (op0)