Skip to content

Commit 58dcf33

Browse files
author
Greg Roth
authored
Return Scatterer object for argument values (#3548)
merged from #3540 An unrelated earlier change mistakenly removed the return on a line calling the Scatterer constructor for an argument value. As a result, the constructor is called, but the resulting object which would insert new extraction ops in the entry block is not used at all. Instead, the default case is encountered where the vector PHI op is used as an insertion point, which places the extractions after the new scalar PHIs that use them. This is caught in the loop case by an assert because the assumptions that caused LCSSA to be skipped for this BB are faulty. (cherry picked from commit bb5dc9f)
1 parent a48ae7e commit 58dcf33

2 files changed

Lines changed: 24 additions & 1 deletion

File tree

lib/Transforms/Scalar/Scalarizer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ Scatterer Scalarizer::scatter(Instruction *Point, Value *V) {
316316
auto InsertPoint = BB->begin();
317317
while (InsertPoint != BB->end() && isa<DbgInfoIntrinsic>(InsertPoint))
318318
InsertPoint++;
319-
Scatterer(BB, InsertPoint, V, AllowFolding, &Scattered[V]);
319+
return Scatterer(BB, InsertPoint, V, AllowFolding, &Scattered[V]);
320320
// HLSL Change - End
321321
}
322322
if (Instruction *VOp = dyn_cast<Instruction>(V)) {
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// RUN: %dxc -T lib_6_3 %s | FileCheck %s
2+
3+
// Test for failure where the extractelement ops ended up after the loop phi that used them
4+
// Resulted in a crash in LCSSA, but the order could have been out of whack regardless
5+
6+
// make sure the four extractions come before their usage in the loop
7+
// CHECK: [[X:%[A-Za-z0-9\.]+]] = extractelement <4 x float> {{%?[A-Za-z0-9]+}}, i32 0
8+
// CHECK: [[Y:%[A-Za-z0-9\.]+]] = extractelement <4 x float> {{%?[A-Za-z0-9]+}}, i32 1
9+
// CHECK: [[Z:%[A-Za-z0-9\.]+]] = extractelement <4 x float> {{%?[A-Za-z0-9]+}}, i32 2
10+
// CHECK: [[W:%[A-Za-z0-9\.]+]] = extractelement <4 x float> {{%?[A-Za-z0-9]+}}, i32 3
11+
12+
// CHECK: phi float {{.*}}[[X]],
13+
// CHECK: phi float {{.*}}[[Y]],
14+
// CHECK: phi float {{.*}}[[Z]],
15+
// CHECK: phi float {{.*}}[[W]],
16+
17+
export
18+
float4 ScatterLoop(float4 color, int ct) {
19+
// surprised this can't be unrolled
20+
for( int i = 0; i < ct; i++ )
21+
color += 1;
22+
return color;
23+
}

0 commit comments

Comments
 (0)