-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[RISCV] Miscompile at -O3 #84200
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@llvm/issue-subscribers-backend-risc-v Author: Yingwei Zheng (dtcxzyw)
Reduced test case: https://godbolt.org/z/1sxbE8eco
```
#include <stdint.h>
#include <stdio.h>
int32_t a, f;
uint16_t e = 10;
static uint8_t f1(uint8_t c, uint8_t d) { return d == 0 ? 0 : c % d; }
static uint32_t f2(uint32_t c, uint32_t d) { return d == 0 ? c : 0; }
static int32_t *h(int32_t l) {
int32_t *n = &a;
return n;
}
static uint64_t g(int16_t k) {
uint16_t m[] = {0, 3};
int32_t *j = h(0);
*j = f1(f2(1 && m[1], 0), e) == 0;
return m[f];
}
int main() {
g(f);
printf("%d\n", a);
}
```
|
Looks like TypePromotion. I'll take this. |
Still fails if I revert the most recent change to TypePromotion
|
The bug is in SelectionDAG but exposed by TypePromotion. We convert some selects into AND/OR in LowerSelect. Select blocks poison propagation, but AND/OR does not. We need to insert a freeze to keep poison from the true/false operand from affecting the AND/OR. |
Select blocks poison, but AND/OR do not. We need to insert a freeze to block poison propagation. This creates suboptimal codegen which I will try to fix with other patches. We should prioritize the correctness fix. Fixes llvm#84200.
Uh oh!
There was an error while loading. Please reload this page.
Reduced test case: https://godbolt.org/z/1sxbE8eco
Clang version: 6e27dd4
The text was updated successfully, but these errors were encountered: