]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR rtl-optimization/43438 (possible wrong code bug)
authorRichard Guenther <rguenther@suse.de>
Tue, 20 Apr 2010 13:09:42 +0000 (13:09 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Tue, 20 Apr 2010 13:09:42 +0000 (13:09 +0000)
2010-04-20  Richard Guenther  <rguenther@suse.de>

PR rtl-optimization/43438
* combine.c (make_extraction): Properly zero-/sign-extend an
extraction of the low part of a CONST_INT.

* gcc.c-torture/execute/pr43438.c: New testcase.

From-SVN: r158555

gcc/ChangeLog
gcc/combine.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/execute/pr43438.c [new file with mode: 0644]

index c8d59b35b91c5bbc269014cfbe6c779fade5131d..794475166e072f128fd7fa2c04e2f1aeb705c675 100644 (file)
@@ -1,3 +1,9 @@
+2010-04-20  Richard Guenther  <rguenther@suse.de>
+
+       PR rtl-optimization/43438
+       * combine.c (make_extraction): Properly zero-/sign-extend an
+       extraction of the low part of a CONST_INT.
+
 2010-04-20  Richard Guenther  <rguenther@suse.de>
 
        PR tree-optimization/43629
index 5d8239d0d9c028abb60d1205f586dfb56b2e74e5..49246d35f623ccf1be47eedb163a597f99af7e99 100644 (file)
@@ -6552,7 +6552,8 @@ make_extraction (enum machine_mode mode, rtx inner, HOST_WIDE_INT pos,
        return new;
 
       if (GET_CODE (new) == CONST_INT)
-       return gen_int_mode (INTVAL (new), mode);
+       return simplify_unary_operation (unsignedp ? ZERO_EXTEND : SIGN_EXTEND,
+                                        mode, new, tmode);
 
       /* If we know that no extraneous bits are set, and that the high
         bit is not set, convert the extraction to the cheaper of
index bbbee43d98602504cd65d1b6769a4923848fd030..45553b688a1ab60d1119d07c379573d11c77a058 100644 (file)
@@ -1,3 +1,8 @@
+2010-04-20  Richard Guenther  <rguenther@suse.de>
+
+       PR rtl-optimization/43438
+       * gcc.c-torture/execute/pr43438.c: New testcase.
+
 2010-04-20  Richard Guenther  <rguenther@suse.de>
 
        PR tree-optimization/43629
diff --git a/gcc/testsuite/gcc.c-torture/execute/pr43438.c b/gcc/testsuite/gcc.c-torture/execute/pr43438.c
new file mode 100644 (file)
index 0000000..aa901ce
--- /dev/null
@@ -0,0 +1,23 @@
+extern void abort (void);
+
+static unsigned char g_2 = 1;
+static int g_9;
+static int *l_8 = &g_9;
+
+static void func_12(int p_13)
+{
+  int * l_17 = &g_9;
+  *l_17 &= 0 < p_13;
+}
+
+int main(void)
+{
+  unsigned char l_11 = 254;
+  *l_8 |= g_2;
+  l_11 |= *l_8;
+  func_12(l_11);
+  if (g_9 != 1)
+    abort ();
+  return 0;
+} 
+