[llvm] cb6240d - [BDCE] Also drop poison-generating metadata

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 31 03:23:05 PST 2024


Author: Nikita Popov
Date: 2024-01-31T12:22:58+01:00
New Revision: cb6240d247b3419dea29eb99261171ea239b1c5c

URL: https://github.com/llvm/llvm-project/commit/cb6240d247b3419dea29eb99261171ea239b1c5c
DIFF: https://github.com/llvm/llvm-project/commit/cb6240d247b3419dea29eb99261171ea239b1c5c.diff

LOG: [BDCE] Also drop poison-generating metadata

The comment was incorrect: !range also applies to calls, and we
do need to drop it in some cases.

Added: 
    

Modified: 
    llvm/lib/Transforms/Scalar/BDCE.cpp
    llvm/test/Transforms/BDCE/invalidate-assumptions.ll

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/Scalar/BDCE.cpp b/llvm/lib/Transforms/Scalar/BDCE.cpp
index 6e6fa6c8ffc4d..4aa87a84f115a 100644
--- a/llvm/lib/Transforms/Scalar/BDCE.cpp
+++ b/llvm/lib/Transforms/Scalar/BDCE.cpp
@@ -75,11 +75,10 @@ static void clearAssumptionsOfUsers(Instruction *I, DemandedBits &DB) {
     Instruction *J = WorkList.pop_back_val();
 
     // NSW, NUW, and exact are based on operands that might have changed.
-    J->dropPoisonGeneratingFlags();
+    J->dropPoisonGeneratingFlagsAndMetadata();
 
-    // We do not have to worry about llvm.assume or range metadata:
-    // 1. llvm.assume demands its operand, so trivializing can't change it.
-    // 2. range metadata only applies to memory accesses which demand all bits.
+    // We do not have to worry about llvm.assume, because it demands its
+    // operand, so trivializing can't change it.
 
     // If all bits of a user are demanded, then we know that nothing below
     // that in the def-use chain needs to be changed.

diff  --git a/llvm/test/Transforms/BDCE/invalidate-assumptions.ll b/llvm/test/Transforms/BDCE/invalidate-assumptions.ll
index 85d21c33d3d91..7280c2757bdc9 100644
--- a/llvm/test/Transforms/BDCE/invalidate-assumptions.ll
+++ b/llvm/test/Transforms/BDCE/invalidate-assumptions.ll
@@ -124,7 +124,7 @@ define i32 @disjoint_indirect(i64 %x) {
 define i32 @range(i32 %x) {
 ; CHECK-LABEL: define i32 @range(
 ; CHECK-SAME: i32 [[X:%.*]]) {
-; CHECK-NEXT:    [[UMIN:%.*]] = call i32 @llvm.umin.i32(i32 [[X]], i32 100), !range [[RNG0:![0-9]+]]
+; CHECK-NEXT:    [[UMIN:%.*]] = call i32 @llvm.umin.i32(i32 [[X]], i32 100)
 ; CHECK-NEXT:    [[AND:%.*]] = and i32 [[UMIN]], -2
 ; CHECK-NEXT:    ret i32 [[AND]]
 ;
@@ -133,6 +133,3 @@ define i32 @range(i32 %x) {
   %and = and i32 %umin, -2
   ret i32 %and
 }
-;.
-; CHECK: [[RNG0]] = !{i32 1, i32 101}
-;.


        


More information about the llvm-commits mailing list