diff options
-rw-r--r-- | gcc/match.pd | 6 | ||||
-rw-r--r-- | gcc/testsuite/gcc.c-torture/compile/pr103314-1.c | 6 |
2 files changed, 11 insertions, 1 deletions
diff --git a/gcc/match.pd b/gcc/match.pd index 4042b53..e5985de 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -1619,7 +1619,11 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) after hoisting the conversion the operation will be narrower. It is also a good if the conversion is a nop as moves the conversion to one side; allowing for combining of the conversions. */ - TYPE_PRECISION (TREE_TYPE (@0)) <= TYPE_PRECISION (type) + TYPE_PRECISION (TREE_TYPE (@0)) < TYPE_PRECISION (type) + /* The conversion check for being a nop can only be done at the gimple + level as fold_binary has some re-association code which can conflict + with this if there is a "constant" which is not a full INTEGER_CST. */ + || (GIMPLE && TYPE_PRECISION (TREE_TYPE (@0)) == TYPE_PRECISION (type)) /* It's also a good idea if the conversion is to a non-integer mode. */ || GET_MODE_CLASS (TYPE_MODE (type)) != MODE_INT diff --git a/gcc/testsuite/gcc.c-torture/compile/pr103314-1.c b/gcc/testsuite/gcc.c-torture/compile/pr103314-1.c new file mode 100644 index 0000000..f4a6313 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr103314-1.c @@ -0,0 +1,6 @@ +/* { dg-options "" } */ +int main() { + int t = 1; + unsigned c = 0, d1 = t ? 1 ^ c ^ 1 >> (-1) : 0; /* { dg-warning "is negative" } */ + return d1; +} |