[all-commits] [llvm/llvm-project] 4acc35: [ConstraintElim] Add missing check to make sure th...

Yingwei Zheng via All-commits all-commits at lists.llvm.org
Thu Nov 2 08:38:18 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 4acc357a3700e6bc7afe3f6393d423c3d8b02d7d
      https://github.com/llvm/llvm-project/commit/4acc357a3700e6bc7afe3f6393d423c3d8b02d7d
  Author: Yingwei Zheng <dtcxzyw2333 at gmail.com>
  Date:   2023-11-02 (Thu, 02 Nov 2023)

  Changed paths:
    M llvm/lib/Transforms/Scalar/ConstraintElimination.cpp
    A llvm/test/Transforms/ConstraintElimination/pr70510.ll

  Log Message:
  -----------
  [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.




More information about the All-commits mailing list