This is an archive of the discontinued LLVM Phabricator instance.

[JumpThreading] See through Cast Instructions
ClosedPublic

Authored by haicheng on Feb 2 2016, 9:04 AM.

Details

Summary

This patch helps JumpThreading capture more optimization opportunities. No significant performance change in SpecINT.

Diff Detail

Repository
rL LLVM

Event Timeline

haicheng updated this revision to Diff 46661.Feb 2 2016, 9:04 AM
haicheng retitled this revision from to [JumpThreading] See through Cast Instructions.
haicheng updated this object.
haicheng added reviewers: mcrosier, gberry, mssimpso.
haicheng set the repository for this revision to rL LLVM.
haicheng updated this revision to Diff 46662.Feb 2 2016, 9:06 AM

Fix a typo.

gberry edited edge metadata.Feb 4 2016, 12:10 PM

It is not clear to me from looking at the added test case what new optimization is being added. I would expect to see some CHECKs of new folded constants if I understand the change correctly.

test/Transforms/JumpThreading/basic.ll
495

These 3 lines are indented funny (tabs?)

It is not clear to me from looking at the added test case what new optimization is being added. I would expect to see some CHECKs of new folded constants if I understand the change correctly.

This patch allows the Entry block threads over the merge block. See the first CHECK-NEXT

haicheng updated this revision to Diff 46952.Feb 4 2016, 1:13 PM
haicheng edited edge metadata.

Fix the format of the test case. Thank you, Geoff.

haicheng marked an inline comment as done.Feb 4 2016, 1:16 PM
gberry added inline comments.Feb 5 2016, 11:01 AM
test/Transforms/JumpThreading/basic.ll
493

It seems like this change to JumpThreading would not be needed if the Merge block code had been simplified to the following:

Merge:
  %B = phi i32 [1, %Entry], [%v1, %F1]
  %M = icmp eq i32 %B, 0 
  br i1 %M, label %T2, label %F2

Are we missing this simplification, or is there something more complex going on in the code this was extracted from that prevents it from happening?

haicheng added inline comments.Feb 5 2016, 11:35 AM
test/Transforms/JumpThreading/basic.ll
493

The simplification is missing. InstCombine can optimize it, but it is called after jumpthreading.

bmakam added a subscriber: bmakam.Feb 5 2016, 12:31 PM
bmakam added inline comments.
test/Transforms/JumpThreading/basic.ll
493

InstSimplify can also optimize it. Have you considered just using the simplified value if the instruction can be simplified? This frequently happens due to phi translation and I think there is an instance where we use this in DuplicateCondBranchOnPHIIntoPred

haicheng updated this revision to Diff 47116.Feb 6 2016, 8:42 PM

Thank you, Balaram. Is this the update that you suggest?

majnemer added inline comments.
lib/Transforms/Scalar/JumpThreading.cpp
413

Please use auto * for the left hand side of the assignment.

bmakam added a comment.Feb 7 2016, 5:14 AM

LGTM once you've addressed the comments.

lib/Transforms/Scalar/JumpThreading.cpp
415

You might need to RAUW NewV,
NewV->replaceAllUsesWith(V);
V->eraseFromParent();

bmakam added inline comments.Feb 7 2016, 4:26 PM
lib/Transforms/Scalar/JumpThreading.cpp
415

I meant V->replaceAllUsesWith(NewV)

haicheng updated this revision to Diff 47530.Feb 10 2016, 2:37 PM
haicheng marked 2 inline comments as done.

Address David and Balaram's comments. Thank you.

haicheng marked 2 inline comments as done.Feb 10 2016, 2:37 PM
mcrosier edited edge metadata.Feb 11 2016, 6:03 AM

Does this patch include the test case for r260110?

Does this patch include the test case for r260110?

test17 is the test case for r260110.

Seems reasonable to me, but I'll let @bmakam's or someone else more familiar with the patch give the final approval.

gberry added inline comments.Feb 11 2016, 10:45 AM
lib/Transforms/Scalar/JumpThreading.cpp
414

It seems like this block deserves a single-line comment explaining why it is being done.

test/Transforms/JumpThreading/basic.ll
514

Can you give some indication of what kind of crash/assert you are testing for here?

haicheng updated this revision to Diff 47689.Feb 11 2016, 11:09 AM
haicheng edited edge metadata.
haicheng marked an inline comment as done.

Address Geoff's comments.

haicheng marked an inline comment as done.Feb 11 2016, 11:10 AM
bmakam accepted this revision.Feb 25 2016, 12:46 PM
bmakam added a reviewer: bmakam.

Sorry, did not realize this was waiting for my approval. LGTM.

This revision is now accepted and ready to land.Feb 25 2016, 12:46 PM
haicheng closed this revision.Feb 26 2016, 2:01 PM

Committed in r261981.