Skip to content

Commit f81f47e

Browse files
committed
[InstCombine] Add fptrunc of max test (NFC)
To guard against regression from #117182.
1 parent c537c75 commit f81f47e

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

llvm/test/Transforms/InstCombine/fptrunc.ll

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,19 @@ define half @fptrunc_select_true_val_extra_use(half %x, float %y, i1 %cond) {
9090
ret half %r
9191
}
9292

93+
define half @fptrunc_max(half %arg) {
94+
; CHECK-LABEL: @fptrunc_max(
95+
; CHECK-NEXT: [[CMP:%.*]] = fcmp olt half [[ARG:%.*]], 0xH0000
96+
; CHECK-NEXT: [[NARROW_SEL:%.*]] = select i1 [[CMP]], half 0xH0000, half [[ARG]]
97+
; CHECK-NEXT: ret half [[NARROW_SEL]]
98+
;
99+
%ext = fpext half %arg to double
100+
%cmp = fcmp olt double %ext, 0.000000e+00
101+
%max = select i1 %cmp, double 0.000000e+00, double %ext
102+
%trunc = fptrunc double %max to half
103+
ret half %trunc
104+
}
105+
93106
; Negative test - this would require an extra instruction.
94107

95108
define half @fptrunc_select_true_val_extra_use_2(half %x, float %y, i1 %cond) {

0 commit comments

Comments
 (0)