Thanks, pushed to master as r17-2530-g6d5d980f76c30 and r17-2532-g182f0056f5c13 (the copysign follow-up). Philipp.
On Sat, 18 Jul 2026 at 02:02, Jeffrey Law <[email protected]> wrote: > > > > On 7/17/2026 10:12 AM, Konstantinos Eleftheriou wrote: > > From: Philipp Tomsich <[email protected]> > > > > The (convert (abs (convert@1 @0))) -> (abs @0) rule added by > > r17-2276-ge2c4fc6b1cff evaluates TYPE_PRECISION on the outer and inner types > > after only types_match, so a vectorized abs-of-narrowed chain like > > > > vect_1 = (vector(2) int) vect_0; > > vect_2 = ABS_EXPR <vect_1>; > > vect_3 = (vector(2) signed long) vect_2; > > > > trips the vector_type tree check when gimple_simplify visits the > > outer conversion (ICE during fre). Use element_precision > > so the guard is evaluable for vectors, and require target support > > for ABS on the narrow vector type before enabling the transform > > there. > > > > Bootstrapped and regtested on aarch64-unknown-linux-gnu, x86_64-pc-linux-gnu > > and riscv64-unknown-linux-gnu. > > > > PR tree-optimization/126291 > > > > gcc/ChangeLog: > > > > * match.pd ((trunc)abs (extend x) -> abs (x)): Use > > element_precision. Require target ABS support for the > > vector case. > > > > gcc/testsuite/ChangeLog: > > > > * gcc.target/aarch64/pr126291.c: New test. > This is OK and more complete than the hack I did. It's unclear to me > if other pattern which optimizes down to an IFN_COPYSIGN needs the same > handling for the element precision. If so, that's pre-approved as well. > > Jeff
