[all-commits] [llvm/llvm-project] 16a127: [IR] Fix !invariant.group in combineMetadataForCSE...

Justin Lebar via All-commits all-commits at lists.llvm.org
Sat May 30 19:01:59 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 16a127b531eb7916d5f3b4839d1a9cc2852df4b1
      https://github.com/llvm/llvm-project/commit/16a127b531eb7916d5f3b4839d1a9cc2852df4b1
  Author: Justin Lebar <justin.lebar at gmail.com>
  Date:   2026-05-30 (Sat, 30 May 2026)

  Changed paths:
    M llvm/lib/Transforms/Utils/Local.cpp
    M llvm/test/Transforms/GVN/invariant.group.ll
    M llvm/test/Transforms/NewGVN/invariant.group.ll
    M llvm/test/Transforms/SimplifyCFG/merge-cond-stores.ll

  Log Message:
  -----------
  [IR] Fix !invariant.group in combineMetadataForCSE when K moves (#200551)

SimplifyCFG mergeConditionalStoreToAddress currently transforms

    if (cond)
      store ptr, x !invariant.group;
    else
      store ptr, y;

into

    store ptr, select(cond, x, y) !invariant.group;  // BUG

It's clearly not valid to preserve !invariant.group here.

Fix this inside combineMetadataForCSE.  It can only preserve
!invariant.group if

 1. !DoesKMove, meaning that original instruction ("K") is replaced by
    the combined instruction in place, without moving it,
 2. Both stores have !invariant.group.

This matches the logic for preserving !invariant.load.

This bug was found by a large run of Opus 4.7 looking for bugs in LLVM.



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