Re: [PATCH] expand: Fix UB in choose_mult_variant [PR105533]

2024-03-07 Thread Richard Biener
On Thu, 7 Mar 2024, Jakub Jelinek wrote: > Hi! > > As documented in the function comment, choose_mult_variant attempts to > compute costs of 3 different cases, val, -val and val - 1. > The -val case is actually only done if val fits into host int, so there > should be no overflow, but the val - 1

[PATCH] expand: Fix UB in choose_mult_variant [PR105533]

2024-03-07 Thread Jakub Jelinek
Hi! As documented in the function comment, choose_mult_variant attempts to compute costs of 3 different cases, val, -val and val - 1. The -val case is actually only done if val fits into host int, so there should be no overflow, but the val - 1 case is done unconditionally. val is shwi (but inside