> The following moves some bitwise patterns from the match-and-simplify
> branch, extending them with proper conditional converts and removing
> the corresponding patterns from fold-const.c
There is a pasto/thinko in the last pattern:
/* Convert ~X ^ C to X ^ ~C. */
(simplify
(bit_xor (convert? (bit_not @0)) INTEGER_CST@1)
(bit_xor (convert @0) (bit_not @1)))
That's incorrect if the types don't have the same precision, as in the other
cases, and is responsible for PR tree-optimization/66757.
Tested on x86_64-suse-linux, OK for the mainline?
2015-07-05 Eric Botcazou <ebotca...@adacore.com>
PR tree-optimization/66757
* match.pd: Add missing condition to ~X ^ C -> X ^ ~C.
2015-07-05 Eric Botcazou <ebotca...@adacore.com>
* gcc.c-torture/execute/pr66757.c: New test.
--
Eric Botcazou
Index: match.pd
===================================================================
--- match.pd (revision 225410)
+++ match.pd (working copy)
@@ -444,7 +444,8 @@ (define_operator_list CBRT BUILT_IN_CBRT
/* Convert ~X ^ C to X ^ ~C. */
(simplify
(bit_xor (convert? (bit_not @0)) INTEGER_CST@1)
- (bit_xor (convert @0) (bit_not @1)))
+ (if (tree_nop_conversion_p (type, TREE_TYPE (@0)))
+ (bit_xor (convert @0) (bit_not @1))))
/* Fold (X & Y) ^ Y as ~X & Y. */
(simplify
/* PR tree-optimization/66757 */
/* Testcase by Zhendong Su <s...@cs.ucdavis.edu> */
int a, b;
int
main (void)
{
unsigned int t = (unsigned char) (~b);
if ((t ^ 1) / 255)
__builtin_abort ();
return 0;
}