This is an archive of the discontinued LLVM Phabricator instance.

[JT] check xor operand is exactly the same in processBranchOnXOR
ClosedPublic

Authored by inclyc on Dec 10 2022, 9:43 PM.

Details

Summary

Reproducer:

; RUN: opt -S -jump-threading < %s
define void @test() {
entry:
br i1 false, label %loop, label %exit

loop:
%bool = phi i1 [ %xor, %loop.latch ], [ false, %entry ]
%cmp = icmp eq i16 0, 1
%xor = xor i1 %cmp, %bool
br i1 %bool, label %loop.latch, label %exit

loop.latch:
%dummy = phi i16 [ 0, %loop ]
br label %loop

exit:
ret void
}

On this occassion, phi node %bool is actually %xor, and doing substitution causes assertion failure.

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

Diff Detail

Event Timeline

inclyc created this revision.Dec 10 2022, 9:43 PM
Herald added a project: Restricted Project. · View Herald TranscriptDec 10 2022, 9:43 PM
Herald added a subscriber: hiraditya. · View Herald Transcript
inclyc requested review of this revision.Dec 10 2022, 9:43 PM
Herald added a project: Restricted Project. · View Herald TranscriptDec 10 2022, 9:43 PM
nikic accepted this revision.Dec 21 2022, 5:27 AM

LGTM

This revision is now accepted and ready to land.Dec 21 2022, 5:27 AM