Find a file
Ian Romanick 67f0fc62fd brw: Replace logical operations with predication
There is more to do here. A few things I have noticed.

1. There are cases where the ideal pass cannot make progress, but the
   "logic op to predicated move" pass can. Sometimes scheduling can
   rearrange this to sequences like:

            cmp.nz.f0.0(16) g99<1>F       g98<1,1,0>F     0x3f800000F
            cmp.g.f0.0(16)  null<1>HF     g106<16,16,1>HF 0x0000HF
    (+f0.0) mov.nz.f0.0(16) null<1>UD     g99<8,8,1>UD

  We should be able to detect this after scheduling, and eliminate the
  mov.nz.

2. We should extend post-scheduling cmod propagation to handle cases
   where a predicated CMP is the only use of an ALU result. I have
   observed sequences like

            and(16)        v5200:UD       v5048+6.0:UD    134217726u
    (+f0.0) cmp.z.f0.0(16) null:D         v5200:D         0d

   and

            or(16)          g113<1>UD     g112<1,1,0>UD   g20<1,1,0>UD
    (-f0.0) mov.nz.f0.0(16) null<1>UD     g113<8,8,1>UD

v2: Don't allow SEL or CSEL in is_valid_logic_source. No shader-db or
fossil-db changes here, but this prevents problems with (possible)
future commits.

v3: Replace hither and yon with nearer and farther. Find both logic
sources in one loop. Use brw_flags_written. Refactor cmod selection (for
BFN vs all other opcodes) to separate function. Suggested by Caio.

v4: Actually remove flags_written now. Suggested (twice) by Caio.
Require that flags written by the nearer logic source matches the flags
written by the logic operation. This fixes cmp_flag_subreg_mismatch and
mov_flag_subreg_mismatch (added in the next commit). Also
s/inst->src[0]/inst->src[src]/. Noticed by Caio.

v5: flags_read was also unused. Noticed by marge.

shader-db:

Lunar Lake
total instructions in shared programs: 17083282 -> 17072645 (-0.06%)
instructions in affected programs: 2076491 -> 2065854 (-0.51%)
helped: 3952 / HURT: 0

total cycles in shared programs: 887823360 -> 889080938 (0.14%)
cycles in affected programs: 472236518 -> 473494096 (0.27%)
helped: 3156 / HURT: 936

total fills in shared programs: 1778 -> 1778 (0.00%)
fills in affected programs: 286 -> 286 (0.00%)
helped: 2 / HURT: 2

LOST:   27
GAINED: 14

Meteor Lake and DG2 had similar results. (Meteor Lake shown)
total instructions in shared programs: 19980337 -> 19965369 (-0.07%)
instructions in affected programs: 2406043 -> 2391075 (-0.62%)
helped: 4621 / HURT: 7

total cycles in shared programs: 887416449 -> 887170456 (-0.03%)
cycles in affected programs: 457957623 -> 457711630 (-0.05%)
helped: 3776 / HURT: 1039

total fills in shared programs: 4371 -> 4375 (0.09%)
fills in affected programs: 798 -> 802 (0.50%)
helped: 4 / HURT: 6

LOST:   15
GAINED: 1

Tiger Lake
total instructions in shared programs: 19904512 -> 19889603 (-0.07%)
instructions in affected programs: 2405908 -> 2390999 (-0.62%)
helped: 4616 / HURT: 22

total cycles in shared programs: 864580948 -> 863953289 (-0.07%)
cycles in affected programs: 459500521 -> 458872862 (-0.14%)
helped: 3710 / HURT: 1093

total spills in shared programs: 3467 -> 3472 (0.14%)
spills in affected programs: 15 -> 20 (33.33%)
helped: 0 / HURT: 1

total fills in shared programs: 2059 -> 2069 (0.49%)
fills in affected programs: 47 -> 57 (21.28%)
helped: 0 / HURT: 1

LOST:   11
GAINED: 9

Ice Lake
total instructions in shared programs: 20821682 -> 20806373 (-0.07%)
instructions in affected programs: 2447072 -> 2431763 (-0.63%)
helped: 4741 / HURT: 1

