Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
glslang
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
glslang
Commits
f83e2f06
Commit
f83e2f06
authored
Oct 25, 2017
by
Aaron Muir Hamilton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
GLSL: Fold constant SHRT_MIN/INT_MIN/LLONG_MIN % -1 to 0.
parent
b5b08462
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
89 additions
and
1 deletion
+89
-1
constFoldIntMin.frag.out
Test/baseResults/constFoldIntMin.frag.out
+51
-0
constFoldIntMin.frag
Test/constFoldIntMin.frag
+13
-0
Constant.cpp
glslang/MachineIndependent/Constant.cpp
+24
-1
AST.FromFile.cpp
gtests/AST.FromFile.cpp
+1
-0
No files found.
Test/baseResults/constFoldIntMin.frag.out
0 → 100644
View file @
f83e2f06
constFoldIntMin.frag
Shader version: 460
Requested GL_AMD_gpu_shader_int16
Requested GL_ARB_gpu_shader_int64
0:? Sequence
0:5 Function Definition: a( ( global void)
0:5 Function Parameters:
0:6 Sequence
0:6 Sequence
0:6 move second child to first child ( temp int16_t)
0:6 'u' ( temp int16_t)
0:6 Constant:
0:6 32768 (const int)
0:7 Sequence
0:7 move second child to first child ( temp int)
0:7 'v' ( temp int)
0:7 Constant:
0:7 -2147483648 (const int)
0:8 Sequence
0:8 move second child to first child ( temp int64_t)
0:8 'w' ( temp int64_t)
0:8 Constant:
0:8 -9223372036854775808 (const int64_t)
0:9 Sequence
0:9 move second child to first child ( temp int16_t)
0:9 'x' ( temp int16_t)
0:9 Constant:
0:9 0 (const int)
0:10 Sequence
0:10 move second child to first child ( temp int)
0:10 'y' ( temp int)
0:10 Constant:
0:10 0 (const int)
0:11 Sequence
0:11 move second child to first child ( temp int64_t)
0:11 'z' ( temp int64_t)
0:11 Constant:
0:11 0 (const int64_t)
0:? Linker Objects
Linked fragment stage:
ERROR: Linking fragment stage: Missing entry point: Each stage requires one entry point
Shader version: 460
Requested GL_AMD_gpu_shader_int16
Requested GL_ARB_gpu_shader_int64
0:? Sequence
0:? Linker Objects
Test/constFoldIntMin.frag
0 → 100644
View file @
f83e2f06
#version 460 core
#extension GL_AMD_gpu_shader_int16 : enable
#extension GL_ARB_gpu_shader_int64 : enable
void
a
(){
int16_t
u
=
-
32768
S
/
-
1
S
;
// SHRT_MIN
int
v
=
-
2147483648
/
-
1
;
// INT_MIN
int64_t
w
=
-
9223372036854775808L
/
-
1L
;
// LLONG_MIN
int16_t
x
=
-
32768
S
%
-
1
S
;
// SHRT_MIN
int
y
=
-
2147483648
%
-
1
;
// INT_MIN
int64_t
z
=
-
9223372036854775808L
%
-
1L
;
// LLONG_MIN
}
\ No newline at end of file
glslang/MachineIndependent/Constant.cpp
View file @
f83e2f06
...
...
@@ -38,6 +38,7 @@
#include <cmath>
#include <cfloat>
#include <cstdlib>
#include <climits>
namespace
{
...
...
@@ -264,7 +265,29 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, const TIntermTyped* right
if
(
rightUnionArray
[
i
]
==
0
)
newConstArray
[
i
]
=
leftUnionArray
[
i
];
else
newConstArray
[
i
]
=
leftUnionArray
[
i
]
%
rightUnionArray
[
i
];
switch
(
getType
().
getBasicType
())
{
case
EbtInt
:
if
(
rightUnionArray
[
i
].
getIConst
()
==
-
1
&&
leftUnionArray
[
i
].
getIConst
()
==
INT_MIN
)
{
newConstArray
[
i
].
setIConst
(
0
);
break
;
}
else
goto
modulo_default
;
case
EbtInt64
:
if
(
rightUnionArray
[
i
].
getI64Const
()
==
-
1
&&
leftUnionArray
[
i
].
getI64Const
()
==
LLONG_MIN
)
{
newConstArray
[
i
].
setI64Const
(
0
);
break
;
}
else
goto
modulo_default
;
#ifdef AMD_EXTENSIONS
case
EbtInt16
:
if
(
rightUnionArray
[
i
].
getIConst
()
==
-
1
&&
leftUnionArray
[
i
].
getIConst
()
==
SHRT_MIN
)
{
newConstArray
[
i
].
setIConst
(
0
);
break
;
}
else
goto
modulo_default
;
#endif
default:
modulo_default:
newConstArray
[
i
]
=
leftUnionArray
[
i
]
%
rightUnionArray
[
i
];
}
}
break
;
...
...
gtests/AST.FromFile.cpp
View file @
f83e2f06
...
...
@@ -115,6 +115,7 @@ INSTANTIATE_TEST_CASE_P(
"330comp.frag"
,
"constErrors.frag"
,
"constFold.frag"
,
"constFoldIntMin.frag"
,
"errors.frag"
,
"forwardRef.frag"
,
"uint.frag"
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment