Skip to content

intel/brw: Use CSEL to implement fsign

Ian Romanick requested to merge idr/mesa:review/an-fsign-of-the-times into main

NOTE: The spirv: commit is from !29091 (merged), but it is necessary for the later commits to continue passing CTS.

The current optimized path for fsign uses predication. This causes problems if we want to generate back-end IR that is mostly SSA. This can be done without too much effort using CSEL. !28666 (merged) has some commits that do this.

As with "intel/brw: Handle fsign optimization in a NIR algebraic pass" in this MR, the changes in !28666 (merged) result in piles of code quality regressions. It is possible to fix many of those code quality regressions by handling some NIR patterns differently. Matching these patterns in the existing C is painful. We have a much nicer way to match NIR patterns, so let's use that instead.

While looking at the code in !28666 (merged), I also noticed that the fp64 fast-path was broken. Instead of trying to fix it in the C code, the first two commits in this MR just delete it. Nothing in shader-db, fossil-db, or any CTS hit this path.

Tiger Lake tends to show somewhat different results because it is effectively the only platform that can have an immediate source for CSEL. All Xe and newer platforms can, but it is limit to HF. Tiger Lake is the only platform that can mix HF and F sources.

shader-db summary across the whole series:

Meteor Lake and DG2 had similar results. (Meteor Lake shown)
total instructions in shared programs: 19663941 -> 19648661 (-0.08%)
instructions in affected programs: 1472676 -> 1457396 (-1.04%)
helped: 3845 / HURT: 1739

total cycles in shared programs: 810391528 -> 809628188 (-0.09%)
cycles in affected programs: 427160602 -> 426397262 (-0.18%)
helped: 5351 / HURT: 1962

total spills in shared programs: 3899 -> 3903 (0.10%)
spills in affected programs: 256 -> 260 (1.56%)
helped: 0 / HURT: 4

total fills in shared programs: 3257 -> 3327 (2.15%)
fills in affected programs: 882 -> 952 (7.94%)
helped: 0 / HURT: 12

LOST:   47
GAINED: 42


Tiger Lake
total instructions in shared programs: 19483335 -> 19467536 (-0.08%)
instructions in affected programs: 1435705 -> 1419906 (-1.10%)
helped: 3836 / HURT: 1720

total cycles in shared programs: 810377129 -> 810951111 (0.07%)
cycles in affected programs: 422074252 -> 422648234 (0.14%)
helped: 5509 / HURT: 1781

total spills in shared programs: 3906 -> 3907 (0.03%)
spills in affected programs: 16 -> 17 (6.25%)
helped: 0 / HURT: 1

total fills in shared programs: 3218 -> 3222 (0.12%)
fills in affected programs: 48 -> 52 (8.33%)
helped: 0 / HURT: 1

LOST:   55
GAINED: 42


Ice Lake
total instructions in shared programs: 20309222 -> 20291750 (-0.09%)
instructions in affected programs: 1514405 -> 1496933 (-1.15%)
helped: 4097 / HURT: 1753

total cycles in shared programs: 831499113 -> 829983208 (-0.18%)
cycles in affected programs: 412820573 -> 411304668 (-0.37%)
helped: 5895 / HURT: 1723

total spills in shared programs: 4580 -> 4565 (-0.33%)
spills in affected programs: 177 -> 162 (-8.47%)
helped: 3 / HURT: 0

total fills in shared programs: 5220 -> 5219 (-0.02%)
fills in affected programs: 354 -> 353 (-0.28%)
helped: 2 / HURT: 1

LOST:   44
GAINED: 40


Skylake
total instructions in shared programs: 18543271 -> 18526062 (-0.09%)
instructions in affected programs: 1444352 -> 1427143 (-1.19%)
helped: 4049 / HURT: 1751

total cycles in shared programs: 817508277 -> 816162747 (-0.16%)
cycles in affected programs: 404575951 -> 403230421 (-0.33%)
helped: 5721 / HURT: 1807

total spills in shared programs: 4300 -> 4286 (-0.33%)
spills in affected programs: 191 -> 177 (-7.33%)
helped: 3 / HURT: 1

total fills in shared programs: 4630 -> 4633 (0.06%)
fills in affected programs: 396 -> 399 (0.76%)
helped: 2 / HURT: 2

LOST:   57
GAINED: 25

fossil-db summary across the whole series:

