-
Notifications
You must be signed in to change notification settings - Fork 12.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CGP] Fix the remove of matched phis in complex addressing mode
When we replace the Phi we created with matched ones it is possible that there are two identical phi nodes in IR. And matcher is smart enough to find that new created phi matches both of them. So we try to replace our phi node with matched ones twice and what is bad we delete our phi node twice causing a crash. As soon as we found that we have two identical Phi nodes it makes sense to do a clean-up and replace one phi node by other one. The patch implements it. Reviewers: john.brawn, reames Reviewed By: john.brawn Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D43758 llvm-svn: 327250
- Loading branch information
Serguei Katkov
committed
Mar 12, 2018
1 parent
8b8d6bf
commit a20e05b
Showing
2 changed files
with
40 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
llvm/test/Transforms/CodeGenPrepare/X86/sink-addrmode-two-phi.ll
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
; RUN: opt -S -codegenprepare -disable-complex-addr-modes=false %s | FileCheck %s --check-prefix=CHECK | ||
target datalayout = | ||
"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128" | ||
target triple = "x86_64-unknown-linux-gnu" | ||
|
||
define void @test() { | ||
entry: | ||
%0 = getelementptr inbounds i64, i64 * null, i64 undef | ||
br label %start | ||
|
||
start: | ||
%val1 = phi i64 * [ %0, %entry ], [ %val4, %exit ] | ||
%val2 = phi i64 * [ null, %entry ], [ %val5, %exit ] | ||
br i1 false, label %slowpath, label %exit | ||
|
||
slowpath: | ||
%elem1 = getelementptr inbounds i64, i64 * undef, i64 undef | ||
br label %exit | ||
|
||
exit: | ||
; CHECK: sunkaddr | ||
%val3 = phi i64 * [ undef, %slowpath ], [ %val2, %start ] | ||
%val4 = phi i64 * [ %elem1, %slowpath ], [ %val1, %start ] | ||
%val5 = phi i64 * [ undef, %slowpath ], [ %val2, %start ] | ||
%loadx = load i64, i64 * %val4, align 8 | ||
br label %start | ||
} |