On Tue, Sep 15, 2020 at 2:25 PM Feng Xue OS <f...@os.amperecomputing.com> wrote: > > >> Add a rule (T)(A) +- (T)(B) -> (T)(A +- B), which works only when (A +- B) > >> could be folded to a simple value. By this rule, a > >> plusminus-mult-with-convert > >> expression could be handed over to the rule (A * C) +- (B * C) -> (A +- B). > > > >Please use INTEGRAL_TYPE_P () instead of TREE_CODE == INTEGER_TYPE > >in all three cases. It's enough to check for INTEGRAL_TYPE_P on one operand, > >the types_match will take care of the other. > > I would have considered using INTEGRAL_TYPE_P(), but if inner type is bool or > enum, can we do plus/minus operation on that?
Yes, the distinction doesn't really exist for the middle-end - they are just integer types with certain precision and signedness. Richard. > Feng > > > > >OK with those changes. > > > >Thanks, > >Richard. > > > > > > Bootstrapped/regtested on x86_64-linux and aarch64-linux. > > > > Feng > > --- > > 2020-09-15 Feng Xue <f...@os.amperecomputing.com> > > > > gcc/ > > PR tree-optimization/94234 > > * match.pd (T)(A) +- (T)(B) -> (T)(A +- B): New simplification. > > > > gcc/testsuite/ > > PR tree-optimization/94234 > > * gcc.dg/pr94234-3.c: New test.