Merge pull request #2262 from colinleroy/optimize-long-assign

Optimize static long assignment a bit
This commit is contained in:
Bob Andrews
2023-12-08 01:58:01 +01:00
committed by GitHub
7 changed files with 373 additions and 35 deletions

41
test/val/long.c Normal file
View File

@@ -0,0 +1,41 @@
#include <stdint.h>
#include <stdio.h>
int res = 0;
int main(void)
{
long a, b;
a = 0x12345678L;
/* Test assignment */
b = a;
if (b != a) {
res++;
}
/* Test increment */
b++;
if (b != 0x12345679L) {
res++;
}
/* Test decrement */
b--;
if (b != 0x12345678L) {
res++;
}
/* Test pre-decrement with test */
if (--b != 0x12345677L) {
res++;
}
a = --b;
if (a != 0x12345676L) {
res++;
}
return res;
}

41
test/val/static-long.c Normal file
View File

@@ -0,0 +1,41 @@
#include <stdint.h>
#include <stdio.h>
int res = 0;
int main(void)
{
static long a, b;
a = 0x12345678L;
/* Test assignment */
b = a;
if (b != a) {
res++;
}
/* Test increment */
b++;
if (b != 0x12345679L) {
res++;
}
/* Test decrement */
b--;
if (b != 0x12345678L) {
res++;
}
/* Test pre-decrement with test */
if (--b != 0x12345677L) {
res++;
}
a = --b;
if (a != 0x12345676L) {
res++;
}
return res;
}