From 6d924fd5f64f417290db024d79e4b4b914142ae8 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Mon, 20 Jul 2020 15:37:27 -0400 Subject: [PATCH] Minor replicate_swizzle optimization. Do it in two tests instead of three, and with two shifts instead of five. --- profiles/mojoshader_profile_common.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/profiles/mojoshader_profile_common.c b/profiles/mojoshader_profile_common.c index b0d84138..e456c074 100644 --- a/profiles/mojoshader_profile_common.c +++ b/profiles/mojoshader_profile_common.c @@ -331,9 +331,9 @@ int writemask_y(const int writemask) int replicate_swizzle(const int swizzle) { - return ( (((swizzle >> 0) & 0x3) == ((swizzle >> 2) & 0x3)) && - (((swizzle >> 2) & 0x3) == ((swizzle >> 4) & 0x3)) && - (((swizzle >> 4) & 0x3) == ((swizzle >> 6) & 0x3)) ); + // elements 1|2 match 3|4 and element 1 matches element 2. + return ( (((swizzle >> 4) & 0xF) == ((swizzle >> 0) & 0xF)) && + (((swizzle >> 0) & 0x3) == ((swizzle >> 2) & 0x3)) ); } // replicate_swizzle int no_swizzle(const int swizzle)