Meteor Lake and DG2 had similar results. (Meteor Lake shown)
*** Shaders only in 'after' results are ignored:
fossil-db/steam-dxvk/batman_arkham_origins/e86d1457083bd7b3/fs.32/1, fossil-db/steam-dxvk/batman_arkham_origins/871ae246c4c38e55/fs.32/0, fossil-db/steam-dxvk/batman_arkham_city_goty/2e146aee04e648e2/fs.32/0, fossil-db/steam-dxvk/batman_arkham_city_goty/7ebfc9df53f36a05/fs.32/0, fossil-db/steam-dxvk/batman_arkham_origins/6eaffc75edc3f755/fs.32/0, and 71 more
from 5 apps: fossil-db/steam-dxvk/batman_arkham_city_goty, fossil-db/steam-dxvk/batman_arkham_origins, fossil-db/steam-native/red_dead_redemption2, fossil-db/steam-native/shooter_demo_g2, fossil-db/steam-native/wolfenstein_youngblood

*** Shaders only in 'before' results are ignored:
fossil-db/steam-native/red_dead_redemption2/fcd04e82b7346f9d/fs.32/0, fossil-db/unicom/655d0acd9d81e46c/fs.16/0, fossil-db/steam-dxvk/assassins_creed_odyssey/d4621999bb2402e1/fs.32/0
from 3 apps: fossil-db/steam-dxvk/assassins_creed_odyssey, fossil-db/steam-native/red_dead_redemption2, fossil-db/unicom

Totals:
Instrs: 154008924 -> 154008167 (-0.00%); split: -0.00%, +0.00%
Cycle count: 17465217044 -> 17461513529 (-0.02%); split: -0.03%, +0.01%
Spill count: 141257 -> 141246 (-0.01%); split: -0.02%, +0.01%
Fill count: 265374 -> 265159 (-0.08%); split: -0.13%, +0.05%
Max live registers: 32595045 -> 32595455 (+0.00%); split: -0.00%, +0.00%
Max dispatch width: 5535872 -> 5537048 (+0.02%); split: +0.02%, -0.00%

Totals from 5896 (0.93% of 631364) affected shaders:
Instrs: 5474275 -> 5473518 (-0.01%); split: -0.11%, +0.10%
Cycle count: 1650743596 -> 1647040081 (-0.22%); split: -0.37%, +0.14%
Spill count: 26325 -> 26314 (-0.04%); split: -0.10%, +0.06%
Fill count: 57334 -> 57119 (-0.37%); split: -0.59%, +0.21%
Max live registers: 432954 -> 433364 (+0.09%); split: -0.00%, +0.10%
Max dispatch width: 49744 -> 50920 (+2.36%); split: +2.44%, -0.08%


Tiger Lake
*** Shaders only in 'before' results are ignored:
fossil-db/steam-native/red_dead_redemption2/14ae9d8b858351a9/fs.32/0, fossil-db/steam-native/red_dead_redemption2/fcd04e82b7346f9d/fs.32/0, fossil-db/unicom/655d0acd9d81e46c/fs.16/0, fossil-db/steam-native/red_dead_redemption2/0b593f9c36936303/fs.32/0
from 2 apps: fossil-db/steam-native/red_dead_redemption2, fossil-db/unicom

Totals:
Instrs: 149561497 -> 149562349 (+0.00%); split: -0.00%, +0.00%
Cycle count: 15158484074 -> 15158962017 (+0.00%); split: -0.01%, +0.01%
Spill count: 60086 -> 60085 (-0.00%); split: -0.02%, +0.01%
Max live registers: 32249268 -> 32249708 (+0.00%); split: -0.00%, +0.00%
Max dispatch width: 5540560 -> 5540504 (-0.00%)

Totals from 5889 (0.93% of 630304) affected shaders:
Instrs: 4740211 -> 4741063 (+0.02%); split: -0.08%, +0.10%
Cycle count: 569862315 -> 570340258 (+0.08%); split: -0.14%, +0.23%
Spill count: 11658 -> 11657 (-0.01%); split: -0.09%, +0.08%
Max live registers: 425680 -> 426120 (+0.10%); split: -0.00%, +0.10%
Max dispatch width: 50296 -> 50240 (-0.11%)


Ice Lake
*** Shaders only in 'after' results are ignored:
fossil-db/steam-native/red_dead_redemption2/14ae9d8b858351a9/fs.32/0, fossil-db/steam-dxvk/batman_arkham_origins/8f375dc4553965af/fs.32/0, fossil-db/steam-dxvk/batman_arkham_origins/b8113ba511c5eaf8/fs.32/0, fossil-db/steam-native/wolfenstein_youngblood/b8cefe7f700304c4/fs.32/0, fossil-db/steam-dxvk/batman_arkham_origins/c201d29e5d1feb90/fs.32/0, and 6 more
from 3 apps: fossil-db/steam-dxvk/batman_arkham_origins, fossil-db/steam-native/red_dead_redemption2, fossil-db/steam-native/wolfenstein_youngblood

