[PATCH] D47927: [WIP][TargetLowering] Simplify expansion of S{ADD,SUB}O
Roman Lebedev via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 8 13:45:14 PDT 2019
lebedev.ri accepted this revision.
lebedev.ri added a comment.
This revision is now accepted and ready to land.
Though the current expansion is just as incorrect for `undef`:
----------------------------------------
Name: sadd
%t = sadd_overflow i8 %LHS, %RHS
%v0 = extractvalue {i8, i1} %t, 0
%v1 = extractvalue {i8, i1} %t, 1
=>
%t = sadd_overflow i8 %LHS, %RHS
%v0 = add i8 %LHS, %RHS
%LHSSign = icmp sge i8 %LHS, 0
%RHSSign = icmp sge i8 %RHS, 0
%SignsMatch = icmp eq i1 %LHSSign, %RHSSign
%SumSign = icmp sge i8 %v0, 0
%SumSignNE = icmp ne i1 %LHSSign, %SumSign
%v1 = and i1 %SignsMatch, %SumSignNE
Done: 1
Optimization is correct!
----------------------------------------
Name: ssub
%t = ssub_overflow i8 %LHS, %RHS
%v0 = extractvalue {i8, i1} %t, 0
%v1 = extractvalue {i8, i1} %t, 1
=>
%t = ssub_overflow i8 %LHS, %RHS
%v0 = sub i8 %LHS, %RHS
%LHSSign = icmp sge i8 %LHS, 0
%RHSSign = icmp sge i8 %RHS, 0
%SignsMatch = icmp ne i1 %LHSSign, %RHSSign
%SumSign = icmp sge i8 %v0, 0
%SumSignNE = icmp ne i1 %LHSSign, %SumSign
%v1 = and i1 %SignsMatch, %SumSignNE
Done: 1
Optimization is correct!
----------------------------------------
Name: sadd
%t = sadd_overflow i8 %LHS, %RHS
%v0 = extractvalue {i8, i1} %t, 0
%v1 = extractvalue {i8, i1} %t, 1
=>
%t = sadd_overflow i8 %LHS, %RHS
%v0 = add i8 %LHS, %RHS
%LHSSign = icmp sge i8 %LHS, 0
%RHSSign = icmp sge i8 %RHS, 0
%SignsMatch = icmp eq i1 %LHSSign, %RHSSign
%SumSign = icmp sge i8 %v0, 0
%SumSignNE = icmp ne i1 %LHSSign, %SumSign
%v1 = and i1 %SignsMatch, %SumSignNE
ERROR: Value mismatch for i1 %v1
Example:
i8 %LHS = #x00 (0)
i8 %RHS = undef
{i8, i1} %t = { #x00 (0), #x0 (0) } [based on undef value]
i8 %v0 = undef
i1 %LHSSign = #x1 (1)
i1 %RHSSign = undef
i1 %SignsMatch = undef
i1 %SumSign = undef
i1 %SumSignNE = undef
Source value: #x0 (0)
Target value: #x1 (1)
----------------------------------------
Name: ssub
%t = ssub_overflow i8 %LHS, %RHS
%v0 = extractvalue {i8, i1} %t, 0
%v1 = extractvalue {i8, i1} %t, 1
=>
%t = ssub_overflow i8 %LHS, %RHS
%v0 = sub i8 %LHS, %RHS
%LHSSign = icmp sge i8 %LHS, 0
%RHSSign = icmp sge i8 %RHS, 0
%SignsMatch = icmp ne i1 %LHSSign, %RHSSign
%SumSign = icmp sge i8 %v0, 0
%SumSignNE = icmp ne i1 %LHSSign, %SumSign
%v1 = and i1 %SignsMatch, %SumSignNE
ERROR: Value mismatch for i1 %v1
Example:
i8 %LHS = undef
i8 %RHS = #x00 (0)
{i8, i1} %t = { #x00 (0), #x0 (0) } [based on undef value]
i8 %v0 = undef
i1 %LHSSign = undef
i1 %RHSSign = #x1 (1)
i1 %SignsMatch = undef
i1 %SumSign = undef
i1 %SumSignNE = undef
Source value: #x0 (0)
Target value: #x1 (1)
So LG i guess..
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D47927/new/
https://reviews.llvm.org/D47927
More information about the llvm-commits
mailing list