From c987f240c65605e2c67b2618f4bd41dfb13e50d3 Mon Sep 17 00:00:00 2001 From: Stephen Heumann Date: Fri, 24 Jun 2022 18:23:29 -0500 Subject: [PATCH] Optimize out ? : operations with constant conditions. The condition expression may become a constant due to optimizations, and optimizing out the ? : operation may also enable further optimizations. --- DAG.pas | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/DAG.pas b/DAG.pas index 3c46e15..52a71d7 100644 --- a/DAG.pas +++ b/DAG.pas @@ -2553,7 +2553,17 @@ case op^.opcode of {check for optimizations of this node} ReverseChildren(op^.right); op^.left := op^.left^.left; end; {if} - end; {else if} + end {else if} + else if opcode = pc_ldc then + if op^.left^.optype in [cgWord,cgUWord] then + if op^.next = nil then + if op^.left^.q <> 0 then begin + if op^.optype = TypeOf(op^.right^.left) then + opv := op^.right^.left; + end {if} + else + if op^.optype = TypeOf(op^.right^.right) then + opv := op^.right^.right; end; {case pc_tri} pc_udi: begin {pc_udi}