stage3/constant_folding.cc
changeset 794 d534db26cbd5
parent 783 3bd2704d9ba9
child 791 ab601bdea102
equal deleted inserted replaced
785:b08167f156a1 794:d534db26cbd5
   446 /* res = a * b */
   446 /* res = a * b */
   447 static void CHECK_OVERFLOW_uint64_MUL(symbol_c *res, symbol_c *a, symbol_c *b) {
   447 static void CHECK_OVERFLOW_uint64_MUL(symbol_c *res, symbol_c *a, symbol_c *b) {
   448 	if (!VALID_CVALUE(uint64, res))
   448 	if (!VALID_CVALUE(uint64, res))
   449 		return;
   449 		return;
   450 	/* Test by pre-condition: If (UINT64_MAX / a) < b => overflow! */
   450 	/* Test by pre-condition: If (UINT64_MAX / a) < b => overflow! */
       
   451 	if (0 == GET_CVALUE(uint64, a))
       
   452 		return; // multiplying by 0 will always result in 0, a valid result!	  
   451 	if ((UINT64_MAX / GET_CVALUE(uint64, a)) < GET_CVALUE(uint64, b))
   453 	if ((UINT64_MAX / GET_CVALUE(uint64, a)) < GET_CVALUE(uint64, b))
   452 		SET_OVFLOW(uint64, res);
   454 		SET_OVFLOW(uint64, res);
   453 }
   455 }
   454 
   456 
   455 
   457