Re: [PATCH] fold-const: Punt on MULT_EXPR in extract_muldiv MIN/MAX_EXPR case [PR111151]

2024-03-26 Thread Richard Biener
On Tue, 26 Mar 2024, Jakub Jelinek wrote: > Hi! > > As I've tried to explain in the comments, the extract_muldiv_1 > MIN/MAX_EXPR optimization is wrong for code == MULT_EXPR. > If the multiplication is done in unsigned type or in signed > type with -fwrapv, it is fairly obvious that max (a, b) *

[PATCH] fold-const: Punt on MULT_EXPR in extract_muldiv MIN/MAX_EXPR case [PR111151]

2024-03-26 Thread Jakub Jelinek
Hi! As I've tried to explain in the comments, the extract_muldiv_1 MIN/MAX_EXPR optimization is wrong for code == MULT_EXPR. If the multiplication is done in unsigned type or in signed type with -fwrapv, it is fairly obvious that max (a, b) * c in many cases isn't equivalent to max (a * c, b * c)