[ConstraintElim] Add missing check to make sure the bound is loop-invariant (#70555)
This PR adds a missing check for https://github.com/llvm/llvm-project/commit/e6a1657fa30c747f4412fc47f567660ebe861a9e to make sure the bound is loop-invariant. Example: ``` define i32 @main() { entry: br label %for.header for.header: %ind1 = phi i64 [ %ind1.i, %for.latch ], [ 0, %entry ] %ind2 = phi i64 [ %ind2.i, %for.latch ], [ 5, %entry ] %rem = srem i64 %ind2, 4 %cmp6 = icmp eq i64 %ind1, %rem br i1 %cmp6, label %exit1, label %for.latch for.latch: %ind2.i = add i64 %ind2, 1 %ind1.i = add i64 %ind1, 1 %cond = icmp eq i64 %ind1.i, 8 br i1 %cond, label %exit2, label %for.header exit2: %cmp = icmp eq i64 %rem, 0 %ret = zext i1 %cmp to i32 ret i32 %ret exit1: ret i32 0 } ``` We cannot infer `%ind1 <u %rem` from `icmp eq i64 %ind1, %rem` in the loop since `%rem` is not a loop-invariant. Fixes #70510.
Loading
Please sign in to comment