[llvm] [InstCombine] limit icmp sgt (shl nsw X, C1), C0 --> icmp sgt X, C0 >> C1 to hasOneUse (PR #74318)

Liao Chunyu via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 6 05:35:14 PST 2023


ChunyuLiao wrote:


> I don't think this is the right way to fix this issue. If I'm reading the transformation log right, the problem seems to be that we lose nsw information in IndVarSimplify?

Could you help give more information? Thanks.
My understanding is that shl's nsw should be retained in IndVarSimplify.

Violent do try. Keep shl's nsw, but it doesn't fix the issue.
```
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp
index 8c29c242215d..b43feb621ad6 100644
--- a/llvm/lib/Analysis/ValueTracking.cpp
+++ b/llvm/lib/Analysis/ValueTracking.cpp
@@ -7309,7 +7309,7 @@ static bool programUndefinedIfUndefOrPoison(const Value *V,
 
       // If an operand is poison and propagates it, mark I as yielding poison.
       for (const Use &Op : I.operands()) {
-        if (YieldsPoison.count(Op) && propagatesPoison(Op)) {
+        if (propagatesPoison(Op)) {
           YieldsPoison.insert(&I);
           break;
         }
```

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


More information about the llvm-commits mailing list