OpenSDE Packages Database (without history before r20070)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

62 lines
2.0 KiB

  1. # --- SDE-COPYRIGHT-NOTE-BEGIN ---
  2. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  3. #
  4. # Filename: package/.../gcc/extract_muldiv.patch
  5. # Copyright (C) 2007 The OpenSDE Project
  6. #
  7. # More information can be found in the files COPYING and README.
  8. #
  9. # This patch file is dual-licensed. It is available under the license the
  10. # patched project is licensed under, as long as it is an OpenSource license
  11. # as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms
  12. # of the GNU General Public License as published by the Free Software
  13. # Foundation; either version 2 of the License, or (at your option) any later
  14. # version.
  15. # --- SDE-COPYRIGHT-NOTE-END ---
  16. Take from http://gcc.gnu.org/ml/gcc-patches/2007-11/msg00948.html
  17. 2007-11-17 Richard Guenther <rguenther@suse.de>
  18. PR middle-end/34130
  19. * fold-const.c (extract_muldiv_1): Do not move negative
  20. constants inside ABS_EXPR.
  21. * gcc.c-torture/execute/pr34130.c: New testcase.
  22. Index: ./gcc/fold-const.c
  23. ===================================================================
  24. *** ./gcc/fold-const.c (revision 130238)
  25. --- ./gcc/fold-const.c (working copy)
  26. *************** extract_muldiv_1 (tree t, tree c, enum t
  27. *** 6095,6100 ****
  28. --- 6095,6103 ----
  29. }
  30. break;
  31. }
  32. + /* If the constant is negative, we cannot simplify this. */
  33. + if (tree_int_cst_sgn (c) == -1)
  34. + break;
  35. /* FALLTHROUGH */
  36. case NEGATE_EXPR:
  37. if ((t1 = extract_muldiv (op0, c, code, wide_type, strict_overflow_p))
  38. Index: ./gcc/testsuite/gcc.c-torture/execute/pr34130.c
  39. ===================================================================
  40. *** ./gcc/testsuite/gcc.c-torture/execute/pr34130.c (revision 0)
  41. --- ./gcc/testsuite/gcc.c-torture/execute/pr34130.c (revision 0)
  42. ***************
  43. *** 0 ****
  44. --- 1,12 ----
  45. + extern void abort (void);
  46. + int foo (int i)
  47. + {
  48. + return -2 * __builtin_abs(i - 2);
  49. + }
  50. + int main()
  51. + {
  52. + if (foo(1) != -2
  53. + || foo(3) != -2)
  54. + abort ();
  55. + return 0;
  56. + }