Skip to content
Merged
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
10 changes: 0 additions & 10 deletions llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2638,16 +2638,6 @@ Instruction *InstCombinerImpl::foldICmpShrConstant(ICmpInst &Cmp,
if (Shr->isExact())
return new ICmpInst(Pred, X, ConstantInt::get(ShrTy, C << ShAmtVal));

if (C.isZero()) {
// == 0 is u< 1.
if (Pred == CmpInst::ICMP_EQ)
return new ICmpInst(CmpInst::ICMP_ULT, X,
ConstantInt::get(ShrTy, (C + 1).shl(ShAmtVal)));
else
return new ICmpInst(CmpInst::ICMP_UGT, X,
ConstantInt::get(ShrTy, (C + 1).shl(ShAmtVal) - 1));
}

if (Shr->hasOneUse()) {
// Canonicalize the shift into an 'and':
// icmp eq/ne (shr X, ShAmt), C --> icmp eq/ne (and X, HiMask), (C << ShAmt)
Expand Down
4 changes: 2 additions & 2 deletions llvm/test/Analysis/ValueTracking/known-power-of-two-urem.ll
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ define i64 @known_power_of_two_urem_loop_lshr(i64 %size, i64 %a) {
; CHECK-NEXT: [[UREM:%.*]] = and i64 [[SIZE:%.*]], [[TMP0]]
; CHECK-NEXT: [[ADD]] = add nuw i64 [[SUM]], [[UREM]]
; CHECK-NEXT: [[I]] = lshr i64 [[PHI]], 1
; CHECK-NEXT: [[ICMP_NOT:%.*]] = icmp ult i64 [[PHI]], 2
; CHECK-NEXT: [[ICMP_NOT:%.*]] = icmp eq i64 [[I]], 0
; CHECK-NEXT: br i1 [[ICMP_NOT]], label [[FOR_END:%.*]], label [[FOR_BODY]]
; CHECK: for.end:
; CHECK-NEXT: ret i64 [[SUM]]
Expand Down Expand Up @@ -328,7 +328,7 @@ define i64 @known_power_of_two_urem_loop_ashr_negative_2(i64 %size, i64 %a) {
; CHECK-NEXT: [[UREM:%.*]] = urem i64 [[SIZE:%.*]], [[PHI]]
; CHECK-NEXT: [[ADD]] = add nsw i64 [[SUM]], [[UREM]]
; CHECK-NEXT: [[I]] = ashr i64 [[PHI]], 2
; CHECK-NEXT: [[ICMP_NOT:%.*]] = icmp ult i64 [[PHI]], 4
; CHECK-NEXT: [[ICMP_NOT:%.*]] = icmp eq i64 [[I]], 0
; CHECK-NEXT: br i1 [[ICMP_NOT]], label [[FOR_END:%.*]], label [[FOR_BODY]]
; CHECK: for.end:
; CHECK-NEXT: ret i64 [[SUM]]
Expand Down
50 changes: 45 additions & 5 deletions llvm/test/Transforms/InstCombine/icmp-shr.ll
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@ define i1 @ashr_ugt_0(i4 %x) {
define i1 @ashr_ugt_0_multiuse(i4 %x, ptr %p) {
; CHECK-LABEL: @ashr_ugt_0_multiuse(
; CHECK-NEXT: [[S:%.*]] = ashr i4 [[X:%.*]], 1
; CHECK-NEXT: [[R:%.*]] = icmp ugt i4 [[X]], 1
; CHECK-NEXT: [[R:%.*]] = icmp ne i4 [[S]], 0
; CHECK-NEXT: store i4 [[S]], ptr [[P:%.*]], align 1
; CHECK-NEXT: ret i1 [[R]]
;
Expand Down Expand Up @@ -934,7 +934,7 @@ define i1 @lshr_eq_0_multiuse(i8 %x) {
; CHECK-LABEL: @lshr_eq_0_multiuse(
; CHECK-NEXT: [[S:%.*]] = lshr i8 [[X:%.*]], 2
; CHECK-NEXT: call void @use(i8 [[S]])
; CHECK-NEXT: [[C:%.*]] = icmp ult i8 [[X]], 4
; CHECK-NEXT: [[C:%.*]] = icmp eq i8 [[S]], 0
; CHECK-NEXT: ret i1 [[C]]
;
%s = lshr i8 %x, 2
Expand All @@ -947,7 +947,7 @@ define i1 @lshr_ne_0_multiuse(i8 %x) {
; CHECK-LABEL: @lshr_ne_0_multiuse(
; CHECK-NEXT: [[S:%.*]] = lshr i8 [[X:%.*]], 2
; CHECK-NEXT: call void @use(i8 [[S]])
; CHECK-NEXT: [[C:%.*]] = icmp ugt i8 [[X]], 3
; CHECK-NEXT: [[C:%.*]] = icmp ne i8 [[S]], 0
; CHECK-NEXT: ret i1 [[C]]
;
%s = lshr i8 %x, 2
Expand All @@ -960,7 +960,7 @@ define i1 @ashr_eq_0_multiuse(i8 %x) {
; CHECK-LABEL: @ashr_eq_0_multiuse(
; CHECK-NEXT: [[S:%.*]] = ashr i8 [[X:%.*]], 2
; CHECK-NEXT: call void @use(i8 [[S]])
; CHECK-NEXT: [[C:%.*]] = icmp ult i8 [[X]], 4
; CHECK-NEXT: [[C:%.*]] = icmp eq i8 [[S]], 0
; CHECK-NEXT: ret i1 [[C]]
;
%s = ashr i8 %x, 2
Expand All @@ -973,7 +973,7 @@ define i1 @ashr_ne_0_multiuse(i8 %x) {
; CHECK-LABEL: @ashr_ne_0_multiuse(
; CHECK-NEXT: [[S:%.*]] = ashr i8 [[X:%.*]], 2
; CHECK-NEXT: call void @use(i8 [[S]])
; CHECK-NEXT: [[C:%.*]] = icmp ugt i8 [[X]], 3
; CHECK-NEXT: [[C:%.*]] = icmp ne i8 [[S]], 0
; CHECK-NEXT: ret i1 [[C]]
;
%s = ashr i8 %x, 2
Expand All @@ -982,6 +982,46 @@ define i1 @ashr_ne_0_multiuse(i8 %x) {
ret i1 %c
}

define i1 @lshr_eq_0(i8 %x) {
; CHECK-LABEL: @lshr_eq_0(
; CHECK-NEXT: [[C:%.*]] = icmp ult i8 [[X:%.*]], 4
; CHECK-NEXT: ret i1 [[C]]
;
%s = lshr i8 %x, 2
%c = icmp eq i8 %s, 0
ret i1 %c
}

define i1 @lshr_ne_0(i8 %x) {
; CHECK-LABEL: @lshr_ne_0(
; CHECK-NEXT: [[C:%.*]] = icmp ugt i8 [[X:%.*]], 3
; CHECK-NEXT: ret i1 [[C]]
;
%s = lshr i8 %x, 2
%c = icmp ne i8 %s, 0
ret i1 %c
}

define i1 @ashr_eq_0(i8 %x) {
; CHECK-LABEL: @ashr_eq_0(
; CHECK-NEXT: [[C:%.*]] = icmp ult i8 [[X:%.*]], 4
; CHECK-NEXT: ret i1 [[C]]
;
%s = ashr i8 %x, 2
%c = icmp eq i8 %s, 0
ret i1 %c
}

define i1 @ashr_ne_0(i8 %x) {
; CHECK-LABEL: @ashr_ne_0(
; CHECK-NEXT: [[C:%.*]] = icmp ugt i8 [[X:%.*]], 3
; CHECK-NEXT: ret i1 [[C]]
;
%s = ashr i8 %x, 2
%c = icmp ne i8 %s, 0
ret i1 %c
}

define i1 @lshr_exact_eq_0_multiuse(i8 %x) {
; CHECK-LABEL: @lshr_exact_eq_0_multiuse(
; CHECK-NEXT: [[S:%.*]] = lshr exact i8 [[X:%.*]], 2
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/Transforms/LoopVectorize/induction.ll
Original file line number Diff line number Diff line change
Expand Up @@ -914,7 +914,7 @@ define float @scalarize_induction_variable_02(ptr %a, ptr %b, i64 %n) {
; IND-NEXT: [[TMP0:%.*]] = add nsw i64 [[SMAX]], -1
; IND-NEXT: [[TMP1:%.*]] = lshr i64 [[TMP0]], 3
; IND-NEXT: [[TMP2:%.*]] = add nuw nsw i64 [[TMP1]], 1
; IND-NEXT: [[MIN_ITERS_CHECK:%.*]] = icmp slt i64 [[N]], 9
; IND-NEXT: [[MIN_ITERS_CHECK:%.*]] = icmp eq i64 [[TMP1]], 0
; IND-NEXT: br i1 [[MIN_ITERS_CHECK]], label [[SCALAR_PH:%.*]], label [[VECTOR_PH:%.*]]
; IND: vector.ph:
; IND-NEXT: [[N_VEC:%.*]] = and i64 [[TMP2]], 4611686018427387902
Expand Down
4 changes: 2 additions & 2 deletions llvm/test/Transforms/LoopVectorize/loop-scalars.ll
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ define void @scalar_store(ptr %a, ptr %b, i64 %n) {
; CHECK-NEXT: [[TMP0:%.*]] = add nsw i64 [[SMAX]], -1
; CHECK-NEXT: [[TMP1:%.*]] = lshr i64 [[TMP0]], 1
; CHECK-NEXT: [[TMP2:%.*]] = add nuw nsw i64 [[TMP1]], 1
; CHECK-NEXT: [[MIN_ITERS_CHECK:%.*]] = icmp slt i64 [[N]], 3
; CHECK-NEXT: [[MIN_ITERS_CHECK:%.*]] = icmp eq i64 [[TMP1]], 0
; CHECK-NEXT: br i1 [[MIN_ITERS_CHECK]], label [[SCALAR_PH:%.*]], label [[VECTOR_PH:%.*]]
; CHECK: vector.ph:
; CHECK-NEXT: [[N_VEC:%.*]] = and i64 [[TMP2]], 9223372036854775806
Expand Down Expand Up @@ -125,7 +125,7 @@ define void @expansion(ptr %a, ptr %b, i64 %n) {
; CHECK-NEXT: [[TMP0:%.*]] = add nsw i64 [[SMAX]], -1
; CHECK-NEXT: [[TMP1:%.*]] = lshr i64 [[TMP0]], 1
; CHECK-NEXT: [[TMP2:%.*]] = add nuw nsw i64 [[TMP1]], 1
; CHECK-NEXT: [[MIN_ITERS_CHECK:%.*]] = icmp slt i64 [[N]], 3
; CHECK-NEXT: [[MIN_ITERS_CHECK:%.*]] = icmp eq i64 [[TMP1]], 0
; CHECK-NEXT: br i1 [[MIN_ITERS_CHECK]], label [[SCALAR_PH:%.*]], label [[VECTOR_PH:%.*]]
; CHECK: vector.ph:
; CHECK-NEXT: [[N_VEC:%.*]] = and i64 [[TMP2]], 9223372036854775806
Expand Down
14 changes: 6 additions & 8 deletions llvm/test/Transforms/PhaseOrdering/ARM/arm_mean_q7.ll
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,11 @@ target triple = "thumbv6m-none-none-eabi"
define void @arm_mean_q7(ptr noundef %pSrc, i32 noundef %blockSize, ptr noundef %pResult) #0 {
; CHECK-LABEL: @arm_mean_q7(
; CHECK-NEXT: entry:
; CHECK-NEXT: [[CMP_NOT10:%.*]] = icmp ult i32 [[BLOCKSIZE:%.*]], 16
; CHECK-NEXT: br i1 [[CMP_NOT10]], label [[WHILE_END:%.*]], label [[WHILE_BODY_PREHEADER:%.*]]
; CHECK: while.body.preheader:
; CHECK-NEXT: [[SHR:%.*]] = lshr i32 [[BLOCKSIZE]], 4
; CHECK-NEXT: br label [[WHILE_BODY:%.*]]
; CHECK-NEXT: [[SHR:%.*]] = lshr i32 [[BLOCKSIZE:%.*]], 4
; CHECK-NEXT: [[CMP_NOT10:%.*]] = icmp eq i32 [[SHR]], 0
; CHECK-NEXT: br i1 [[CMP_NOT10]], label [[WHILE_END:%.*]], label [[WHILE_BODY:%.*]]
; CHECK: while.body:
; CHECK-NEXT: [[SUM_013:%.*]] = phi i32 [ [[TMP2:%.*]], [[WHILE_BODY]] ], [ 0, [[WHILE_BODY_PREHEADER]] ]
; CHECK-NEXT: [[SUM_013:%.*]] = phi i32 [ [[TMP2:%.*]], [[WHILE_BODY]] ], [ 0, [[WHILE_BODY_PREHEADER:%.*]] ]
; CHECK-NEXT: [[PSRC_ADDR_012:%.*]] = phi ptr [ [[ADD_PTR:%.*]], [[WHILE_BODY]] ], [ [[PSRC:%.*]], [[WHILE_BODY_PREHEADER]] ]
; CHECK-NEXT: [[BLKCNT_011:%.*]] = phi i32 [ [[DEC:%.*]], [[WHILE_BODY]] ], [ [[SHR]], [[WHILE_BODY_PREHEADER]] ]
; CHECK-NEXT: [[TMP0:%.*]] = load <16 x i8>, ptr [[PSRC_ADDR_012]], align 1
Expand All @@ -30,8 +28,8 @@ define void @arm_mean_q7(ptr noundef %pSrc, i32 noundef %blockSize, ptr noundef
; CHECK-NEXT: [[SCEVGEP:%.*]] = getelementptr i8, ptr [[PSRC]], i32 [[TMP3]]
; CHECK-NEXT: br label [[WHILE_END]]
; CHECK: while.end:
; CHECK-NEXT: [[PSRC_ADDR_0_LCSSA:%.*]] = phi ptr [ [[PSRC]], [[ENTRY:%.*]] ], [ [[SCEVGEP]], [[WHILE_END_LOOPEXIT]] ]
; CHECK-NEXT: [[SUM_0_LCSSA:%.*]] = phi i32 [ 0, [[ENTRY]] ], [ [[TMP2]], [[WHILE_END_LOOPEXIT]] ]
; CHECK-NEXT: [[PSRC_ADDR_0_LCSSA:%.*]] = phi ptr [ [[PSRC]], [[WHILE_BODY_PREHEADER]] ], [ [[SCEVGEP]], [[WHILE_END_LOOPEXIT]] ]
; CHECK-NEXT: [[SUM_0_LCSSA:%.*]] = phi i32 [ 0, [[WHILE_BODY_PREHEADER]] ], [ [[TMP2]], [[WHILE_END_LOOPEXIT]] ]
; CHECK-NEXT: [[AND:%.*]] = and i32 [[BLOCKSIZE]], 15
; CHECK-NEXT: [[CMP2_NOT15:%.*]] = icmp eq i32 [[AND]], 0
; CHECK-NEXT: br i1 [[CMP2_NOT15]], label [[WHILE_END5:%.*]], label [[VECTOR_BODY:%.*]]
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/Transforms/PhaseOrdering/X86/ctlz-loop.ll
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ define i32 @ctlz_loop_with_abs(i32 %n) {
; CHECK-NEXT: [[I_02:%.*]] = phi i32 [ [[INC:%.*]], [[WHILE_BODY]] ], [ 0, [[WHILE_BODY_PREHEADER]] ]
; CHECK-NEXT: [[TMP1]] = lshr i32 [[N_ADDR_03]], 1
; CHECK-NEXT: [[INC]] = add nuw nsw i32 [[I_02]], 1
; CHECK-NEXT: [[TOBOOL_NOT:%.*]] = icmp samesign ult i32 [[N_ADDR_03]], 2
; CHECK-NEXT: [[TOBOOL_NOT:%.*]] = icmp eq i32 [[TMP1]], 0
; CHECK-NEXT: br i1 [[TOBOOL_NOT]], label [[WHILE_END]], label [[WHILE_BODY]]
; CHECK: while.end:
; CHECK-NEXT: [[I_0_LCSSA:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[INC]], [[WHILE_BODY]] ]
Expand Down
Loading