This is an archive of the discontinued LLVM Phabricator instance.

[InstCombine] Add transform `(icmp pred (shl {nsw and/or nuw} X, Y), C)` -> `(icmp pred X, C)`
ClosedPublic

Authored by goldstein.w.n on Mar 5 2023, 5:20 PM.

Details

Summary

Three new transforms:

  1. (icmp pred (shl nsw nuw X, Y), C) [if C <= 0] -> (icmp pred X, C)
  2. (icmp eq/ne (shl {nsw|nuw} X, Y), 0) -> (icmp eq/ne X, 0)
  3. (icmp slt (shl nsw X, Y), 0/1) -> (icmp pred X, 0/1) (icmp sgt (shl nsw X, Y), 0/-1) -> (icmp pred X, 0/-1)

Diff Detail

Event Timeline

goldstein.w.n created this revision.Mar 5 2023, 5:20 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 5 2023, 5:20 PM
Herald added a subscriber: hiraditya. · View Herald Transcript
goldstein.w.n requested review of this revision.Mar 5 2023, 5:20 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 5 2023, 5:20 PM
nikic accepted this revision.May 28 2023, 3:22 AM

LGTM

llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
2254–2258

Can we drop this fold now?

This revision is now accepted and ready to land.May 28 2023, 3:22 AM
This revision was landed with ongoing or failed builds.Jun 5 2023, 11:01 AM
This revision was automatically updated to reflect the committed changes.