csmith-project / creduce

C-Reduce, a C and C++ program reducer
Other
1.25k stars 123 forks source link

Missed opportunities for reducing test cases #273

Open berolinux opened 7 months ago

berolinux commented 7 months ago

Trying to find a test case for https://github.com/llvm/llvm-project/issues/72026 with creduce resulted in

enum { a, b, c };
struct {
  long d[c]
} e;
enum { f = 3 };
char g();
void h() { asm("" : "+m"(e.d[b + (g() & f)])); }

This is already a lot more manageable than the original code, but could be reduced quite a bit further manually:

long a[0];
char b();
void c() { asm("" : "+m"(a[1 + (b() & 1)])); }

Looks like creduce misses opportunities to

  1. remove an unnecessary struct when the a member moved outside of the struct is sufficient
  2. change an enum to a static number (twice)