[llvm] 1b1c817 - [InstCombine] Drop poison flags in simplifyAssocCastAssoc()
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 9 02:58:12 PST 2023
Author: Nikita Popov
Date: 2023-11-09T11:58:02+01:00
New Revision: 1b1c81772fe50a1cb2b2adf8d8cf442c0b73602f
URL: https://github.com/llvm/llvm-project/commit/1b1c81772fe50a1cb2b2adf8d8cf442c0b73602f
DIFF: https://github.com/llvm/llvm-project/commit/1b1c81772fe50a1cb2b2adf8d8cf442c0b73602f.diff
LOG: [InstCombine] Drop poison flags in simplifyAssocCastAssoc()
The nneg flag on zext may no longer hold after the reassociation.
Added:
Modified:
llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
llvm/test/Transforms/InstCombine/assoc-cast-assoc.ll
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
index 1474cc9c3fdb54e..2e0b185769041cc 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);
+ Cast->dropPoisonGeneratingFlags();
return true;
}
diff --git a/llvm/test/Transforms/InstCombine/assoc-cast-assoc.ll b/llvm/test/Transforms/InstCombine/assoc-cast-assoc.ll
index 61039f7f1a5d9e6..2d15318d0b0a4b6 100644
--- a/llvm/test/Transforms/InstCombine/assoc-cast-assoc.ll
+++ b/llvm/test/Transforms/InstCombine/assoc-cast-assoc.ll
@@ -77,8 +77,9 @@ define <2 x i32> @AndZextAndVec(<2 x i8> %a) {
define i24 @zext_nneg(i16 %a) {
; CHECK-LABEL: @zext_nneg(
-; CHECK-NEXT: [[RESIZE:%.*]] = zext nneg i16 [[A:%.*]] to i24
-; CHECK-NEXT: ret i24 [[RESIZE]]
+; CHECK-NEXT: [[TMP1:%.*]] = and i16 [[A:%.*]], 32767
+; CHECK-NEXT: [[AND2:%.*]] = zext nneg i16 [[TMP1]] to i24
+; CHECK-NEXT: ret i24 [[AND2]]
;
%and1 = and i16 %a, 32767
%resize = zext nneg i16 %and1 to i24
More information about the llvm-commits
mailing list