Hi, I'm trying to study "Match and Simplify" recently, and I had this sample code:
int main() { int n = 1000; int *a = malloc (sizeof(int) * n); int *b = malloc (sizeof(int) * n); int *c = malloc (sizeof(int) * n); for (int i = 0; i < n; i++) { if (a[i] & b[i]) { a[i] ^= c[i]; } } } But this code cannot be vectorized very well. I hope it can become like this: int main() { int n = 1000; int *a = malloc (sizeof(int) * n); int *b = malloc (sizeof(int) * n); int *c = malloc (sizeof(int) * n); for (int i = 0; i < n; i++) { int cond = ((a[i] & b[i]) == 1); unsigned int mask = cond ? -1 : 0; a[i] ^= (c[i] & mask); } } This can finally result in concise and efficient vectorized instructions. But I want to know if this can be achieved through "Match and Simplify"? Because when I tried to write the pattern, I found that the condtional statement here seemed not to be matched well, as there is not an else block. Or is this not possible with "Match and Simplify"? Is it possible to implement it in if-conversion? Thanks Hanke Zhang