ITADN

SCFCanonicalizeFor MoveWhileToFor crashes on scf.while with andi condition

#2396Openxys-syx 创建于 2026-04-06
X
xys-syxcommented
When `scf.while` has an `arith.andi` condition, `MoveWhileToFor` tries both operands of the `andi` in a loop using the same `WhileToForHelper`. If `i=0` succeeds, the loop continues to `i=1`, whose `computeLegality` call resets, causing a segfault. The minimal reproducible example is as following: ``` // RUN: enzymexlamlir-opt --canonicalize-scf-for %s module { func.func @repro(%arg0: i32, %arg1: i64) -> (i32, i64) { %c2560 = arith.constant 2560 : i32 %c0 = arith.constant 0 : i32 %result:2 = scf.while (%iv = %c2560, %acc = %arg1) : (i32, i64) -> (i32, i64) { %diff = arith.subi %arg0, %c2560 : i32 %cmp0 = arith.cmpi sle, %iv, %diff : i32 %next = arith.addi %iv, %c2560 : i32 %diff2 = arith.subi %arg0, %iv : i32 %cmp1 = arith.cmpi sge, %diff2, %c2560 : i32 %cond = arith.andi %cmp0, %cmp1 : i1 scf.condition(%cond) %next, %acc : i32, i64 } do { ^bb0(%iv: i32, %acc: i64): scf.yield %iv, %acc : i32, i64 } return %result#0, %result#1 : i32, i64 } } ```
0 条评论