*** Shaders only in 'before' results are ignored:
fossil-db/steam-dxvk/assassins_creed_odyssey/5b7924135d9cfbcc/fs.32/0, fossil-db/steam-dxvk/assassins_creed_odyssey/695d0a7113ca9b81/fs.32/0, fossil-db/steam-native/red_dead_redemption2/fcd04e82b7346f9d/fs.32/0, fossil-db/steam-dxvk/assassins_creed_odyssey/3cc9c38bb549d6e6/fs.32/0, fossil-db/steam-dxvk/assassins_creed_odyssey/1579eb27515f8258/fs.32/0, and 1 more
from 3 apps: fossil-db/steam-dxvk/assassins_creed_odyssey, fossil-db/steam-native/red_dead_redemption2, fossil-db/unicom

Totals:
Instrs: 150534183 -> 150535015 (+0.00%); split: -0.00%, +0.00%
Cycle count: 14993160758 -> 14992937943 (-0.00%); split: -0.00%, +0.00%
Spill count: 59851 -> 59854 (+0.01%)
Fill count: 99768 -> 99767 (-0.00%); split: -0.00%, +0.00%
Max live registers: 32605677 -> 32606116 (+0.00%); split: -0.00%, +0.00%
Max dispatch width: 5617712 -> 5617800 (+0.00%); split: +0.00%, -0.00%

Totals from 5902 (0.93% of 634932) affected shaders:
Instrs: 4736472 -> 4737304 (+0.02%); split: -0.08%, +0.10%
Cycle count: 598559898 -> 598337083 (-0.04%); split: -0.09%, +0.05%
Spill count: 10218 -> 10221 (+0.03%)
Fill count: 22388 -> 22387 (-0.00%); split: -0.01%, +0.01%
Max live registers: 424782 -> 425221 (+0.10%); split: -0.00%, +0.10%
Max dispatch width: 50512 -> 50600 (+0.17%); split: +0.35%, -0.17%


Skylake
*** Shaders only in 'after' results are ignored:
fossil-db/steam-dxvk/batman_arkham_city_goty/eb90d1c67abca260/fs.32/0, fossil-db/steam-dxvk/batman_arkham_city_goty/29a8f26e52b7ea13/fs.32/0, fossil-db/steam-dxvk/batman_arkham_city_goty/1ea8c1ec52f2ef72/fs.32/0
from 1 apps: fossil-db/steam-dxvk/batman_arkham_city_goty

*** Shaders only in 'before' results are ignored:
fossil-db/steam-dxvk/assassins_creed_odyssey/b953c364ce61a8b9/fs.32/0, fossil-db/steam-native/red_dead_redemption2/fcd04e82b7346f9d/fs.32/0, fossil-db/steam-dxvk/assassins_creed_odyssey/68f629c63ef2692a/fs.32/0, fossil-db/steam-dxvk/assassins_creed_odyssey/503747cb36843115/fs.32/0
from 2 apps: fossil-db/steam-dxvk/assassins_creed_odyssey, fossil-db/steam-native/red_dead_redemption2

Totals:
Instrs: 139128159 -> 139128747 (+0.00%); split: -0.00%, +0.00%
Cycle count: 14465766483 -> 14465740498 (-0.00%); split: -0.00%, +0.00%
Spill count: 57991 -> 57987 (-0.01%)
Fill count: 95205 -> 95124 (-0.09%)
Max live registers: 31925468 -> 31925907 (+0.00%); split: -0.00%, +0.00%
Max dispatch width: 5484552 -> 5484536 (-0.00%); split: +0.00%, -0.00%

Totals from 5812 (0.93% of 625513) affected shaders:
Instrs: 4488884 -> 4489472 (+0.01%); split: -0.08%, +0.10%
Cycle count: 578751367 -> 578725382 (-0.00%); split: -0.06%, +0.05%
Spill count: 9248 -> 9244 (-0.04%)
Fill count: 19677 -> 19596 (-0.41%)
Max live registers: 416433 -> 416872 (+0.11%); split: -0.00%, +0.11%
Max dispatch width: 50024 -> 50008 (-0.03%); split: +0.10%, -0.13%
Edited by Ian Romanick

Merge request reports

Loading