This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug middle-end/55027] simplify vector multiplication by 1


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55027

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
           Keywords|                            |missed-optimization
   Last reconfirmed|                            |2012-10-23
                 CC|                            |rguenth at gcc dot gnu.org
     Ever Confirmed|0                           |1
           Severity|normal                      |enhancement

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> 2012-10-23 09:41:54 UTC ---
For integer values the generic folding with

      if (! FLOAT_TYPE_P (type))
        {
          if (integer_zerop (arg1))
            return omit_one_operand_loc (loc, type, arg1, arg0);
          if (integer_onep (arg1))
            return non_lvalue_loc (loc, fold_convert_loc (loc, type, arg0));

catches this.  For float values we have

          /* Maybe fold x * 0 to 0.  The expressions aren't the same
             when x is NaN, since x * 0 is also NaN.  Nor are they the
             same in modes with signed zeros, since multiplying a
             negative value by 0 gives -0, not +0.  */
          if (!HONOR_NANS (TYPE_MODE (TREE_TYPE (arg0)))
              && !HONOR_SIGNED_ZEROS (TYPE_MODE (TREE_TYPE (arg0)))
              && real_zerop (arg1))
            return omit_one_operand_loc (loc, type, arg1, arg0);
          /* In IEEE floating point, x*1 is not equivalent to x for snans.
             Likewise for complex arithmetic with signed zeros.  */
          if (!HONOR_SNANS (TYPE_MODE (TREE_TYPE (arg0)))
              && (!HONOR_SIGNED_ZEROS (TYPE_MODE (TREE_TYPE (arg0)))
                  || !COMPLEX_FLOAT_TYPE_P (TREE_TYPE (arg0)))
              && real_onep (arg1))
            return non_lvalue_loc (loc, fold_convert_loc (loc, type, arg0));

but neiter real_zerop or real_onep handle vector types (there are more
predicates like that).  I adjusted the integer predicates to also handle
vector types, so I suppose the same needs to be done for the real predicates.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]