On Wed, 5 Nov 2025, Dhruv Chawla wrote: > On 27/08/25 18:27, Richard Biener wrote: > > External email: Use caution opening links or attachments > > > > > > On Mon, 25 Aug 2025, [email protected] wrote: > > > >> From: Dhruv Chawla <[email protected]> > >> > >> For ==, < and <=, the fold is to 0. For !=, > and >=, the fold is to 1. > >> This only applies when C != 0. > > > > So -50 << 1 < 1 is true, so does this only work for unsigned types, > > or tree_expr_nonnegative_p in addition to tree_expr_nonzero_p? > > I've probably mislead you when asking to simply extend it to other compare > > operators. For == it should of course work when nonzero only. > > > > Or am I missing something? > > > > Why did you restrict this to #if GIMPLE in v2? > > Hi Richi, > > Sorry for the (very) long delay in getting back to you, I got quite badly > stuck trying various approaches with this patch. I have attached patch v3 > to this email. The #if GIMPLE was something left over from v1, I had > forgotten to remove it. > > The primary issue I ran into is that tree_expr_nonnegative_p doesn't really > work for function parameters (which was causing my tests to fail), because it > calls into gimple_stmt_nonnegative_warnv_p which doesn't work for the > GIMPLE_NOP > that params have as the gimple_code. > > I tried extending tree_expr_nonnegative_p with something similar to > expr_not_equal_to but that kept causing ICEs/miscompiles that I couldn't > figure > out so I have left it as a FIXME in match-shift-cmp-1.c.
OK. Thanks, Richard.
