[PATCH] D65542: [PeepholeOptimizer] Don't assume bitcast def always has input
Jinsong Ji via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 15 10:05:16 PDT 2019
jsji updated this revision to Diff 215423.
jsji added a comment.
Herald added a subscriber: steven.zhang.
Rebased to latest ToT.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D65542/new/
https://reviews.llvm.org/D65542
Files:
llvm/lib/CodeGen/PeepholeOptimizer.cpp
llvm/lib/Target/PowerPC/PPCInstrVSX.td
llvm/test/CodeGen/PowerPC/bitcast-peelhole.ll
Index: llvm/test/CodeGen/PowerPC/bitcast-peelhole.ll
===================================================================
--- /dev/null
+++ llvm/test/CodeGen/PowerPC/bitcast-peelhole.ll
@@ -0,0 +1,13 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; REQUIRES: asserts
+; RUN: llc -mcpu=pwr9 -ppc-asm-full-reg-names -ppc-vsr-nums-as-vr \
+; RUN: -mtriple=powerpc64le-unknown-unknown < %s | FileCheck %s
+
+define < 4 x i32> @bitCast() {
+; CHECK-LABEL: bitCast:
+; CHECK: # %bb.0: # %entry
+; CHECK-NEXT: xxleqv v2, v2, v2
+; CHECK-NEXT: blr
+entry:
+ ret < 4 x i32> <i32 -1, i32 -1,i32 -1,i32 -1 >
+}
Index: llvm/lib/Target/PowerPC/PPCInstrVSX.td
===================================================================
--- llvm/lib/Target/PowerPC/PPCInstrVSX.td
+++ llvm/lib/Target/PowerPC/PPCInstrVSX.td
@@ -1314,7 +1314,7 @@
isReMaterializable = 1 in {
def XXLEQVOnes : XX3Form_SameOp<60, 186, (outs vsrc:$XT), (ins),
"xxleqv $XT, $XT, $XT", IIC_VecGeneral,
- [(set v4i32:$XT, (v4i32 immAllOnesV))]>;
+ [(set v4i32:$XT, (bitconvert (v16i8 immAllOnesV)))]>;
}
def XXLORC : XX3Form<60, 170,
@@ -4103,8 +4103,6 @@
}
let Predicates = [HasP8Vector] in {
- def : Pat<(v4i32 (bitconvert (v16i8 immAllOnesV))),
- (XXLEQVOnes)>;
def : Pat<(v1i128 (bitconvert (v16i8 immAllOnesV))),
(v1i128 (COPY_TO_REGCLASS(XXLEQVOnes), VSRC))>;
def : Pat<(v2i64 (bitconvert (v16i8 immAllOnesV))),
Index: llvm/lib/CodeGen/PeepholeOptimizer.cpp
===================================================================
--- llvm/lib/CodeGen/PeepholeOptimizer.cpp
+++ llvm/lib/CodeGen/PeepholeOptimizer.cpp
@@ -1853,6 +1853,11 @@
SrcIdx = OpIdx;
}
+ // In some rare case, Def has no input, SrcIdx is out of bound,
+ // getOperand(SrcIdx) will fail below.
+ if (SrcIdx >= Def->getNumOperands())
+ return ValueTrackerResult();
+
// Stop when any user of the bitcast is a SUBREG_TO_REG, replacing with a COPY
// will break the assumed guarantees for the upper bits.
for (const MachineInstr &UseMI : MRI.use_nodbg_instructions(DefOp.getReg())) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D65542.215423.patch
Type: text/x-patch
Size: 2223 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190815/adea5ba4/attachment.bin>
More information about the llvm-commits
mailing list