Skip to content
Snippets Groups Projects
Commit d55835b8 authored by Faith Ekstrand's avatar Faith Ekstrand :speech_balloon:
Browse files

nir/algebraic: Add optimizations for "a == a && a CMP b"


This sequence shows up The Talos Principal, at least under Vulkan,
and prevents loop analysis from properly computing trip counts in a
few loops.

Reviewed-by: default avatarIan Romanick <ian.d.romanick@intel.com>
parent 8962cc96
No related branches found
No related tags found
No related merge requests found
......@@ -464,6 +464,14 @@ def bitfield_reverse(u):
optimizations += [(bitfield_reverse('x@32'), ('bitfield_reverse', 'x'))]
# For any float comparison operation, "cmp", if you have "a == a && a cmp b"
# then the "a == a" is redundant because it's equivalent to "a is not NaN"
# and, if a is a NaN then the second comparison will fail anyway.
for op in ['flt', 'fge', 'feq']:
optimizations += [
(('iand', ('feq', a, a), (op, a, b)), (op, a, b)),
(('iand', ('feq', a, a), (op, b, a)), (op, b, a)),
]
# Add optimizations to handle the case where the result of a ternary is
# compared to a constant. This way we can take things like
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment