https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103194
--- Comment #12 from Hongtao.liu <crazylht at gmail dot com> ---
(In reply to Hongtao.liu from comment #9)
> (In reply to H.J. Lu from comment #6)
> > Created attachment 51785 [details]
> > The v2 incomplete patch
> >
> > Hongtao, please finish it. Thanks.
>
> I'm trying to handle narrowing part in match.pd and add else return; when
> precision is not equal.
>
> (for bit_op (bit_and bit_xor bit_ior)
> (simplify
> (bit_op (convert@0 @1) (convert@2 @3))
> (if (INTEGRAL_TYPE_P (type)
> && INTEGRAL_TYPE_P (TREE_TYPE (@1))
> && tree_nop_conversion_p (TREE_TYPE (@1), TREE_TYPE (@3))
> && single_use (@0)
> && single_use (@2)
> && TYPE_PRECISION (type) < TYPE_PRECISION (TREE_TYPE (@1)))
> (with { tree type1 = TREE_TYPE (@1); }
> (convert (bit_op @1 (convert:type1 @3)))))))
>
> (for bit_op (bit_and bit_xor bit_ior)
> (simplify
> (bit_op (convert@0 @1) INTEGER_CST@2)
> (if (INTEGRAL_TYPE_P (type)
> && INTEGRAL_TYPE_P (TREE_TYPE (@1))
> && single_use (@0)
> && TYPE_PRECISION (type) < TYPE_PRECISION (TREE_TYPE (@1)))
> (convert (bit_op @1 { fold_convert (TREE_TYPE (@1), @2); })))))
Since there's infinite loop, i'll still handle conversions in tree-ssa-ccp.c as
HJ's attached patch.