mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-08 04:48:08 +02:00
nir: Fix constant folding for irhadd/urhadd
This should be a subtract, not an add. The comment's proof is correct, but the (wrong) expression we actually use isn't what it's in the comment! Correct the discrepancy. The lowering in nir_opt_algebraic was correctly typed. Fixes:272e927d0e("nir/spirv: initial handling of OpenCL.std extension opcodes") Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com> Reviewed-by: Jason Ekstrand <jason@jlekstrand.net> Reviewed-by: Karol Herbst <kherbst@redhat.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11671> (cherry picked from commit3da23a9c7e)
This commit is contained in:
parent
ec910d2e24
commit
1b3211780f
2 changed files with 3 additions and 3 deletions
|
|
@ -4432,7 +4432,7 @@
|
|||
"description": "nir: Fix constant folding for irhadd/urhadd",
|
||||
"nominated": true,
|
||||
"nomination_type": 1,
|
||||
"resolution": 0,
|
||||
"resolution": 1,
|
||||
"main_sha": null,
|
||||
"because_sha": "272e927d0e9fed6e791d706ff5d895b6c2036fc0"
|
||||
},
|
||||
|
|
|
|||
|
|
@ -770,8 +770,8 @@ binop("uhadd", tuint, _2src_commutative, "(src0 & src1) + ((src0 ^ src1) >> 1)")
|
|||
#
|
||||
# (x + y + 1) >> 1 = (x | y) + (-(x ^ y) + 1) >> 1)
|
||||
# = (x | y) - ((x ^ y) >> 1)
|
||||
binop("irhadd", tint, _2src_commutative, "(src0 | src1) + ((src0 ^ src1) >> 1)")
|
||||
binop("urhadd", tuint, _2src_commutative, "(src0 | src1) + ((src0 ^ src1) >> 1)")
|
||||
binop("irhadd", tint, _2src_commutative, "(src0 | src1) - ((src0 ^ src1) >> 1)")
|
||||
binop("urhadd", tuint, _2src_commutative, "(src0 | src1) - ((src0 ^ src1) >> 1)")
|
||||
|
||||
binop("umod", tuint, "", "src1 == 0 ? 0 : src0 % src1")
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue