File tree 2 files changed +47
-1
lines changed
2 files changed +47
-1
lines changed Original file line number Diff line number Diff line change @@ -71,6 +71,42 @@ struct SpecializationContext
71
71
module->getContainerPool ().free (&cleanInsts);
72
72
}
73
73
74
+ bool isUnsimplifiedArithmeticInst (IRInst* inst)
75
+ {
76
+ switch (inst->getOp ())
77
+ {
78
+ case kIROp_Add :
79
+ case kIROp_Sub :
80
+ case kIROp_Mul :
81
+ case kIROp_Div :
82
+ case kIROp_Neg :
83
+ case kIROp_Not :
84
+ case kIROp_Eql :
85
+ case kIROp_Neq :
86
+ case kIROp_Leq :
87
+ case kIROp_Geq :
88
+ case kIROp_Less :
89
+ case kIROp_IRem :
90
+ case kIROp_FRem :
91
+ case kIROp_Greater :
92
+ case kIROp_Lsh :
93
+ case kIROp_Rsh :
94
+ case kIROp_BitAnd :
95
+ case kIROp_BitOr :
96
+ case kIROp_BitXor :
97
+ case kIROp_BitNot :
98
+ case kIROp_BitCast :
99
+ case kIROp_CastIntToFloat :
100
+ case kIROp_CastFloatToInt :
101
+ case kIROp_IntCast :
102
+ case kIROp_FloatCast :
103
+ case kIROp_Select :
104
+ return true ;
105
+ default :
106
+ return false ;
107
+ }
108
+ }
109
+
74
110
// An instruction is then fully specialized if and only
75
111
// if it is in our set.
76
112
//
@@ -133,6 +169,14 @@ struct SpecializationContext
133
169
return areAllOperandsFullySpecialized (inst);
134
170
}
135
171
172
+ if (isUnsimplifiedArithmeticInst (inst))
173
+ {
174
+ // For arithmetic insts, we want to wait for simplification before specialization,
175
+ // since different insts can simplify to the same value.
176
+ //
177
+ return false ;
178
+ }
179
+
136
180
// The default case is that a global value is always specialized.
137
181
if (inst->getParent () == module->getModuleInst ())
138
182
{
@@ -1092,6 +1136,7 @@ struct SpecializationContext
1092
1136
{
1093
1137
this ->changed = true ;
1094
1138
eliminateDeadCode (module->getModuleInst ());
1139
+ applySparseConditionalConstantPropagationForGlobalScope (this ->module , this ->sink );
1095
1140
}
1096
1141
1097
1142
// Once the work list has gone dry, we should have the invariant
Original file line number Diff line number Diff line change @@ -1493,7 +1493,8 @@ DeclRef<Decl> Linkage::specializeWithArgTypes(
1493
1493
DiagnosticSink* sink)
1494
1494
{
1495
1495
SemanticsVisitor visitor (getSemanticsForReflection ());
1496
- visitor = visitor.withSink (sink);
1496
+ SemanticsVisitor::ExprLocalScope scope;
1497
+ visitor = visitor.withSink (sink).withExprLocalScope (&scope);
1497
1498
1498
1499
SLANG_AST_BUILDER_RAII (getASTBuilder ());
1499
1500
You can’t perform that action at this time.
0 commit comments