This is an archive of the discontinued LLVM Phabricator instance.

Move a transform from InstCombine to InstSimplify.
ClosedPublic

Authored by majnemer on Jul 13 2016, 4:42 PM.

Details

Summary

This transform doesn't require any new instructions, it can safely live
in InstSimplify.

[ConstantFolding] Extend FoldReinterpretLoadFromConstPtr to handle negative offsets

Treat loads which clip before the start of a global initializer the same
way we treat clipping beyond the end of the initializer: use zeros.

[ConstantFolding] Fold masked loads

We can constant fold a masked load if the operands are appropriately
constant.

Diff Detail

Repository
rL LLVM

Event Timeline

majnemer updated this revision to Diff 63882.Jul 13 2016, 4:42 PM
majnemer retitled this revision from to Move a transform from InstCombine to InstSimplify..
majnemer updated this object.
majnemer added reviewers: mkuper, spatel, RKSimon.
majnemer added a subscriber: llvm-commits.
majnemer updated this revision to Diff 63884.Jul 13 2016, 4:47 PM

Update the revision to contain only the relevant changes.

mkuper added inline comments.Jul 13 2016, 5:02 PM
lib/Analysis/ConstantFolding.cpp
1857 ↗(On Diff #63884)

Missing null check?

1862 ↗(On Diff #63884)

I think this can return an undef - in which case you'll bail, when you don't necessarily have to. Although undef masks are probably rare, so it doesn't matter that much.
Also, do we have a helper to check that the mask is a constant/undef? If so, maybe call that before entering the loop for an early exit?

majnemer added inline comments.Jul 13 2016, 5:09 PM
lib/Analysis/ConstantFolding.cpp
1857 ↗(On Diff #63884)

Ah, good catch.

1862 ↗(On Diff #63884)

I think undef masks could be handled later. We already know that Mask is a Constant * because Operands is an ArrayRef of Constant *.

majnemer updated this revision to Diff 63887.Jul 13 2016, 5:12 PM
  • Address review comments
mkuper accepted this revision.Jul 13 2016, 5:21 PM
mkuper edited edge metadata.

LGTM

lib/Analysis/ConstantFolding.cpp
1862 ↗(On Diff #63887)

UndefValue* is a Constant*.
But I agree, it doesn't really matter at this point.

This revision is now accepted and ready to land.Jul 13 2016, 5:21 PM
This revision was automatically updated to reflect the committed changes.