1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
|
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
; RUN: opt -S -passes='require<profile-summary>,function(codegenprepare)' -mtriple=x86_64-unknown-unknown < %s | FileCheck %s
; Make sure the nsw flag is dropped when the load ext is combined.
define i32 @simplify_load_ext_drop_trunc_nsw(ptr %p) {
; CHECK-LABEL: define i32 @simplify_load_ext_drop_trunc_nsw(
; CHECK-SAME: ptr [[P:%.*]]) {
; CHECK-NEXT: [[ENTRY:.*:]]
; CHECK-NEXT: [[X:%.*]] = load i32, ptr [[P]], align 4
; CHECK-NEXT: [[TMP0:%.*]] = and i32 [[X]], 255
; CHECK-NEXT: [[TRUNC:%.*]] = trunc i32 [[TMP0]] to i8
; CHECK-NEXT: [[EXT1:%.*]] = sext i8 [[TRUNC]] to i16
; CHECK-NEXT: call void @use(i32 [[TMP0]])
; CHECK-NEXT: [[EXT2:%.*]] = zext i16 [[EXT1]] to i32
; CHECK-NEXT: ret i32 [[EXT2]]
;
entry:
%x = load i32, ptr %p, align 4
%trunc = trunc nsw i32 %x to i8
%ext1 = sext i8 %trunc to i16
%conv2 = and i32 %x, 255
call void @use(i32 %conv2)
%ext2 = zext i16 %ext1 to i32
ret i32 %ext2
}
; Make sure the nsw flag is dropped when the load ext is combined.
define i32 @simplify_load_ext_drop_shl_nsw(ptr %p) {
; CHECK-LABEL: define i32 @simplify_load_ext_drop_shl_nsw(
; CHECK-SAME: ptr [[P:%.*]]) {
; CHECK-NEXT: [[ENTRY:.*:]]
; CHECK-NEXT: [[X:%.*]] = load i32, ptr [[P]], align 4
; CHECK-NEXT: [[TMP0:%.*]] = and i32 [[X]], 255
; CHECK-NEXT: [[SHL:%.*]] = shl i32 [[TMP0]], 24
; CHECK-NEXT: call void @use(i32 [[TMP0]])
; CHECK-NEXT: ret i32 [[SHL]]
;
entry:
%x = load i32, ptr %p, align 4
%shl = shl nsw i32 %x, 24
%conv2 = and i32 %x, 255
call void @use(i32 %conv2)
ret i32 %shl
}
define i32 @simplify_load_ext_keep_trunc_nuw(ptr %p) {
; CHECK-LABEL: define i32 @simplify_load_ext_keep_trunc_nuw(
; CHECK-SAME: ptr [[P:%.*]]) {
; CHECK-NEXT: [[ENTRY:.*:]]
; CHECK-NEXT: [[X:%.*]] = load i32, ptr [[P]], align 4
; CHECK-NEXT: [[TMP0:%.*]] = and i32 [[X]], 255
; CHECK-NEXT: [[TRUNC:%.*]] = trunc nuw i32 [[TMP0]] to i8
; CHECK-NEXT: [[EXT1:%.*]] = sext i8 [[TRUNC]] to i16
; CHECK-NEXT: call void @use(i32 [[TMP0]])
; CHECK-NEXT: [[EXT2:%.*]] = zext i16 [[EXT1]] to i32
; CHECK-NEXT: ret i32 [[EXT2]]
;
entry:
%x = load i32, ptr %p, align 4
%trunc = trunc nuw i32 %x to i8
%ext1 = sext i8 %trunc to i16
%conv2 = and i32 %x, 255
call void @use(i32 %conv2)
%ext2 = zext i16 %ext1 to i32
ret i32 %ext2
}
define i32 @simplify_load_ext_drop_shl_nuw(ptr %p) {
; CHECK-LABEL: define i32 @simplify_load_ext_drop_shl_nuw(
; CHECK-SAME: ptr [[P:%.*]]) {
; CHECK-NEXT: [[ENTRY:.*:]]
; CHECK-NEXT: [[X:%.*]] = load i32, ptr [[P]], align 4
; CHECK-NEXT: [[TMP0:%.*]] = and i32 [[X]], 255
; CHECK-NEXT: [[SHL:%.*]] = shl nuw i32 [[TMP0]], 24
; CHECK-NEXT: call void @use(i32 [[TMP0]])
; CHECK-NEXT: ret i32 [[SHL]]
;
entry:
%x = load i32, ptr %p, align 4
%shl = shl nuw i32 %x, 24
%conv2 = and i32 %x, 255
call void @use(i32 %conv2)
ret i32 %shl
}
declare void @use(i32)
|