Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix an ordering bug in the scalarizer.
I've added a new test case that causes the scalarizer to try and use dead-and-erased values - caused by the basic blocks not being in domination order within the function. To fix this, instead of iterating through the blocks in function order, I walk them in reverse post order. Differential Revision: https://reviews.llvm.org/D52540 llvm-svn: 344128
- Loading branch information
Neil Henning
committed
Oct 10, 2018
1 parent
0c17cbf
commit 3d45798
Showing
4 changed files
with
55 additions
and
3 deletions.
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
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
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,23 @@ | ||
; RUN: opt %s -scalarizer -S -o - | FileCheck %s | ||
|
||
; This input caused the scalarizer to replace & erase gathered results when | ||
; future gathered results depended on them being alive | ||
|
||
define dllexport spir_func <4 x i32> @main(float %a) { | ||
entry: | ||
%i = insertelement <4 x float> undef, float %a, i32 0 | ||
br label %z | ||
|
||
y: | ||
; CHECK: %f.upto0 = insertelement <4 x i32> undef, i32 %b.i0, i32 0 | ||
; CHECK: %f.upto1 = insertelement <4 x i32> %f.upto0, i32 %b.i0, i32 1 | ||
; CHECK: %f.upto2 = insertelement <4 x i32> %f.upto1, i32 %b.i0, i32 2 | ||
; CHECK: %f = insertelement <4 x i32> %f.upto2, i32 %b.i0, i32 3 | ||
%f = shufflevector <4 x i32> %b, <4 x i32> undef, <4 x i32> zeroinitializer | ||
ret <4 x i32> %f | ||
|
||
z: | ||
; CHECK: %b.i0 = bitcast float %a to i32 | ||
%b = bitcast <4 x float> %i to <4 x i32> | ||
br label %y | ||
} |
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,24 @@ | ||
; RUN: opt %s -scalarizer -verify -S -o - | FileCheck %s | ||
|
||
define void @f3() local_unnamed_addr { | ||
bb1: | ||
br label %bb2 | ||
|
||
bb3: | ||
; CHECK-LABEL: bb3: | ||
; CHECK-NEXT: br label %bb4 | ||
%h.10.0.vec.insert = shufflevector <1 x i16> %h.10.1, <1 x i16> undef, <1 x i32> <i32 0> | ||
br label %bb4 | ||
|
||
bb2: | ||
; CHECK-LABEL: bb2: | ||
; CHECK: phi i16 | ||
%h.10.1 = phi <1 x i16> [ undef, %bb1 ] | ||
br label %bb3 | ||
|
||
bb4: | ||
; CHECK-LABEL: bb4: | ||
; CHECK: phi i16 | ||
%h.10.2 = phi <1 x i16> [ %h.10.0.vec.insert, %bb3 ] | ||
ret void | ||
} |