This is an archive of the discontinued LLVM Phabricator instance.

[AVX-512][InstCombine] Teach InstCombine to turn scalar add/sub/mul/div with rounding intrinsics into normal IR operations if the rounding mode is CUR_DIRECTION.
ClosedPublic

Authored by craig.topper on Dec 17 2016, 10:19 AM.

Details

Summary

I only do this for unmasked cases for now because isel is failing to fold the mask. I'll try to fix that soon.

I'll do the same thing for packed add/sub/mul/div in a future patch.

Diff Detail

Repository
rL LLVM

Event Timeline

craig.topper retitled this revision from to [AVX-512][InstCombine] Teach InstCombine to turn scalar add/sub/mul/div with rounding intrinsics into normal IR operations if the rounding mode is CUR_DIRECTION..
craig.topper updated this object.
craig.topper added reviewers: delena, RKSimon, zvi.
craig.topper added a subscriber: llvm-commits.
zvi edited edge metadata.Dec 20 2016, 4:09 AM

Other than a minor comment, LGTM.

lib/Transforms/InstCombine/InstCombineCalls.cpp
1783 ↗(On Diff #81845)

is if(dync_cast<>) really needed here? Can the cast ever fail?

craig.topper added inline comments.Dec 21 2016, 9:05 AM
lib/Transforms/InstCombine/InstCombineCalls.cpp
1783 ↗(On Diff #81845)

You're right the cast can never fail for well formed use of the intrinsic. I'll change it before I commit.

RKSimon added inline comments.Dec 21 2016, 9:09 AM
lib/Transforms/InstCombine/InstCombineCalls.cpp
1783 ↗(On Diff #81845)

Will something have caught badly formed uses of the intrinsic before this?

I think Simon is right. Nothing will catch the badly formed intrinsic before this. So we should keep a dyn_cast here.

craig.topper accepted this revision.Dec 25 2016, 5:52 PM
craig.topper added a reviewer: craig.topper.

Accepting based on Zvi's LGTM and determining that the dyn_cast helps keep the optimization robust against badly formed uses of the intrinsics.

This revision is now accepted and ready to land.Dec 25 2016, 5:52 PM
This revision was automatically updated to reflect the committed changes.