On Mon, Sep 14, 2026 at 8:17 AM Hongyu Wang <[email protected]> wrote: > > Uros Bizjak <[email protected]> 于2026年9月11日周五 17:22写道: > > > > On Fri, Sep 11, 2026 at 10:50 AM Hongyu Wang <[email protected]> wrote: > > > > > > Hi, > > > > > > The unordered compares (UNLT, UNLE, UNGT, UNGE and UNEQ) must not raise > > > FE_INVALID on a quiet NaN. AVX and AVX512 have an imm8 encoding for the > > > quiet _UQ predicate of each, so just select it. > > > > > > Legacy SSE2 has only 8 predicates and can express UNGE/UNGT/UNLT/UNLE > > > only as the signaling NLT/NLE. So reject those four codes in the packed > > > FP vec_cmp expanders under trapping math and NaNs are honored. > > > > > > Bootstrapped & regtested under x86_64-pc-linux-gnu. Ok for trunk? > > > > > > gcc/ChangeLog: > > > > > > PR target/127177 > > > * config/i386/i386-expand.cc (ix86_fp_cmp_code_to_pcmp_immediate): > > > Return the _UQ predicate immediates for UNLE, UNLT, UNGE, UNGT and > > > UNEQ. > > > * config/i386/i386.cc (ix86_print_operand):Likewise to print the > > > _uq suffixed AVX predicates for these codes. > > > * config/i386/predicates.md (ix86_fp_vec_cmp_operator): New > > > predicate. > > > * config/i386/sse.md (vec_cmp<mode><sseintvecmodelower>): Use the > > > new predicate for the VF_128 compare. > > > * config/i386/mmx.md (vec_cmpv2sfv2si): Likewise. > > > > > > gcc/testsuite/ChangeLog: > > > > > > PR target/127177 > > > * gcc.target/i386/pr127177-1.c: New test. > > > * gcc.target/i386/pr127177-2.c: Likewise. > > > * gcc.target/i386/pr127177-3.c: Likewise. > > > * gcc.target/i386/pr127177-4.c: Likewise. > > > * gcc.target/i386/pr127177-5.c: Likewise. > > > > > +;; SSE2 doesn't have quiet vector compare for LT/LE/GT/GE, so > > > +;; disable them under trapping-math or HONOR_NANS. > > > + > > > +(define_predicate "ix86_fp_vec_cmp_operator" > > > + (and (match_operand 0 "comparison_operator") > > > + (ior (not (match_code "unlt,unle,ungt,unge")) > > > + (match_test "TARGET_AVX > > > + || !flag_trapping_math > > > + || !HONOR_NANS (GET_MODE (XEXP (op, 0)))")))) > > > > FYI, binary operators (ior, and, ...) can have multiple inputs in > > define_predicate, so: > > > > (ior (not (match_code "...")) > > (match_test "TARGET_AVX") > > (not (match_test "flag_trapping_math")) > > (not (match_test "HONOR_NANS (...)"))) > > > > Indeed, updated in the attached patch.
So reject those four codes in the packed FP vec_cmp expanders under trapping math and NaNs are honored. This reads like a word is missing, so perhaps: So reject those four codes in the packed FP vec_cmp expanders when trapping math is in effect and NaNs are honored. LGTM otherwise. Thanks, Uros.