total cycles in shared programs: 876811334 -> 876360389 (-0.05%)
cycles in affected programs: 438363075 -> 437912130 (-0.10%)
helped: 4000 / HURT: 724

total fills in shared programs: 3837 -> 3835 (-0.05%)
fills in affected programs: 302 -> 300 (-0.66%)
helped: 1 / HURT: 0

LOST:   12
GAINED: 9

Skylake
total instructions in shared programs: 19041784 -> 19026462 (-0.08%)
instructions in affected programs: 2397491 -> 2382169 (-0.64%)
helped: 4711 / HURT: 0

total cycles in shared programs: 868019298 -> 867790279 (-0.03%)
cycles in affected programs: 441110462 -> 440881443 (-0.05%)
helped: 3915 / HURT: 788

total fills in shared programs: 3767 -> 3765 (-0.05%)
fills in affected programs: 302 -> 300 (-0.66%)
helped: 1 / HURT: 0

LOST:   4
GAINED: 3

fossil-db:

Lunar Lake
Totals:
Instrs: 924697067 -> 922488661 (-0.24%); split: -0.25%, +0.01%
Subgroup size: 40939424 -> 40939744 (+0.00%)
Cycle count: 106291402322 -> 105964111203 (-0.31%); split: -0.66%, +0.35%
Spill count: 3423988 -> 3421004 (-0.09%); split: -0.34%, +0.25%
Fill count: 4877087 -> 4862981 (-0.29%); split: -1.21%, +0.92%
Max live registers: 193812217 -> 193805296 (-0.00%)
Max dispatch width: 49089184 -> 49085216 (-0.01%); split: +0.01%, -0.02%

Totals from 453746 (22.47% of 2019504) affected shaders:
Instrs: 529674876 -> 527466470 (-0.42%); split: -0.43%, +0.02%
Subgroup size: 320 -> 640 (+100.00%)
Cycle count: 87892218969 -> 87564927850 (-0.37%); split: -0.79%, +0.42%
Spill count: 3302695 -> 3299711 (-0.09%); split: -0.35%, +0.26%
Fill count: 4778154 -> 4764048 (-0.30%); split: -1.23%, +0.94%
Max live registers: 65405449 -> 65398528 (-0.01%)
Max dispatch width: 10793104 -> 10789136 (-0.04%); split: +0.04%, -0.08%

Meteor Lake and DG2 had similar results. (Meteor Lake shown)
Totals:
Instrs: 998057341 -> 995683321 (-0.24%); split: -0.25%, +0.01%
Subgroup size: 27545440 -> 27545656 (+0.00%)
Cycle count: 93854696449 -> 93709099572 (-0.16%); split: -0.62%, +0.46%
Spill count: 3709547 -> 3701296 (-0.22%); split: -0.50%, +0.28%
Fill count: 5032889 -> 5014189 (-0.37%); split: -1.28%, +0.91%
Max live registers: 121823974 -> 121810927 (-0.01%)
Max dispatch width: 38021936 -> 38020536 (-0.00%); split: +0.06%, -0.07%

Totals from 505565 (22.13% of 2284025) affected shaders:
Instrs: 549480901 -> 547106881 (-0.43%); split: -0.45%, +0.02%
Subgroup size: 216 -> 432 (+100.00%)
Cycle count: 76260069937 -> 76114473060 (-0.19%); split: -0.76%, +0.57%
Spill count: 3526038 -> 3517787 (-0.23%); split: -0.53%, +0.29%
Fill count: 4844826 -> 4826126 (-0.39%); split: -1.33%, +0.94%
Max live registers: 38085235 -> 38072188 (-0.03%)
Max dispatch width: 8015432 -> 8014032 (-0.02%); split: +0.30%, -0.32%

Tiger Lake
Totals:
Instrs: 1013436935 -> 1011070083 (-0.23%); split: -0.25%, +0.02%
Cycle count: 85763486346 -> 85580242131 (-0.21%); split: -0.68%, +0.47%
Spill count: 3903905 -> 3902350 (-0.04%); split: -0.36%, +0.32%
Fill count: 6801966 -> 6787600 (-0.21%); split: -0.70%, +0.49%
Max live registers: 122298352 -> 122284634 (-0.01%)
Max dispatch width: 37957184 -> 37964608 (+0.02%); split: +0.10%, -0.08%

