[llvm] 3f53a58 - [ValueTracking] Fix incorrect computeConstantRange() arguments
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 31 07:57:58 PDT 2023
Author: Nikita Popov
Date: 2023-03-31T16:56:56+02:00
New Revision: 3f53a58597bc84418f8b83934ef2f5c5d615626b
URL: https://github.com/llvm/llvm-project/commit/3f53a58597bc84418f8b83934ef2f5c5d615626b
DIFF: https://github.com/llvm/llvm-project/commit/3f53a58597bc84418f8b83934ef2f5c5d615626b.diff
LOG: [ValueTracking] Fix incorrect computeConstantRange() arguments
The second argument is ForSigned, not UseInstrInfo.
Added:
Modified:
llvm/lib/Analysis/ValueTracking.cpp
llvm/test/Transforms/InstCombine/saturating-add-sub.ll
Removed:
################################################################################
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp
index 628a12491458b..3fa776337771f 100644
--- a/llvm/lib/Analysis/ValueTracking.cpp
+++ b/llvm/lib/Analysis/ValueTracking.cpp
@@ -5444,7 +5444,7 @@ static ConstantRange computeConstantRangeIncludingKnownBits(
KnownBits Known = computeKnownBits(
V, DL, Depth, AC, CxtI, DT, ORE, UseInstrInfo);
ConstantRange CR1 = ConstantRange::fromKnownBits(Known, ForSigned);
- ConstantRange CR2 = computeConstantRange(V, UseInstrInfo);
+ ConstantRange CR2 = computeConstantRange(V, ForSigned, UseInstrInfo);
ConstantRange::PreferredRangeType RangeType =
ForSigned ? ConstantRange::Signed : ConstantRange::Unsigned;
return CR1.intersectWith(CR2, RangeType);
diff --git a/llvm/test/Transforms/InstCombine/saturating-add-sub.ll b/llvm/test/Transforms/InstCombine/saturating-add-sub.ll
index dae370fbdb227..4e77f53158b5d 100644
--- a/llvm/test/Transforms/InstCombine/saturating-add-sub.ll
+++ b/llvm/test/Transforms/InstCombine/saturating-add-sub.ll
@@ -967,8 +967,7 @@ define i8 @test_scalar_usub_add_nuw_no_ov(i8 %a) {
define i8 @test_scalar_usub_add_nuw_nsw_no_ov(i8 %a) {
; CHECK-LABEL: @test_scalar_usub_add_nuw_nsw_no_ov(
-; CHECK-NEXT: [[B:%.*]] = add nuw nsw i8 [[A:%.*]], 10
-; CHECK-NEXT: [[R:%.*]] = call i8 @llvm.usub.sat.i8(i8 [[B]], i8 9)
+; CHECK-NEXT: [[R:%.*]] = add i8 [[A:%.*]], 1
; CHECK-NEXT: ret i8 [[R]]
;
%b = add nuw nsw i8 %a, 10
More information about the llvm-commits
mailing list