Fix signed left-shifts added in e93acb2d228c.
Since we now require C99, this is undefined behavior.
Thanks to Luc Trudeau for the report and Alex Converse for the
suggestion on how to make the macro safe for all integer sizes.
Change-Id: I99a1342dfedb3e17a6869269be317c2ed26bfe9b
diff --git a/aom_dsp/aom_dsp_common.h b/aom_dsp/aom_dsp_common.h
index a7ea1b9..96ba3eb 100644
--- a/aom_dsp/aom_dsp_common.h
+++ b/aom_dsp/aom_dsp_common.h
@@ -35,6 +35,11 @@
#define IS_POWER_OF_TWO(x) (((x) & ((x)-1)) == 0)
+/* Left shifting a negative value became undefined behavior in C99 (downgraded
+ from merely implementation-defined in C89). This should still compile to the
+ correct thing on any two's-complement machine, but avoid ubsan warnings.*/
+#define AOM_SIGNED_SHL(x, shift) ((x) * (((x)*0 + 1) << (shift)))
+
// These can be used to give a hint about branch outcomes.
// This can have an effect, even if your target processor has a
// good branch predictor, as these hints can affect basic block