[llvm] [InstCombine] Fix missing argument typo in `InstCombinerImpl::foldICmpShlConstant` (PR #94899)
via llvm-commits
llvm-commits at lists.llvm.org
Sun Jun 9 05:02:40 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-transforms
Author: Yingwei Zheng (dtcxzyw)
<details>
<summary>Changes</summary>
Closes #<!-- -->94897.
---
Full diff: https://github.com/llvm/llvm-project/pull/94899.diff
2 Files Affected:
- (modified) llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp (+4-3)
- (modified) llvm/test/Transforms/InstCombine/icmp.ll (+10)
``````````diff
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
index 89193f8ff94b6..9965825e582be 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
@@ -2441,9 +2441,10 @@ Instruction *InstCombinerImpl::foldICmpShlConstant(ICmpInst &Cmp,
Type *TruncTy = ShType->getWithNewBitWidth(TypeBits - Amt);
Constant *NewC =
ConstantInt::get(TruncTy, RHSC.ashr(*ShiftAmt).trunc(TypeBits - Amt));
- return new ICmpInst(
- CmpPred, Builder.CreateTrunc(X, TruncTy, "", Shl->hasNoSignedWrap()),
- NewC);
+ return new ICmpInst(CmpPred,
+ Builder.CreateTrunc(X, TruncTy, "", /*IsNUW=*/false,
+ Shl->hasNoSignedWrap()),
+ NewC);
}
}
diff --git a/llvm/test/Transforms/InstCombine/icmp.ll b/llvm/test/Transforms/InstCombine/icmp.ll
index 4dbe2fc88ff71..723dbbc7101dc 100644
--- a/llvm/test/Transforms/InstCombine/icmp.ll
+++ b/llvm/test/Transforms/InstCombine/icmp.ll
@@ -5295,3 +5295,13 @@ define i1 @test_icmp_shl_sgt(i64 %x) {
%cmp = icmp sgt i64 %shl, 8589934591
ret i1 %cmp
}
+
+define i1 @pr94897(i32 range(i32 -2147483648, 0) %x) {
+; CHECK-LABEL: @pr94897(
+; CHECK-NEXT: [[CMP:%.*]] = icmp ugt i32 [[X:%.*]], -3
+; CHECK-NEXT: ret i1 [[CMP]]
+;
+ %shl = shl nsw i32 %x, 24
+ %cmp = icmp ugt i32 %shl, -50331648
+ ret i1 %cmp
+}
``````````
</details>
https://github.com/llvm/llvm-project/pull/94899
More information about the llvm-commits
mailing list