Bug 34160 - [glsl] piglit glsl-const-builtin-inversesqrt regression
Summary: [glsl] piglit glsl-const-builtin-inversesqrt regression
Status: CLOSED FIXED
Alias: None
Product: Mesa
Classification: Unclassified
Component: glsl-compiler (show other bugs)
Version: git
Hardware: All All
: medium normal
Assignee: Chad Versace
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-02-10 21:11 UTC by Vinson Lee
Modified: 2011-07-29 16:37 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:


Attachments
Path 1/2: Reverts bad commit (1.95 KB, patch)
2011-02-14 13:46 UTC, Chad Versace
Details | Splinter Review
Patch 2/2: Fix bug (3.22 KB, patch)
2011-02-14 13:47 UTC, Chad Versace
Details | Splinter Review

Description Vinson Lee 2011-02-10 21:11:20 UTC
mesa: 596684eb93067f5281ce7c32123a7f009c8a98c6 (master)

piglit glsl-const-builtin-inversesqrt now fails on swrast, softpipe, and llvmpipe but previously passed.

$ shader_runner glsl-const-builtin-inversesqrt.shader_test
Failed to compile FS: 0:7(38): error: initializer of const variable `undef1' must be a constant expression
0:8(39): error: initializer of const variable `undef2' must be a constant expression

PIGLIT: {'result': 'fail' }
Comment 1 Vinson Lee 2011-02-10 21:47:22 UTC
e7c1f058d18f62aa4871aec623f994d7b68cb8c1 is the first bad commit
commit e7c1f058d18f62aa4871aec623f994d7b68cb8c1
Author: Chad Versace <chad.versace@intel.com>
Date:   Tue Feb 1 10:14:28 2011 -0800

    glsl: Avoid division-by-zero during constant-folding
    
    Avoid division-by-zero when constant-folding the following expression
    types:
        ir_unop_rsq
        ir_binop_div
        ir_binop_mod
    
    Fixes bugs:
    https://bugs.freedesktop.org//show_bug.cgi?id=33306
    https://bugs.freedesktop.org//show_bug.cgi?id=33508
    
    Fixes Piglit tests:
    glslparsertest/glsl2/div-by-zero-01.frag
    glslparsertest/glsl2/div-by-zero-02.frag
    glslparsertest/glsl2/div-by-zero-03.frag
    glslparsertest/glsl2/modulus-zero-01.frag
    glslparsertest/glsl2/modulus-zero-02.frag
    
    NOTE: This is a candidate for the 7.9 and 7.10 branches.

:040000 040000 b58b41754aff93d01fbf81c552b40e59801ea67c 226e21904666b0f43eac705ca1ffdaafd693fbb6 M	src
bisect run success
Comment 2 Ian Romanick 2011-02-11 11:14:42 UTC
We had discussed this commit on the mailing list (see http://marc.info/?l=mesa3d-dev&m=129668262525334&w=2), and I thought Chad was going to fix.  That doesn't seem to have happened yet.
Comment 3 Gordon Jin 2011-02-11 21:25:19 UTC
This passes on my side with i965 and swrast:
const float undef2 = inversesqrt(-1.0);
Comment 4 Chad Versace 2011-02-14 13:45:11 UTC
Attached are two patches that I wish to commit. One fixes this bug, the other is closely related.

Please review them. I wish to know if:
1) They cause any other regressions.
2) They produce the constant-folding behavior we desire.
Comment 5 Chad Versace 2011-02-14 13:46:39 UTC
Created attachment 43355 [details] [review]
Path 1/2: Reverts bad commit
Comment 6 Chad Versace 2011-02-14 13:47:02 UTC
Created attachment 43356 [details] [review]
Patch 2/2: Fix bug
Comment 7 Chad Versace 2011-02-15 15:48:51 UTC
Marking RESOLVED/FIXED.

Fixed by:

commit 62c8c773334c1b0cdd484997a4ccec8945713f8c
Author: Chad Versace <chad.versace@intel.com>
Date:   Mon Feb 14 13:22:39 2011 -0800

    glsl: Reinstate constant-folding for division by zero
    
    Fixes regression: https://bugs.freedesktop.org/show_bug.cgi?id=34160
    
    Commit e7c1f058d18f62aa4871aec623f994d7b68cb8c1 disabled constant-folding
    when division-by-zero occured. This was a mistake, because the spec does
    allow division by zero. (From section 5.9 of the GLSL 1.20 spec: Dividing
    by zero does not cause an exception but does result in an unspecified
    value.)
    
    For floating-point division, the original pre-e7c1f05 behavior is
    reinstated.
    
    For integer division, constant-fold 1/0 to 0.
Comment 8 fangxun 2011-02-17 01:58:57 UTC
It passes on my side with the fixed commit.
Comment 9 Vinson Lee 2011-07-29 16:37:52 UTC
mesa: 120d71a45cfda1edfa8cd6b1732e209eb98b53d8 (master)

Verified fixed.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.