Skip to content
Snippets Groups Projects

Ternary Expressions, Improved Integer Divisions, and Iteration Space Fix

Merged Frederik Hennig requested to merge fhennig/ternary into backend-rework
All threads resolved!
Viewing commit ef0ddbf5
Show latest version
3 files
+ 35
0
Preferences
Compare changes
Files
3
@@ -27,6 +27,7 @@ from ..ast.expressions import (
PsLt,
PsGt,
PsNe,
PsTernary,
)
from ..ast.util import AstEqWrapper
@@ -247,6 +248,13 @@ class EliminateConstants:
false = self._typify(PsConstantExpr(PsConstant(False, PsBoolType())))
return false, True
# Trivial ternaries
case PsTernary(PsConstantExpr(c), then, els):
if c.value:
return then, subtree_constness[1]
else:
return els, subtree_constness[2]
# end match: no idempotence or dominance encountered
# Detect constant expressions