forked from OSchip/llvm-project
[InstCombine] auto-generate better checks; NFC
llvm-svn: 298377
This commit is contained in:
parent
79379cae15
commit
00ece756c3
|
@ -1,6 +1,14 @@
|
||||||
; RUN: opt < %s -instcombine -S | grep "add nuw nsw i32"
|
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
|
||||||
|
; RUN: opt < %s -instcombine -S | FileCheck %s
|
||||||
|
|
||||||
define double @x(i32 %a, i32 %b) nounwind {
|
define double @x(i32 %a, i32 %b) {
|
||||||
|
; CHECK-LABEL: @x(
|
||||||
|
; CHECK-NEXT: [[M:%.*]] = lshr i32 [[A:%.*]], 24
|
||||||
|
; CHECK-NEXT: [[N:%.*]] = and i32 [[M]], [[B:%.*]]
|
||||||
|
; CHECK-NEXT: [[ADDCONV:%.*]] = add nuw nsw i32 [[N]], 1
|
||||||
|
; CHECK-NEXT: [[P:%.*]] = sitofp i32 [[ADDCONV]] to double
|
||||||
|
; CHECK-NEXT: ret double [[P]]
|
||||||
|
;
|
||||||
%m = lshr i32 %a, 24
|
%m = lshr i32 %a, 24
|
||||||
%n = and i32 %m, %b
|
%n = and i32 %m, %b
|
||||||
%o = sitofp i32 %n to double
|
%o = sitofp i32 %n to double
|
||||||
|
|
|
@ -1,41 +1,47 @@
|
||||||
|
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
|
||||||
; RUN: opt < %s -instcombine -S | FileCheck %s
|
; RUN: opt < %s -instcombine -S | FileCheck %s
|
||||||
|
|
||||||
; CHECK-LABEL: test1
|
|
||||||
; CHECK: ret i1 true
|
|
||||||
define i1 @test1(i8 %A) {
|
define i1 @test1(i8 %A) {
|
||||||
|
; CHECK-LABEL: @test1(
|
||||||
|
; CHECK-NEXT: ret i1 true
|
||||||
|
;
|
||||||
%B = sitofp i8 %A to double
|
%B = sitofp i8 %A to double
|
||||||
%C = fcmp ult double %B, 128.0
|
%C = fcmp ult double %B, 128.0
|
||||||
ret i1 %C
|
ret i1 %C
|
||||||
}
|
}
|
||||||
|
|
||||||
; CHECK-LABEL: test2
|
|
||||||
; CHECK: ret i1 true
|
|
||||||
define i1 @test2(i8 %A) {
|
define i1 @test2(i8 %A) {
|
||||||
|
; CHECK-LABEL: @test2(
|
||||||
|
; CHECK-NEXT: ret i1 true
|
||||||
|
;
|
||||||
%B = sitofp i8 %A to double
|
%B = sitofp i8 %A to double
|
||||||
%C = fcmp ugt double %B, -128.1
|
%C = fcmp ugt double %B, -128.1
|
||||||
ret i1 %C
|
ret i1 %C
|
||||||
}
|
}
|
||||||
|
|
||||||
; CHECK-LABEL: test3
|
|
||||||
; CHECK: ret i1 true
|
|
||||||
define i1 @test3(i8 %A) {
|
define i1 @test3(i8 %A) {
|
||||||
|
; CHECK-LABEL: @test3(
|
||||||
|
; CHECK-NEXT: ret i1 true
|
||||||
|
;
|
||||||
%B = sitofp i8 %A to double
|
%B = sitofp i8 %A to double
|
||||||
%C = fcmp ule double %B, 127.0
|
%C = fcmp ule double %B, 127.0
|
||||||
ret i1 %C
|
ret i1 %C
|
||||||
}
|
}
|
||||||
|
|
||||||
; CHECK-LABEL: test4
|
|
||||||
; CHECK: icmp ne i8 %A, 127
|
|
||||||
; CHECK-NEXT: ret i1
|
|
||||||
define i1 @test4(i8 %A) {
|
define i1 @test4(i8 %A) {
|
||||||
|
; CHECK-LABEL: @test4(
|
||||||
|
; CHECK-NEXT: [[C:%.*]] = icmp ne i8 [[A:%.*]], 127
|
||||||
|
; CHECK-NEXT: ret i1 [[C]]
|
||||||
|
;
|
||||||
%B = sitofp i8 %A to double
|
%B = sitofp i8 %A to double
|
||||||
%C = fcmp ult double %B, 127.0
|
%C = fcmp ult double %B, 127.0
|
||||||
ret i1 %C
|
ret i1 %C
|
||||||
}
|
}
|
||||||
|
|
||||||
; CHECK-LABEL: test5
|
|
||||||
; CHECK: ret i32
|
|
||||||
define i32 @test5(i32 %A) {
|
define i32 @test5(i32 %A) {
|
||||||
|
; CHECK-LABEL: @test5(
|
||||||
|
; CHECK-NEXT: ret i32 [[A:%.*]]
|
||||||
|
;
|
||||||
%B = sitofp i32 %A to double
|
%B = sitofp i32 %A to double
|
||||||
%C = fptosi double %B to i32
|
%C = fptosi double %B to i32
|
||||||
%D = uitofp i32 %C to double
|
%D = uitofp i32 %C to double
|
||||||
|
@ -43,10 +49,11 @@ define i32 @test5(i32 %A) {
|
||||||
ret i32 %E
|
ret i32 %E
|
||||||
}
|
}
|
||||||
|
|
||||||
; CHECK-LABEL: test6
|
|
||||||
; CHECK: and i32 %A, 39
|
|
||||||
; CHECK-NEXT: ret i32
|
|
||||||
define i32 @test6(i32 %A) {
|
define i32 @test6(i32 %A) {
|
||||||
|
; CHECK-LABEL: @test6(
|
||||||
|
; CHECK-NEXT: [[ADDCONV:%.*]] = and i32 [[A:%.*]], 39
|
||||||
|
; CHECK-NEXT: ret i32 [[ADDCONV]]
|
||||||
|
;
|
||||||
%B = and i32 %A, 7
|
%B = and i32 %A, 7
|
||||||
%C = and i32 %A, 32
|
%C = and i32 %A, 32
|
||||||
%D = sitofp i32 %B to double
|
%D = sitofp i32 %B to double
|
||||||
|
@ -56,35 +63,39 @@ define i32 @test6(i32 %A) {
|
||||||
ret i32 %G
|
ret i32 %G
|
||||||
}
|
}
|
||||||
|
|
||||||
; CHECK-LABEL: test7
|
define i32 @test7(i32 %A) {
|
||||||
; CHECK: ret i32
|
; CHECK-LABEL: @test7(
|
||||||
define i32 @test7(i32 %A) nounwind {
|
; CHECK-NEXT: ret i32 [[A:%.*]]
|
||||||
|
;
|
||||||
%B = sitofp i32 %A to double
|
%B = sitofp i32 %A to double
|
||||||
%C = fptoui double %B to i32
|
%C = fptoui double %B to i32
|
||||||
ret i32 %C
|
ret i32 %C
|
||||||
}
|
}
|
||||||
|
|
||||||
; CHECK-LABEL: test8
|
define i32 @test8(i32 %A) {
|
||||||
; CHECK: ret i32
|
; CHECK-LABEL: @test8(
|
||||||
define i32 @test8(i32 %A) nounwind {
|
; CHECK-NEXT: ret i32 [[A:%.*]]
|
||||||
|
;
|
||||||
%B = uitofp i32 %A to double
|
%B = uitofp i32 %A to double
|
||||||
%C = fptosi double %B to i32
|
%C = fptosi double %B to i32
|
||||||
ret i32 %C
|
ret i32 %C
|
||||||
}
|
}
|
||||||
|
|
||||||
; CHECK-LABEL: test9
|
define i32 @test9(i8 %A) {
|
||||||
; CHECK: zext i8
|
; CHECK-LABEL: @test9(
|
||||||
; CHECK-NEXT: ret i32
|
; CHECK-NEXT: [[C:%.*]] = zext i8 [[A:%.*]] to i32
|
||||||
define i32 @test9(i8 %A) nounwind {
|
; CHECK-NEXT: ret i32 [[C]]
|
||||||
|
;
|
||||||
%B = sitofp i8 %A to float
|
%B = sitofp i8 %A to float
|
||||||
%C = fptoui float %B to i32
|
%C = fptoui float %B to i32
|
||||||
ret i32 %C
|
ret i32 %C
|
||||||
}
|
}
|
||||||
|
|
||||||
; CHECK-LABEL: test10
|
define i32 @test10(i8 %A) {
|
||||||
; CHECK: sext i8
|
; CHECK-LABEL: @test10(
|
||||||
; CHECK-NEXT: ret i32
|
; CHECK-NEXT: [[C:%.*]] = sext i8 [[A:%.*]] to i32
|
||||||
define i32 @test10(i8 %A) nounwind {
|
; CHECK-NEXT: ret i32 [[C]]
|
||||||
|
;
|
||||||
%B = sitofp i8 %A to float
|
%B = sitofp i8 %A to float
|
||||||
%C = fptosi float %B to i32
|
%C = fptosi float %B to i32
|
||||||
ret i32 %C
|
ret i32 %C
|
||||||
|
@ -92,10 +103,12 @@ define i32 @test10(i8 %A) nounwind {
|
||||||
|
|
||||||
; If the input value is outside of the range of the output cast, it's
|
; If the input value is outside of the range of the output cast, it's
|
||||||
; undefined behavior, so we can assume it fits.
|
; undefined behavior, so we can assume it fits.
|
||||||
; CHECK-LABEL: test11
|
|
||||||
; CHECK: trunc
|
define i8 @test11(i32 %A) {
|
||||||
; CHECK-NEXT: ret i8
|
; CHECK-LABEL: @test11(
|
||||||
define i8 @test11(i32 %A) nounwind {
|
; CHECK-NEXT: [[C:%.*]] = trunc i32 [[A:%.*]] to i8
|
||||||
|
; CHECK-NEXT: ret i8 [[C]]
|
||||||
|
;
|
||||||
%B = sitofp i32 %A to float
|
%B = sitofp i32 %A to float
|
||||||
%C = fptosi float %B to i8
|
%C = fptosi float %B to i8
|
||||||
ret i8 %C
|
ret i8 %C
|
||||||
|
@ -103,80 +116,101 @@ define i8 @test11(i32 %A) nounwind {
|
||||||
|
|
||||||
; If the input value is negative, it'll be outside the range of the
|
; If the input value is negative, it'll be outside the range of the
|
||||||
; output cast, and thus undefined behavior.
|
; output cast, and thus undefined behavior.
|
||||||
; CHECK-LABEL: test12
|
|
||||||
; CHECK: zext i8
|
define i32 @test12(i8 %A) {
|
||||||
; CHECK-NEXT: ret i32
|
; CHECK-LABEL: @test12(
|
||||||
define i32 @test12(i8 %A) nounwind {
|
; CHECK-NEXT: [[C:%.*]] = zext i8 [[A:%.*]] to i32
|
||||||
|
; CHECK-NEXT: ret i32 [[C]]
|
||||||
|
;
|
||||||
%B = sitofp i8 %A to float
|
%B = sitofp i8 %A to float
|
||||||
%C = fptoui float %B to i32
|
%C = fptoui float %B to i32
|
||||||
ret i32 %C
|
ret i32 %C
|
||||||
}
|
}
|
||||||
|
|
||||||
; This can't fold because the 25-bit input doesn't fit in the mantissa.
|
; This can't fold because the 25-bit input doesn't fit in the mantissa.
|
||||||
; CHECK-LABEL: test13
|
|
||||||
; CHECK: uitofp
|
define i32 @test13(i25 %A) {
|
||||||
; CHECK-NEXT: fptoui
|
; CHECK-LABEL: @test13(
|
||||||
define i32 @test13(i25 %A) nounwind {
|
; CHECK-NEXT: [[B:%.*]] = uitofp i25 [[A:%.*]] to float
|
||||||
|
; CHECK-NEXT: [[C:%.*]] = fptoui float [[B]] to i32
|
||||||
|
; CHECK-NEXT: ret i32 [[C]]
|
||||||
|
;
|
||||||
%B = uitofp i25 %A to float
|
%B = uitofp i25 %A to float
|
||||||
%C = fptoui float %B to i32
|
%C = fptoui float %B to i32
|
||||||
ret i32 %C
|
ret i32 %C
|
||||||
}
|
}
|
||||||
|
|
||||||
; But this one can.
|
; But this one can.
|
||||||
; CHECK-LABEL: test14
|
|
||||||
; CHECK: zext i24
|
define i32 @test14(i24 %A) {
|
||||||
; CHECK-NEXT: ret i32
|
; CHECK-LABEL: @test14(
|
||||||
define i32 @test14(i24 %A) nounwind {
|
; CHECK-NEXT: [[C:%.*]] = zext i24 [[A:%.*]] to i32
|
||||||
|
; CHECK-NEXT: ret i32 [[C]]
|
||||||
|
;
|
||||||
%B = uitofp i24 %A to float
|
%B = uitofp i24 %A to float
|
||||||
%C = fptoui float %B to i32
|
%C = fptoui float %B to i32
|
||||||
ret i32 %C
|
ret i32 %C
|
||||||
}
|
}
|
||||||
|
|
||||||
; And this one can too.
|
; And this one can too.
|
||||||
; CHECK-LABEL: test15
|
|
||||||
; CHECK: trunc i32
|
define i24 @test15(i32 %A) {
|
||||||
; CHECK-NEXT: ret i24
|
; CHECK-LABEL: @test15(
|
||||||
define i24 @test15(i32 %A) nounwind {
|
; CHECK-NEXT: [[C:%.*]] = trunc i32 [[A:%.*]] to i24
|
||||||
|
; CHECK-NEXT: ret i24 [[C]]
|
||||||
|
;
|
||||||
%B = uitofp i32 %A to float
|
%B = uitofp i32 %A to float
|
||||||
%C = fptoui float %B to i24
|
%C = fptoui float %B to i24
|
||||||
ret i24 %C
|
ret i24 %C
|
||||||
}
|
}
|
||||||
|
|
||||||
; This can fold because the 25-bit input is signed and we disard the sign bit.
|
; This can fold because the 25-bit input is signed and we discard the sign bit.
|
||||||
; CHECK-LABEL: test16
|
|
||||||
; CHECK: zext
|
define i32 @test16(i25 %A) {
|
||||||
define i32 @test16(i25 %A) nounwind {
|
; CHECK-LABEL: @test16(
|
||||||
|
; CHECK-NEXT: [[C:%.*]] = zext i25 [[A:%.*]] to i32
|
||||||
|
; CHECK-NEXT: ret i32 [[C]]
|
||||||
|
;
|
||||||
%B = sitofp i25 %A to float
|
%B = sitofp i25 %A to float
|
||||||
%C = fptoui float %B to i32
|
%C = fptoui float %B to i32
|
||||||
ret i32 %C
|
ret i32 %C
|
||||||
}
|
}
|
||||||
|
|
||||||
; This can't fold because the 26-bit input won't fit the mantissa
|
; This can't fold because the 26-bit input won't fit the mantissa
|
||||||
; even after disarding the signed bit.
|
; even after discarding the signed bit.
|
||||||
; CHECK-LABEL: test17
|
|
||||||
; CHECK: sitofp
|
define i32 @test17(i26 %A) {
|
||||||
; CHECK-NEXT: fptoui
|
; CHECK-LABEL: @test17(
|
||||||
define i32 @test17(i26 %A) nounwind {
|
; CHECK-NEXT: [[B:%.*]] = sitofp i26 [[A:%.*]] to float
|
||||||
|
; CHECK-NEXT: [[C:%.*]] = fptoui float [[B]] to i32
|
||||||
|
; CHECK-NEXT: ret i32 [[C]]
|
||||||
|
;
|
||||||
%B = sitofp i26 %A to float
|
%B = sitofp i26 %A to float
|
||||||
%C = fptoui float %B to i32
|
%C = fptoui float %B to i32
|
||||||
ret i32 %C
|
ret i32 %C
|
||||||
}
|
}
|
||||||
|
|
||||||
; This can fold because the 54-bit output is signed and we disard the sign bit.
|
; This can fold because the 54-bit output is signed and we discard the sign bit.
|
||||||
; CHECK-LABEL: test18
|
|
||||||
; CHECK: trunc
|
define i54 @test18(i64 %A) {
|
||||||
define i54 @test18(i64 %A) nounwind {
|
; CHECK-LABEL: @test18(
|
||||||
|
; CHECK-NEXT: [[C:%.*]] = trunc i64 [[A:%.*]] to i54
|
||||||
|
; CHECK-NEXT: ret i54 [[C]]
|
||||||
|
;
|
||||||
%B = sitofp i64 %A to double
|
%B = sitofp i64 %A to double
|
||||||
%C = fptosi double %B to i54
|
%C = fptosi double %B to i54
|
||||||
ret i54 %C
|
ret i54 %C
|
||||||
}
|
}
|
||||||
|
|
||||||
; This can't fold because the 55-bit output won't fit the mantissa
|
; This can't fold because the 55-bit output won't fit the mantissa
|
||||||
; even after disarding the sign bit.
|
; even after discarding the sign bit.
|
||||||
; CHECK-LABEL: test19
|
|
||||||
; CHECK: sitofp
|
define i55 @test19(i64 %A) {
|
||||||
; CHECK-NEXT: fptosi
|
; CHECK-LABEL: @test19(
|
||||||
define i55 @test19(i64 %A) nounwind {
|
; CHECK-NEXT: [[B:%.*]] = sitofp i64 [[A:%.*]] to double
|
||||||
|
; CHECK-NEXT: [[C:%.*]] = fptosi double [[B]] to i55
|
||||||
|
; CHECK-NEXT: ret i55 [[C]]
|
||||||
|
;
|
||||||
%B = sitofp i64 %A to double
|
%B = sitofp i64 %A to double
|
||||||
%C = fptosi double %B to i55
|
%C = fptosi double %B to i55
|
||||||
ret i55 %C
|
ret i55 %C
|
||||||
|
|
Loading…
Reference in New Issue