[all-commits] [llvm/llvm-project] 1a9569: [RISCV][TTI] Avoid an infinite recursion issue in ...

Philip Reames via All-commits all-commits at lists.llvm.org
Fri Sep 27 07:47:31 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 1a9569c4f025ef72a427a6c03be6d4b5db72cf1c
      https://github.com/llvm/llvm-project/commit/1a9569c4f025ef72a427a6c03be6d4b5db72cf1c
  Author: Philip Reames <preames at rivosinc.com>
  Date:   2024-09-27 (Fri, 27 Sep 2024)

  Changed paths:
    M llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp
    M llvm/test/Analysis/CostModel/RISCV/cast.ll
    M llvm/test/Analysis/CostModel/RISCV/cttz_elts.ll

  Log Message:
  -----------
  [RISCV][TTI] Avoid an infinite recursion issue in getCastInstrCost (#110164)

Calling into BasicTTI is not always safe. In particular, BasicTTI does
not have a full legalization implementation (vector widening is
missing), and falls back on scalarization. The problem is that
scalarization for <N x i1> vectors is cost in terms of the cast API and
we can end up in an infinite recursive cycle.

The "right" fix for this would be teach BasicTTI how to model the full
legalization state machine, but several attempts at doing so have
resulted in dead ends or undesirable cost changes for targets I don't
understand.

This patch instead papers over the issue by avoiding the call to the
base class when dealing with an i1 source or dest. This doesn't
necessarily produce correct costs, but it should at least return
something semi-sensible and not crash.

Fixes https://github.com/llvm/llvm-project/issues/108708



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list