This is an archive of the discontinued LLVM Phabricator instance.

[InstSimplify] Missed optimization in math expression: (x+x)/x == 2
AbandonedPublic

Authored by Quolyk on Dec 23 2017, 9:14 AM.

Details

Summary

Motivation: https://bugs.llvm.org/show_bug.cgi?id=35709. I'm not sure how do I need to handle NSWSHL, NUWSHL, SHL

Diff Detail

Event Timeline

Quolyk created this revision.Dec 23 2017, 9:14 AM
majnemer added inline comments.
lib/Analysis/InstructionSimplify.cpp
997

I believe this needs to be m_NUWShl.

test/Transforms/InstSimplify/div.ll
147–154

This seems wrong as per https://www.rise4fun.com/Alive/Gslf

ERROR: Mismatch in values of i32 %div

Example:
%x i32 = 0x800FE842 (2148526146, -2146441150)
%add i32 = 0x001FD084 (2084996)
Source value: 0x00000000 (0)
Target value: 0x00000002 (2)

grandinj added inline comments.
lib/Analysis/InstructionSimplify.cpp
997

Is that not trivially extendable to

(X << C) / X -> C

for any

C <= bitwidth(X)

?

Quolyk added inline comments.Dec 24 2017, 4:17 AM
lib/Analysis/InstructionSimplify.cpp
997

I think that would be pow(2, C), not just C

RKSimon resigned from this revision.Jan 14 2018, 7:16 AM
Quolyk abandoned this revision.Jan 30 2018, 5:01 AM

Abandoning, as it was fixed in D42032