Page MenuHomePhabricator

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

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.Sun, May 28, 3:22 AM

LGTM

llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
2191–2195

Can we drop this fold now?

This revision is now accepted and ready to land.Sun, May 28, 3:22 AM