Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2099,9 +2099,9 @@ static Instruction *simplifyIRemMulShl(BinaryOperator &I,
return false;
};

bool Op0PreserveNSW = true, Op1PreserveNSW = true;
bool Op0PreserveNSW = true, Unused;
if (MatchShiftOrMulXC(Op0, X, Y, Op0PreserveNSW) &&
MatchShiftOrMulXC(Op1, X, Z, Op1PreserveNSW)) {
MatchShiftOrMulXC(Op1, X, Z, Unused)) {
// pass
} else if (MatchShiftCX(Op0, Y, X) && MatchShiftCX(Op1, Z, X)) {
ShiftByX = true;
Expand Down Expand Up @@ -2137,7 +2137,7 @@ static Instruction *simplifyIRemMulShl(BinaryOperator &I,
};

OverflowingBinaryOperator *BO1 = cast<OverflowingBinaryOperator>(Op1);
bool BO1HasNSW = Op1PreserveNSW && BO1->hasNoSignedWrap();
bool BO1HasNSW = BO1->hasNoSignedWrap();
bool BO1HasNUW = BO1->hasNoUnsignedWrap();
bool BO1NoWrap = IsSRem ? BO1HasNSW : BO1HasNUW;
// (rem (mul X, Y), (mul nuw/nsw X, Z))
Expand Down
4 changes: 1 addition & 3 deletions llvm/test/Transforms/InstCombine/rem-mul-shl.ll
Original file line number Diff line number Diff line change
Expand Up @@ -388,9 +388,7 @@ define i8 @srem_XY_XZ_with_CY_gt_CZ_drop_nsw(i8 noundef %X) {
define i8 @srem_XY_XZ_with_CY_gt_CZ_drop_nsw_commuted(i8 noundef %X) {
; CHECK-LABEL: @srem_XY_XZ_with_CY_gt_CZ_drop_nsw_commuted(
; CHECK-NEXT: [[BO0:%.*]] = mul nsw i8 [[X:%.*]], 127
; CHECK-NEXT: [[BO1:%.*]] = shl nsw i8 [[X]], 7
; CHECK-NEXT: [[R:%.*]] = srem i8 [[BO0]], [[BO1]]
; CHECK-NEXT: ret i8 [[R]]
; CHECK-NEXT: ret i8 [[BO0]]
;
%BO0 = mul nsw i8 %X, 127
%BO1 = shl nsw i8 %X, 7
Expand Down
Loading