[prev in list] [next in list] [prev in thread] [next in thread]
List: gcc-bugs
Subject: [Bug tree-optimization/110067] New: [14 Regression] Wrong code on pixman-0.42.2
From: "slyfox at gcc dot gnu.org via Gcc-bugs" <gcc-bugs () gcc ! gnu ! org>
Date: 2023-05-31 22:42:56
Message-ID: bug-110067-4 () http ! gcc ! gnu ! org/bugzilla/
[Download RAW message or body]
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110067
Bug ID: 110067
Summary: [14 Regression] Wrong code on pixman-0.42.2
Product: gcc
Version: 14.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: slyfox at gcc dot gnu.org
Target Milestone: ---
This week's gcc r14-1423-gfefa7db2c31fee started failing pixman-0.42.2 test
suite:
pixman> FAIL: scaling-crash-test
pixman> FAIL: cover-test
pixman> FAIL: affine-test
pixman> FAIL: filter-reduction-test
pixman> FAIL: scaling-test
I think it's a gcc bug.
Extracted example from scaling-test:
// $ cat bug.c
#include <stdint.h>
#include <stdio.h>
#define BILINEAR_INTERPOLATION_BITS 7
#define force_inline __inline__ __attribute__ ((__always_inline__))
__attribute__((noipa))
static void
fetch_pixel_no_alpha_32_bug (void *out)
{
uint32_t *ret = out;
*ret = 0xff499baf;
}
static force_inline uint32_t
bilinear_interpolation_local (uint32_t tl, uint32_t tr,
uint32_t bl, uint32_t br,
int distx, int disty)
{
uint64_t distxy, distxiy, distixy, distixiy;
uint64_t tl64, tr64, bl64, br64;
uint64_t f, r;
distx <<= (8 - BILINEAR_INTERPOLATION_BITS);
disty <<= (8 - BILINEAR_INTERPOLATION_BITS);
distxy = distx * disty;
distxiy = distx * (256 - disty);
distixy = (256 - distx) * disty;
distixiy = (256 - distx) * (256 - disty);
/* Alpha and Blue */
tl64 = tl & 0xff0000ff;
tr64 = tr & 0xff0000ff;
bl64 = bl & 0xff0000ff;
br64 = br & 0xff0000ff;
f = tl64 * distixiy + tr64 * distxiy + bl64 * distixy + br64 * distxy;
r = f & 0x0000ff0000ff0000ull;
/* Red and Green */
tl64 = tl;
tl64 = ((tl64 << 16) & 0x000000ff00000000ull) | (tl64 & 0x0000ff00ull);
tr64 = tr;
tr64 = ((tr64 << 16) & 0x000000ff00000000ull) | (tr64 & 0x0000ff00ull);
bl64 = bl;
bl64 = ((bl64 << 16) & 0x000000ff00000000ull) | (bl64 & 0x0000ff00ull);
br64 = br;
br64 = ((br64 << 16) & 0x000000ff00000000ull) | (br64 & 0x0000ff00ull);
f = tl64 * distixiy + tr64 * distxiy + bl64 * distixy + br64 * distxy;
r |= ((f >> 16) & 0x000000ff00000000ull) | (f & 0xff000000ull);
return (uint32_t)(r >> 16);
}
__attribute__((noipa))
static void
bits_image_fetch_pixel_bilinear_32_bug (void *out)
{
uint32_t br;
uint32_t *ret = out;
fetch_pixel_no_alpha_32_bug (&br);
*ret = bilinear_interpolation_local (0, 0, 0, br, 0x41, 0x42);
}
int main() {
uint32_t r;
bits_image_fetch_pixel_bilinear_32_bug (&r);
printf("r=%08x\n", r);
}
Triggering:
$ gcc-14 -O2 -fno-strict-aliasing bug.c -o bug14 && ./bug14
r=4200282d
$ gcc-13 -O2 -fno-strict-aliasing bug.c -o bug13 && ./bug13
r=4213282d
Note that returned values are not identical.
$ gcc-14 -v |& unnix
Using built-in specs.
COLLECT_GCC=/<<NIX>>/gcc-14.0.0/bin/gcc
COLLECT_LTO_WRAPPER=/<<NIX>>/gcc-14.0.0/libexec/gcc/x86_64-unknown-linux-gnu/14.0.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with:
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 14.0.0 99999999 (experimental) (GCC)=
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic