This is an archive of the discontinued LLVM Phabricator instance.

Added a new transformation " (X + Y) - (X + Z) --> (Y - Z) "
AbandonedPublic

Authored by sonamkumari on Oct 15 2014, 11:43 PM.

Details

Summary

Hi All,

Submitted a patch related to subtraction optimization.

The optimization is :
(X + Y) - (X + Z) --> (Y - Z)

Please help in reviewing it.

Regards,
Sonam.

Diff Detail

Event Timeline

sonamkumari retitled this revision from to Added a new transformation " (X + Y) - (X + Z) --> (Y - Z) ".
sonamkumari updated this object.
sonamkumari edited the test plan for this revision. (Show Details)
sonamkumari added reviewers: dexonsmith, majnemer, suyog.
sonamkumari added a subscriber: Unknown Object (MLST).
majnemer edited edge metadata.Oct 15 2014, 11:56 PM

This instcombine is definitely not needed. This sort of thing is best handled by reassociate. In fact, it already handles this case today:

~/llvm/Debug+Asserts/bin/opt -reassociate -instcombine t.ll -o - -S

define i32 @test45(i32 %x, i32 %y, i32 %z) {
  %sub = sub i32 %y, %z
  ret i32 %sub
}

Hi David,

Thanks for pointing out the mistake and reviewing the patch.

Regards,
Sonam.

sonamkumari abandoned this revision.Dec 1 2014, 1:20 AM