ref: 56338bb08045561cdc17b33c9e9f4e5721807778
parent: a926e8f5971ee8598fc7083ad9911da0c23fc76d
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Wed Nov 17 05:43:58 EST 2021
cc1: Fix validation of folded multiplication The code was negating the minimum of the type but that value was already negative in the case of integer and float expressions.
--- a/src/cmd/cc/cc1/fold.c
+++ b/src/cmd/cc/cc1/fold.c
@@ -15,7 +15,7 @@
addi(TINT l, TINT r, Type *tp)
{
struct limits *lim = getlimits(tp);
- TINT max = lim->max.i, min = -lim->min.i;
+ TINT max = lim->max.i, min = lim->min.i;
if (l < 0 && r < 0 && l >= min - r ||
l == 0 ||
@@ -63,7 +63,7 @@
muli(TINT l, TINT r, Type *tp)
{
struct limits *lim = getlimits(tp);
- TINT max = lim->max.i, min = -lim->min.i;
+ TINT max = lim->max.i, min = lim->min.i;
if (l > -1 && l <= 1 ||
r > -1 && r <= 1 ||