This is an archive of the discontinued LLVM Phabricator instance.

[PowerPC] Fix ADDE, SUBE do not know how to promote operator
ClosedPublic

Authored by ZhangKang on Dec 27 2018, 10:21 PM.

Details

Summary

This patch is created to fix the Bugzilla bug 39815.

This patch is to support promotion integer result for the instruction ADDE, SUBE.

Before this fix, for below test case:

@b = common local_unnamed_addr global i64* null, align 8
@a = common local_unnamed_addr global i8 0, align 1

define void @testADDEPromoteResult() {
entry:
  %0 = load i64*, i64** @b, align 8
  %1 = load i64, i64* %0, align 8
  %cmp = icmp ne i64* %0, null
  %conv1 = zext i1 %cmp to i64
  %add = add nsw i64 %1, %conv1
  %2 = trunc i64 %add to i8
  %conv2 = and i8 %2, 5
  store i8 %conv2, i8* @a, align 1
  ret void
}

We use llc test.ll to build the case, then we will get below error:

PromoteIntegerResult #0: t28: i8,i64 = adde t29, Constant:i8<0>, t24:1

Do not know how to promote this operator!
UNREACHABLE executed at /home/ken/llvm/llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp:55!
Stack dump:
0.	Program arguments: llc sim.ll
1.	Running pass 'Function Pass Manager' on module 'sim.ll'.
2.	Running pass 'PowerPC DAG->DAG Pattern Instruction Selection' on function '@testPromoteOperand'

Diff Detail

Repository
rL LLVM

Event Timeline

ZhangKang created this revision.Dec 27 2018, 10:21 PM
hfinkel accepted this revision.Dec 28 2018, 6:37 AM
hfinkel added inline comments.
llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
146 ↗(On Diff #179604)

I think that this works, but...

Please add a comment to PromoteIntRes_ADDSUBCARRY stating that it is also handling promotion for the ADDE/SUBE nodes (which differ from the ADDCARRY/SUBCARRY nodes in that the third operand is the input carry flag instead of a carry Boolean).

LGTM.

This revision is now accepted and ready to land.Dec 28 2018, 6:37 AM
ZhangKang updated this revision to Diff 179643.Dec 28 2018, 9:22 AM

Add the comments for PromoteIntRes_ADDSUBCARRY.

ZhangKang marked 2 inline comments as done.Dec 28 2018, 9:23 AM
ZhangKang added inline comments.
llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
146 ↗(On Diff #179604)

I have added comments for PromoteIntRes_ADDSUBCARRY.

jsji added inline comments.Dec 28 2018, 9:51 AM
llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
871 ↗(On Diff #179643)

typo: noes -> nodes

ZhangKang updated this revision to Diff 179687.Dec 29 2018, 5:52 AM
ZhangKang marked an inline comment as done.

Modify the spelling erros.

ZhangKang marked 2 inline comments as done.Dec 29 2018, 5:53 AM
ZhangKang added inline comments.
llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
871 ↗(On Diff #179643)

Done.

ZhangKang marked an inline comment as done.Dec 29 2018, 5:54 AM
ZhangKang edited the summary of this revision. (Show Details)Dec 29 2018, 11:16 PM
This revision was automatically updated to reflect the committed changes.