[all-commits] [llvm/llvm-project] 5d111a: [DAGCombiner] Avoid double deletion when replacing...

Yingwei Zheng via All-commits all-commits at lists.llvm.org
Tue Aug 26 20:21:44 PDT 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 5d111a20c566d16f80faaa8eed1a382aacd045de
      https://github.com/llvm/llvm-project/commit/5d111a20c566d16f80faaa8eed1a382aacd045de
  Author: Yingwei Zheng <dtcxzyw2333 at gmail.com>
  Date:   2025-08-27 (Wed, 27 Aug 2025)

  Changed paths:
    M llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
    M llvm/test/CodeGen/X86/freeze.ll
    M llvm/test/CodeGen/X86/midpoint-int-vec-256.ll

  Log Message:
  -----------
  [DAGCombiner] Avoid double deletion when replacing multiple frozen/unfrozen uses (#155427)

Closes https://github.com/llvm/llvm-project/issues/155345.
In the original case, we have one frozen use and two unfrozen uses:
```
t73: i8 = select t81, Constant:i8<0>, t18
t75: i8 = select t10, t18, t73
t59: i8 = freeze t18 (combining)

t80: i8 = freeze t59 (another user of t59)
```

In `DAGCombiner::visitFREEZE`, we replace all uses of `t18` with `t59`.
After updating the uses, `t59: i8 = freeze t18` will be updated to `t59:
i8 = freeze t59` (`AddModifiedNodeToCSEMaps`) and CSEed into `t80: i8 =
freeze t59` (`ReplaceAllUsesWith`). As the previous call to
`AddModifiedNodeToCSEMaps` already removed `t59` from the CSE map,
`ReplaceAllUsesWith` cannot remove `t59` again.

For clarity, see the following call graph:
```
ReplaceAllUsesOfValueWith(t18, t59)
  ReplaceAllUsesWith(t18, t59)
    RemoveNodeFromCSEMaps(t73)
    update t73
    AddModifiedNodeToCSEMaps(t73)
    RemoveNodeFromCSEMaps(t75)
    update t75
    AddModifiedNodeToCSEMaps(t75)
    RemoveNodeFromCSEMaps(t59) <- first delection
    update t59
    AddModifiedNodeToCSEMaps(t59)
        ReplaceAllUsesWith(t59, t80)
            RemoveNodeFromCSEMaps(t59) <- second delection
                Boom!
```

This patch unfreezes all the uses first to avoid triggering CSE when
introducing cycles.



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