https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94482

--- Comment #13 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to Martin Liška from comment #9)
> (In reply to Evan Nemerson from comment #8)
> > Created attachment 48204 [details]
> > Reduced test case, ASan/UBSan clean
> > 
> > Here is the reduced test case which works with -fsanitize=address,undefined
> > -Wno-psabi -Wall -Werror.
> > 
> > This one is self-contained, and instead of using assert the return value is
> > 0 on success and 1 on failure.
> 
> Thank you.
> The git bisection revisions remain the same for the reduced test-case.
> Isn't the problem right now the violation of -Wpsabi?
> 
> pr94482-v2.c: In function ‘s’:
> pr94482-v2.c:8:1: warning: SSE vector return without SSE enabled changes the
> ABI [-Wpsabi]
>     8 | l s(__INT64_TYPE__ a) {
>       | ^
> pr94482-v2.c: In function ‘p’:
> pr94482-v2.c:16:3: note: the ABI for passing parameters with 16-byte
> alignment has changed in GCC 4.6
>    16 | l p(l a, __INT64_TYPE__ i, int q) {
>       |   ^
> pr94482-v2.c:16:3: warning: SSE vector argument without SSE enabled changes
> the ABI [-Wpsabi]

No, that's not an issue here.  All of the code is inlined into main anyways,
with -fno-inline the code is fine.  Making the two non-main functions static
makes the testcase easier to look at.  You can see after inlining the IL
has lots of redundancies that should be irrelevant but GIMPLE IL support
is too limited on the GCC 9 branch to do that editing there.

The assembly shows:

        movl    16(%esp), %eax
        movl    20(%esp), %edx
...
        xorl    $1729, %eax
        orl     %edx, %eax
        setne   %al

which is the final comparison but those stack slots are never written to.

If you look at the GIMPLE before RTL expansion it looks like

main ()
{
  union k r_;
  vector(4) int n;
  union k r_;
  vector(4) int n;
  long long int _1;
  _Bool _2;
  int _6;
  vector(4) int _18;
  vector(4) int _20;

;;   basic block 2, loop depth 0
;;    pred:       ENTRY
  BIT_FIELD_REF <r_.i64, 64, 0> = 1729;
  _18 = MEM[(union  *)&r_];
  MEM[(char * {ref-all})&m] = _18;
  n = _18;
  MEM[(char * {ref-all})&u] = MEM[(char * {ref-all})&n];
  BIT_FIELD_REF <r_.i64, 64, 64> = 2;
  _20 = MEM[(union  *)&r_];
  MEM[(char * {ref-all})&v] = _20;
  o = _20;
  n ={v} {CLOBBER};
  n = _20;
  MEM[(char * {ref-all})&t] = MEM[(char * {ref-all})&n];
  _1 = BIT_FIELD_REF <_20, 64, 0>;
  _2 = _1 != 1729;
  _6 = (int) _2;
  n ={v} {CLOBBER};
  return _6;
;;    succ:       EXIT

but the body should be simplifiable to just

  BIT_FIELD_REF <r_.i64, 64, 0> = 1729;
  BIT_FIELD_REF <r_.i64, 64, 64> = 2;
  _20 = MEM[(union  *)&r_];
  _1 = BIT_FIELD_REF <_20, 64, 0>;
  _2 = _1 != 1729;
  _6 = (int) _2;
  return _6;

of course the unrelated stmts may actually trigger the miscompile.  GCC 9
does not have BIT_FIELD_REF support for the GIMPLE FE (but it should be
backportable I guess).

Reply via email to