Last active
September 26, 2015 22:17
-
-
Save JayFoxRox/d98fcc8312d33e69b1df to your computer and use it in GitHub Desktop.
select min and max value
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
uint x; | |
uint y; | |
if (false) { // 46 cycles, 9 instrs. | |
x = min(ia,ib); | |
y = max(ia,ib); | |
} | |
if (false) { // 30 cycles, 15 instrs. | |
if (ia <= ib) { | |
x = ia; | |
y = ib; | |
} else { | |
x = ib; | |
y = ia; | |
} | |
} | |
if (true) { // 30 cycles, 14 instrs. | |
x = ib; | |
y = ia; | |
if (ia <= ib) { | |
x = ia; | |
y = ib; | |
} | |
} | |
if (true) { // 30 cycles, 15 instrs. | |
uvec2 iab = uvec2(ia,ib); | |
uvec2 tmp = (iab.x <= iab.y) ? iab.xy : iab.yx; | |
x = tmp.x; | |
y = tmp.y; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment