Bug 98381 - [11 Regression] Wrong code with -O3 -march=skylake-avx512 by r11-3072
Summary: [11 Regression] Wrong code with -O3 -march=skylake-avx512 by r11-3072
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 11.0
: P1 normal
Target Milestone: 11.0
Assignee: Richard Biener
URL:
Keywords: wrong-code
Depends on:
Blocks: yarpgen
  Show dependency treegraph
 
Reported: 2020-12-18 20:03 UTC by Vsevolod Livinskii
Modified: 2021-11-01 23:07 UTC (History)
6 users (show)

See Also:
Host:
Target:
Build:
Known to work: 9.3.0
Known to fail: 11.0
Last reconfirmed: 2020-12-19 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Vsevolod Livinskii 2020-12-18 20:03:46 UTC
Reproducer:
//func.cpp
extern bool var_22;
void test(long long a, unsigned b, unsigned long long c) {
  for (long i = 0; i < 16; i += 1ULL)
    if (a)
      var_22 = 5023804122334ULL >= (char)c;
}

//driver.cpp 
#include <stdio.h>
long long int a = -2161098602020439353LL;
unsigned int b = 1621447385U;
unsigned long long int c = 16505450185101189749ULL;
bool var_22 = (bool)0;

void test(long long int a, unsigned int b, unsigned long long int c);

int main() {
    test(a, b, c);
    printf("%d\n", (int)var_22);
}

Error:
>$ g++ -O3 -march=skylake-avx512 func.cpp driver.cpp && sde -skx -- ./a.out
0
>$ g++ -O0 func.cpp driver.cpp && sde -skx -- ./a.out
1

gcc version 11.0.0 20201217 (6f8486523f61bf0aa476dfa4197d1e3b71a0a8f3) (GCC)
Comment 1 H.J. Lu 2020-12-19 14:18:15 UTC
It is caused by r11-3072.
Comment 2 Richard Biener 2021-01-04 09:03:54 UTC
Mine.
Comment 3 GCC Commits 2021-01-05 14:54:56 UTC
The master branch has been updated by Richard Biener <rguenth@gcc.gnu.org>:

https://gcc.gnu.org/g:01da03c915f086fb9aa36b809c1a06a9f661533b

commit r11-6468-g01da03c915f086fb9aa36b809c1a06a9f661533b
Author: Richard Biener <rguenther@suse.de>
Date:   Tue Jan 5 14:23:55 2021 +0100

    tree-optimization/98381 - fix live bool vector extract
    
    This fixes extraction of live bool vector results for the case of
    integer mode vectors.
    
    2021-01-05  Richard Biener  <rguenther@suse.de>
    
            PR tree-optimization/98381
            * tree.c (vector_element_bits): Properly compute bool vector
            element size.
            * tree-vect-loop.c (vectorizable_live_operation): Properly
            compute the last lane bit offset.
Comment 4 Richard Biener 2021-01-05 14:56:57 UTC
Fixed.