@@ -546,3 +546,93 @@ entry:
546546 %sel = select i1 %cond , float %t , float 0 .000000e+00
547547 ret float %sel
548548}
549+
550+ ; -----------------------------------------------------------------------------
551+ ; Test select with i1 condition and zero ret val for half fp (cond ? a : 0)
552+ ; -----------------------------------------------------------------------------
553+ define dso_local noundef half @select_i1_half_0 (i1 %cond , half %val ) nounwind {
554+ ; RV64ZDINX_ZICOND-LABEL: select_i1_half_0:
555+ ; RV64ZDINX_ZICOND: # %bb.0: # %entry
556+ ; RV64ZDINX_ZICOND-NEXT: # kill: def $x11_w killed $x11_w def $x11
557+ ; RV64ZDINX_ZICOND-NEXT: andi a0, a0, 1
558+ ; RV64ZDINX_ZICOND-NEXT: czero.eqz a0, a1, a0
559+ ; RV64ZDINX_ZICOND-NEXT: lui a1, 1048560
560+ ; RV64ZDINX_ZICOND-NEXT: or a0, a0, a1
561+ ; RV64ZDINX_ZICOND-NEXT: # kill: def $x10_w killed $x10_w killed $x10
562+ ; RV64ZDINX_ZICOND-NEXT: ret
563+ ;
564+ ; RV64ZDINX_NOZICOND-LABEL: select_i1_half_0:
565+ ; RV64ZDINX_NOZICOND: # %bb.0: # %entry
566+ ; RV64ZDINX_NOZICOND-NEXT: # kill: def $x11_w killed $x11_w def $x11
567+ ; RV64ZDINX_NOZICOND-NEXT: slli a0, a0, 63
568+ ; RV64ZDINX_NOZICOND-NEXT: srai a0, a0, 63
569+ ; RV64ZDINX_NOZICOND-NEXT: and a0, a0, a1
570+ ; RV64ZDINX_NOZICOND-NEXT: lui a1, 1048560
571+ ; RV64ZDINX_NOZICOND-NEXT: or a0, a0, a1
572+ ; RV64ZDINX_NOZICOND-NEXT: # kill: def $x10_w killed $x10_w killed $x10
573+ ; RV64ZDINX_NOZICOND-NEXT: ret
574+ ;
575+ ; RV64ZHINX_ZICOND-LABEL: select_i1_half_0:
576+ ; RV64ZHINX_ZICOND: # %bb.0: # %entry
577+ ; RV64ZHINX_ZICOND-NEXT: # kill: def $x11_h killed $x11_h def $x11
578+ ; RV64ZHINX_ZICOND-NEXT: andi a0, a0, 1
579+ ; RV64ZHINX_ZICOND-NEXT: czero.eqz a0, a1, a0
580+ ; RV64ZHINX_ZICOND-NEXT: # kill: def $x10_h killed $x10_h killed $x10
581+ ; RV64ZHINX_ZICOND-NEXT: ret
582+ ;
583+ ; RV64FD-LABEL: select_i1_half_0:
584+ ; RV64FD: # %bb.0: # %entry
585+ ; RV64FD-NEXT: fmv.x.w a1, fa0
586+ ; RV64FD-NEXT: slli a0, a0, 63
587+ ; RV64FD-NEXT: srai a0, a0, 63
588+ ; RV64FD-NEXT: and a0, a0, a1
589+ ; RV64FD-NEXT: lui a1, 1048560
590+ ; RV64FD-NEXT: or a0, a0, a1
591+ ; RV64FD-NEXT: fmv.w.x fa0, a0
592+ ; RV64FD-NEXT: ret
593+ ;
594+ ; RV32ZFINX_ZICOND-LABEL: select_i1_half_0:
595+ ; RV32ZFINX_ZICOND: # %bb.0: # %entry
596+ ; RV32ZFINX_ZICOND-NEXT: # kill: def $x11_w killed $x11_w def $x11
597+ ; RV32ZFINX_ZICOND-NEXT: andi a0, a0, 1
598+ ; RV32ZFINX_ZICOND-NEXT: czero.eqz a0, a1, a0
599+ ; RV32ZFINX_ZICOND-NEXT: lui a1, 1048560
600+ ; RV32ZFINX_ZICOND-NEXT: or a0, a0, a1
601+ ; RV32ZFINX_ZICOND-NEXT: # kill: def $x10_w killed $x10_w killed $x10
602+ ; RV32ZFINX_ZICOND-NEXT: ret
603+ ;
604+ ; RV32ZFINX_NOZICOND-LABEL: select_i1_half_0:
605+ ; RV32ZFINX_NOZICOND: # %bb.0: # %entry
606+ ; RV32ZFINX_NOZICOND-NEXT: # kill: def $x11_w killed $x11_w def $x11
607+ ; RV32ZFINX_NOZICOND-NEXT: slli a0, a0, 31
608+ ; RV32ZFINX_NOZICOND-NEXT: srai a0, a0, 31
609+ ; RV32ZFINX_NOZICOND-NEXT: and a0, a0, a1
610+ ; RV32ZFINX_NOZICOND-NEXT: lui a1, 1048560
611+ ; RV32ZFINX_NOZICOND-NEXT: or a0, a0, a1
612+ ; RV32ZFINX_NOZICOND-NEXT: # kill: def $x10_w killed $x10_w killed $x10
613+ ; RV32ZFINX_NOZICOND-NEXT: ret
614+ ;
615+ ; RV32ZDINX_ZICOND-LABEL: select_i1_half_0:
616+ ; RV32ZDINX_ZICOND: # %bb.0: # %entry
617+ ; RV32ZDINX_ZICOND-NEXT: # kill: def $x11_w killed $x11_w def $x11
618+ ; RV32ZDINX_ZICOND-NEXT: andi a0, a0, 1
619+ ; RV32ZDINX_ZICOND-NEXT: czero.eqz a0, a1, a0
620+ ; RV32ZDINX_ZICOND-NEXT: lui a1, 1048560
621+ ; RV32ZDINX_ZICOND-NEXT: or a0, a0, a1
622+ ; RV32ZDINX_ZICOND-NEXT: # kill: def $x10_w killed $x10_w killed $x10
623+ ; RV32ZDINX_ZICOND-NEXT: ret
624+ ;
625+ ; RV32ZDINX_NOZICOND-LABEL: select_i1_half_0:
626+ ; RV32ZDINX_NOZICOND: # %bb.0: # %entry
627+ ; RV32ZDINX_NOZICOND-NEXT: # kill: def $x11_w killed $x11_w def $x11
628+ ; RV32ZDINX_NOZICOND-NEXT: slli a0, a0, 31
629+ ; RV32ZDINX_NOZICOND-NEXT: srai a0, a0, 31
630+ ; RV32ZDINX_NOZICOND-NEXT: and a0, a0, a1
631+ ; RV32ZDINX_NOZICOND-NEXT: lui a1, 1048560
632+ ; RV32ZDINX_NOZICOND-NEXT: or a0, a0, a1
633+ ; RV32ZDINX_NOZICOND-NEXT: # kill: def $x10_w killed $x10_w killed $x10
634+ ; RV32ZDINX_NOZICOND-NEXT: ret
635+ entry:
636+ %sel = select i1 %cond , half %val , half 0xH0000
637+ ret half %sel
638+ }
0 commit comments