aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2022-08-10 15:45:22 +0200
committerRichard Biener <rguenther@suse.de>2022-08-10 16:38:41 +0200
commitf675afa4eeac9910a2c085a95aa04d6d9f2fd8d6 (patch)
tree7c0370d11e5f03e310bc30d2a18ce3a5d934afdc /gcc
parentfed766af32ed6cd371016cc24e931131e19b4eb1 (diff)
downloadgcc-f675afa4eeac9910a2c085a95aa04d6d9f2fd8d6.zip
gcc-f675afa4eeac9910a2c085a95aa04d6d9f2fd8d6.tar.gz
gcc-f675afa4eeac9910a2c085a95aa04d6d9f2fd8d6.tar.bz2
tree-optimization/106513 - fix mistake in bswap symbolic number shifts
This fixes a mistake in typing a local variable in the symbolic shift routine. PR tree-optimization/106513 * gimple-ssa-store-merging.cc (do_shift_rotate): Use uint64_t for head_marker. * gcc.dg/torture/pr106513.c: New testcase.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/gimple-ssa-store-merging.cc2
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr106513.c26
2 files changed, 27 insertions, 1 deletions
diff --git a/gcc/gimple-ssa-store-merging.cc b/gcc/gimple-ssa-store-merging.cc
index 0640168..b80b8ea 100644
--- a/gcc/gimple-ssa-store-merging.cc
+++ b/gcc/gimple-ssa-store-merging.cc
@@ -263,7 +263,7 @@ do_shift_rotate (enum tree_code code,
int count)
{
int i, size = TYPE_PRECISION (n->type) / BITS_PER_UNIT;
- unsigned head_marker;
+ uint64_t head_marker;
if (count < 0
|| count >= TYPE_PRECISION (n->type)
diff --git a/gcc/testsuite/gcc.dg/torture/pr106513.c b/gcc/testsuite/gcc.dg/torture/pr106513.c
new file mode 100644
index 0000000..aa4f4d5
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr106513.c
@@ -0,0 +1,26 @@
+/* { dg-do run } */
+
+typedef __INT64_TYPE__ int64_t;
+
+__attribute__((noinline)) int64_t
+swap64 (int64_t n)
+{
+ return (((n & (((int64_t) 0xff) )) << 56) |
+ ((n & (((int64_t) 0xff) << 8)) << 40) |
+ ((n & (((int64_t) 0xff) << 16)) << 24) |
+ ((n & (((int64_t) 0xff) << 24)) << 8) |
+ ((n & (((int64_t) 0xff) << 32)) >> 8) |
+ ((n & (((int64_t) 0xff) << 40)) >> 24) |
+ ((n & (((int64_t) 0xff) << 48)) >> 40) |
+ ((n & ((int64_t)(0xffull << 56))) >> 56));
+}
+
+int main (void)
+{
+ volatile int64_t n = 0x8000000000000000ll;
+
+ if (swap64(n) != 0xffffffffffffff80ll)
+ __builtin_abort ();
+
+ return 0;
+}