Skip to content

Commit

Permalink
[InstCombine] Pre-commit tests (NFC)
Browse files Browse the repository at this point in the history
  • Loading branch information
AZero13 committed Nov 14, 2024
1 parent 1b44c3a commit 5bde6a4
Showing 1 changed file with 164 additions and 0 deletions.
164 changes: 164 additions & 0 deletions llvm/test/Transforms/InstCombine/ashr-lshr.ll
Original file line number Diff line number Diff line change
Expand Up @@ -1075,6 +1075,170 @@ entry:
call void @use(i32 %and)
%shr = ashr i32 %and, 31
ret i32 %shr
define i32 @ashr_shift_mul(i32 noundef %x) {
; CHECK-LABEL: @ashr_shift_mul(
; CHECK-NEXT: [[A:%.*]] = ashr exact i32 [[X:%.*]], 3
; CHECK-NEXT: [[RES:%.*]] = mul i32 [[A]], 9
; CHECK-NEXT: ret i32 [[RES]]
;
%a = ashr exact i32 %x, 3
%res = mul i32 %a, 9
ret i32 %res
}

define i32 @ashr_shift_mul_nuw(i32 noundef %x) {
; CHECK-LABEL: @ashr_shift_mul_nuw(
; CHECK-NEXT: [[A:%.*]] = ashr exact i32 [[X:%.*]], 3
; CHECK-NEXT: [[RES:%.*]] = mul nuw i32 [[A]], 9
; CHECK-NEXT: ret i32 [[RES]]
;
%a = ashr exact i32 %x, 3
%res = mul nuw i32 %a, 9
ret i32 %res
}

define i32 @ashr_shift_mul_nsw(i32 noundef %x) {
; CHECK-LABEL: @ashr_shift_mul_nsw(
; CHECK-NEXT: [[A:%.*]] = ashr exact i32 [[X:%.*]], 3
; CHECK-NEXT: [[RES:%.*]] = mul nsw i32 [[A]], 9
; CHECK-NEXT: ret i32 [[RES]]
;
%a = ashr exact i32 %x, 3
%res = mul nsw i32 %a, 9
ret i32 %res
}

define i32 @lshr_shift_mul_nuw(i32 noundef %x) {
; CHECK-LABEL: @lshr_shift_mul_nuw(
; CHECK-NEXT: [[A:%.*]] = lshr exact i32 [[X:%.*]], 3
; CHECK-NEXT: [[RES:%.*]] = mul nuw i32 [[A]], 9
; CHECK-NEXT: ret i32 [[RES]]
;
%a = lshr exact i32 %x, 3
%res = mul nuw i32 %a, 9
ret i32 %res
}

define i32 @lshr_shift_mul(i32 noundef %x) {
; CHECK-LABEL: @lshr_shift_mul(
; CHECK-NEXT: [[A:%.*]] = lshr exact i32 [[X:%.*]], 3
; CHECK-NEXT: [[RES:%.*]] = mul i32 [[A]], 9
; CHECK-NEXT: ret i32 [[RES]]
;
%a = lshr exact i32 %x, 3
%res = mul i32 %a, 9
ret i32 %res
}

define i32 @lshr_shift_mul_nsw(i32 noundef %x) {
; CHECK-LABEL: @lshr_shift_mul_nsw(
; CHECK-NEXT: [[A:%.*]] = lshr exact i32 [[X:%.*]], 3
; CHECK-NEXT: [[RES:%.*]] = mul nuw nsw i32 [[A]], 9
; CHECK-NEXT: ret i32 [[RES]]
;
%a = lshr exact i32 %x, 3
%res = mul nsw i32 %a, 9
ret i32 %res
}

; Negative test

define i32 @lshr_no_exact(i32 %x) {
; CHECK-LABEL: @lshr_no_exact(
; CHECK-NEXT: [[A:%.*]] = lshr i32 [[X:%.*]], 3
; CHECK-NEXT: [[RES:%.*]] = mul nuw nsw i32 [[A]], 9
; CHECK-NEXT: ret i32 [[RES]]
;
%a = lshr i32 %x, 3
%res = mul nsw i32 %a, 9
ret i32 %res
}

; Negative test

define i32 @ashr_no_exact(i32 %x) {
; CHECK-LABEL: @ashr_no_exact(
; CHECK-NEXT: [[A:%.*]] = ashr i32 [[X:%.*]], 3
; CHECK-NEXT: [[RES:%.*]] = mul nsw i32 [[A]], 9
; CHECK-NEXT: ret i32 [[RES]]
;
%a = ashr i32 %x, 3
%res = mul nsw i32 %a, 9
ret i32 %res
}

define i32 @lshr_no_undef(i32 %x) {
; CHECK-LABEL: @lshr_no_undef(
; CHECK-NEXT: [[A:%.*]] = lshr exact i32 [[X:%.*]], 3
; CHECK-NEXT: [[RES:%.*]] = mul nuw nsw i32 [[A]], 9
; CHECK-NEXT: ret i32 [[RES]]
;
%a = lshr exact i32 %x, 3
%res = mul nsw i32 %a, 9
ret i32 %res
}

define i32 @ashr_no_undef(i32 %x) {
; CHECK-LABEL: @ashr_no_undef(
; CHECK-NEXT: [[A:%.*]] = ashr exact i32 [[X:%.*]], 3
; CHECK-NEXT: [[RES:%.*]] = mul nsw i32 [[A]], 9
; CHECK-NEXT: ret i32 [[RES]]
;
%a = ashr exact i32 %x, 3
%res = mul nsw i32 %a, 9
ret i32 %res
}

define i32 @lshr_multiuse(i32 noundef %x) {
; CHECK-LABEL: @lshr_multiuse(
; CHECK-NEXT: [[A:%.*]] = lshr exact i32 [[X:%.*]], 3
; CHECK-NEXT: call void @use(i32 [[A]])
; CHECK-NEXT: [[RES:%.*]] = mul nuw nsw i32 [[A]], 9
; CHECK-NEXT: ret i32 [[RES]]
;
%a = lshr exact i32 %x, 3
call void @use(i32 %a)
%res = mul nsw i32 %a, 9
ret i32 %res
}

define i32 @lshr_multiuse_no_flags(i32 noundef %x) {
; CHECK-LABEL: @lshr_multiuse_no_flags(
; CHECK-NEXT: [[A:%.*]] = lshr exact i32 [[X:%.*]], 3
; CHECK-NEXT: call void @use(i32 [[A]])
; CHECK-NEXT: [[RES:%.*]] = mul i32 [[A]], 9
; CHECK-NEXT: ret i32 [[RES]]
;
%a = lshr exact i32 %x, 3
call void @use(i32 %a)
%res = mul i32 %a, 9
ret i32 %res
}

define i32 @ashr_multiuse_no_flags(i32 noundef %x) {
; CHECK-LABEL: @ashr_multiuse_no_flags(
; CHECK-NEXT: [[A:%.*]] = ashr exact i32 [[X:%.*]], 3
; CHECK-NEXT: call void @use(i32 [[A]])
; CHECK-NEXT: [[RES:%.*]] = mul i32 [[A]], 9
; CHECK-NEXT: ret i32 [[RES]]
;
%a = ashr exact i32 %x, 3
call void @use(i32 %a)
%res = mul i32 %a, 9
ret i32 %res
}

define i32 @ashr_multiuse(i32 noundef %x) {
; CHECK-LABEL: @ashr_multiuse(
; CHECK-NEXT: [[A:%.*]] = ashr exact i32 [[X:%.*]], 3
; CHECK-NEXT: call void @use(i32 [[A]])
; CHECK-NEXT: [[RES:%.*]] = mul nsw i32 [[A]], 9
; CHECK-NEXT: ret i32 [[RES]]
;
%a = ashr exact i32 %x, 3
call void @use(i32 %a)
%res = mul nsw i32 %a, 9
ret i32 %res
}

declare void @use(i32)

0 comments on commit 5bde6a4

Please sign in to comment.