diff options
Diffstat (limited to 'llvm/test/Transforms/InstCombine')
-rw-r--r-- | llvm/test/Transforms/InstCombine/cast-set-preserve-signed-dbg-val.ll | 4 | ||||
-rw-r--r-- | llvm/test/Transforms/InstCombine/icmp-trunc.ll | 30 | ||||
-rw-r--r-- | llvm/test/Transforms/InstCombine/ptr-int-cast.ll | 11 |
3 files changed, 42 insertions, 3 deletions
diff --git a/llvm/test/Transforms/InstCombine/cast-set-preserve-signed-dbg-val.ll b/llvm/test/Transforms/InstCombine/cast-set-preserve-signed-dbg-val.ll index 7cc4446..ad45d1e 100644 --- a/llvm/test/Transforms/InstCombine/cast-set-preserve-signed-dbg-val.ll +++ b/llvm/test/Transforms/InstCombine/cast-set-preserve-signed-dbg-val.ll @@ -11,10 +11,8 @@ define i16 @test5(i16 %A) !dbg !34 { call void @llvm.dbg.value(metadata i32 %C, metadata !37, metadata !DIExpression()), !dbg !41 ; Preserve the dbg.value for the DCE'd 32-bit 'and'. - ; - ; The high 16 bits of the original 'and' require sign-extending the new 16-bit and: ; CHECK-NEXT: #dbg_value(i16 [[and]], [[C:![0-9]+]], - ; CHECK-SAME: !DIExpression(DW_OP_LLVM_convert, 16, DW_ATE_signed, DW_OP_LLVM_convert, 32, DW_ATE_signed, DW_OP_stack_value) + ; CHECK-SAME: !DIExpression(DW_OP_LLVM_convert, 16, DW_ATE_unsigned, DW_OP_LLVM_convert, 32, DW_ATE_unsigned, DW_OP_stack_value) %D = trunc i32 %C to i16, !dbg !42 call void @llvm.dbg.value(metadata i16 %D, metadata !38, metadata !DIExpression()), !dbg !42 diff --git a/llvm/test/Transforms/InstCombine/icmp-trunc.ll b/llvm/test/Transforms/InstCombine/icmp-trunc.ll index b85deab..ad76ef7 100644 --- a/llvm/test/Transforms/InstCombine/icmp-trunc.ll +++ b/llvm/test/Transforms/InstCombine/icmp-trunc.ll @@ -3,6 +3,7 @@ ; RUN: opt < %s -passes=instcombine -S -data-layout="n8" | FileCheck %s --check-prefixes=CHECK,DL8 declare void @use(i8) +declare void @use2(i4) define i1 @ult_2(i32 %x) { ; CHECK-LABEL: @ult_2( @@ -785,3 +786,32 @@ define <2 x i1> @uge_nsw_non_splat(<2 x i32> %x) { ret <2 x i1> %r } +define i1 @trunc_icmp(i8 %a0) { +; CHECK-LABEL: @trunc_icmp( +; CHECK-NEXT: [[TZ:%.*]] = tail call range(i8 0, 9) i8 @llvm.cttz.i8(i8 [[A0:%.*]], i1 false) +; CHECK-NEXT: [[TR:%.*]] = trunc nuw i8 [[TZ]] to i4 +; CHECK-NEXT: [[C:%.*]] = icmp eq i8 [[A0]], 0 +; CHECK-NEXT: call void @use2(i4 [[TR]]) +; CHECK-NEXT: ret i1 [[C]] +; + %tz = tail call range(i8 0, 9) i8 @llvm.cttz.i8(i8 %a0, i1 false) + %tr = trunc i8 %tz to i4 + %c = icmp eq i4 %tr, 8 + call void @use2(i4 %tr) + ret i1 %c +} + +define i1 @do_not_mask_trunc_eq_i32_i8(i32 %x) { +; DL64-LABEL: @do_not_mask_trunc_eq_i32_i8( +; DL64-NEXT: [[R:%.*]] = icmp eq i32 [[X:%.*]], 42 +; DL64-NEXT: ret i1 [[R]] +; +; DL8-LABEL: @do_not_mask_trunc_eq_i32_i8( +; DL8-NEXT: [[T:%.*]] = trunc nuw i32 [[X:%.*]] to i8 +; DL8-NEXT: [[R:%.*]] = icmp eq i8 [[T]], 42 +; DL8-NEXT: ret i1 [[R]] +; + %t = trunc nuw i32 %x to i8 + %r = icmp eq i8 %t, 42 + ret i1 %r +} diff --git a/llvm/test/Transforms/InstCombine/ptr-int-cast.ll b/llvm/test/Transforms/InstCombine/ptr-int-cast.ll index 69b8f69..82ecbd4 100644 --- a/llvm/test/Transforms/InstCombine/ptr-int-cast.ll +++ b/llvm/test/Transforms/InstCombine/ptr-int-cast.ll @@ -86,3 +86,14 @@ define <4 x ptr> @test7(<4 x i128> %arg) nounwind { %p1 = inttoptr <4 x i128> %arg to <4 x ptr> ret <4 x ptr> %p1 } + +define i64 @ptrtoint_gep_sub(ptr %ptr, i64 %end.addr) { +; CHECK-LABEL: @ptrtoint_gep_sub( +; CHECK-NEXT: ret i64 [[END_ADDR:%.*]] +; + %ptr.addr = ptrtoint ptr %ptr to i64 + %size = sub i64 %end.addr, %ptr.addr + %end = getelementptr i8, ptr %ptr, i64 %size + %end.addr2 = ptrtoint ptr %end to i64 + ret i64 %end.addr2 +} |