HomePhabricator

[InstCombine] (-NSW x) ==/!= x --> x ==/!= 0 (PR39480)

Authored by lebedev.ri on Aug 6 2020, 1:02 AM.

Description

[InstCombine] (-NSW x) ==/!= x --> x ==/!= 0 (PR39480)

Name: (-x) == x --> x == 0
%neg_x = sub nsw i8 0, %x ; %x must not be INT_MIN
%r = icmp eq i8 %neg_x, %x

=>

%r = icmp eq i8 %x, 0

Name: (-x) != x --> x != 0
%neg_x = sub nsw i8 0, %x ; %x must not be INT_MIN
%r = icmp ne i8 %neg_x, %x

=>

%r = icmp ne i8 %x, 0

https://rise4fun.com/Alive/4slH

https://bugs.llvm.org/show_bug.cgi?id=39480

Details

Committed
lebedev.riAug 6 2020, 1:50 AM
Parents
rG5060f5682b01: [InstCombine] (-NSW x) s> x --> x s< 0 (PR39480)
Branches
Unknown
Tags
Unknown