Totals from 525103 (23.03% of 2280298) affected shaders:
Instrs: 570013347 -> 567646495 (-0.42%); split: -0.44%, +0.03%
Cycle count: 71392808767 -> 71209564552 (-0.26%); split: -0.82%, +0.56%
Spill count: 3757751 -> 3756196 (-0.04%); split: -0.38%, +0.33%
Fill count: 6648525 -> 6634159 (-0.22%); split: -0.72%, +0.51%
Max live registers: 39876402 -> 39862684 (-0.03%)
Max dispatch width: 8453816 -> 8461240 (+0.09%); split: +0.44%, -0.36%

Ice Lake
Totals:
Instrs: 1014312031 -> 1011938992 (-0.23%); split: -0.24%, +0.01%
Cycle count: 86550003161 -> 86343662349 (-0.24%); split: -0.39%, +0.15%
Spill count: 3039497 -> 3035267 (-0.14%); split: -0.33%, +0.19%
Fill count: 5376655 -> 5370235 (-0.12%); split: -0.43%, +0.32%
Max live registers: 125551684 -> 125537675 (-0.01%)
Max dispatch width: 41300016 -> 41301552 (+0.00%); split: +0.02%, -0.02%

Totals from 537158 (23.01% of 2334535) affected shaders:
Instrs: 555656911 -> 553283872 (-0.43%); split: -0.44%, +0.01%
Cycle count: 71869799780 -> 71663458968 (-0.29%); split: -0.47%, +0.19%
Spill count: 2844469 -> 2840239 (-0.15%); split: -0.35%, +0.20%
Fill count: 5006995 -> 5000575 (-0.13%); split: -0.47%, +0.34%
Max live registers: 39809729 -> 39795720 (-0.04%)
Max dispatch width: 9226240 -> 9227776 (+0.02%); split: +0.10%, -0.08%

Skylake
Totals:
Instrs: 519584256 -> 518938991 (-0.12%); split: -0.13%, +0.00%
Cycle count: 57935410863 -> 57867852550 (-0.12%); split: -0.22%, +0.10%
Spill count: 636741 -> 636728 (-0.00%); split: -0.06%, +0.06%
Fill count: 860470 -> 860314 (-0.02%); split: -0.19%, +0.17%
Max live registers: 87895659 -> 87889485 (-0.01%)
Max dispatch width: 32565912 -> 32567080 (+0.00%); split: +0.03%, -0.03%

Totals from 235957 (13.59% of 1736653) affected shaders:
Instrs: 158020578 -> 157375313 (-0.41%); split: -0.41%, +0.00%
Cycle count: 44881056772 -> 44813498459 (-0.15%); split: -0.28%, +0.13%
Spill count: 461098 -> 461085 (-0.00%); split: -0.09%, +0.09%
Fill count: 601255 -> 601099 (-0.03%); split: -0.27%, +0.24%
Max live registers: 16143628 -> 16137454 (-0.04%)
Max dispatch width: 4664240 -> 4665408 (+0.03%); split: +0.20%, -0.17%

