On Fri, Mar 03, 2023 at 03:35:44PM -0600, Segher Boessenkool wrote: > > +complex_multiply_builtin_code (machine_mode mode) > > +{ > > + return (built_in_function) (BUILT_IN_COMPLEX_MUL_MIN + mode > > + - MIN_MODE_COMPLEX_FLOAT); > > +} > > There should be an assert that the mode is as expected > gcc_assert (IN_RANGE (mode, MIN_MODE_COMPLEX_FLOAT, > MAX_MODE_COMPLEX_FLOAT)); > or such. > > Using more temporaries should make this simpler as well, obviate the > need for explicit casts, and make everything fit on short lines.
While I can use a temporary to shorten the line, I can't eliminate the case, or I'll get a warning about implicit conversion from int to the enum built_in_function. Here is what I will use: static inline built_in_function complex_multiply_builtin_code (machine_mode mode) { gcc_assert (IN_RANGE (mode, MIN_MODE_COMPLEX_FLOAT, MAX_MODE_COMPLEX_FLOAT)); int func = BUILT_IN_COMPLEX_MUL_MIN + mode - MIN_MODE_COMPLEX_FLOAT; return (built_in_function) func; } -- Michael Meissner, IBM PO Box 98, Ayer, Massachusetts, USA, 01432 email: meiss...@linux.ibm.com