aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/simplify-rtx.cc4
-rw-r--r--gcc/testsuite/gcc.c-torture/execute/pr104839.c37
2 files changed, 39 insertions, 2 deletions
diff --git a/gcc/simplify-rtx.cc b/gcc/simplify-rtx.cc
index 3355b1a..5d4939c 100644
--- a/gcc/simplify-rtx.cc
+++ b/gcc/simplify-rtx.cc
@@ -1527,7 +1527,7 @@ simplify_context::simplify_unary_operation_1 (rtx_code code, machine_mode mode,
if (partial_subreg_p (temp))
{
SUBREG_PROMOTED_VAR_P (temp) = 1;
- SUBREG_PROMOTED_SET (temp, 1);
+ SUBREG_PROMOTED_SET (temp, SRP_SIGNED);
}
return temp;
}
@@ -1662,7 +1662,7 @@ simplify_context::simplify_unary_operation_1 (rtx_code code, machine_mode mode,
if (partial_subreg_p (temp))
{
SUBREG_PROMOTED_VAR_P (temp) = 1;
- SUBREG_PROMOTED_SET (temp, 0);
+ SUBREG_PROMOTED_SET (temp, SRP_UNSIGNED);
}
return temp;
}
diff --git a/gcc/testsuite/gcc.c-torture/execute/pr104839.c b/gcc/testsuite/gcc.c-torture/execute/pr104839.c
new file mode 100644
index 0000000..1703df6
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/execute/pr104839.c
@@ -0,0 +1,37 @@
+/* PR rtl-optimization/104839 */
+
+__attribute__((noipa)) short
+foo (void)
+{
+ return -1;
+}
+
+__attribute__((noipa)) int
+bar (void)
+{
+ short i = foo ();
+ if (i == -2)
+ return 2;
+ long k = i;
+ int j = -1;
+ volatile long s = 300;
+ if (k < 0)
+ {
+ k += s;
+ if (k < 0)
+ j = 0;
+ }
+ else if (k >= s)
+ j = 0;
+ if (j != -1)
+ return 1;
+ return 0;
+}
+
+int
+main ()
+{
+ if (bar () != 0)
+ __builtin_abort ();
+ return 0;
+}