summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/fold-bitand-4.c
diff options
context:
space:
mode:
authoraaw <aaw@138bc75d-0d04-0410-961f-82ee72b054a4>2007-09-23 20:05:40 +0000
committeraaw <aaw@138bc75d-0d04-0410-961f-82ee72b054a4>2007-09-23 20:05:40 +0000
commit4486d2b7f11c5ca684304a8cff46baefc892d089 (patch)
tree2d3fd9b7aeae8ab84d172e1ceed387e1e4e97364 /gcc/testsuite/gcc.dg/fold-bitand-4.c
parentee37867ca544a6c76553fc9563f5162797b3a869 (diff)
downloadgcc-4486d2b7f11c5ca684304a8cff46baefc892d089.tar.gz
gcc/
fold-const.c (fold_binary): Fold BIT_AND_EXPR's with a pointer operand. (get_pointer_modulus_and_residue): New function. gcc/testsuite/ gcc.dg/fold-bitand-1.c: New test. gcc.dg/fold-bitand-2.c: New test. gcc.dg/fold-bitand-3.c: New test. gcc.dg/fold-bitand-4.c: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@128701 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/testsuite/gcc.dg/fold-bitand-4.c')
-rw-r--r--gcc/testsuite/gcc.dg/fold-bitand-4.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/fold-bitand-4.c b/gcc/testsuite/gcc.dg/fold-bitand-4.c
new file mode 100644
index 00000000000..7d824260ff0
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/fold-bitand-4.c
@@ -0,0 +1,44 @@
+/* { dg-do compile } */
+/* { dg-options "-fdump-tree-original" } */
+
+typedef char char4[4] __attribute__ ((aligned (4)));
+char4 c4[4] __attribute__ ((aligned (16)));
+
+typedef char char16[16] __attribute__ ((aligned (16)));
+char16 c16[4] __attribute__ ((aligned (4)));
+
+int f1 (void)
+{
+ /* 12 */
+ return 15 & (__SIZE_TYPE__)&c4[3];
+}
+
+int f2 (int i)
+{
+ /* Indeterminate */
+ return 15 & (__SIZE_TYPE__)&c4[i];
+}
+
+int f3 (int i)
+{
+ /* 0 */
+ return 3 & (__SIZE_TYPE__)&c4[i];
+}
+
+int f4 (int i)
+{
+ /* Indeterminate */
+ return 7 & (__SIZE_TYPE__)&c16[i];
+}
+
+int f5 (int i)
+{
+ /* 0 */
+ return 3 & (__SIZE_TYPE__)&c16[i];
+}
+
+/* { dg-final { scan-tree-dump-times "return 12" 1 "original" } } */
+/* { dg-final { scan-tree-dump-times "\& 15" 1 "original" } } */
+/* { dg-final { scan-tree-dump-times "return 0" 2 "original" } } */
+/* { dg-final { scan-tree-dump-times "\& 7" 1 "original" } } */
+/* { dg-final { cleanup-tree-dump "original" } } */