[all-commits] [llvm/llvm-project] fd97df: [LV] Don't mark ptrs as safe to speculate if fed b...

Florian Hahn via All-commits all-commits at lists.llvm.org
Fri Jun 20 05:05:40 PDT 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: fd97dfbb78e3c9aea16873617b6d61b5b8a64474
      https://github.com/llvm/llvm-project/commit/fd97dfbb78e3c9aea16873617b6d61b5b8a64474
  Author: Florian Hahn <flo at fhahn.com>
  Date:   2025-06-20 (Fri, 20 Jun 2025)

  Changed paths:
    M llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp
    M llvm/test/Transforms/LoopVectorize/X86/drop-poison-generating-flags.ll
    M llvm/test/Transforms/LoopVectorize/dereferenceable-info-from-assumption-constant-size.ll
    M llvm/test/Transforms/LoopVectorize/dereferenceable-info-from-assumption-variable-size.ll
    M llvm/test/Transforms/LoopVectorize/load-deref-pred-poison-ub-ops-feeding-pointer.ll

  Log Message:
  -----------
  [LV] Don't mark ptrs as safe to speculate if fed by UB/poison op. (#143204)

Add additional checks before marking pointers safe to load
speculatively. If some computations feeding the pointer may trigger UB,
we cannot load the pointer speculatively, because we cannot compute the
address speculatively. The UB triggering instructions will be
predicated, but if the predicated block does not execute the result is
poison.

Similarly, we also cannot load the pointer speculatively if it may be
poison. The patch also checks if any of the operands defined outside the
loop may be poison when entering the loop. We *don't* need to check if
any operation inside the loop may produce poison due to flags, as those
will be dropped if needed.

There are some types of instructions inside the loop that can produce
poison independent of flags. Currently loads are also checked, not sure
if there's a convenient API to check for all such operands.

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

PR: https://github.com/llvm/llvm-project/pull/143204



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