[PATCH] D142901: [InstSimplify] Simplify UREM and SREM left shifted operands

Noah Goldstein via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 30 10:29:13 PST 2023


goldstein.w.n added inline comments.


================
Comment at: llvm/lib/Analysis/InstructionSimplify.cpp:995
 
+Value *simplifyRemShifts(Value *Op0, Value *Op1, bool IsSigned,
+                         const SimplifyQuery &Q) {
----------------
Instead of a new helper maybe this should be in `simplifyRem` which already appears to have:
```
  // (X << Y) % X -> 0
  if (Q.IIQ.UseInstrInfo &&
      ((Opcode == Instruction::SRem &&
        match(Op0, m_NSWShl(m_Specific(Op1), m_Value()))) ||
       (Opcode == Instruction::URem &&
        match(Op0, m_NUWShl(m_Specific(Op1), m_Value())))))
    return Constant::getNullValue(Op0->getType());
```

This is really just a superset of that case, so maybe expanding the existing logic would be simpler?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D142901/new/

https://reviews.llvm.org/D142901



More information about the llvm-commits mailing list