Issue 159905
Summary [X86][MMX] ConstExpr function fails to identify sub _expression_ as constant _expression_
Labels new issue
Assignees
Reporter mahesh-attarde
    I have test case that seems to regressed for latest constexpr changes.

```
#include<immintrin.h>
constexpr
__m64 foo(__m64 a, int b){
    return (__m64)(long long)a << b;
}
int main(){
 foo((__m64){5},1);
    return 0;
}
```
gcc-trunk works fine. clang-trunk errors out. 

```
<source>:3:7: error: constexpr function never produces a constant _expression_ [-Winvalid-constexpr]
    3 | __m64 foo(__m64 a, int b){
      |       ^~~
<source>:4:19: note: subexpression not valid in a constant _expression_
    4 |     return (__m64)(long long)a << b;
```

Following change passed 
```
#include<immintrin.h>
constexpr
__m64 foo(__m64 a, int b){
    if(b > 63)
        return (__m64){0};
    return (__m64)(long long)a << b;
}
int main(){
    foo((__m64){5},1);
    return 0;
}
```
here is repro https://godbolt.org/z/d7obEcb57
Does anyone know what may be trouble here?
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to