weld icon indicating copy to clipboard operation
weld copied to clipboard

rangeiter not picked up by the loop fusion transform

Open mihai-varga opened this issue 7 years ago • 0 comments

The following code could be optimized into a single for loop

|x:i64|
let cand = result(
	for(rangeiter(0L, x, 1L), appender[i64], |b, i, n|
		merge(b, n)
	)
);
let res = result(
	for(cand, appender[i64], |b, i, n|
		if(n % 2L == 0L, merge(b, n), b)
	)
);
{res}

But Weld currently produces:

|x|
  {result(
    for(
      result(
          for(
            rangeiter([],0L,x,1L),
            appender[i64],
            |b,i,n|
              merge(b,n)
          )
        ),
      appender[i64],
      |b__1,i__1,n__1|
        if(
          ((n__1%2L)==0L),
          merge(b__1,n__1),
          b__1
        )
    )
  )}

mihai-varga avatar Apr 09 '18 14:04 mihai-varga