Reviewed-by: Caio Oliveira <caio.oliveira@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/39030>
2026-06-23 15:49:13 +00:00
.ci-farms ci-farms/vmware: Disable vmware tests for now 2026-06-17 18:11:48 -07:00
.ci-farms-disabled ci-farms/vmware: Disable vmware tests for now 2026-06-17 18:11:48 -07:00
.github/workflows meson: remove unused osmesa option 2025-06-23 06:42:50 +00:00
.gitlab radv: introduce RADV_EXPERIMENTAL envvar for experimental features 2026-03-30 07:27:01 +00:00
.gitlab-ci rti: Initial commit 2026-06-21 17:10:43 +00:00
.marge/hooks marge/pipeline_message: print details for any pipeline that hasn't succeeded 2026-02-13 14:44:30 +00:00
android amd/virtio: enable Android amdgpu-virtio build option 2026-06-08 08:29:43 +00:00
bin tools: Update imgui to the docking branch and add backends 2026-06-21 17:10:43 +00:00
build-support
docs kk: Disable workarounds 1-6 in macOS 27 2026-06-23 09:52:24 +00:00
include drm-uapi: Sync the panthor header 2026-06-19 18:20:30 +00:00
licenses licenses: add missing licenses 2025-01-08 20:37:51 +00:00
src brw: Replace logical operations with predication 2026-06-23 15:49:13 +00:00
subprojects perfetto: v56.1 update 2026-06-17 16:39:52 +00:00
.clang-format meson: Restore .clang-format for ninja clang-format target 2026-02-02 13:30:55 +00:00
.clang-format-ignore ethosu: Switch to the weight encoder from Regor 2026-03-23 07:45:55 +00:00
.clang-format-include kk: Enable code formatting enforcement 2026-05-25 15:30:32 +00:00
.dir-locals.el
.editorconfig editorconfig: Set for glsl files 2025-11-14 19:31:17 +00:00
.git-blame-ignore-revs radv: Add re-format commit to .git-blame-ignore-revs 2025-11-12 07:55:36 +00:00
.gitattributes
.gitignore Revert "add VK CTS validation report for a0 interpolation fix" 2026-02-10 18:07:18 +00:00
.gitlab-ci.yml ci: changing .gitlab-ci.yml itself also means the container jobs must exist 2026-03-18 14:19:02 +00:00
.graphqlrc.yml
.mailmap mailmap: Update my email 2026-03-12 23:36:00 +00:00
.mr-label-maker.yml mr-label-maker: Add rule for new trace replay config files 2026-05-11 08:02:05 +00:00
.shellcheckrc ci: move shellcheck options to .shellcheckrc 2024-10-24 22:43:03 +00:00
clippy.toml meson: Bump the minimum rust version to 1.85.0 2026-05-30 01:20:10 +00:00
CODEOWNERS CODEOWNERS: add Jay 2026-05-27 20:03:10 +00:00
meson.build rti: Initial commit 2026-06-21 17:10:43 +00:00
meson.options rti: Initial commit 2026-06-21 17:10:43 +00:00
README.rst docs: Match README installation guide with meson.rst 2024-07-27 11:53:53 +00:00
rustfmt.toml mesa: Add rustfmt.toml 2024-11-18 22:29:14 +00:00
VERSION VERSION: bump to 26.2 2026-04-15 13:15:35 +00:00

`Mesa <https://mesa3d.org>`_ - The 3D Graphics Library
======================================================


Source
------

This repository lives at https://gitlab.freedesktop.org/mesa/mesa.
Other repositories are likely forks, and code found there is not supported.


Build & install
---------------

You can find more information in our documentation (`docs/install.rst
<https://docs.mesa3d.org/install.html>`_), but the recommended way is to use
Meson (`docs/meson.rst <https://docs.mesa3d.org/meson.html>`_):

.. code-block:: sh

  $ meson setup build
  $ ninja -C build/
  $ sudo ninja -C build/ install

Support
-------

Many Mesa devs hang on IRC; if you're not sure which channel is
appropriate, you should ask your question on `OFTC's #dri-devel
<irc://irc.oftc.net/dri-devel>`_, someone will redirect you if
necessary.
Remember that not everyone is in the same timezone as you, so it might
take a while before someone qualified sees your question.
To figure out who you're talking to, or which nick to ping for your
question, check out `Who's Who on IRC
<https://dri.freedesktop.org/wiki/WhosWho/>`_.

The next best option is to ask your question in an email to the
mailing lists: `mesa-dev\@lists.freedesktop.org
<https://lists.freedesktop.org/mailman/listinfo/mesa-dev>`_


Bug reports
-----------

If you think something isn't working properly, please file a bug report
(`docs/bugs.rst <https://docs.mesa3d.org/bugs.html>`_).


Contributing
------------

Contributions are welcome, and step-by-step instructions can be found in our
documentation (`docs/submittingpatches.rst
<https://docs.mesa3d.org/submittingpatches.html>`_).

Note that Mesa uses gitlab for patches submission, review and discussions.