This is v2 of the second half of the PR122569 series (v1 1/2) is
already applied.

Reviewers asked to factor the shift-cascade matching out of
clz_table_index:  1/2 does that (no functional change), introducing the
msb_or_cascade_{32,64} helpers; 2/2 then recognises the variant CLZ
idiom that isolates the MSB via (value - (value >> 1)) before the
DeBruijn multiply, reusing the 64-bit helper.

Bootstrapped and regression-tested on x86_64-linux-gnu and aarch64-linux-gnu.

Changes in v2:
- v1 1/2 ("fix DeBruijn CLZ table validator shift-by-64 UB") has been
  applied upstream and is dropped from this series.
- Per reviewer feedback, factor the MSB OR-cascade matching out of
  clz_table_index into reusable msb_or_cascade_32 / msb_or_cascade_64
  match helpers (new 1/2), so the recognition pattern (2/2) can be built
  on top of the 64-bit helper instead of respelling the cascade.

Philipp Tomsich (2):
  match.pd: factor MSB OR-cascade out of clz_table_index
  tree-optimization/122569 - recognize CLZ via isolated MSB DeBruijn
    lookup

 gcc/match.pd                               | 78 ++++++++++++++--------
 gcc/testsuite/gcc.dg/tree-ssa/pr122569-3.c | 38 +++++++++++
 gcc/tree-ssa-forwprop.cc                   | 32 +++++++--
 3 files changed, 116 insertions(+), 32 deletions(-)
 create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/pr122569-3.c

-- 
2.34.1

base-commit: 1904b9207203bbe45d6ce6a472d6a0c7e1bbd873
branch: ptomsich/pr122569-v2

Reply via email to