This is an archive of the discontinued LLVM Phabricator instance.

[PPC] In PPCBoolRetToInt change the bool value to i64 if the target is ppc64
ClosedPublic

Authored by Carrot on Mar 27 2017, 3:56 PM.

Details

Summary

In PPCBoolRetToInt bool value is changed to i32 type. On ppc64 it may introduce an extra zero extension for the return value. This patch changes the integer type to i64 to avoid the zero extension on ppc64.

This patch fixed PR32442.

Diff Detail

Repository
rL LLVM

Event Timeline

Carrot created this revision.Mar 27 2017, 3:56 PM
echristo accepted this revision.Mar 27 2017, 4:06 PM

Couple of small nits, otherwise LGTM.

-eric

lib/Target/PowerPC/PPCBoolRetToInt.cpp
91 ↗(On Diff #93189)

Update?

197 ↗(On Diff #93189)

Let's just always assume we have a TargetMachine and return false if not?

test/CodeGen/PowerPC/pr32442.ll
2 ↗(On Diff #93189)

Throw the PR number in here as a comment?

This revision is now accepted and ready to land.Mar 27 2017, 4:06 PM
nemanjai added inline comments.Mar 28 2017, 1:01 AM
lib/Target/PowerPC/PPCBoolRetToInt.cpp
93 ↗(On Diff #93189)

Just a personal preference nit...
Maybe turn this into a conditional operator for the initialization (rather than the assignment in the if).

Carrot updated this revision to Diff 93290.Mar 28 2017, 1:35 PM
Carrot marked 3 inline comments as done.
Carrot added inline comments.
test/CodeGen/PowerPC/pr32442.ll
2 ↗(On Diff #93189)

It is contained in the filename.

echristo added inline comments.Mar 28 2017, 1:39 PM
test/CodeGen/PowerPC/pr32442.ll
2 ↗(On Diff #93189)

So it is. Perhaps a more descriptive filename and a link to the PR :)

Carrot updated this revision to Diff 93300.Mar 28 2017, 2:30 PM
Carrot marked an inline comment as done.
echristo added inline comments.Mar 28 2017, 2:32 PM
test/CodeGen/PowerPC/pr32442.ll
2 ↗(On Diff #93189)

Any reason this can't go into the other file?

Carrot added inline comments.Mar 28 2017, 3:10 PM
test/CodeGen/PowerPC/pr32442.ll
2 ↗(On Diff #93189)

Test case BoolRetToIntTest.ll runs BoolRetToInt pass only, and check the LLVM IR. The extra zero extension is not very obvious at this time, it is explicitly generated at the machine instruction phase.

echristo added inline comments.Mar 28 2017, 3:12 PM
test/CodeGen/PowerPC/pr32442.ll
2 ↗(On Diff #93189)

Aha. That makes sense.

How about BoolRetToIntTest-2.ll then and leave the PR in the comment section?

I realize this seems like a crazy amount of care over file naming, but historically I've found that pr named tests aren't very helpful.

Carrot updated this revision to Diff 93313.Mar 28 2017, 3:20 PM
Carrot marked an inline comment as done.

LGTM.

Thanks!

This revision was automatically updated to reflect the committed changes.
Carrot updated this revision to Diff 101824.Jun 7 2017, 3:16 PM

The first commit triggered bug pr32608, and was reverted by r299153. Now the bug has been fixed by r304001, so I will try to commit it again. Unfortunately INITIALIZE_TM_PASS has been removed and TargetMachine access mechanism is changed, so I modified the patch to use new mechanism.

Please take another look.

One inline nit then LGTM.

-eric

lib/Target/PowerPC/PPCBoolRetToInt.cpp
197 ↗(On Diff #93189)

If you get a PPCTargetMachine you shouldn't have to cast the subtarget.

Carrot updated this revision to Diff 101838.Jun 7 2017, 4:01 PM
Carrot marked an inline comment as done.