summaryrefslogtreecommitdiffstats
path: root/llvm/lib/IR
diff options
context:
space:
mode:
authorSanjay Patel <spatel@rotateright.com>2018-07-03 13:44:22 +0000
committerSanjay Patel <spatel@rotateright.com>2018-07-03 13:44:22 +0000
commit3074b9e53f46f7ea398b34c325553dcccf02607a (patch)
treee3ab572ec741b29695e26be1fcbebb03bc52e33b /llvm/lib/IR
parentffc1681620881901eb064046234e61b0ea4a6df4 (diff)
downloadbcm5719-llvm-3074b9e53f46f7ea398b34c325553dcccf02607a.tar.gz
bcm5719-llvm-3074b9e53f46f7ea398b34c325553dcccf02607a.zip
[InstCombine] fold shuffle-with-binop and common value
This is the last significant change suggested in PR37806: https://bugs.llvm.org/show_bug.cgi?id=37806#c5 ...though there are several follow-ups noted in the code comments in this patch to complete this transform. It's possible that a binop feeding a select-shuffle has been eliminated by earlier transforms (or the code was just written like this in the 1st place), so we'll fail to match the patterns that have 2 binops from: D48401, D48678, D48662, D48485. In that case, we can try to materialize identity constants for the remaining binop to fill in the "ghost" lanes of the vector (where we just want to pass through the original values of the source operand). I added comments to ConstantExpr::getBinOpIdentity() to show planned follow-ups. For now, we only handle the 5 commutative integer binops (add/mul/and/or/xor). Differential Revision: https://reviews.llvm.org/D48830 llvm-svn: 336196
Diffstat (limited to 'llvm/lib/IR')
-rw-r--r--llvm/lib/IR/Constants.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/llvm/lib/IR/Constants.cpp b/llvm/lib/IR/Constants.cpp
index ad99c0a8587..9b8670c7f3f 100644
--- a/llvm/lib/IR/Constants.cpp
+++ b/llvm/lib/IR/Constants.cpp
@@ -2261,6 +2261,9 @@ Constant *ConstantExpr::getAShr(Constant *C1, Constant *C2, bool isExact) {
isExact ? PossiblyExactOperator::IsExact : 0);
}
+// FIXME: Add a parameter to specify the operand number for non-commutative ops.
+// For example, the operand 1 identity constant for any shift is the null value
+// because shift-by-0 always returns operand 0.
Constant *ConstantExpr::getBinOpIdentity(unsigned Opcode, Type *Ty) {
switch (Opcode) {
default:
@@ -2277,6 +2280,8 @@ Constant *ConstantExpr::getBinOpIdentity(unsigned Opcode, Type *Ty) {
case Instruction::And:
return Constant::getAllOnesValue(Ty);
+
+ // FIXME: FAdd / FMul?
}
}
OpenPOWER on IntegriCloud