This is an archive of the discontinued LLVM Phabricator instance.

[DivRemPairs] Strip division's poison generating flag
ClosedPublic

Authored by aqjune on Feb 18 2023, 12:47 PM.

Details

Summary

Given this transformation: X % Y -> X - (X / Y) * Y

This patch strips off the poison-generating flag of X / Y such as exact, because it may make the optimized form result poison whereas X % Y does not.

The issue was reported here: https://github.com/llvm/llvm-project/issues/60748

Diff Detail

Event Timeline

aqjune created this revision.Feb 18 2023, 12:47 PM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 18 2023, 12:47 PM
aqjune requested review of this revision.Feb 18 2023, 12:47 PM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 18 2023, 12:47 PM
aqjune retitled this revision from [DivRemPairs] Strip division's poison generating flag Given this transformation: X % Y -> X - (X / Y) * Y This patch strips off the poison-generating flag of X / Y such as exact, because it may make the optimized form result poison whereas X % Y... to [DivRemPairs] Strip division's poison generating flag.Feb 18 2023, 12:48 PM
aqjune edited the summary of this revision. (Show Details)
nikic accepted this revision.Feb 18 2023, 12:53 PM

LGTM

llvm/lib/Transforms/Scalar/DivRemPairs.cpp
376

Not really necessary to check has first.

llvm/test/Transforms/DivRemPairs/AArch64/div-rem-pairs.ll
18

Please don't use unnamed instructions (opt -S -passes=instnamer).

This revision is now accepted and ready to land.Feb 18 2023, 12:53 PM
aqjune updated this revision to Diff 498619.Feb 18 2023, 1:00 PM

Reflect comments

aqjune marked 2 inline comments as done.Feb 18 2023, 1:00 PM
This revision was landed with ongoing or failed builds.Feb 18 2023, 1:01 PM
This revision was automatically updated to reflect the committed changes.