Add folding of redundant OpSelect insns
authorArseny Kapoulkine <arseny.kapoulkine@gmail.com>
Thu, 15 Feb 2018 04:45:36 +0000 (20:45 -0800)
committerSteven Perron <31666470+s-perron@users.noreply.github.com>
Thu, 15 Feb 2018 15:03:22 +0000 (10:03 -0500)
commit32a8e04c7dd4dc7139d73b8e1081fd81e08cc66f
treecfa98206c5d3401dc3efbf29713113288b826dc1
parent0e9f2f948a50c02c1675765c6f847cb64139305a
Add folding of redundant OpSelect insns

We can fold OpSelect into one of the operands in two cases:

- condition is constant
- both results are the same

Even if the original shader doesn't have either of these, if-conversion
pass sometimes ends up generating instructions like

   %7127 = OpSelect %int %3220 %7058 %7058

And this optimization cleans them up.
source/opt/folding_rules.cpp
test/opt/fold_test.cpp