[llvm] [InstCombine] Drop poison generating flags on Or in simplifyAssocCastAssoc. (PR #74763)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 7 13:07:10 PST 2023
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-transforms
Author: Craig Topper (topperc)
<details>
<summary>Changes</summary>
Fixes #<!-- -->74739.
---
Full diff: https://github.com/llvm/llvm-project/pull/74763.diff
2 Files Affected:
- (modified) llvm/lib/Transforms/InstCombine/InstructionCombining.cpp (+1)
- (modified) llvm/test/Transforms/InstCombine/or.ll (+13)
``````````diff
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 fd415682b67f3..8c8aab2bcba6a 100644
--- a/llvm/test/Transforms/InstCombine/or.ll
+++ b/llvm/test/Transforms/InstCombine/or.ll
@@ -1608,3 +1608,16 @@ define i8 @drop_disjoint(i8 %x) {
%b = or disjoint i8 %a, 1
ret i8 %b
}
+
+; 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 i32 [[B]], 65537
+; CHECK-NEXT: ret i32 [[C]]
+;
+ %a = or i16 %x, 1
+ %b = zext i16 %a to i32
+ %c = or disjoint i32 %b, 65536
+ ret i32 %c
+}
``````````
</details>
https://github.com/llvm/llvm-project/pull/74763
More information about the llvm-commits
mailing list