Skip to content

Commit 1b1c817

Browse files
committed
[InstCombine] Drop poison flags in simplifyAssocCastAssoc()
The nneg flag on zext may no longer hold after the reassociation.
1 parent 0bd0d72 commit 1b1c817

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

llvm/lib/Transforms/InstCombine/InstructionCombining.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,7 @@ static bool simplifyAssocCastAssoc(BinaryOperator *BinOp1,
356356

357357
IC.replaceOperand(*Cast, 0, BinOp2->getOperand(0));
358358
IC.replaceOperand(*BinOp1, 1, FoldedC);
359+
Cast->dropPoisonGeneratingFlags();
359360
return true;
360361
}
361362

llvm/test/Transforms/InstCombine/assoc-cast-assoc.ll

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,9 @@ define <2 x i32> @AndZextAndVec(<2 x i8> %a) {
7777

7878
define i24 @zext_nneg(i16 %a) {
7979
; CHECK-LABEL: @zext_nneg(
80-
; CHECK-NEXT: [[RESIZE:%.*]] = zext nneg i16 [[A:%.*]] to i24
81-
; CHECK-NEXT: ret i24 [[RESIZE]]
80+
; CHECK-NEXT: [[TMP1:%.*]] = and i16 [[A:%.*]], 32767
81+
; CHECK-NEXT: [[AND2:%.*]] = zext nneg i16 [[TMP1]] to i24
82+
; CHECK-NEXT: ret i24 [[AND2]]
8283
;
8384
%and1 = and i16 %a, 32767
8485
%resize = zext nneg i16 %and1 to i24

0 commit comments

Comments
 (0)