Skip to content

[DAGCombiner] visitFREEZE: Early exit when N is deleted #128161

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16158,11 +16158,13 @@ SDValue DAGCombiner::visitFREEZE(SDNode *N) {
DAG.UpdateNodeOperands(FrozenMaybePoisonOperand.getNode(),
MaybePoisonOperand);
}

// This node has been merged with another.
if (N->getOpcode() == ISD::DELETED_NODE)
return SDValue(N, 0);
}

// This node has been merged with another.
if (N->getOpcode() == ISD::DELETED_NODE)
return SDValue(N, 0);
assert(N->getOpcode() != ISD::DELETED_NODE && "Node was deleted!");

// The whole node may have been updated, so the value we were holding
// may no longer be valid. Re-fetch the operand we're `freeze`ing.
Expand Down
32 changes: 32 additions & 0 deletions llvm/test/CodeGen/X86/pr128143.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
; RUN: llc < %s -mtriple=x86_64-- | FileCheck %s

@g_1 = external global i8
@g_2 = external global i8

; Make sure we don't crash on this test.

define i1 @test(i1 %cmp1, i32 %x) {
; CHECK-LABEL: test:
; CHECK: # %bb.0: # %entry
; CHECK-NEXT: movq g_2@GOTPCREL(%rip), %rcx
; CHECK-NEXT: xorl %eax, %eax
; CHECK-NEXT: cmpq %rcx, g_1@GOTPCREL(%rip)
; CHECK-NEXT: setne %al
; CHECK-NEXT: cmpl %eax, %esi
; CHECK-NEXT: setb %cl
; CHECK-NEXT: orb %cl, %al
; CHECK-NEXT: andb %dil, %al
; CHECK-NEXT: # kill: def $al killed $al killed $eax
; CHECK-NEXT: retq
entry:
%cmp2 = icmp ne ptr @g_1, @g_2
%fr = freeze ptr @g_1
%cmp3 = icmp ne ptr %fr, @g_2
%ext1 = zext i1 %cmp3 to i32
%sel1 = select i1 %cmp1, i1 %cmp2, i1 false
%cmp4 = icmp ult i32 %x, %ext1
%sel3 = select i1 %cmp1, i1 %cmp4, i1 false
%or = or i1 %sel1, %sel3
ret i1 %or
}