[llvm] 09a05f5 - [InstCombine] Drop poison generating flags on Or in simplifyAssocCastAssoc.

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 7 13:35:44 PST 2023


Author: Craig Topper
Date: 2023-12-07T13:35:28-08:00
New Revision: 09a05f5dcb7946494828b00d767198341ff78604

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

LOG: [InstCombine] Drop poison generating flags on Or in simplifyAssocCastAssoc.

Fixes #74739.

Added: 
    

Modified: 
    llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
    llvm/test/Transforms/InstCombine/or.ll

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
index 30e058000d2bc..f072f5cec3094 100644
--- a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
@@ -356,6 +356,7 @@ static bool simplifyAssocCastAssoc(BinaryOperator *BinOp1,
 
   IC.replaceOperand(*Cast, 0, BinOp2->getOperand(0));
   IC.replaceOperand(*BinOp1, 1, FoldedC);
+  BinOp1->dropPoisonGeneratingFlags();
   Cast->dropPoisonGeneratingFlags();
   return true;
 }

diff  --git a/llvm/test/Transforms/InstCombine/or.ll b/llvm/test/Transforms/InstCombine/or.ll
index 3dd6bb440575f..8c8aab2bcba6a 100644
--- a/llvm/test/Transforms/InstCombine/or.ll
+++ b/llvm/test/Transforms/InstCombine/or.ll
@@ -1609,11 +1609,11 @@ define i8 @drop_disjoint(i8 %x) {
   ret i8 %b
 }
 
-; FIXME: We should drop disjoint here.
+; Make sure we drop disjoint when combining the Ors.
 define i32 @assoc_cast_assoc_disjoint(i16 %x) {
 ; CHECK-LABEL: @assoc_cast_assoc_disjoint(
 ; CHECK-NEXT:    [[B:%.*]] = zext i16 [[X:%.*]] to i32
-; CHECK-NEXT:    [[C:%.*]] = or disjoint i32 [[B]], 65537
+; CHECK-NEXT:    [[C:%.*]] = or i32 [[B]], 65537
 ; CHECK-NEXT:    ret i32 [[C]]
 ;
   %a = or i16 %x, 1


        


More information about the llvm-commits mailing list