[PATCH] D28871: [CodeGenPrep]No negative cost in the ExtLd promotion
Jun Bum Lim via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 27 09:28:02 PST 2017
This revision was automatically updated to reflect the committed changes.
Closed by commit rL293307: [CodeGenPrep]No negative cost in the ExtLd promotion (authored by junbuml).
Changed prior to commit:
https://reviews.llvm.org/D28871?vs=85979&id=86063#toc
Repository:
rL LLVM
https://reviews.llvm.org/D28871
Files:
llvm/trunk/lib/CodeGen/CodeGenPrepare.cpp
llvm/trunk/test/CodeGen/AArch64/arm64-codegen-prepare-extload.ll
Index: llvm/trunk/test/CodeGen/AArch64/arm64-codegen-prepare-extload.ll
===================================================================
--- llvm/trunk/test/CodeGen/AArch64/arm64-codegen-prepare-extload.ll
+++ llvm/trunk/test/CodeGen/AArch64/arm64-codegen-prepare-extload.ll
@@ -636,3 +636,24 @@
%final = add i64 %sextres, %zextLd0
ret i64 %final
}
+
+define i64 @promoteZextShl(i1 %c, i16* %P) {
+entry:
+; OPTALL-LABEL: promoteZextShl
+; OPTALL-LABEL: entry:
+; OPT: %[[LD:.*]] = load i16, i16* %P
+; OPT: %[[EXT:.*]] = zext i16 %[[LD]] to i64
+; OPT-LABEL: if.then:
+; OPT: shl nsw i64 %[[EXT]], 1
+; DISABLE-LABEL: if.then:
+; DISABLE: %r = sext i32 %shl2 to i64
+ %ld = load i16, i16* %P
+ br i1 %c, label %end, label %if.then
+if.then:
+ %z = zext i16 %ld to i32
+ %shl2 = shl nsw i32 %z, 1
+ %r = sext i32 %shl2 to i64
+ ret i64 %r
+end:
+ ret i64 0
+}
Index: llvm/trunk/lib/CodeGen/CodeGenPrepare.cpp
===================================================================
--- llvm/trunk/lib/CodeGen/CodeGenPrepare.cpp
+++ llvm/trunk/lib/CodeGen/CodeGenPrepare.cpp
@@ -4297,7 +4297,10 @@
// one extension but leave one. However, we optimistically keep going,
// because the new extension may be removed too.
long long TotalCreatedInstsCost = CreatedInstsCost + NewCreatedInstsCost;
- TotalCreatedInstsCost -= ExtCost;
+ // FIXME: It would be possible to propagate a negative value instead of
+ // conservatively ceiling it to 0.
+ TotalCreatedInstsCost =
+ std::max((long long)0, (TotalCreatedInstsCost - ExtCost));
if (!StressExtLdPromotion &&
(TotalCreatedInstsCost > 1 ||
!isPromotedInstructionLegal(*TLI, *DL, PromotedVal))) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D28871.86063.patch
Type: text/x-patch
Size: 1711 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170127/8a721ca2/attachment.bin>
More information about the llvm-commits
mailing list