nir/algebraic: Optimize ushr of pack_half, not ishr

When a = -1.0, pack_half_2x16(vec2(0x0000, 0xBC00)) will produce
0xBC000000.  The ishr will produce 0xFFFFBC00.  The replacement
pack_half_2x16(vec2(0xBC00, 0x0000)) will produce 0x0000BC00.

Fixes: 1f72857739 ("nir/algebraic: add some half packing optimizations")
Reviewed-by: Rhys Perry <pendingchaos02@gmail.com>
Reviewed-by: Matt Turner <mattst88@gmail.com>
Cc: Connor Abbott <cwabbott0@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4515>
(cherry picked from commit a2bf41ec65)
This commit is contained in:
Ian Romanick 2020-04-02 12:14:12 -07:00 committed by Eric Engestrom
parent fa01a9397f
commit 750a0125df
2 changed files with 2 additions and 2 deletions

View file

@ -661,7 +661,7 @@
"description": "nir/algebraic: Optimize ushr of pack_half, not ishr",
"nominated": true,
"nomination_type": 1,
"resolution": 0,
"resolution": 1,
"master_sha": null,
"because_sha": "1f72857739beed55276f263f49b3802c336b8c58"
},

View file

@ -998,7 +998,7 @@ optimizations.extend([
# Optimize half packing
(('ishl', ('pack_half_2x16', ('vec2', a, 0)), 16), ('pack_half_2x16', ('vec2', 0, a))),
(('ishr', ('pack_half_2x16', ('vec2', 0, a)), 16), ('pack_half_2x16', ('vec2', a, 0))),
(('ushr', ('pack_half_2x16', ('vec2', 0, a)), 16), ('pack_half_2x16', ('vec2', a, 0))),
(('iadd', ('pack_half_2x16', ('vec2', a, 0)), ('pack_half_2x16', ('vec2', 0, b))),
('pack_half_2x16', ('vec2', a, b))),