summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2005-01-07 09:08:10 +0000
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2005-01-07 09:08:10 +0000
commitfd66f0957feffca75b4901f15093493f1247b5bd (patch)
tree63fa10dd04b8390aaf8f713cf0d4f78f5b708e64
parentd118b6d1242a4fd8bb7179e46f7a51e4c4ee1664 (diff)
downloadppe42-gcc-fd66f0957feffca75b4901f15093493f1247b5bd.tar.gz
ppe42-gcc-fd66f0957feffca75b4901f15093493f1247b5bd.zip
PR tree-optimization/19283
* fold-const.c (fold_widened_comparison): Return NULL if shorter_type is not shorter than the original type. * gcc.c-torture/execute/20050106-1.c: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@93043 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog4
-rw-r--r--gcc/fold-const.c5
-rw-r--r--gcc/testsuite/ChangeLog3
-rw-r--r--gcc/testsuite/gcc.c-torture/execute/20050106-1.c19
4 files changed, 30 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 6d610b49226..7b8fca5672f 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,9 @@
2005-01-07 Jakub Jelinek <jakub@redhat.com>
+ PR tree-optimization/19283
+ * fold-const.c (fold_widened_comparison): Return NULL if shorter_type
+ is not shorter than the original type.
+
PR rtl-optimization/19012
* config/i386/i386.md (addqi_1_slp): Set memory attribute.
diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index a3d1f1d5350..21ee14cc563 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -5993,7 +5993,10 @@ fold_widened_comparison (enum tree_code code, tree type, tree arg0, tree arg1)
if (arg0_unw == arg0)
return NULL_TREE;
shorter_type = TREE_TYPE (arg0_unw);
-
+
+ if (TYPE_PRECISION (TREE_TYPE (arg0)) <= TYPE_PRECISION (shorter_type))
+ return NULL_TREE;
+
arg1_unw = get_unwidened (arg1, shorter_type);
if (!arg1_unw)
return NULL_TREE;
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index fdfd6012c8a..321a27a61eb 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,8 @@
2005-01-07 Jakub Jelinek <jakub@redhat.com>
+ PR tree-optimization/19283
+ * gcc.c-torture/execute/20050106-1.c: New test.
+
PR rtl-optimization/18861
* gcc.dg/20050105-1.c: New test.
diff --git a/gcc/testsuite/gcc.c-torture/execute/20050106-1.c b/gcc/testsuite/gcc.c-torture/execute/20050106-1.c
new file mode 100644
index 00000000000..e49732de40e
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/execute/20050106-1.c
@@ -0,0 +1,19 @@
+/* PR tree-optimization/19283 */
+
+void abort (void);
+
+static inline unsigned short
+foo (unsigned int *p)
+{
+ return *p;
+};
+
+unsigned int u;
+
+int
+main ()
+{
+ if ((foo (&u) & 0x8000) != 0)
+ abort ();
+ return 0;
+}
OpenPOWER on IntegriCloud