stage3/constant_folding.cc
changeset 776 96a1199d0739
parent 774 979af2009d88
child 780 9fbdf8a7430e
equal deleted inserted replaced
775:0422ee273152 776:96a1199d0739
   204 		{SET_OVFLOW(dtype, symbol);}                                                                              \
   204 		{SET_OVFLOW(dtype, symbol);}                                                                              \
   205 	else if (IS_NONCONST (dtype, operand))                                                                            \
   205 	else if (IS_NONCONST (dtype, operand))                                                                            \
   206 		{SET_NONCONST(dtype, symbol);}                                                                            \
   206 		{SET_NONCONST(dtype, symbol);}                                                                            \
   207 }
   207 }
   208 
   208 
   209 /* Meet rules
   209 /* Constant Propagation: Rules for Meet from "Cooper K., Torczon L. - Engineering a Compiler, Second Edition - 2011"
   210  * - any * T = any
   210  * at 9.3 Static Single-Assignment Form  page 517
   211  * - any * B = B
   211  * - any * undefined = any
   212  * - constant * constant = constant (if equal)
   212  * - any * non_const = non_const
   213  * - constant * constant = B        (if not equal)
   213  * - constant * constant = constant  (if equal)
       
   214  * - constant * constant = non_const (if not equal)
   214  */
   215  */
   215 #define COMPUTE_MEET_SEMILATTICE(dtype, c1, c2, resValue) {\
   216 #define COMPUTE_MEET_SEMILATTICE(dtype, c1, c2, resValue) {\
   216 		if ((c1._##dtype.value != c2._##dtype.value && c2._##dtype.status == symbol_c::cs_const_value && c1._##dtype.status == symbol_c::cs_const_value) ||\
   217 		if (( c1._##dtype.value  != c2._##dtype.value && c2._##dtype.status == symbol_c::cs_const_value &&\
       
   218               c1._##dtype.status == symbol_c::cs_const_value) ||\
   217 		    ( c1._##dtype.status == symbol_c::cs_non_const && c2._##dtype.status == symbol_c::cs_const_value ) ||\
   219 		    ( c1._##dtype.status == symbol_c::cs_non_const && c2._##dtype.status == symbol_c::cs_const_value ) ||\
   218 		    ( c2._##dtype.status == symbol_c::cs_non_const && c1._##dtype.status == symbol_c::cs_const_value  )) {\
   220 		    ( c2._##dtype.status == symbol_c::cs_non_const && c1._##dtype.status == symbol_c::cs_const_value  )) {\
   219 			resValue._##dtype.status = symbol_c::cs_non_const;\
   221 			resValue._##dtype.status = symbol_c::cs_non_const;\
   220 		} else {\
   222 		} else {\
   221 			resValue._##dtype.status = symbol_c::cs_const_value;\
   223 			resValue._##dtype.status = symbol_c::cs_const_value;\