@@ -788,12 +788,10 @@ _Py_uop_sym_set_compact_int(JitOptContext *ctx, JitOptRef ref)
788788}
789789
790790JitOptRef
791- _Py_uop_sym_new_predicate (JitOptContext * ctx , JitOptRef subject_ref , JitOptRef constant_ref , JitOptPredicateKind kind , bool invert )
791+ _Py_uop_sym_new_predicate (JitOptContext * ctx , JitOptRef lhs_ref , JitOptRef rhs_ref , JitOptPredicateKind kind , bool invert )
792792{
793- assert (_Py_uop_sym_is_const (ctx , constant_ref ));
794-
795- JitOptSymbol * subject = PyJitRef_Unwrap (subject_ref );
796- JitOptSymbol * constant = PyJitRef_Unwrap (constant_ref );
793+ JitOptSymbol * lhs = PyJitRef_Unwrap (lhs_ref );
794+ JitOptSymbol * rhs = PyJitRef_Unwrap (rhs_ref );
797795
798796 JitOptSymbol * res = sym_new (ctx );
799797 if (res == NULL ) {
@@ -803,22 +801,12 @@ _Py_uop_sym_new_predicate(JitOptContext *ctx, JitOptRef subject_ref, JitOptRef c
803801 res -> tag = JIT_SYM_PREDICATE_TAG ;
804802 res -> predicate .invert = invert ;
805803 res -> predicate .kind = kind ;
806- res -> predicate .subject = (uint16_t )(subject - allocation_base (ctx ));
807- res -> predicate .constant = (uint16_t )(constant - allocation_base (ctx ));
804+ res -> predicate .lhs = (uint16_t )(lhs - allocation_base (ctx ));
805+ res -> predicate .rhs = (uint16_t )(rhs - allocation_base (ctx ));
808806
809807 return PyJitRef_Wrap (res );
810808}
811809
812- bool
813- _Py_uop_sym_is_known_singleton (JitOptContext * ctx , JitOptRef ref )
814- {
815- if (_Py_uop_sym_is_safe_const (ctx , ref )) {
816- PyObject * value = _Py_uop_sym_get_const (ctx , ref );
817- return value == Py_None || value == Py_True || value == Py_False ;
818- }
819- return false;
820- }
821-
822810void
823811_Py_uop_sym_apply_predicate_narrowing (JitOptContext * ctx , JitOptRef ref , bool branch_is_true )
824812{
@@ -833,10 +821,17 @@ _Py_uop_sym_apply_predicate_narrowing(JitOptContext *ctx, JitOptRef ref, bool br
833821 return ;
834822 }
835823
836- if (pred .kind == JIT_PRED_IS ) {
837- JitOptRef subject_ref = PyJitRef_Wrap (allocation_base (ctx ) + pred .subject );
838- JitOptRef constant_ref = PyJitRef_Wrap (allocation_base (ctx ) + pred .constant );
839- PyObject * const_val = _Py_uop_sym_get_const (ctx , constant_ref );
824+ JitOptRef lhs_ref = PyJitRef_Wrap (allocation_base (ctx ) + pred .lhs );
825+ JitOptRef rhs_ref = PyJitRef_Wrap (allocation_base (ctx ) + pred .rhs );
826+
827+ bool lhs_is_const = _Py_uop_sym_is_safe_const (ctx , lhs_ref );
828+ bool rhs_is_const = _Py_uop_sym_is_safe_const (ctx , rhs_ref );
829+
830+ if (pred .kind == JIT_PRED_IS && (lhs_is_const || rhs_is_const )) {
831+ JitOptRef subject_ref = lhs_is_const ? rhs_ref : lhs_ref ;
832+ JitOptRef const_ref = lhs_is_const ? lhs_ref : rhs_ref ;
833+
834+ PyObject * const_val = _Py_uop_sym_get_const (ctx , const_ref );
840835 if (const_val == NULL ) {
841836 return ;
842837 }
0 commit comments