Skip to content

Commit

Permalink
[InstCombine] Drop poison flags in simplifyAssocCastAssoc()
Browse files Browse the repository at this point in the history
The nneg flag on zext may no longer hold after the reassociation.
  • Loading branch information
nikic committed Nov 9, 2023
1 parent 0bd0d72 commit 1b1c817
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
5 changes: 3 additions & 2 deletions llvm/test/Transforms/InstCombine/assoc-cast-assoc.ll
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 1b1c817

Please sign in to comment.