1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 03:02:36 +01:00
llvm-mirror/test/Transforms/Scalarizer/order-bug-inseltpoison.ll
Juneyoung Lee c88238ea77 [Scalarizer] Use poison as insertelement's placeholder
This patch makes Scalarizer to use poison as insertelement's placeholder.

It contains two changes in Scalarizer.cpp, and the both changes does not change the semantics of the optimized program.
It is because the placeholder value (poison) is already completely hidden by following insertelement instructions.

The first change at visitBitCastInst() creates poison vector of MidTy and consecutively inserts FanIn times,
which is # of elems of MidTy.
The second change at ScalarizerVisitor::finish() creates poison with Op->getType(), and it is filled with
Count insertelements.

The test diffs show that the poison value is never exposed after insertelements.

Reviewed By: nikic

Differential Revision: https://reviews.llvm.org/D93989
2021-01-04 00:35:28 +09:00

25 lines
866 B
LLVM

; RUN: opt %s -scalarizer -S -o - | FileCheck %s
; RUN: opt %s -passes='function(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> poison, float %a, i32 0
br label %z
y:
; CHECK: %f.upto0 = insertelement <4 x i32> poison, 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> poison, <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
}