Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/d3dcompiler_43/hlsl.y | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-)
diff --git a/dlls/d3dcompiler_43/hlsl.y b/dlls/d3dcompiler_43/hlsl.y index 932a75bb6dd..92d0da0b64c 100644 --- a/dlls/d3dcompiler_43/hlsl.y +++ b/dlls/d3dcompiler_43/hlsl.y @@ -2870,11 +2870,26 @@ static void replace_node(struct hlsl_ir_node *old, struct hlsl_ir_node *new) hlsl_src_remove(src); hlsl_src_from_node(src, new); } - list_add_before(&old->entry, &new->entry); list_remove(&old->entry); free_instr(old); }
+static BOOL fold_ident(struct hlsl_ir_node *instr) +{ + if (instr->type == HLSL_IR_EXPR) + { + struct hlsl_ir_expr *expr = expr_from_node(instr); + + if (expr->op == HLSL_IR_UNOP_IDENT) + { + replace_node(&expr->node, expr->operands[0].node); + return TRUE; + } + } + + return FALSE; +} + static BOOL fold_constants(struct hlsl_ir_node *instr) { struct hlsl_ir_constant *arg1, *arg2 = NULL, *res; @@ -2933,6 +2948,7 @@ static BOOL fold_constants(struct hlsl_ir_node *instr) return FALSE; }
+ list_add_before(&expr->node.entry, &res->node.entry); replace_node(&expr->node, &res->node); return TRUE; } @@ -3134,6 +3150,7 @@ HRESULT parse_hlsl(enum shader_type type, DWORD major, DWORD minor,
list_move_head(entry_func->body, &hlsl_ctx.static_initializers);
+ transform_ir(fold_ident, entry_func->body); while (transform_ir(fold_constants, entry_func->body)); while (transform_ir(dce, entry_func->body));