From 029e84caf411eeaf5a458af0a987708500ec1ab5 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Thu, 10 Dec 2015 00:37:51 +0000 Subject: [PATCH] PeepholeOptimizer: Ignore dead implicit defs Target-specific instructions may have uninteresting physreg clobbers, for target-specific reasons. The peephole pass doesn't need to concern itself with such defs, as long as they're implicit and marked as dead. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@255182 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/PeepholeOptimizer.cpp | 6 ++++++ test/CodeGen/WebAssembly/conv.ll | 28 ++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/lib/CodeGen/PeepholeOptimizer.cpp b/lib/CodeGen/PeepholeOptimizer.cpp index 0fabc40b64e..f861edf7da2 100644 --- a/lib/CodeGen/PeepholeOptimizer.cpp +++ b/lib/CodeGen/PeepholeOptimizer.cpp @@ -1343,6 +1343,9 @@ bool PeepholeOptimizer::foldImmediate(MachineInstr *MI, MachineBasicBlock *MBB, MachineOperand &MO = MI->getOperand(i); if (!MO.isReg() || MO.isDef()) continue; + // Ignore dead implicit defs. + if (MO.isImplicit() && MO.isDead()) + continue; unsigned Reg = MO.getReg(); if (!TargetRegisterInfo::isVirtualRegister(Reg)) continue; @@ -1703,6 +1706,9 @@ ValueTrackerResult ValueTracker::getNextSourceFromBitcast() { const MachineOperand &MO = Def->getOperand(OpIdx); if (!MO.isReg() || !MO.getReg()) continue; + // Ignore dead implicit defs. + if (MO.isImplicit() && MO.isDead()) + continue; assert(!MO.isDef() && "We should have skipped all the definitions by now"); if (SrcIdx != EndOpIdx) // Multiple sources? diff --git a/test/CodeGen/WebAssembly/conv.ll b/test/CodeGen/WebAssembly/conv.ll index 76fa38090a1..e1acaca2c9e 100644 --- a/test/CodeGen/WebAssembly/conv.ll +++ b/test/CodeGen/WebAssembly/conv.ll @@ -225,3 +225,31 @@ define i64 @anyext(i32 %x) { %w = shl i64 %y, 32 ret i64 %w } + +; CHECK-LABEL: bitcast_i32_to_float: +; CHECK: f32.reinterpret/i32 $push0=, $0{{$}} +define float @bitcast_i32_to_float(i32 %a) { + %t = bitcast i32 %a to float + ret float %t +} + +; CHECK-LABEL: bitcast_float_to_i32: +; CHECK: i32.reinterpret/f32 $push0=, $0{{$}} +define i32 @bitcast_float_to_i32(float %a) { + %t = bitcast float %a to i32 + ret i32 %t +} + +; CHECK-LABEL: bitcast_i64_to_double: +; CHECK: f64.reinterpret/i64 $push0=, $0{{$}} +define double @bitcast_i64_to_double(i64 %a) { + %t = bitcast i64 %a to double + ret double %t +} + +; CHECK-LABEL: bitcast_double_to_i64: +; CHECK: i64.reinterpret/f64 $push0=, $0{{$}} +define i64 @bitcast_double_to_i64(double %a) { + %t = bitcast double %a to i64 + ret i64 %t +} -- 2.11.0