This is an archive of the discontinued LLVM Phabricator instance.

[GlobalISel] Combine icmp eq/ne (ext (icmp cc, x, y)), true/false)
Needs ReviewPublic

Authored by paquette on Nov 18 2020, 4:43 PM.

Details

Reviewers
aemerson
arsenm
Summary

This implements the following combines:

icmp ne ([sz]ext (icmp cc, x, y)), 0) -> icmp cc, x, y
icmp eq, ([sz]ext (icmp cc x, y)), 0) -> icmp inv(cc), x, y
icmp ne, (zext (icmp cc, x, y)), 1) -> icmp inv(cc), x, y
icmp eq, (zext (icmp cc, x, y)), 1) -> icmp cc, x, y
icmp ne, (sext (icmp cc, x, y)), -1) -> icmp inv(cc), x, y
icmp eq, (sext (icmp cc, x, y)), -1) -> icmp cc, x, y

This is similar to a combine in TargetLowering::SimplifySetCC.

IR example: https://godbolt.org/z/qzx81v

Diff Detail

Event Timeline

paquette created this revision.Nov 18 2020, 4:43 PM
Herald added a project: Restricted Project. · View Herald TranscriptNov 18 2020, 4:44 PM
paquette requested review of this revision.Nov 18 2020, 4:44 PM
aemerson added inline comments.Nov 18 2020, 11:15 PM
llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp
3149–3150

I'm not convinced this is necessary. If legality is something that a target should care about then I think they shouldn't add this combine post-legalization.

3172

SrcCmp is a better name?

3188

Same here.

arsenm added inline comments.Sep 28 2022, 2:18 PM
llvm/include/llvm/CodeGen/GlobalISel/CombinerHelper.h
101

BuildFnTy already exists

Herald added a project: Restricted Project. · View Herald TranscriptSep 28 2022, 2:18 PM