HomePhabricator

[InstCombine] improve folds for icmp with multiply operands (PR47432)

Authored by spatel on Sep 7 2020, 9:37 AM.

Description

[InstCombine] improve folds for icmp with multiply operands (PR47432)

Check for no overflow along with an odd constant before
we lose information by converting to bitwise logic.

https://rise4fun.com/Alive/2Xl

Pre: C1 != 0
%mx = mul nsw i8 %x, C1
%my = mul nsw i8 %y, C1
%r = icmp eq i8 %mx, %my
=>
%r = icmp eq i8 %x, %y

Name: nuw ne
Pre: C1 != 0
%mx = mul nuw i8 %x, C1
%my = mul nuw i8 %y, C1
%r = icmp ne i8 %mx, %my
=>
%r = icmp ne i8 %x, %y

Name: odd ne
Pre: C1 % 2 != 0
%mx = mul i8 %x, C1
%my = mul i8 %y, C1
%r = icmp ne i8 %mx, %my
=>
%r = icmp ne i8 %x, %y

Details

Committed
spatelSep 7 2020, 9:40 AM
Parents
rG11d8eedfa5b7: [InstCombine] move/add tests for icmp with mul operands; NFC
Branches
Unknown
Tags
Unknown