Mesa's r300 DRI driver produces incorrect output (garbles the display) if r300_state.c is compiled with -ftree-vrp (-O2 -fno-tree-vrp works fine; all files except r300_state.c can be compiled with normal -O2).
Created attachment 13804 [details] Preprocessed source, bzip2-ed Attaching preprocessed source of r300_state.c
Can you narrow it down to a specific function?
r300SetupPixelShader()
Sorry, I can't see what is wrong. There is no effective difference in assembly with/without -ftree-vrp.
Created attachment 14038 [details] miscompiles with gcc 4.2 -O2 here is a simple test case reproducing the issue. eg: % gcc -O2 ivopts-issue.c && ./a.out && gcc -O2 -fno-ivopts ivopts-issue.c && ./a.out 0 0 1 2 2 2 1 1
more info: the tree-vrp issue is raised by ivopts pass: without ivopts: D.1541_13 = 3 - i_31; D.1542_14 = (unsigned int) D.1541_13; D.1543_15 = D.1542_14 * 4; D.1544_16 = (int *) D.1543_15; with ivopts: D.1607_62 = (int *) i_31; D.1608_63 = D.1607_62 * -4B; D.1544_64 = D.1608_63 + 12B; D.1544_16 = D.1544_64; vrp finds that D.1608_63 is 0, and so replaces D.1544_64 with 12 D.1607_62 = (int *) i_31; D.1608_63 = D.1607_62 * -4B; D.1544_64 = D.1608_63 + 12B; D.1544_16 = D.1544_64;
the following patch fixes the testcase ivopts-issue.c, but breaks everything else... someone else will find a correct patch :) --- gcc-4.2.1/gcc/tree-ssa-loop-ivopts.c.pix 2006-10-06 21:32:04.000000000 +0200 +++ gcc-4.2.1/gcc/tree-ssa-loop-ivopts.c 2007-08-08 00:23:49.000000000 +0200 @@ -3061,7 +3061,9 @@ get_computation_aff (struct loop *loop, expr = fold_convert (ctype, expr); } - if (TYPE_UNSIGNED (utype)) + if (POINTER_TYPE_P (utype)) + uutype = ctype; + else if (TYPE_UNSIGNED (utype)) uutype = utype; else {
Known to work: 4.1.2 4.3.0 Known to fail: 4.2.1
This should work on the trunk also via the pointer plus branch merge where we no longer get a multiplication in a pointer type.
Confirmed. (use -m32 on x86_64)
Change target milestone to 4.2.3, as 4.2.2 has been released.
4.2.3 is being released now, changing milestones of open bugs to 4.2.4.
4.2.4 is being released, changing milestones to 4.2.5.
Closing 4.2 branch, fixed in 4.3.