Message ID | 20220622173045.1253663-1-ibuclaw@gdcproject.org |
---|---|
State | New |
Headers | show |
Series | tilegx: Fix infinite loop in gen-mul-tables generator | expand |
On 6/22/2022 11:30 AM, Iain Buclaw via Gcc-patches wrote: > Hi, > > Since around GCC 10, the condition `j < (INTMAX_MAX / 10)' will get > optimized into `j != 922337203685477580', which will result in an > infinite loop for certain inputs of `j'. > > This patch just copies the condition already used by the -DTILEPRO > generator code, which doesn't fall into the same trap. > > OK for mainline? OK for backporting to all open release branches? Sure, but note the tile ports have been deprecated for a long time and I've got a TODO to finally remove them. jeff
Excerpts from Jeff Law via Gcc-patches's message of Juni 22, 2022 8:16 pm: > > > On 6/22/2022 11:30 AM, Iain Buclaw via Gcc-patches wrote: >> Hi, >> >> Since around GCC 10, the condition `j < (INTMAX_MAX / 10)' will get >> optimized into `j != 922337203685477580', which will result in an >> infinite loop for certain inputs of `j'. >> >> This patch just copies the condition already used by the -DTILEPRO >> generator code, which doesn't fall into the same trap. >> >> OK for mainline? OK for backporting to all open release branches? > Sure, but note the tile ports have been deprecated for a long time and > I've got a TODO to finally remove them. > Noted, and I wouldn't mind seeing the back of this port either. I encountered this as I occasionally I run a modified version of config-list.mk to test the D front-end. As the target isn't gone yet, best to ensure it can still build, even when it is assumed broken. Iain.
On 6/24/2022 12:19 PM, Iain Buclaw wrote: > Excerpts from Jeff Law via Gcc-patches's message of Juni 22, 2022 8:16 pm: >> >> On 6/22/2022 11:30 AM, Iain Buclaw via Gcc-patches wrote: >>> Hi, >>> >>> Since around GCC 10, the condition `j < (INTMAX_MAX / 10)' will get >>> optimized into `j != 922337203685477580', which will result in an >>> infinite loop for certain inputs of `j'. >>> >>> This patch just copies the condition already used by the -DTILEPRO >>> generator code, which doesn't fall into the same trap. >>> >>> OK for mainline? OK for backporting to all open release branches? >> Sure, but note the tile ports have been deprecated for a long time and >> I've got a TODO to finally remove them. >> > Noted, and I wouldn't mind seeing the back of this port either. > > I encountered this as I occasionally I run a modified version of > config-list.mk to test the D front-end. As the target isn't gone yet, > best to ensure it can still build, even when it is assumed broken. Understood. I've got no objection to you going ahead and installing the patch if it makes your life easier... Just wanted to make you aware if you were looking to do something more with that port. jeff
diff --git a/gcc/config/tilepro/gen-mul-tables.cc b/gcc/config/tilepro/gen-mul-tables.cc index 52183982f65..c125748a328 100644 --- a/gcc/config/tilepro/gen-mul-tables.cc +++ b/gcc/config/tilepro/gen-mul-tables.cc @@ -1192,11 +1192,11 @@ tilegx_emit (long long multiplier, int num_ops) long long next_pow10; while (((j * 10) < abs_multiplier) - && (j < (INTMAX_MAX / 10))) + && (j < (j * 10))) j = j * 10; prev_pow10 = j; - next_pow10 = (j > (INTMAX_MAX / 10)) ? 0 : j * 10; + next_pow10 = j * 10; if ((abs_multiplier - prev_pow10 <= 100) || (next_pow10