[llvm] [IPSCCP] Add range attribute handling. (PR #86747)

Andreas Jonson via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 10 12:22:11 PDT 2024


================
@@ -788,6 +794,17 @@ class SCCPInstVisitor : public InstVisitor<SCCPInstVisitor> {
       markOverdefined(ValueState[V], V);
   }
 
+  void trackValueOfArgument(Argument *A) {
+    if (A->getType()->isIntegerTy()) {
----------------
andjo403 wrote:

Tried to add a test for vector like below but was not optimized when I remove the check. But maybe I did something wrong.
```
define void @range_attribute_vec(<2 x i32> range(i32 0, 10) %v) {
  %c1 = icmp ult <2 x i32> %v, <i32 10, i32 10>
  call void @use(<2 x i1> %c1)
  %c2 = icmp ult <2 x i32> %v, <i32 9, i32 9>
  call void @use(<2 x i1> %c2)
  %c3 = icmp ugt <2 x i32> %v, <i32 9, i32 9>
  call void @use(<2 x i1> %c3)
  %c4 = icmp ugt <2 x i32> %v, <i32 8, i32 8>
  call void @use(<2 x i1> %c4)
  ret void
}
```

https://github.com/llvm/llvm-project/pull/86747


More information about the llvm-commits mailing list