[llvm] 403bb33 - [InstCombine] add tests for fpext+select+fptrunc; NFC
Sanjay Patel via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 5 07:50:29 PST 2019
Author: Sanjay Patel
Date: 2019-12-05T10:49:29-05:00
New Revision: 403bb33a2e6a966b9dae203cf7845d6d0538e76b
URL: https://github.com/llvm/llvm-project/commit/403bb33a2e6a966b9dae203cf7845d6d0538e76b
DIFF: https://github.com/llvm/llvm-project/commit/403bb33a2e6a966b9dae203cf7845d6d0538e76b.diff
LOG: [InstCombine] add tests for fpext+select+fptrunc; NFC
Added:
Modified:
llvm/test/Transforms/InstCombine/fptrunc.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/InstCombine/fptrunc.ll b/llvm/test/Transforms/InstCombine/fptrunc.ll
index 3790210fbe52..e1b2b1b9c531 100644
--- a/llvm/test/Transforms/InstCombine/fptrunc.ll
+++ b/llvm/test/Transforms/InstCombine/fptrunc.ll
@@ -48,3 +48,87 @@ define <2 x half> @fmul_constant_op1(<2 x float> %x) {
%r = fptrunc <2 x float> %bo to <2 x half>
ret <2 x half> %r
}
+
+define float @fptrunc_select_true_val(float %x, double %y, i1 %cond) {
+; CHECK-LABEL: @fptrunc_select_true_val(
+; CHECK-NEXT: [[E:%.*]] = fpext float [[X:%.*]] to double
+; CHECK-NEXT: [[SEL:%.*]] = select fast i1 [[COND:%.*]], double [[Y:%.*]], double [[E]]
+; CHECK-NEXT: [[R:%.*]] = fptrunc double [[SEL]] to float
+; CHECK-NEXT: ret float [[R]]
+;
+ %e = fpext float %x to double
+ %sel = select fast i1 %cond, double %y, double %e
+ %r = fptrunc double %sel to float
+ ret float %r
+}
+
+define <2 x float> @fptrunc_select_false_val(<2 x float> %x, <2 x double> %y, <2 x i1> %cond) {
+; CHECK-LABEL: @fptrunc_select_false_val(
+; CHECK-NEXT: [[E:%.*]] = fpext <2 x float> [[X:%.*]] to <2 x double>
+; CHECK-NEXT: [[SEL:%.*]] = select nnan <2 x i1> [[COND:%.*]], <2 x double> [[E]], <2 x double> [[Y:%.*]]
+; CHECK-NEXT: [[R:%.*]] = fptrunc <2 x double> [[SEL]] to <2 x float>
+; CHECK-NEXT: ret <2 x float> [[R]]
+;
+ %e = fpext <2 x float> %x to <2 x double>
+ %sel = select nnan <2 x i1> %cond, <2 x double> %e, <2 x double> %y
+ %r = fptrunc <2 x double> %sel to <2 x float>
+ ret <2 x float> %r
+}
+
+declare void @use(float)
+
+define half @fptrunc_select_true_val_extra_use(half %x, float %y, i1 %cond) {
+; CHECK-LABEL: @fptrunc_select_true_val_extra_use(
+; CHECK-NEXT: [[E:%.*]] = fpext half [[X:%.*]] to float
+; CHECK-NEXT: call void @use(float [[E]])
+; CHECK-NEXT: [[SEL:%.*]] = select ninf i1 [[COND:%.*]], float [[Y:%.*]], float [[E]]
+; CHECK-NEXT: [[R:%.*]] = fptrunc float [[SEL]] to half
+; CHECK-NEXT: ret half [[R]]
+;
+ %e = fpext half %x to float
+ call void @use(float %e)
+ %sel = select ninf i1 %cond, float %y, float %e
+ %r = fptrunc float %sel to half
+ ret half %r
+}
+
+define half @fptrunc_select_true_val_extra_use_2(half %x, float %y, i1 %cond) {
+; CHECK-LABEL: @fptrunc_select_true_val_extra_use_2(
+; CHECK-NEXT: [[E:%.*]] = fpext half [[X:%.*]] to float
+; CHECK-NEXT: [[SEL:%.*]] = select ninf i1 [[COND:%.*]], float [[Y:%.*]], float [[E]]
+; CHECK-NEXT: call void @use(float [[SEL]])
+; CHECK-NEXT: [[R:%.*]] = fptrunc float [[SEL]] to half
+; CHECK-NEXT: ret half [[R]]
+;
+ %e = fpext half %x to float
+ %sel = select ninf i1 %cond, float %y, float %e
+ call void @use(float %sel)
+ %r = fptrunc float %sel to half
+ ret half %r
+}
+
+define float @fptrunc_select_true_val_type_mismatch(half %x, double %y, i1 %cond) {
+; CHECK-LABEL: @fptrunc_select_true_val_type_mismatch(
+; CHECK-NEXT: [[E:%.*]] = fpext half [[X:%.*]] to double
+; CHECK-NEXT: [[SEL:%.*]] = select i1 [[COND:%.*]], double [[Y:%.*]], double [[E]]
+; CHECK-NEXT: [[R:%.*]] = fptrunc double [[SEL]] to float
+; CHECK-NEXT: ret float [[R]]
+;
+ %e = fpext half %x to double
+ %sel = select i1 %cond, double %y, double %e
+ %r = fptrunc double %sel to float
+ ret float %r
+}
+
+define float @fptrunc_select_true_val_type_mismatch_fast(half %x, double %y, i1 %cond) {
+; CHECK-LABEL: @fptrunc_select_true_val_type_mismatch_fast(
+; CHECK-NEXT: [[E:%.*]] = fpext half [[X:%.*]] to double
+; CHECK-NEXT: [[SEL:%.*]] = select fast i1 [[COND:%.*]], double [[Y:%.*]], double [[E]]
+; CHECK-NEXT: [[R:%.*]] = fptrunc double [[SEL]] to float
+; CHECK-NEXT: ret float [[R]]
+;
+ %e = fpext half %x to double
+ %sel = select fast i1 %cond, double %y, double %e
+ %r = fptrunc double %sel to float
+ ret float %r
+}
More information about the llvm-commits
mailing list