On 2/6/2022 下午 5:04, Segher Boessenkool wrote: > Hi! > > On Thu, Jun 02, 2022 at 01:30:04PM +0800, HAO CHEN GUI wrote: >> Segher, >> Does BCD comparison return false when either operand is invalid coding? > > It sets all of LT, GT, and EQ to 0 (it normally sets exactly one of them > to 1). It sets bit 3 (the "SO" bit usually) to 1. > > That is what the machine insns do. What the builtins do is undefined as > far as I know? If So we can do whatever is most convenient, so, not > handle it specifically at all, just go with what falls out. We defined the following unordered BCD builtins in rs6000-builtin.def. They check the bit 3 for overflow. const signed int __builtin_bcdadd_ov_v1ti (vsq, vsq, const int<1>); BCDADD_OV_V1TI bcdadd_unordered_v1ti {} const signed int __builtin_bcdadd_ov_v16qi (vsc, vsc, const int<1>); BCDADD_OV_V16QI bcdadd_unordered_v16qi {} Also Xlc defines three BCD builtins for overflow and invalid coding. https://www.ibm.com/docs/en/xl-c-and-cpp-linux/16.1.1?topic=functions-bcd-test-add-subtract-overflow Shall GCC keep up with Xlc? Please advise. Thanks Gui Haochen > >> If yes, the result could be 3-way. We can check gt and eq bits for ge. > > You can check the LT bit, instead: it is only one branch insn, and also > only one setbc[r] insn (it can be slightly more expensive if you can use > only older insns). > >> We still can't use crnot to only check lt bit as there could be invalid >> coding. >> Also, do you think finite-math-only excludes invalid coding? Seems GCC >> doesn't clear define it. > > This is not floating-point code at all, it should not be influenced at > all by finite-math-only! > > > Segher
Re: [PATCH v2, rs6000] Fix ICE on expand bcd__ [PR100736]
_ [PR100736]
HAO CHEN GUI via Gcc-patches Mon, 06 Jun 2022 01:14:42 -0700
- [PATCH v2, rs6000] Fix ICE on expand bcd<b... HAO CHEN GUI via Gcc-patches
- Ping [PATCH v2, rs6000] Fix ICE on expan... HAO CHEN GUI via Gcc-patches
- Re: [PATCH v2, rs6000] Fix ICE on expand... Kewen.Lin via Gcc-patches
- Re: [PATCH v2, rs6000] Fix ICE on ex... Segher Boessenkool
- Re: [PATCH v2, rs6000] Fix ICE o... Segher Boessenkool
- Re: [PATCH v2, rs6000] Fix I... HAO CHEN GUI via Gcc-patches
- Re: [PATCH v2, rs6000] ... Segher Boessenkool
- Re: [PATCH v2, rs60... HAO CHEN GUI via Gcc-patches