@@ -1562,9 +1562,9 @@ OpFunctionEnd
15621562
15631563TEST_F (UpgradeMemoryModelTest, TessellationControlBarrierNoChange) {
15641564 const std::string text = R"(
1565- ; CHECK: [[none:%\w+]] = OpConstant {{%\w+}} 0
1566- ; CHECK: [[workgroup:%\w+]] = OpConstant {{%\w+}} 2
1567- ; CHECK: OpControlBarrier [[workgroup]] [[workgroup]] [[none]]
1565+ ; CHECK: [[none:%\w+]] = OpConstant {{%\w+}} 0{{\s*$}}
1566+ ; CHECK: [[workgroup:%\w+]] = OpConstant {{%\w+}} 2{{\s*$}}
1567+ ; CHECK: OpControlBarrier [[workgroup]] [[workgroup]] [[none]]{{\s*$}}
15681568OpCapability Tessellation
15691569OpMemoryModel Logical GLSL450
15701570OpEntryPoint TessellationControl %func "func"
@@ -1583,11 +1583,11 @@ OpFunctionEnd
15831583 SinglePassRunAndMatch<opt::UpgradeMemoryModel>(text, true );
15841584}
15851585
1586- TEST_F (UpgradeMemoryModelTest, TessellationControlBarrierAddOutput ) {
1586+ TEST_F (UpgradeMemoryModelTest, TessellationControlBarrierRelaxedNoChange ) {
15871587 const std::string text = R"(
1588- ; CHECK: [[workgroup :%\w+]] = OpConstant {{%\w+}} 2
1589- ; CHECK: [[output :%\w+]] = OpConstant {{%\w+}} 4096
1590- ; CHECK: OpControlBarrier [[workgroup]] [[workgroup]] [[output]]
1588+ ; CHECK: [[none :%\w+]] = OpConstant {{%\w+}} 0{{\s*$}}
1589+ ; CHECK: [[workgroup :%\w+]] = OpConstant {{%\w+}} 2{{\s*$}}
1590+ ; CHECK: OpControlBarrier [[workgroup]] [[workgroup]] [[none]]{{\s*$}}
15911591OpCapability Tessellation
15921592OpMemoryModel Logical GLSL450
15931593OpEntryPoint TessellationControl %func "func" %var
@@ -1610,25 +1610,52 @@ OpFunctionEnd
16101610 SinglePassRunAndMatch<opt::UpgradeMemoryModel>(text, true );
16111611}
16121612
1613+ TEST_F (UpgradeMemoryModelTest, TessellationControlBarrierAddOutput) {
1614+ const std::string text = R"(
1615+ ; CHECK: [[workgroup:%\w+]] = OpConstant {{%\w+}} 2{{\s*$}}
1616+ ; CHECK: [[acqrel_workgroup_output:%\w+]] = OpConstant {{%\w+}} 4360{{\s*$}}
1617+ ; CHECK: OpControlBarrier [[workgroup]] [[workgroup]] [[acqrel_workgroup_output]]{{\s*$}}
1618+ OpCapability Tessellation
1619+ OpMemoryModel Logical GLSL450
1620+ OpEntryPoint TessellationControl %func "func" %var
1621+ %void = OpTypeVoid
1622+ %int = OpTypeInt 32 0
1623+ %workgroup = OpConstant %int 2
1624+ %acqrel_workgroup = OpConstant %int 264
1625+ %ptr_int_Output = OpTypePointer Output %int
1626+ %var = OpVariable %ptr_int_Output Output
1627+ %func_ty = OpTypeFunction %void
1628+ %func = OpFunction %void None %func_ty
1629+ %1 = OpLabel
1630+ %ld = OpLoad %int %var
1631+ OpControlBarrier %workgroup %workgroup %acqrel_workgroup
1632+ OpStore %var %ld
1633+ OpReturn
1634+ OpFunctionEnd
1635+ )" ;
1636+
1637+ SinglePassRunAndMatch<opt::UpgradeMemoryModel>(text, true );
1638+ }
1639+
16131640TEST_F (UpgradeMemoryModelTest, TessellationMemoryBarrierNoChange) {
16141641 const std::string text = R"(
1615- ; CHECK: [[none :%\w+]] = OpConstant {{%\w+}} 0
1616- ; CHECK: [[workgroup :%\w+]] = OpConstant {{%\w+}} 2
1617- ; CHECK: OpMemoryBarrier [[workgroup]] [[none]]
1642+ ; CHECK: [[workgroup :%\w+]] = OpConstant {{%\w+}} 2{{\s*$}}
1643+ ; CHECK: [[acqrel_workgroup :%\w+]] = OpConstant {{%\w+}} 264{{\s*$}}
1644+ ; CHECK: OpMemoryBarrier [[workgroup]] [[acqrel_workgroup]]{{\s*$}}
16181645OpCapability Tessellation
16191646OpMemoryModel Logical GLSL450
16201647OpEntryPoint TessellationControl %func "func" %var
16211648%void = OpTypeVoid
16221649%int = OpTypeInt 32 0
1623- %none = OpConstant %int 0
16241650%workgroup = OpConstant %int 2
1651+ %acqrel_workgroup = OpConstant %int 264
16251652%ptr_int_Output = OpTypePointer Output %int
16261653%var = OpVariable %ptr_int_Output Output
16271654%func_ty = OpTypeFunction %void
16281655%func = OpFunction %void None %func_ty
16291656%1 = OpLabel
16301657%ld = OpLoad %int %var
1631- OpMemoryBarrier %workgroup %none
1658+ OpMemoryBarrier %workgroup %acqrel_workgroup
16321659OpStore %var %ld
16331660OpReturn
16341661OpFunctionEnd
@@ -1639,16 +1666,16 @@ OpFunctionEnd
16391666
16401667TEST_F (UpgradeMemoryModelTest, TessellationControlBarrierAddOutputSubFunction) {
16411668 const std::string text = R"(
1642- ; CHECK: [[workgroup:%\w+]] = OpConstant {{%\w+}} 2
1643- ; CHECK: [[output :%\w+]] = OpConstant {{%\w+}} 4096
1644- ; CHECK: OpControlBarrier [[workgroup]] [[workgroup]] [[output]]
1669+ ; CHECK: [[workgroup:%\w+]] = OpConstant {{%\w+}} 2{{\s*$}}
1670+ ; CHECK: [[acqrel_workgroup_output :%\w+]] = OpConstant {{%\w+}} 4360{{\s*$}}
1671+ ; CHECK: OpControlBarrier [[workgroup]] [[workgroup]] [[acqrel_workgroup_output]]{{\s*$}}
16451672OpCapability Tessellation
16461673OpMemoryModel Logical GLSL450
16471674OpEntryPoint TessellationControl %func "func" %var
16481675%void = OpTypeVoid
16491676%int = OpTypeInt 32 0
1650- %none = OpConstant %int 0
16511677%workgroup = OpConstant %int 2
1678+ %acqrel_workgroup = OpConstant %int 264
16521679%ptr_int_Output = OpTypePointer Output %int
16531680%var = OpVariable %ptr_int_Output Output
16541681%func_ty = OpTypeFunction %void
@@ -1660,7 +1687,7 @@ OpFunctionEnd
16601687%sub_func = OpFunction %void None %func_ty
16611688%2 = OpLabel
16621689%ld = OpLoad %int %var
1663- OpControlBarrier %workgroup %workgroup %none
1690+ OpControlBarrier %workgroup %workgroup %acqrel_workgroup
16641691OpStore %var %ld
16651692OpReturn
16661693OpFunctionEnd
@@ -1672,16 +1699,16 @@ OpFunctionEnd
16721699TEST_F (UpgradeMemoryModelTest,
16731700 TessellationControlBarrierAddOutputDifferentFunctions) {
16741701 const std::string text = R"(
1675- ; CHECK: [[workgroup:%\w+]] = OpConstant {{%\w+}} 2
1676- ; CHECK: [[output :%\w+]] = OpConstant {{%\w+}} 4096
1677- ; CHECK: OpControlBarrier [[workgroup]] [[workgroup]] [[output]]
1702+ ; CHECK: [[workgroup:%\w+]] = OpConstant {{%\w+}} 2{{\s*$}}
1703+ ; CHECK: [[acqrel_workgroup_output :%\w+]] = OpConstant {{%\w+}} 4360{{\s*$}}
1704+ ; CHECK: OpControlBarrier [[workgroup]] [[workgroup]] [[acqrel_workgroup_output]]{{\s*$}}
16781705OpCapability Tessellation
16791706OpMemoryModel Logical GLSL450
16801707OpEntryPoint TessellationControl %func "func" %var
16811708%void = OpTypeVoid
16821709%int = OpTypeInt 32 0
1683- %none = OpConstant %int 0
16841710%workgroup = OpConstant %int 2
1711+ %acqrel_workgroup = OpConstant %int 264
16851712%ptr_int_Output = OpTypePointer Output %int
16861713%var = OpVariable %ptr_int_Output Output
16871714%func_ty = OpTypeFunction %void
@@ -1701,7 +1728,7 @@ OpReturnValue %ld
17011728OpFunctionEnd
17021729%barrier_func = OpFunction %void None %func_ty
17031730%3 = OpLabel
1704- OpControlBarrier %workgroup %workgroup %none
1731+ OpControlBarrier %workgroup %workgroup %acqrel_workgroup
17051732OpReturn
17061733OpFunctionEnd
17071734%st_func = OpFunction %void None %st_func_ty
@@ -1717,21 +1744,22 @@ OpFunctionEnd
17171744
17181745TEST_F (UpgradeMemoryModelTest, ChangeControlBarrierMemoryScope) {
17191746 std::string text = R"(
1720- ; CHECK: [[workgroup:%\w+]] = OpConstant {{%\w+}} 2
1721- ; CHECK: [[queuefamily:%\w+]] = OpConstant {{%\w+}} 5
1722- ; CHECK: OpControlBarrier [[workgroup]] [[queuefamily]]
1747+ ; CHECK: [[workgroup:%\w+]] = OpConstant {{%\w+}} 2{{\s*$}}
1748+ ; CHECK: [[acqrel_workgroup:%\w+]] = OpConstant {{%\w+}} 264{{\s*$}}
1749+ ; CHECK: [[queuefamily:%\w+]] = OpConstant {{%\w+}} 5{{\s*$}}
1750+ ; CHECK: OpControlBarrier [[workgroup]] [[queuefamily]] [[acqrel_workgroup]]{{\s*$}}
17231751OpCapability Shader
17241752OpMemoryModel Logical GLSL450
17251753OpEntryPoint GLCompute %func "func"
17261754%void = OpTypeVoid
17271755%int = OpTypeInt 32 0
1728- %none = OpConstant %int 0
17291756%device = OpConstant %int 1
17301757%workgroup = OpConstant %int 2
1758+ %acqrel_workgroup = OpConstant %int 264
17311759%func_ty = OpTypeFunction %void
17321760%func = OpFunction %void None %func_ty
17331761%1 = OpLabel
1734- OpControlBarrier %workgroup %device %none
1762+ OpControlBarrier %workgroup %device %acqrel_workgroup
17351763OpReturn
17361764OpFunctionEnd
17371765)" ;
@@ -1741,19 +1769,20 @@ OpFunctionEnd
17411769
17421770TEST_F (UpgradeMemoryModelTest, ChangeMemoryBarrierMemoryScope) {
17431771 std::string text = R"(
1744- ; CHECK: [[queuefamily:%\w+]] = OpConstant {{%\w+}} 5
1745- ; CHECK: OpMemoryBarrier [[queuefamily]]
1772+ ; CHECK: [[acqrel_workgroup:%\w+]] = OpConstant {{%\w+}} 264{{\s*$}}
1773+ ; CHECK: [[queuefamily:%\w+]] = OpConstant {{%\w+}} 5{{\s*$}}
1774+ ; CHECK: OpMemoryBarrier [[queuefamily]] [[acqrel_workgroup]]{{\s*$}}
17461775OpCapability Shader
17471776OpMemoryModel Logical GLSL450
17481777OpEntryPoint GLCompute %func "func"
17491778%void = OpTypeVoid
17501779%int = OpTypeInt 32 0
1751- %none = OpConstant %int 0
17521780%device = OpConstant %int 1
1781+ %acqrel_workgroup = OpConstant %int 264
17531782%func_ty = OpTypeFunction %void
17541783%func = OpFunction %void None %func_ty
17551784%1 = OpLabel
1756- OpMemoryBarrier %device %none
1785+ OpMemoryBarrier %device %acqrel_workgroup
17571786OpReturn
17581787OpFunctionEnd
17591788)" ;
0 commit comments