https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108359
--- Comment #5 from Andrew Macleod <amacleod at redhat dot com> --- Created attachment 54240 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=54240&action=edit sample implementation In fact that appears to work... The attached (untested) patch simply does that at the higher level, and produces: Folding statement: _11 = i_23 >> k_24; folding with relation i_23 pe8 k_24 Registering value_relation (_11 <= i_23) (bb6) at _11 = i_23 >> k_24; Queued stmt for removal. Folds to: 0 We'd probably want to push the equivalence relation deeper into wi_fold_in_parts as well so that if it was given [0,5] >> [0,5] it would also do the right thing. The current patch works because it is providing wi_fold_in_parts the higher level pairs [0,0] and [5,5]. if it was presented with [0,5] [0,5] if would simply do the normal fold. we'd also want wi_fold_in_parts to DTRT when we give it an equivalence and break it down into components. NOt sure we want to do that for this release tho...?