[llvm-commits] [llvm] r71238 - /llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp

Duncan Sands baldrick at free.fr
Sat May 9 00:29:34 PDT 2009


Hi Anton,

> +      case ISD::UREM:
> +      case ISD::SREM:
> +       if (VT == MVT::i16)
> +         LC = (isSigned ? RTLIB::SREM_I16  : RTLIB::UREM_I16);
> +       else if (VT == MVT::i32)
> +         LC = (isSigned ? RTLIB::SREM_I32  : RTLIB::UREM_I32);
> +       else if (VT == MVT::i64)
> +         LC = (isSigned ? RTLIB::SREM_I64  : RTLIB::UREM_I64);
> +       else if (VT == MVT::i128)
> +         LC = (isSigned ? RTLIB::SREM_I128 : RTLIB::UREM_I128);

how about factoring this kind of logic, into a function that
returns the UREM libcall for a given value type, and another
for SREM.  In fact I think all libcall lookups should be done
that way.  The advantage is that if a new type size is added
(eg: i8 UREM) then only one place has to be modified.  I already
did this for libcalls that depend on more than one value type,
see RTLIB::getFPROUND for example.

Ciao,

Duncan.



More information about the llvm-commits mailing list