This is an archive of the discontinued LLVM Phabricator instance.

[InstCombine] fix sub(add(X,Y),umin(Y,Z)) --> add(X,usub.sat(Y,Z))
ClosedPublic

Authored by Chenbing.Zheng on May 10 2022, 11:38 PM.

Details

Summary

This patch fix bug left in D124503.
We should do
sub(add(X,Z),umin(Y,Z)) --> add(X,usub.sat(Z,Y))
instead of
sub(add(X,Z),umin(Y,Z)) --> add(X,usub.sat(Y,Z)).

I forget to update sub-minmax.ll in D124503,
[[TMP1:%.*]] = call i8 @llvm.usub.sat.i8(i8 [[Y:%.*]], i8 [[Z:%.*]]) and
[[TMP1:%.*]] = call i8 @llvm.usub.sat.i8(i8 [[Z:%.*]], i8 [[Y:%.*]]) can both pass llvm-lit test.

Diff Detail

Event Timeline

Herald added a project: Restricted Project. · View Herald TranscriptMay 10 2022, 11:38 PM
Herald added a subscriber: hiraditya. · View Herald Transcript
Chenbing.Zheng requested review of this revision.May 10 2022, 11:38 PM
spatel accepted this revision.May 11 2022, 5:50 AM

This shows a shortcoming of the auto-generated check lines. We don't guarantee that we have captured the parameters with the displayed names, so y and z were swapped (miscompile), but it still passed testing. We used to capture parameters directly with the script, so there was no risk of this bug, but that changed somewhere along the line to make the script more flexible. But we can still do that with a script option:
400587ba0c8b1453

Please update/rebase.

This revision is now accepted and ready to land.May 11 2022, 5:50 AM
spatel requested changes to this revision.May 11 2022, 5:51 AM

I accidentally marked as approved (the patch itself looks ok, but we should update the tests here first).

This revision now requires changes to proceed.May 11 2022, 5:51 AM

rebase and update tests

spatel accepted this revision.May 12 2022, 4:40 AM

LGTM

This revision is now accepted and ready to land.May 12 2022, 4:40 AM
This revision was landed with ongoing or failed builds.May 12 2022, 6:58 PM
This revision was automatically updated to reflect the committed changes.