aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/config/i386/i386.cc2
-rw-r--r--gcc/gimple-fold.cc6
-rw-r--r--gcc/testsuite/gcc.dg/pr120074.c20
3 files changed, 27 insertions, 1 deletions
diff --git a/gcc/config/i386/i386.cc b/gcc/config/i386/i386.cc
index f28c92a..89f518c 100644
--- a/gcc/config/i386/i386.cc
+++ b/gcc/config/i386/i386.cc
@@ -12320,6 +12320,7 @@ get_thread_pointer (machine_mode tp_mode, bool to_reg)
static GTY(()) rtx ix86_tls_index_symbol;
+#if TARGET_WIN32_TLS
static rtx
ix86_tls_index (void)
{
@@ -12331,6 +12332,7 @@ ix86_tls_index (void)
else
return ix86_tls_index_symbol;
}
+#endif
/* Construct the SYMBOL_REF for the tls_get_addr function. */
diff --git a/gcc/gimple-fold.cc b/gcc/gimple-fold.cc
index 94d5a1e..5884b79 100644
--- a/gcc/gimple-fold.cc
+++ b/gcc/gimple-fold.cc
@@ -8334,6 +8334,8 @@ fold_truth_andor_for_ifcombine (enum tree_code code, tree truth_type,
ll_and_mask &= sign;
if (l_xor)
{
+ if (ll_bitsize != lr_bitsize)
+ return 0;
if (!lr_and_mask.get_precision ())
lr_and_mask = sign;
else
@@ -8355,6 +8357,8 @@ fold_truth_andor_for_ifcombine (enum tree_code code, tree truth_type,
rl_and_mask &= sign;
if (r_xor)
{
+ if (rl_bitsize != rr_bitsize)
+ return 0;
if (!rr_and_mask.get_precision ())
rr_and_mask = sign;
else
@@ -8762,7 +8766,7 @@ fold_truth_andor_for_ifcombine (enum tree_code code, tree truth_type,
wide_int lr_mask, rr_mask;
if (lr_and_mask.get_precision ())
lr_mask = wi::lshift (wide_int::from (lr_and_mask, rnprec, UNSIGNED),
- xlr_bitpos);
+ xlr_bitpos);
else
lr_mask = wi::shifted_mask (xlr_bitpos, lr_bitsize, false, rnprec);
if (rr_and_mask.get_precision ())
diff --git a/gcc/testsuite/gcc.dg/pr120074.c b/gcc/testsuite/gcc.dg/pr120074.c
new file mode 100644
index 0000000..3f31516
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr120074.c
@@ -0,0 +1,20 @@
+/* PR tree-optimization/120074 */
+/* { dg-do compile } */
+/* { dg-options "-O1 -fno-tree-copy-prop -fno-tree-forwprop -fno-tree-ccp" } */
+
+int foo (int);
+short a;
+int b;
+
+int
+bar (int d, int e)
+{
+ return d < 0 || d > __INT_MAX__ >> e;
+}
+
+int
+main ()
+{
+ int f = bar ((b ^ a) & 3, __SIZEOF_INT__ * __CHAR_BIT__ - 2);
+ foo (f);
+}