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.
This commit is contained in:
Stephen Heumann 2022-06-24 18:23:29 -05:00
parent 102d6873a3
commit c987f240c6

12
DAG.pas
View File

@ -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}