From 4c7650c3eaf4dfbe5971864bf084e76f844051ee Mon Sep 17 00:00:00 2001 From: Xavier Leroy Date: Fri, 8 Jul 2016 15:44:46 +0200 Subject: Unwanted partial constant propagation in 64-bit integer arguments to builtins Here are two examples that cause an internal error in Asmexpand.ml: volatile long long x; void f(unsigned int i) { x = i; } unsigned g(unsigned i) { return __builtin_clzll(i); } The argument "i" to builtin volatile store or __builtin_clzll is turned into a BA_splitlong(BA_int 0, BA ), which Asmexpand.ml doesn't know how to handle. The fix (in AST.builtin_arg_ok) is to prevent this 'optimization' for all builtins except those of the "OK_all" kind, i.e. __builtin_annot. Regression tests were added and tested on IA32. Need to retest on ARM and PowerPC. --- test/regression/builtins-arm.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'test/regression/builtins-arm.c') diff --git a/test/regression/builtins-arm.c b/test/regression/builtins-arm.c index 5fa867c2..709343ce 100644 --- a/test/regression/builtins-arm.c +++ b/test/regression/builtins-arm.c @@ -7,6 +7,7 @@ int main(int argc, char ** argv) unsigned int x = 0x12345678; unsigned int y = 0xDEADBEEF; unsigned long long xx = 0x1234567812345678ULL; + unsigned z; double a = 3.14159; unsigned short s = 0x1234; @@ -15,6 +16,8 @@ int main(int argc, char ** argv) printf("clz(%x) = %d\n", x, __builtin_clz(x)); printf("clzll(%llx) = %d\n", (unsigned long long) x, __builtin_clzll(x)); printf("clzll(%llx) = %d\n", xx, __builtin_clzll(xx)); + z = __builtin_bswap(x); + printf("clzll(%lx) = %d\n", z, __builtin_clzll(z)); printf("fsqrt(%f) = %f\n", a, __builtin_fsqrt(a)); printf ("read_16_rev = %x\n", __builtin_read16_reversed(&s)); -- cgit