[llvm-bugs] [Bug 35090] New: SREM/UREM can now be legal

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Oct 25 19:36:58 PDT 2017


            Bug ID: 35090
           Summary: SREM/UREM can now be legal
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Backend: PowerPC
          Assignee: unassignedbugs at nondot.org
          Reporter: hfinkel at anl.gov
                CC: jtony at ca.ibm.com, llvm-bugs at lists.llvm.org,
                    powerllvm at ca.ibm.com

In lib/Target/PowerPC/PPCISelLowering.cpp, we have this:

  // PowerPC has no SREM/UREM instructions unless we are on P9
  // On P9 we may use a hardware instruction to compute the remainder.
  // The instructions are not legalized directly because in the cases where the
  // result of both the remainder and the division is required it is more
  // efficient to compute the remainder from the result of the division rather
  // than use the remainder instruction.
  if (Subtarget.isISA3_0()) {
    setOperationAction(ISD::SREM, MVT::i32, Custom);
    setOperationAction(ISD::UREM, MVT::i32, Custom);
    setOperationAction(ISD::SREM, MVT::i64, Custom);
    setOperationAction(ISD::UREM, MVT::i64, Custom);
  } else {
    setOperationAction(ISD::SREM, MVT::i32, Expand);
    setOperationAction(ISD::UREM, MVT::i32, Expand);
    setOperationAction(ISD::SREM, MVT::i64, Expand);
    setOperationAction(ISD::UREM, MVT::i64, Expand);

but as of:

  [llvm] r312862 - [DivRempairs] add a pass to optimize div/rem pairs (PR31028)

the rationale for using custom lowering here should no longer be true. At the
IR level, we perform the transformation where the remainder is computed from
the result of the division when both a required. We should now be able to lower
these directly.

You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20171026/a0e4a1f3/attachment.html>

More information about the llvm-bugs mailing list