git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@4997
4a8a32a2-be11-0410-ad9d-
d568d2c75423
--- /dev/null
+/* Test arithmetic CSE with /+-*
+
+ type: char, short, long
+ attr: volatile,
+ */
+
+void
+test_arithCse(void)
+{
+ (attr) {type} res;
+ {attr} {type} i = 10;
+
+ /* addition with 0 */
+ res = i + 0;
+ ASSERT (i == 10);
+
+ res = 0 + i;
+ ASSERT (res == 10);
+
+ /* multiplication with 1 */
+ res = 1 * i;
+ ASSERT (res == 10);
+
+ res = i * 1;
+ ASSERT (res == 10);
+
+ /* multiplication with 0 */
+ res = 0 * i;
+ ASSERT (res == 0);
+
+ res = i * 0;
+ ASSERT (res == 0);
+
+ /* multiplication with -1 */
+ res = -1 * i;
+ ASSERT (res == -i);
+
+ res = i * -1;
+ ASSERT (res == -i);
+
+ /* division by 1 */
+ res = i / 1;
+ ASSERT (res == i);
+
+ /* division by -1 */
+ res = i / -1;
+ ASSERT (res == -i);
+}
\ No newline at end of file