aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc')
-rw-r--r--gcc/fold-const.cc2
-rw-r--r--gcc/testsuite/gcc.dg/pr112733.c16
2 files changed, 17 insertions, 1 deletions
diff --git a/gcc/fold-const.cc b/gcc/fold-const.cc
index dff09b8..2692b98 100644
--- a/gcc/fold-const.cc
+++ b/gcc/fold-const.cc
@@ -14563,7 +14563,7 @@ multiple_of_p (tree type, const_tree top, const_tree bottom, bool nowrap)
&& TREE_CODE (op2) == INTEGER_CST
&& integer_pow2p (bottom)
&& wi::multiple_of_p (wi::to_widest (op2),
- wi::to_widest (bottom), UNSIGNED))
+ wi::to_widest (bottom), SIGNED))
return true;
op1 = gimple_assign_rhs1 (stmt);
diff --git a/gcc/testsuite/gcc.dg/pr112733.c b/gcc/testsuite/gcc.dg/pr112733.c
new file mode 100644
index 0000000..d6f99f7
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr112733.c
@@ -0,0 +1,16 @@
+/* PR middle-end/112733 */
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+signed char a, c;
+short b;
+
+void
+foo (void)
+{
+ signed char *e = &a;
+ c = foo != 0;
+ *e &= c;
+ for (; b; --b)
+ *e &= -128;
+}