Re: the elimination of if blocks in GCC during if-conversion and vectorization

2023-10-26 Thread Richard Biener via Gcc
On Mon, Oct 23, 2023 at 2:56 PM Hanke Zhang wrote: > > Richard Biener 于2023年10月23日周一 20:32写道: > > > > On Mon, Oct 23, 2023 at 12:50 PM Hanke Zhang wrote: > > > > > > Hi Richard: > > > > > > Thanks for your advice. But when I try a simpler example like the one > > > below before looking at the co

Re: the elimination of if blocks in GCC during if-conversion and vectorization

2023-10-23 Thread Hanke Zhang via Gcc
Richard Biener 于2023年10月23日周一 20:32写道: > > On Mon, Oct 23, 2023 at 12:50 PM Hanke Zhang wrote: > > > > Hi Richard: > > > > Thanks for your advice. But when I try a simpler example like the one > > below before looking at the code, GCC still does nothing. > > > > int main() { > > int width; >

Re: the elimination of if blocks in GCC during if-conversion and vectorization

2023-10-23 Thread Richard Biener via Gcc
On Mon, Oct 23, 2023 at 12:50 PM Hanke Zhang wrote: > > Hi Richard: > > Thanks for your advice. But when I try a simpler example like the one > below before looking at the code, GCC still does nothing. > > int main() { > int width; > scanf("%d", &width); > int sum = 0; > for (int i

Re: the elimination of if blocks in GCC during if-conversion and vectorization

2023-10-23 Thread Hanke Zhang via Gcc
Hi Richard: Thanks for your advice. But when I try a simpler example like the one below before looking at the code, GCC still does nothing. int main() { int width; scanf("%d", &width); int sum = 0; for (int i = 0; i < width; i++) sum += i; printf("%d\n", sum); } I tried O3 an

Re: the elimination of if blocks in GCC during if-conversion and vectorization

2023-10-19 Thread Richard Biener via Gcc
On Tue, Oct 17, 2023 at 2:39 PM Hanke Zhang wrote: > > Hi Richard > I get it, thank you again. > > And I got another problem, so I'd like ask it by the way. Can the left > shift of the induction variable in a loop be optimized as a constant? > Like the code below: > > int ans = 0; > int width = ra

Re: the elimination of if blocks in GCC during if-conversion and vectorization

2023-10-17 Thread Hanke Zhang via Gcc
Hi Richard I get it, thank you again. And I got another problem, so I'd like ask it by the way. Can the left shift of the induction variable in a loop be optimized as a constant? Like the code below: int ans = 0; int width = rand() % 16; for (int j = 0; j < width; j++) ans += 1 << (j + width)

Re: the elimination of if blocks in GCC during if-conversion and vectorization

2023-10-17 Thread Hanke Zhang via Gcc
Richard Biener 于2023年10月17日周二 17:26写道: > > On Thu, Oct 12, 2023 at 2:18 PM Hanke Zhang via Gcc wrote: > > > > Hi, I'm recently working on vectorization of GCC. I'm stuck in a small > > problem and would like to ask for advice. > > > > For example, for the following code: > > > > int main() { > >

Re: the elimination of if blocks in GCC during if-conversion and vectorization

2023-10-17 Thread Richard Biener via Gcc
On Tue, Oct 17, 2023 at 1:54 PM Hanke Zhang wrote: > > Richard Biener 于2023年10月17日周二 17:26写道: > > > > On Thu, Oct 12, 2023 at 2:18 PM Hanke Zhang via Gcc wrote: > > > > > > Hi, I'm recently working on vectorization of GCC. I'm stuck in a small > > > problem and would like to ask for advice. > >

Re: the elimination of if blocks in GCC during if-conversion and vectorization

2023-10-17 Thread Richard Biener via Gcc
On Thu, Oct 12, 2023 at 2:18 PM Hanke Zhang via Gcc wrote: > > Hi, I'm recently working on vectorization of GCC. I'm stuck in a small > problem and would like to ask for advice. > > For example, for the following code: > > int main() { > int size = 1000; > int *foo = malloc(sizeof(int) * size)