brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.9 KiB · a599129 Raw
87 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 52; RUN: opt -S -passes='require<profile-summary>,function(codegenprepare)' -mtriple=x86_64-unknown-unknown < %s | FileCheck %s3 4; Make sure the nsw flag is dropped when the load ext is combined.5define i32 @simplify_load_ext_drop_trunc_nsw(ptr %p) {6; CHECK-LABEL: define i32 @simplify_load_ext_drop_trunc_nsw(7; CHECK-SAME: ptr [[P:%.*]]) {8; CHECK-NEXT:  [[ENTRY:.*:]]9; CHECK-NEXT:    [[X:%.*]] = load i32, ptr [[P]], align 410; CHECK-NEXT:    [[TMP0:%.*]] = and i32 [[X]], 25511; CHECK-NEXT:    [[TRUNC:%.*]] = trunc i32 [[TMP0]] to i812; CHECK-NEXT:    [[EXT1:%.*]] = sext i8 [[TRUNC]] to i1613; CHECK-NEXT:    call void @use(i32 [[TMP0]])14; CHECK-NEXT:    [[EXT2:%.*]] = zext i16 [[EXT1]] to i3215; CHECK-NEXT:    ret i32 [[EXT2]]16;17entry:18  %x = load i32, ptr %p, align 419  %trunc = trunc nsw i32 %x to i820  %ext1 = sext i8 %trunc to i1621  %conv2 = and i32 %x, 25522  call void @use(i32 %conv2)23  %ext2 = zext i16 %ext1 to i3224  ret i32 %ext225}26 27; Make sure the nsw flag is dropped when the load ext is combined.28define i32 @simplify_load_ext_drop_shl_nsw(ptr %p) {29; CHECK-LABEL: define i32 @simplify_load_ext_drop_shl_nsw(30; CHECK-SAME: ptr [[P:%.*]]) {31; CHECK-NEXT:  [[ENTRY:.*:]]32; CHECK-NEXT:    [[X:%.*]] = load i32, ptr [[P]], align 433; CHECK-NEXT:    [[TMP0:%.*]] = and i32 [[X]], 25534; CHECK-NEXT:    [[SHL:%.*]] = shl i32 [[TMP0]], 2435; CHECK-NEXT:    call void @use(i32 [[TMP0]])36; CHECK-NEXT:    ret i32 [[SHL]]37;38entry:39  %x = load i32, ptr %p, align 440  %shl = shl nsw i32 %x, 2441  %conv2 = and i32 %x, 25542  call void @use(i32 %conv2)43  ret i32 %shl44}45 46define i32 @simplify_load_ext_keep_trunc_nuw(ptr %p) {47; CHECK-LABEL: define i32 @simplify_load_ext_keep_trunc_nuw(48; CHECK-SAME: ptr [[P:%.*]]) {49; CHECK-NEXT:  [[ENTRY:.*:]]50; CHECK-NEXT:    [[X:%.*]] = load i32, ptr [[P]], align 451; CHECK-NEXT:    [[TMP0:%.*]] = and i32 [[X]], 25552; CHECK-NEXT:    [[TRUNC:%.*]] = trunc nuw i32 [[TMP0]] to i853; CHECK-NEXT:    [[EXT1:%.*]] = sext i8 [[TRUNC]] to i1654; CHECK-NEXT:    call void @use(i32 [[TMP0]])55; CHECK-NEXT:    [[EXT2:%.*]] = zext i16 [[EXT1]] to i3256; CHECK-NEXT:    ret i32 [[EXT2]]57;58entry:59  %x = load i32, ptr %p, align 460  %trunc = trunc nuw i32 %x to i861  %ext1 = sext i8 %trunc to i1662  %conv2 = and i32 %x, 25563  call void @use(i32 %conv2)64  %ext2 = zext i16 %ext1 to i3265  ret i32 %ext266}67 68define i32 @simplify_load_ext_drop_shl_nuw(ptr %p) {69; CHECK-LABEL: define i32 @simplify_load_ext_drop_shl_nuw(70; CHECK-SAME: ptr [[P:%.*]]) {71; CHECK-NEXT:  [[ENTRY:.*:]]72; CHECK-NEXT:    [[X:%.*]] = load i32, ptr [[P]], align 473; CHECK-NEXT:    [[TMP0:%.*]] = and i32 [[X]], 25574; CHECK-NEXT:    [[SHL:%.*]] = shl nuw i32 [[TMP0]], 2475; CHECK-NEXT:    call void @use(i32 [[TMP0]])76; CHECK-NEXT:    ret i32 [[SHL]]77;78entry:79  %x = load i32, ptr %p, align 480  %shl = shl nuw i32 %x, 2481  %conv2 = and i32 %x, 25582  call void @use(i32 %conv2)83  ret i32 %shl84}85 86declare void @use(i32)87