-
Notifications
You must be signed in to change notification settings - Fork 722
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a flag for the upstream global reassociation algorithm change (#6625
) This PR (#6598) pulls the upstream global reassociation algorithm change in DXC and can reduce redundant calculations obviously. However, from the testing result of a large offline suite of shaders, some shaders got worse compilation results and couldn't benefit from this upstream change. This PR adds a flag for the upstream global reassociation change. It would be easier to roll back if a shader get worse compilation result due to this upstream change. This is part 2 of the fix for #6593.
- Loading branch information
1 parent
6a34e29
commit 1ee70fd
Showing
9 changed files
with
119 additions
and
21 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
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
31 changes: 31 additions & 0 deletions
31
tools/clang/test/DXC/Passes/reassociate/reassociation-flag.hlsl
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,31 @@ | ||
// RUN: %dxc -T cs_6_3 -E cs_main %s -opt-enable aggressive-reassociation | FileCheck %s -check-prefixes=CHECK,COMMON_FACTOR | ||
// RUN: %dxc -T cs_6_3 -E cs_main %s -opt-disable aggressive-reassociation | FileCheck %s -check-prefixes=CHECK,NO_COMMON_FACTOR | ||
|
||
// Make sure DXC recognize the common factor and generate optimized dxils if the enable-aggressive-reassociation is true. | ||
|
||
// CHECK: [[FACTOR_SRC1:%.*]] = call i32 @dx.op.flattenedThreadIdInGroup.i32(i32 96) | ||
// CHECK: [[FACTOR_SRC0:%.*]] = call i32 @dx.op.threadIdInGroup.i32(i32 95, i32 0) | ||
|
||
// COMMON_FACTOR: [[FACTOR:%.*]] = mul i32 [[FACTOR_SRC0]], [[FACTOR_SRC1]] | ||
// COMMON_FACTOR: mul i32 [[FACTOR]], | ||
// COMMON_FACTOR: mul i32 [[FACTOR]], | ||
|
||
// NO_COMMON_FACTOR: [[EXPRESSION_0:%.*]] = mul i32 [[FACTOR_SRC1]], | ||
// NO_COMMON_FACTOR: mul i32 [[EXPRESSION_0]], [[FACTOR_SRC0]] | ||
// NO_COMMON_FACTOR: [[EXPRESSION_1:%.*]] = mul i32 [[FACTOR_SRC0]], [[FACTOR_SRC1]] | ||
// NO_COMMON_FACTOR: mul i32 [[EXPRESSION_1]], | ||
|
||
|
||
RWTexture1D < float2 > outColorBuffer : register ( u0 ) ; | ||
|
||
[ numthreads ( 8 , 8 , 1 ) ] | ||
void cs_main ( uint3 GroupID : SV_GroupID , uint GroupIndex : SV_GroupIndex , uint3 GTID : SV_GroupThreadID , uint3 DispatchThreadID : SV_DispatchThreadID ) | ||
{ | ||
// DXC should recognize (GroupIndex * GTID.x) is a common factor | ||
uint a = GroupIndex * GroupID.x; | ||
uint b = GroupIndex * DispatchThreadID.x; | ||
uint c = a * GTID.x; | ||
uint d = b * GTID.x; | ||
|
||
outColorBuffer [ DispatchThreadID.y ] = float2(c, d); | ||
} |
24 changes: 24 additions & 0 deletions
24
tools/clang/test/DXC/Passes/reassociate/reassociation-flag.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,24 @@ | ||
; RUN: %dxopt %s -reassociate,EnableAggressiveReassociation=1 -gvn -S | FileCheck %s -check-prefixes=CHECK,COMMON_FACTOR | ||
; RUN: %dxopt %s -reassociate,EnableAggressiveReassociation=0 -gvn -S | FileCheck %s -check-prefixes=CHECK,NO_COMMON_FACTOR | ||
|
||
; CHECK: @test1 | ||
|
||
; COMMON_FACTOR: %[[FACTOR:.*]] = mul i32 %X4, %X3 | ||
; COMMON_FACTOR-NEXT: %[[C:.*]] = mul i32 %[[FACTOR]], %X1 | ||
; COMMON_FACTOR-NEXT: %[[D:.*]] = mul i32 %[[FACTOR]], %X2 | ||
|
||
; NO_COMMON_FACTOR: %[[A:.*]] = mul i32 %X3, %X1 | ||
; NO_COMMON_FACTOR: %[[B:.*]] = mul i32 %X3, %X2 | ||
; NO_COMMON_FACTOR: %[[C:.*]] = mul i32 %[[A]], %X4 | ||
; NO_COMMON_FACTOR: %[[D:.*]] = mul i32 %[[B]], %X4 | ||
|
||
; CHECK: %[[E:.*]] = xor i32 %[[C]], %[[D]] | ||
; CHECK: ret i32 %[[E]] | ||
define i32 @test1(i32 %X1, i32 %X2, i32 %X3, i32 %X4) { | ||
%A = mul i32 %X3, %X1 | ||
%B = mul i32 %X3, %X2 | ||
%C = mul i32 %A, %X4 | ||
%D = mul i32 %B, %X4 | ||
%E = xor i32 %C, %D | ||
ret i32 %E | ||
} |
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