llvm.org GIT mirror llvm / 41e2c98
[WebAssembly] Switch to MC for instruction printing. This encompasses several changes which are all interconnected: - Use the MC framework for printing almost all instructions. - AsmStrings are now live. - This introduces an indirection between LLVM vregs and WebAssembly registers, and a new pass, WebAssemblyRegNumbering, for computing a basic the mapping. This addresses some basic issues with argument registers and unused registers. - The way ARGUMENT instructions are handled no longer generates redundant get_local+set_local for every argument. This also changes the assembly syntax somewhat; most notably, MC's printing use sigils on label names, so those are no longer present, and push/pop now have a sigil to keep them unambiguous. The usage of set_local/get_local/$push/$pop will continue to evolve significantly. This patch is just one step of a larger change. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@252858 91177308-0d34-0410-b5e6-96231b3b80d8 Dan Gohman 4 years ago
38 changed file(s) with 747 addition(s) and 1077 deletion(s). Raw diff Collapse all Expand all
2020 WebAssemblyMachineFunctionInfo.cpp
2121 WebAssemblyMCInstLower.cpp
2222 WebAssemblyRegisterInfo.cpp
23 WebAssemblyRegNumbering.cpp
2324 WebAssemblySelectionDAGInfo.cpp
2425 WebAssemblySubtarget.cpp
2526 WebAssemblyTargetMachine.cpp
3535
3636 void WebAssemblyInstPrinter::printRegName(raw_ostream &OS,
3737 unsigned RegNo) const {
38 if (TargetRegisterInfo::isPhysicalRegister(RegNo))
39 OS << getRegisterName(RegNo);
40 else
41 OS << TargetRegisterInfo::virtReg2Index(RegNo);
38 // FIXME: Revisit whether we actually print the get_local explicitly.
39 OS << "(get_local " << RegNo << ")";
4240 }
4341
4442 void WebAssemblyInstPrinter::printInst(const MCInst *MI, raw_ostream &OS,
4543 StringRef Annot,
4644 const MCSubtargetInfo &STI) {
4745 printInstruction(MI, OS);
46
47 const MCInstrDesc &Desc = MII.get(MI->getOpcode());
48 if (Desc.isVariadic())
49 for (unsigned i = Desc.getNumOperands(), e = MI->getNumOperands(); i < e;
50 ++i) {
51 OS << ", ";
52 printOperand(MI, i, OS);
53 }
54
4855 printAnnotation(OS, Annot);
4956
5057 unsigned NumDefs = MII.get(MI->getOpcode()).getNumDefs();
5158 assert(NumDefs <= 1 &&
5259 "Instructions with multiple result values not implemented");
5360
54 if (NumDefs != 0) {
61 // FIXME: Revisit whether we actually print the set_local explicitly.
62 if (NumDefs != 0)
5563 OS << "\n"
56 "\t" "set_local ";
57 printRegName(OS, MI->getOperand(0).getReg());
58 OS << ", pop";
59 }
64 "\t" "set_local " << MI->getOperand(0).getReg() << ", $pop";
65 }
66
67 static std::string toString(const APFloat &FP) {
68 static const size_t BufBytes = 128;
69 char buf[BufBytes];
70 if (FP.isNaN())
71 assert((FP.bitwiseIsEqual(APFloat::getQNaN(FP.getSemantics())) ||
72 FP.bitwiseIsEqual(
73 APFloat::getQNaN(FP.getSemantics(), /*Negative=*/true))) &&
74 "convertToHexString handles neither SNaN nor NaN payloads");
75 // Use C99's hexadecimal floating-point representation.
76 auto Written = FP.convertToHexString(
77 buf, /*hexDigits=*/0, /*upperCase=*/false, APFloat::rmNearestTiesToEven);
78 (void)Written;
79 assert(Written != 0);
80 assert(Written < BufBytes);
81 return buf;
6082 }
6183
6284 void WebAssemblyInstPrinter::printOperand(const MCInst *MI, unsigned OpNo,
6486 const MCOperand &Op = MI->getOperand(OpNo);
6587 if (Op.isReg()) {
6688 if (OpNo < MII.get(MI->getOpcode()).getNumDefs())
67 O << "push";
89 O << "$push";
6890 else
6991 printRegName(O, Op.getReg());
7092 } else if (Op.isImm())
71 O << '#' << Op.getImm();
93 O << Op.getImm();
7294 else if (Op.isFPImm())
73 O << '#' << Op.getFPImm();
95 O << toString(APFloat(Op.getFPImm()));
7496 else {
7597 assert(Op.isExpr() && "unknown operand kind in printOperand");
7698 Op.getExpr()->print(O, &MAI);
2626 CodeGenOpt::Level OptLevel);
2727
2828 FunctionPass *createWebAssemblyCFGStackify();
29 FunctionPass *createWebAssemblyRegNumbering();
2930
3031 FunctionPass *createWebAssemblyRelooper();
3132
1414 //===----------------------------------------------------------------------===//
1515
1616 #include "WebAssembly.h"
17 #include "InstPrinter/WebAssemblyInstPrinter.h"
18 #include "MCTargetDesc/WebAssemblyMCTargetDesc.h"
19 #include "WebAssemblyMCInstLower.h"
1720 #include "WebAssemblyMachineFunctionInfo.h"
1821 #include "WebAssemblyRegisterInfo.h"
1922 #include "WebAssemblySubtarget.h"
20 #include "InstPrinter/WebAssemblyInstPrinter.h"
21 #include "MCTargetDesc/WebAssemblyMCTargetDesc.h"
22
2323 #include "llvm/ADT/SmallString.h"
2424 #include "llvm/ADT/StringExtras.h"
2525 #include "llvm/CodeGen/Analysis.h"
2727 #include "llvm/CodeGen/MachineConstantPool.h"
2828 #include "llvm/CodeGen/MachineInstr.h"
2929 #include "llvm/IR/DataLayout.h"
30 #include "llvm/IR/DebugInfo.h"
30 #include "llvm/MC/MCContext.h"
3131 #include "llvm/MC/MCStreamer.h"
3232 #include "llvm/MC/MCSymbol.h"
3333 #include "llvm/Support/Debug.h"
4141 namespace {
4242
4343 class WebAssemblyAsmPrinter final : public AsmPrinter {
44 const WebAssemblyInstrInfo *TII;
4544 const MachineRegisterInfo *MRI;
46 unsigned NumArgs;
45 const WebAssemblyFunctionInfo *MFI;
4746
4847 public:
4948 WebAssemblyAsmPrinter(TargetMachine &TM, std::unique_ptr Streamer)
50 : AsmPrinter(TM, std::move(Streamer)), TII(nullptr), MRI(nullptr) {}
49 : AsmPrinter(TM, std::move(Streamer)), MRI(nullptr), MFI(nullptr) {}
5150
5251 private:
5352 const char *getPassName() const override {
6362 }
6463
6564 bool runOnMachineFunction(MachineFunction &MF) override {
66 const auto &Subtarget = MF.getSubtarget();
67 TII = Subtarget.getInstrInfo();
6865 MRI = &MF.getRegInfo();
69 NumArgs = MF.getInfo()->getParams().size();
66 MFI = MF.getInfo();
7067 return AsmPrinter::runOnMachineFunction(MF);
7168 }
7269
8178 void EmitEndOfAsmFile(Module &M) override;
8279
8380 std::string getRegTypeName(unsigned RegNo) const;
84 static std::string toString(const APFloat &APF);
8581 const char *toString(MVT VT) const;
8682 std::string regToString(const MachineOperand &MO);
87 std::string argToString(const MachineOperand &MO);
8883 };
8984
9085 } // end anonymous namespace
9287 //===----------------------------------------------------------------------===//
9388 // Helpers.
9489 //===----------------------------------------------------------------------===//
95
96 // Operand type (if any), followed by the lower-case version of the opcode's
97 // name matching the names WebAssembly opcodes are expected to have. The
98 // tablegen names are uppercase and suffixed with their type (after an
99 // underscore). Conversions are additionally prefixed with their input type
100 // (before a double underscore).
101 static std::string OpcodeName(const WebAssemblyInstrInfo *TII,
102 const MachineInstr *MI) {
103 std::string N(StringRef(TII->getName(MI->getOpcode())).lower());
104 std::string::size_type Len = N.length();
105 std::string::size_type Under = N.rfind('_');
106 bool HasType = std::string::npos != Under;
107 std::string::size_type NameEnd = HasType ? Under : Len;
108 std::string Name(&N[0], &N[NameEnd]);
109 if (!HasType)
110 return Name;
111 for (const char *typelessOpcode : { "return", "call", "br_if" })
112 if (Name == typelessOpcode)
113 return Name;
114 std::string Type(&N[NameEnd + 1], &N[Len]);
115 std::string::size_type DoubleUnder = Name.find("__");
116 bool IsConv = std::string::npos != DoubleUnder;
117 if (!IsConv)
118 return Type + '.' + Name;
119 std::string InType(&Name[0], &Name[DoubleUnder]);
120 return Type + '.' + std::string(&Name[DoubleUnder + 2], &Name[NameEnd]) +
121 '/' + InType;
122 }
123
124 static std::string toSymbol(StringRef S) { return ("$" + S).str(); }
12590
12691 std::string WebAssemblyAsmPrinter::getRegTypeName(unsigned RegNo) const {
12792 const TargetRegisterClass *TRC = MRI->getRegClass(RegNo);
13398 return "?";
13499 }
135100
136 std::string WebAssemblyAsmPrinter::toString(const APFloat &FP) {
137 static const size_t BufBytes = 128;
138 char buf[BufBytes];
139 if (FP.isNaN())
140 assert((FP.bitwiseIsEqual(APFloat::getQNaN(FP.getSemantics())) ||
141 FP.bitwiseIsEqual(
142 APFloat::getQNaN(FP.getSemantics(), /*Negative=*/true))) &&
143 "convertToHexString handles neither SNaN nor NaN payloads");
144 // Use C99's hexadecimal floating-point representation.
145 auto Written = FP.convertToHexString(
146 buf, /*hexDigits=*/0, /*upperCase=*/false, APFloat::rmNearestTiesToEven);
147 (void)Written;
148 assert(Written != 0);
149 assert(Written < BufBytes);
150 return buf;
151 }
152
153101 std::string WebAssemblyAsmPrinter::regToString(const MachineOperand &MO) {
154102 unsigned RegNo = MO.getReg();
155103 if (TargetRegisterInfo::isPhysicalRegister(RegNo))
156104 return WebAssemblyInstPrinter::getRegisterName(RegNo);
157105
158 // WebAssembly arguments and local variables are in the same index space, and
159 // there are no explicit varargs, so we just add the number of arguments to
160 // the virtual register number to get the local variable number.
161 return utostr(TargetRegisterInfo::virtReg2Index(RegNo) + NumArgs);
162 }
163
164 std::string WebAssemblyAsmPrinter::argToString(const MachineOperand &MO) {
165 unsigned ArgNo = MO.getImm();
166 // Same as above, but we don't need to add NumArgs here.
167 return utostr(ArgNo);
106 return utostr(MFI->getWAReg(RegNo));
168107 }
169108
170109 const char *WebAssemblyAsmPrinter::toString(MVT VT) const {
202141 SmallString<128> Str;
203142 raw_svector_ostream OS(Str);
204143
205 for (MVT VT : MF->getInfo()->getParams())
206 OS << "\t" ".param "
207 << toString(VT) << '\n';
208 for (MVT VT : MF->getInfo()->getResults())
209 OS << "\t" ".result "
210 << toString(VT) << '\n';
144 for (MVT VT : MFI->getParams())
145 OS << "\t" ".param " << toString(VT) << '\n';
146 for (MVT VT : MFI->getResults())
147 OS << "\t" ".result " << toString(VT) << '\n';
211148
212149 bool FirstVReg = true;
213150 for (unsigned Idx = 0, IdxE = MRI->getNumVirtRegs(); Idx != IdxE; ++Idx) {
214151 unsigned VReg = TargetRegisterInfo::index2VirtReg(Idx);
215 // FIXME: Don't skip dead virtual registers for now: that would require
216 // remapping all locals' numbers.
217 // if (!MRI->use_empty(VReg)) {
218 if (FirstVReg)
219 OS << "\t" ".local ";
220 else
221 OS << ", ";
222 OS << getRegTypeName(VReg);
223 FirstVReg = false;
224 //}
152 if (!MRI->use_empty(VReg)) {
153 if (FirstVReg)
154 OS << "\t" ".local ";
155 else
156 OS << ", ";
157 OS << getRegTypeName(VReg);
158 FirstVReg = false;
159 }
225160 }
226161 if (!FirstVReg)
227162 OS << '\n';
235170
236171 void WebAssemblyAsmPrinter::EmitInstruction(const MachineInstr *MI) {
237172 DEBUG(dbgs() << "EmitInstruction: " << *MI << '\n');
238 SmallString<128> Str;
239 raw_svector_ostream OS(Str);
240173
241174 unsigned NumDefs = MI->getDesc().getNumDefs();
242175 assert(NumDefs <= 1 &&
243176 "Instructions with multiple result values not implemented");
244177
245 OS << '\t';
246
247178 switch (MI->getOpcode()) {
248 case TargetOpcode::COPY:
249 OS << "get_local push, " << regToString(MI->getOperand(1));
250 break;
179 case TargetOpcode::COPY: {
180 // TODO: Figure out a way to lower COPY instructions to MCInst form.
181 SmallString<128> Str;
182 raw_svector_ostream OS(Str);
183 OS << "\t" "set_local " << regToString(MI->getOperand(0)) << ", "
184 "(get_local " << regToString(MI->getOperand(1)) << ")";
185 OutStreamer->EmitRawText(OS.str());
186 break;
187 }
251188 case WebAssembly::ARGUMENT_I32:
252189 case WebAssembly::ARGUMENT_I64:
253190 case WebAssembly::ARGUMENT_F32:
254191 case WebAssembly::ARGUMENT_F64:
255 OS << "get_local push, " << argToString(MI->getOperand(1));
192 // These represent values which are live into the function entry, so there's
193 // no instruction to emit.
256194 break;
257195 default: {
258 OS << OpcodeName(TII, MI);
259 bool NeedComma = false;
260 bool DefsPushed = false;
261 if (NumDefs != 0 && !MI->isCall()) {
262 OS << " push";
263 NeedComma = true;
264 DefsPushed = true;
265 }
266 for (const MachineOperand &MO : MI->uses()) {
267 if (MO.isReg() && MO.isImplicit())
268 continue;
269 if (NeedComma)
270 OS << ',';
271 NeedComma = true;
272 OS << ' ';
273 switch (MO.getType()) {
274 default:
275 llvm_unreachable("unexpected machine operand type");
276 case MachineOperand::MO_Register:
277 OS << "(get_local " << regToString(MO) << ')';
278 break;
279 case MachineOperand::MO_Immediate:
280 OS << MO.getImm();
281 break;
282 case MachineOperand::MO_FPImmediate:
283 OS << toString(MO.getFPImm()->getValueAPF());
284 break;
285 case MachineOperand::MO_GlobalAddress:
286 OS << toSymbol(MO.getGlobal()->getName());
287 break;
288 case MachineOperand::MO_MachineBasicBlock:
289 OS << toSymbol(MO.getMBB()->getSymbol()->getName());
290 break;
291 }
292 if (NumDefs != 0 && !DefsPushed) {
293 // Special-case for calls; print the push after the callee.
294 assert(MI->isCall());
295 OS << ", push";
296 DefsPushed = true;
297 }
298 }
299 break;
300 }
301 }
302
303 OutStreamer->EmitRawText(OS.str());
304
305 if (NumDefs != 0) {
306 SmallString<128> Str;
307 raw_svector_ostream OS(Str);
308 const MachineOperand &Operand = MI->getOperand(0);
309 OS << "\tset_local " << regToString(Operand) << ", pop";
310 OutStreamer->EmitRawText(OS.str());
196 WebAssemblyMCInstLower MCInstLowering(OutContext, *this);
197 MCInst TmpInst;
198 MCInstLowering.Lower(MI, TmpInst);
199 EmitToStreamer(*OutStreamer, TmpInst);
200 break;
201 }
311202 }
312203 }
313204
339230 if (Str.empty())
340231 OS << "\t.imports\n";
341232
342 OS << "\t.import " << toSymbol(F.getName()) << " \"\" \"" << F.getName()
343 << "\"";
233 MCSymbol *Sym = OutStreamer->getContext().getOrCreateSymbol(F.getName());
234 OS << "\t.import " << *Sym << " \"\" " << *Sym;
344235
345236 const WebAssemblyTargetLowering &TLI =
346237 *TM.getSubtarget(F).getTargetLowering();
2222
2323 multiclass CALL {
2424 def CALL_#vt : I<(outs vt:$dst), (ins global:$callee, variable_ops),
25 [(set vt:$dst, (WebAssemblycall1 (WebAssemblywrapper tglobaladdr:$callee)))]>;
25 [(set vt:$dst, (WebAssemblycall1 (WebAssemblywrapper tglobaladdr:$callee)))],
26 "call $callee, $dst">;
2627 def CALL_INDIRECT_#vt : I<(outs vt:$dst), (ins I32:$callee, variable_ops),
27 [(set vt:$dst, (WebAssemblycall1 I32:$callee))]>;
28 [(set vt:$dst, (WebAssemblycall1 I32:$callee))],
29 "call_indirect $callee, $dst">;
2830 }
2931 let Uses = [SP32, SP64], isCall = 1 in {
3032 defm : CALL;
3335 defm : CALL;
3436
3537 def CALL_VOID : I<(outs), (ins global:$callee, variable_ops),
36 [(WebAssemblycall0 (WebAssemblywrapper tglobaladdr:$callee))]>;
38 [(WebAssemblycall0 (WebAssemblywrapper tglobaladdr:$callee))],
39 "call $callee">;
3740 def CALL_INDIRECT_VOID : I<(outs), (ins I32:$callee, variable_ops),
38 [(WebAssemblycall0 I32:$callee)]>;
41 [(WebAssemblycall0 I32:$callee)],
42 "call_indirect $callee">;
3943 } // Uses = [SP32,SP64], isCall = 1
4044
4145 /*
4040 // currently.
4141 let isTerminator = 1, hasCtrlDep = 1, isBarrier = 1 in {
4242 def SWITCH_I32 : I<(outs), (ins I32:$index, variable_ops),
43 [(WebAssemblyswitch I32:$index)]>;
43 [(WebAssemblyswitch I32:$index)],
44 "switch $index">;
4445 def SWITCH_I64 : I<(outs), (ins I64:$index, variable_ops),
45 [(WebAssemblyswitch I64:$index)]>;
46 [(WebAssemblyswitch I64:$index)],
47 "switch $index">;
4648 } // isTerminator = 1, hasCtrlDep = 1, isBarrier = 1
4749
4850 // Placemarkers to indicate the start of a block or loop scope.
1313 //===----------------------------------------------------------------------===//
1414
1515 #include "WebAssemblyMCInstLower.h"
16 #include "WebAssemblyMachineFunctionInfo.h"
1617 #include "llvm/ADT/SmallString.h"
17 #include "llvm/IR/Constants.h"
1818 #include "llvm/CodeGen/AsmPrinter.h"
1919 #include "llvm/CodeGen/MachineBasicBlock.h"
20 #include "llvm/CodeGen/MachineFunction.h"
2021 #include "llvm/CodeGen/MachineInstr.h"
22 #include "llvm/IR/Constants.h"
2123 #include "llvm/MC/MCAsmInfo.h"
2224 #include "llvm/MC/MCContext.h"
2325 #include "llvm/MC/MCExpr.h"
5456 default:
5557 MI->dump();
5658 llvm_unreachable("unknown operand type");
57 case MachineOperand::MO_Register:
59 case MachineOperand::MO_Register: {
5860 // Ignore all implicit register operands.
5961 if (MO.isImplicit())
6062 continue;
61 MCOp = MCOperand::createReg(MO.getReg());
63 // TODO: Handle physical registers.
64 const WebAssemblyFunctionInfo &MFI =
65 *MI->getParent()->getParent()->getInfo();
66 unsigned WAReg = MFI.getWAReg(MO.getReg());
67 MCOp = MCOperand::createReg(WAReg);
6268 break;
69 }
6370 case MachineOperand::MO_Immediate:
6471 MCOp = MCOperand::createImm(MO.getImm());
6572 break;
66 case MachineOperand::MO_FPImmediate:
67 MCOp = MCOperand::createFPImm(
68 MO.getFPImm()->getValueAPF().convertToDouble());
73 case MachineOperand::MO_FPImmediate: {
74 // TODO: MC converts all floating point immediate operands to double.
75 // This is fine for numeric values, but may cause NaNs to change bits.
76 const ConstantFP *Imm = MO.getFPImm();
77 if (Imm->getType()->isFloatTy())
78 MCOp = MCOperand::createFPImm(Imm->getValueAPF().convertToFloat());
79 else if (Imm->getType()->isDoubleTy())
80 MCOp = MCOperand::createFPImm(Imm->getValueAPF().convertToDouble());
81 else
82 llvm_unreachable("unknown floating point immediate type");
6983 break;
84 }
7085 case MachineOperand::MO_MachineBasicBlock:
7186 MCOp = MCOperand::createExpr(
7287 MCSymbolRefExpr::create(MO.getMBB()->getSymbol(), Ctx));
7388 break;
74 case MachineOperand::MO_RegisterMask:
75 continue;
7689 case MachineOperand::MO_GlobalAddress:
7790 MCOp = LowerSymbolOperand(MO, GetGlobalAddressSymbol(MO));
7891 break;
2929 std::vector Params;
3030 std::vector Results;
3131
32 /// A mapping from CodeGen vreg index to WebAssembly register number.
33 std::vector WARegs;
34
3235 public:
33 explicit WebAssemblyFunctionInfo(MachineFunction &MF)
34 : MF(MF) {}
36 explicit WebAssemblyFunctionInfo(MachineFunction &MF) : MF(MF) {}
3537 ~WebAssemblyFunctionInfo() override;
3638
3739 void addParam(MVT VT) { Params.push_back(VT); }
3941
4042 void addResult(MVT VT) { Results.push_back(VT); }
4143 const std::vector &getResults() const { return Results; }
44
45 void initWARegs() {
46 assert(WARegs.empty());
47 WARegs.resize(MF.getRegInfo().getNumVirtRegs(), -1u);
48 }
49 void setWAReg(unsigned VReg, unsigned WAReg) {
50 WARegs[TargetRegisterInfo::virtReg2Index(VReg)] = WAReg;
51 }
52 unsigned getWAReg(unsigned VReg) const {
53 return WARegs[TargetRegisterInfo::virtReg2Index(VReg)];
54 }
4255 };
4356
4457 } // end namespace llvm
174174
175175 void WebAssemblyPassConfig::addPreEmitPass() {
176176 addPass(createWebAssemblyCFGStackify());
177 addPass(createWebAssemblyRegNumbering());
177178 }
1515 ; CHECK-LABEL: call_i32_nullary:
1616 ; CHECK-NEXT: .result i32
1717 ; CHECK-NEXT: .local i32
18 ; CHECK-NEXT: call $i32_nullary, push{{$}}
19 ; CHECK-NEXT: set_local 0, pop
18 ; CHECK-NEXT: call i32_nullary, $push{{$}}
19 ; CHECK-NEXT: set_local 0, $pop
2020 ; CHECK-NEXT: return (get_local 0)
2121 define i32 @call_i32_nullary() {
2222 %r = call i32 @i32_nullary()
2626 ; CHECK-LABEL: call_i64_nullary:
2727 ; CHECK-NEXT: .result i64
2828 ; CHECK-NEXT: .local i64
29 ; CHECK-NEXT: call $i64_nullary, push{{$}}
30 ; CHECK-NEXT: set_local 0, pop
29 ; CHECK-NEXT: call i64_nullary, $push{{$}}
30 ; CHECK-NEXT: set_local 0, $pop
3131 ; CHECK-NEXT: return (get_local 0)
3232 define i64 @call_i64_nullary() {
3333 %r = call i64 @i64_nullary()
3737 ; CHECK-LABEL: call_float_nullary:
3838 ; CHECK-NEXT: .result f32
3939 ; CHECK-NEXT: .local f32
40 ; CHECK-NEXT: call $float_nullary, push{{$}}
41 ; CHECK-NEXT: set_local 0, pop
40 ; CHECK-NEXT: call float_nullary, $push{{$}}
41 ; CHECK-NEXT: set_local 0, $pop
4242 ; CHECK-NEXT: return (get_local 0)
4343 define float @call_float_nullary() {
4444 %r = call float @float_nullary()
4848 ; CHECK-LABEL: call_double_nullary:
4949 ; CHECK-NEXT: .result f64
5050 ; CHECK-NEXT: .local f64
51 ; CHECK-NEXT: call $double_nullary, push{{$}}
52 ; CHECK-NEXT: set_local 0, pop
51 ; CHECK-NEXT: call double_nullary, $push{{$}}
52 ; CHECK-NEXT: set_local 0, $pop
5353 ; CHECK-NEXT: return (get_local 0)
5454 define double @call_double_nullary() {
5555 %r = call double @double_nullary()
5757 }
5858
5959 ; CHECK-LABEL: call_void_nullary:
60 ; CHECK-NEXT: call $void_nullary{{$}}
60 ; CHECK-NEXT: call void_nullary{{$}}
6161 ; CHECK-NEXT: return
6262 define void @call_void_nullary() {
6363 call void @void_nullary()
6868 ; CHECK-NEXT: .param i32
6969 ; CHECK-NEXT: .result i32
7070 ; CHECK-NEXT: .local i32, i32
71 ; CHECK-NEXT: get_local push, 0
72 ; CHECK-NEXT: set_local 1, pop
73 ; CHECK-NEXT: call $i32_unary, push, (get_local 1){{$}}
74 ; CHECK-NEXT: set_local 2, pop
75 ; CHECK-NEXT: return (get_local 2)
71 ; CHECK-NEXT: call i32_unary, $push, (get_local 0){{$}}
72 ; CHECK-NEXT: set_local 1, $pop
73 ; CHECK-NEXT: return (get_local 1)
7674 define i32 @call_i32_unary(i32 %a) {
7775 %r = call i32 @i32_unary(i32 %a)
7876 ret i32 %r
8381 ; CHECK-NEXT: .param i32
8482 ; CHECK-NEXT: .result i32
8583 ; CHECK-NEXT: .local i32, i32, i32
86 ; CHECK-NEXT: get_local push, 1
87 ; CHECK-NEXT: set_local 2, pop
88 ; CHECK-NEXT: get_local push, 0
89 ; CHECK-NEXT: set_local 3, pop
90 ; CHECK-NEXT: call $i32_binary, push, (get_local 3), (get_local 2){{$}}
91 ; CHECK-NEXT: set_local 4, pop
92 ; CHECK-NEXT: return (get_local 4)
84 ; CHECK-NEXT: call i32_binary, $push, (get_local 0), (get_local 1){{$}}
85 ; CHECK-NEXT: set_local 2, $pop
86 ; CHECK-NEXT: return (get_local 2)
9387 define i32 @call_i32_binary(i32 %a, i32 %b) {
9488 %r = call i32 @i32_binary(i32 %a, i32 %b)
9589 ret i32 %r
9892 ; CHECK-LABEL: call_indirect_void:
9993 ; CHECK-NEXT: .param i32
10094 ; CHECK-NEXT: .local i32
101 ; CHECK-NEXT: get_local push, 0
102 ; CHECK-NEXT: set_local 1, pop
103 ; CHECK-NEXT: call_indirect (get_local 1){{$}}
95 ; CHECK-NEXT: call_indirect (get_local 0){{$}}
10496 ; CHECK-NEXT: return
10597 define void @call_indirect_void(void ()* %callee) {
10698 call void %callee()
111103 ; CHECK-NEXT: .param i32
112104 ; CHECK-NEXT: .result i32
113105 ; CHECK-NEXT: .local i32, i32
114 ; CHECK-NEXT: get_local push, 0
115 ; CHECK-NEXT: set_local 1, pop
116 ; CHECK-NEXT: call_indirect (get_local 1), push{{$}}
117 ; CHECK-NEXT: set_local 2, pop
118 ; CHECK-NEXT: return (get_local 2)
106 ; CHECK-NEXT: call_indirect (get_local 0), $push{{$}}
107 ; CHECK-NEXT: set_local 1, $pop
108 ; CHECK-NEXT: return (get_local 1)
119109 define i32 @call_indirect_i32(i32 ()* %callee) {
120110 %t = call i32 %callee()
121111 ret i32 %t
122112 }
123113
124114 ; CHECK-LABEL: tail_call_void_nullary:
125 ; CHECK-NEXT: call $void_nullary{{$}}
115 ; CHECK-NEXT: call void_nullary{{$}}
126116 ; CHECK-NEXT: return{{$}}
127117 define void @tail_call_void_nullary() {
128118 tail call void @void_nullary()
130120 }
131121
132122 ; CHECK-LABEL: fastcc_tail_call_void_nullary:
133 ; CHECK-NEXT: call $void_nullary{{$}}
123 ; CHECK-NEXT: call void_nullary{{$}}
134124 ; CHECK-NEXT: return{{$}}
135125 define void @fastcc_tail_call_void_nullary() {
136126 tail call fastcc void @void_nullary()
138128 }
139129
140130 ; CHECK-LABEL: coldcc_tail_call_void_nullary:
141 ; CHECK-NEXT: call $void_nullary
131 ; CHECK-NEXT: call void_nullary
142132 ; CHECK-NEXT: return{{$}}
143133 define void @coldcc_tail_call_void_nullary() {
144134 tail call coldcc void @void_nullary()
1313 ; CHECK: i32.add
1414 ; CHECK: br_if
1515 ; CHECK: call
16 ; CHECK: br $BB0_1{{$}}
16 ; CHECK: br BB0_1{{$}}
1717 ; CHECK: return{{$}}
1818 define void @test0(i32 %n) {
1919 entry:
4141 ; CHECK: i32.add
4242 ; CHECK: br_if
4343 ; CHECK: call
44 ; CHECK: br $BB1_1{{$}}
44 ; CHECK: br BB1_1{{$}}
4545 ; CHECK: return{{$}}
4646 define void @test1(i32 %n) {
4747 entry:
6565 ; Test that a simple loop is handled as expected.
6666
6767 ; CHECK-LABEL: test2:
68 ; CHECK: block $BB2_2{{$}}
69 ; CHECK: br_if $BB2_2, {{.*}}
68 ; CHECK: block BB2_2{{$}}
69 ; CHECK: br_if BB2_2, {{.*}}
7070 ; CHECK: BB2_1:
71 ; CHECK: br_if $BB2_1, (get_local 16){{$}}
71 ; CHECK: br_if BB2_1, (get_local 10){{$}}
7272 ; CHECK: BB2_2:
7373 ; CHECK: return{{$}}
7474 define void @test2(double* nocapture %p, i32 %n) {
9797 }
9898
9999 ; CHECK-LABEL: doublediamond:
100 ; CHECK: block $BB3_5{{$}}
101 ; CHECK: block $BB3_4{{$}}
102 ; CHECK: block $BB3_2{{$}}
103 ; CHECK: br_if $BB3_2, (get_local 7){{$}}
104 ; CHECK: br $BB3_5{{$}}
100 ; CHECK: block BB3_5{{$}}
101 ; CHECK: block BB3_4{{$}}
102 ; CHECK: block BB3_2{{$}}
103 ; CHECK: br_if BB3_2, (get_local 4){{$}}
104 ; CHECK: br BB3_5{{$}}
105105 ; CHECK: BB3_2:
106 ; CHECK: br_if $BB3_4, (get_local 10){{$}}
107 ; CHECK: br $BB3_5{{$}}
106 ; CHECK: br_if BB3_4, (get_local 6){{$}}
107 ; CHECK: br BB3_5{{$}}
108108 ; CHECK: BB3_4:
109109 ; CHECK: BB3_5:
110 ; CHECK: return (get_local 6){{$}}
110 ; CHECK: return (get_local 3){{$}}
111111 define i32 @doublediamond(i32 %a, i32 %b, i32* %p) {
112112 entry:
113113 %c = icmp eq i32 %a, 0
132132 }
133133
134134 ; CHECK-LABEL: triangle:
135 ; CHECK: block $BB4_2{{$}}
136 ; CHECK: br_if $BB4_2, (get_local 5){{$}}
135 ; CHECK: block BB4_2{{$}}
136 ; CHECK: br_if BB4_2, (get_local 3){{$}}
137137 ; CHECK: BB4_2:
138 ; CHECK: return (get_local 4){{$}}
138 ; CHECK: return (get_local 2){{$}}
139139 define i32 @triangle(i32* %p, i32 %a) {
140140 entry:
141141 %c = icmp eq i32 %a, 0
150150 }
151151
152152 ; CHECK-LABEL: diamond:
153 ; CHECK: block $BB5_3{{$}}
154 ; CHECK: block $BB5_2{{$}}
155 ; CHECK: br_if $BB5_2, (get_local 5){{$}}
156 ; CHECK: br $BB5_3{{$}}
153 ; CHECK: block BB5_3{{$}}
154 ; CHECK: block BB5_2{{$}}
155 ; CHECK: br_if BB5_2, (get_local 3){{$}}
156 ; CHECK: br BB5_3{{$}}
157157 ; CHECK: BB5_2:
158158 ; CHECK: BB5_3:
159 ; CHECK: return (get_local 4){{$}}
159 ; CHECK: return (get_local 2){{$}}
160160 define i32 @diamond(i32* %p, i32 %a) {
161161 entry:
162162 %c = icmp eq i32 %a, 0
175175
176176 ; CHECK-LABEL: single_block:
177177 ; CHECK-NOT: br
178 ; CHECK: return (get_local 2){{$}}
178 ; CHECK: return (get_local 1){{$}}
179179 define i32 @single_block(i32* %p) {
180180 entry:
181181 store volatile i32 0, i32* %p
185185 ; CHECK-LABEL: minimal_loop:
186186 ; CHECK-NOT: br
187187 ; CHECK: BB7_1:
188 ; CHECK: i32.store (get_local 1), (get_local 3){{$}}
189 ; CHECK: br $BB7_1{{$}}
188 ; CHECK: i32.store (get_local 0), (get_local 2){{$}}
189 ; CHECK: br BB7_1{{$}}
190190 define i32 @minimal_loop(i32* %p) {
191191 entry:
192192 store volatile i32 0, i32* %p
199199 ; CHECK-LABEL: simple_loop:
200200 ; CHECK-NOT: br
201201 ; CHECK: BB8_1:
202 ; CHECK: loop $BB8_2{{$}}
203 ; CHECK: br_if $BB8_1, (get_local 6){{$}}
204 ; CHECK: return (get_local 4){{$}}
202 ; CHECK: loop BB8_2{{$}}
203 ; CHECK: br_if BB8_1, (get_local 3){{$}}
204 ; CHECK: return (get_local 2){{$}}
205205 define i32 @simple_loop(i32* %p, i32 %a) {
206206 entry:
207207 %c = icmp eq i32 %a, 0
216216 }
217217
218218 ; CHECK-LABEL: doubletriangle:
219 ; CHECK: block $BB9_4{{$}}
220 ; CHECK: block $BB9_3{{$}}
221 ; CHECK: br_if $BB9_4, (get_local 7){{$}}
222 ; CHECK: br_if $BB9_3, (get_local 10){{$}}
219 ; CHECK: block BB9_4{{$}}
220 ; CHECK: block BB9_3{{$}}
221 ; CHECK: br_if BB9_4, (get_local 4){{$}}
222 ; CHECK: br_if BB9_3, (get_local 6){{$}}
223223 ; CHECK: BB9_3:
224224 ; CHECK: BB9_4:
225 ; CHECK: return (get_local 6){{$}}
225 ; CHECK: return (get_local 3){{$}}
226226 define i32 @doubletriangle(i32 %a, i32 %b, i32* %p) {
227227 entry:
228228 %c = icmp eq i32 %a, 0
244244 }
245245
246246 ; CHECK-LABEL: ifelse_earlyexits:
247 ; CHECK: block $BB10_4{{$}}
248 ; CHECK: block $BB10_2{{$}}
249 ; CHECK: br_if $BB10_2, (get_local 7){{$}}
250 ; CHECK: br $BB10_4{{$}}
247 ; CHECK: block BB10_4{{$}}
248 ; CHECK: block BB10_2{{$}}
249 ; CHECK: br_if BB10_2, (get_local 4){{$}}
250 ; CHECK: br BB10_4{{$}}
251251 ; CHECK: BB10_2:
252 ; CHECK: br_if $BB10_4, (get_local 10){{$}}
252 ; CHECK: br_if BB10_4, (get_local 6){{$}}
253253 ; CHECK: BB10_4:
254 ; CHECK: return (get_local 6){{$}}
254 ; CHECK: return (get_local 3){{$}}
255255 define i32 @ifelse_earlyexits(i32 %a, i32 %b, i32* %p) {
256256 entry:
257257 %c = icmp eq i32 %a, 0
1010 ; CHECK-NEXT: .param f32{{$}}
1111 ; CHECK-NEXT: .result i32{{$}}
1212 ; CHECK-NEXT: .local f32, f32, i32, i32, i32{{$}}
13 ; CHECK-NEXT: get_local push, 0{{$}}
14 ; CHECK-NEXT: set_local 2, pop{{$}}
15 ; CHECK-NEXT: get_local push, 1{{$}}
16 ; CHECK-NEXT: set_local 3, pop{{$}}
17 ; CHECK-NEXT: f32.eq push, (get_local 3), (get_local 3){{$}}
18 ; CHECK-NEXT: set_local 4, pop{{$}}
19 ; CHECK-NEXT: f32.eq push, (get_local 2), (get_local 2){{$}}
20 ; CHECK-NEXT: set_local 5, pop{{$}}
21 ; CHECK-NEXT: i32.and push, (get_local 5), (get_local 4){{$}}
22 ; CHECK-NEXT: set_local 6, pop{{$}}
23 ; CHECK-NEXT: return (get_local 6){{$}}
13 ; CHECK-NEXT: f32.eq $push, (get_local 1), (get_local 1){{$}}
14 ; CHECK-NEXT: set_local 2, $pop{{$}}
15 ; CHECK-NEXT: f32.eq $push, (get_local 0), (get_local 0){{$}}
16 ; CHECK-NEXT: set_local 3, $pop{{$}}
17 ; CHECK-NEXT: i32.and $push, (get_local 3), (get_local 2){{$}}
18 ; CHECK-NEXT: set_local 4, $pop{{$}}
19 ; CHECK-NEXT: return (get_local 4){{$}}
2420 define i32 @ord_f32(float %x, float %y) {
2521 %a = fcmp ord float %x, %y
2622 %b = zext i1 %a to i32
3228 ; CHECK-NEXT: .param f32{{$}}
3329 ; CHECK-NEXT: .result i32{{$}}
3430 ; CHECK-NEXT: .local f32, f32, i32, i32, i32{{$}}
35 ; CHECK-NEXT: get_local push, 0{{$}}
36 ; CHECK-NEXT: set_local 2, pop{{$}}
37 ; CHECK-NEXT: get_local push, 1{{$}}
38 ; CHECK-NEXT: set_local 3, pop{{$}}
39 ; CHECK-NEXT: f32.ne push, (get_local 3), (get_local 3){{$}}
40 ; CHECK-NEXT: set_local 4, pop{{$}}
41 ; CHECK-NEXT: f32.ne push, (get_local 2), (get_local 2){{$}}
42 ; CHECK-NEXT: set_local 5, pop{{$}}
43 ; CHECK-NEXT: i32.or push, (get_local 5), (get_local 4){{$}}
44 ; CHECK-NEXT: set_local 6, pop{{$}}
45 ; CHECK-NEXT: return (get_local 6){{$}}
31 ; CHECK-NEXT: f32.ne $push, (get_local 1), (get_local 1){{$}}
32 ; CHECK-NEXT: set_local 2, $pop{{$}}
33 ; CHECK-NEXT: f32.ne $push, (get_local 0), (get_local 0){{$}}
34 ; CHECK-NEXT: set_local 3, $pop{{$}}
35 ; CHECK-NEXT: i32.or $push, (get_local 3), (get_local 2){{$}}
36 ; CHECK-NEXT: set_local 4, $pop{{$}}
37 ; CHECK-NEXT: return (get_local 4){{$}}
4638 define i32 @uno_f32(float %x, float %y) {
4739 %a = fcmp uno float %x, %y
4840 %b = zext i1 %a to i32
5446 ; CHECK-NEXT: .param f32{{$}}
5547 ; CHECK-NEXT: .result i32{{$}}
5648 ; CHECK-NEXT: .local f32, f32, i32{{$}}
57 ; CHECK-NEXT: get_local push, 1{{$}}
58 ; CHECK-NEXT: set_local 2, pop{{$}}
59 ; CHECK-NEXT: get_local push, 0{{$}}
60 ; CHECK-NEXT: set_local 3, pop{{$}}
61 ; CHECK-NEXT: f32.eq push, (get_local 3), (get_local 2){{$}}
62 ; CHECK-NEXT: set_local 4, pop{{$}}
63 ; CHECK-NEXT: return (get_local 4){{$}}
49 ; CHECK-NEXT: f32.eq $push, (get_local 0), (get_local 1){{$}}
50 ; CHECK-NEXT: set_local 2, $pop{{$}}
51 ; CHECK-NEXT: return (get_local 2){{$}}
6452 define i32 @oeq_f32(float %x, float %y) {
6553 %a = fcmp oeq float %x, %y
6654 %b = zext i1 %a to i32
6856 }
6957
7058 ; CHECK-LABEL: une_f32:
71 ; CHECK: f32.ne push, (get_local 3), (get_local 2){{$}}
72 ; CHECK-NEXT: set_local 4, pop{{$}}
59 ; CHECK: f32.ne $push, (get_local 0), (get_local 1){{$}}
60 ; CHECK-NEXT: set_local 2, $pop{{$}}
7361 define i32 @une_f32(float %x, float %y) {
7462 %a = fcmp une float %x, %y
7563 %b = zext i1 %a to i32
7765 }
7866
7967 ; CHECK-LABEL: olt_f32:
80 ; CHECK: f32.lt push, (get_local 3), (get_local 2){{$}}
81 ; CHECK-NEXT: set_local 4, pop{{$}}
68 ; CHECK: f32.lt $push, (get_local 0), (get_local 1){{$}}
69 ; CHECK-NEXT: set_local 2, $pop{{$}}
8270 define i32 @olt_f32(float %x, float %y) {
8371 %a = fcmp olt float %x, %y
8472 %b = zext i1 %a to i32
8674 }
8775
8876 ; CHECK-LABEL: ole_f32:
89 ; CHECK: f32.le push, (get_local 3), (get_local 2){{$}}
90 ; CHECK-NEXT: set_local 4, pop{{$}}
77 ; CHECK: f32.le $push, (get_local 0), (get_local 1){{$}}
78 ; CHECK-NEXT: set_local 2, $pop{{$}}
9179 define i32 @ole_f32(float %x, float %y) {
9280 %a = fcmp ole float %x, %y
9381 %b = zext i1 %a to i32
9583 }
9684
9785 ; CHECK-LABEL: ogt_f32:
98 ; CHECK: f32.gt push, (get_local 3), (get_local 2){{$}}
99 ; CHECK-NEXT: set_local 4, pop{{$}}
86 ; CHECK: f32.gt $push, (get_local 0), (get_local 1){{$}}
87 ; CHECK-NEXT: set_local 2, $pop{{$}}
10088 define i32 @ogt_f32(float %x, float %y) {
10189 %a = fcmp ogt float %x, %y
10290 %b = zext i1 %a to i32
10492 }
10593
10694 ; CHECK-LABEL: oge_f32:
107 ; CHECK: f32.ge push, (get_local 3), (get_local 2){{$}}
108 ; CHECK-NEXT: set_local 4, pop{{$}}
95 ; CHECK: f32.ge $push, (get_local 0), (get_local 1){{$}}
96 ; CHECK-NEXT: set_local 2, $pop{{$}}
10997 define i32 @oge_f32(float %x, float %y) {
11098 %a = fcmp oge float %x, %y
11199 %b = zext i1 %a to i32
119107 ; CHECK-NEXT: .param f32{{$}}
120108 ; CHECK-NEXT: .result i32{{$}}
121109 ; CHECK-NEXT: .local f32, f32, i32, i32, i32, i32, i32{{$}}
122 ; CHECK-NEXT: get_local push, 1{{$}}
123 ; CHECK-NEXT: set_local 2, pop{{$}}
124 ; CHECK-NEXT: get_local push, 0{{$}}
125 ; CHECK-NEXT: set_local 3, pop{{$}}
126 ; CHECK-NEXT: f32.eq push, (get_local 3), (get_local 2){{$}}
127 ; CHECK-NEXT: set_local 4, pop{{$}}
128 ; CHECK-NEXT: f32.ne push, (get_local 2), (get_local 2){{$}}
129 ; CHECK-NEXT: set_local 5, pop{{$}}
130 ; CHECK-NEXT: f32.ne push, (get_local 3), (get_local 3){{$}}
131 ; CHECK-NEXT: set_local 6, pop{{$}}
132 ; CHECK-NEXT: i32.or push, (get_local 6), (get_local 5){{$}}
133 ; CHECK-NEXT: set_local 7, pop{{$}}
134 ; CHECK-NEXT: i32.or push, (get_local 4), (get_local 7){{$}}
135 ; CHECK-NEXT: set_local 8, pop{{$}}
136 ; CHECK-NEXT: return (get_local 8){{$}}
110 ; CHECK-NEXT: f32.eq $push, (get_local 0), (get_local 1){{$}}
111 ; CHECK-NEXT: set_local 2, $pop{{$}}
112 ; CHECK-NEXT: f32.ne $push, (get_local 1), (get_local 1){{$}}
113 ; CHECK-NEXT: set_local 3, $pop{{$}}
114 ; CHECK-NEXT: f32.ne $push, (get_local 0), (get_local 0){{$}}
115 ; CHECK-NEXT: set_local 4, $pop{{$}}
116 ; CHECK-NEXT: i32.or $push, (get_local 4), (get_local 3){{$}}
117 ; CHECK-NEXT: set_local 5, $pop{{$}}
118 ; CHECK-NEXT: i32.or $push, (get_local 2), (get_local 5){{$}}
119 ; CHECK-NEXT: set_local 6, $pop{{$}}
120 ; CHECK-NEXT: return (get_local 6){{$}}
137121 define i32 @ueq_f32(float %x, float %y) {
138122 %a = fcmp ueq float %x, %y
139123 %b = zext i1 %a to i32
141125 }
142126
143127 ; CHECK-LABEL: one_f32:
144 ; CHECK: f32.ne push, (get_local 3), (get_local 2){{$}}
145 ; CHECK-NEXT: set_local 4, pop{{$}}
128 ; CHECK: f32.ne $push, (get_local 0), (get_local 1){{$}}
129 ; CHECK-NEXT: set_local 2, $pop{{$}}
146130 define i32 @one_f32(float %x, float %y) {
147131 %a = fcmp one float %x, %y
148132 %b = zext i1 %a to i32
150134 }
151135
152136 ; CHECK-LABEL: ult_f32:
153 ; CHECK: f32.lt push, (get_local 3), (get_local 2){{$}}
154 ; CHECK-NEXT: set_local 4, pop{{$}}
137 ; CHECK: f32.lt $push, (get_local 0), (get_local 1){{$}}
138 ; CHECK-NEXT: set_local 2, $pop{{$}}
155139 define i32 @ult_f32(float %x, float %y) {
156140 %a = fcmp ult float %x, %y
157141 %b = zext i1 %a to i32
159143 }
160144
161145 ; CHECK-LABEL: ule_f32:
162 ; CHECK: f32.le push, (get_local 3), (get_local 2){{$}}
163 ; CHECK-NEXT: set_local 4, pop{{$}}
146 ; CHECK: f32.le $push, (get_local 0), (get_local 1){{$}}
147 ; CHECK-NEXT: set_local 2, $pop{{$}}
164148 define i32 @ule_f32(float %x, float %y) {
165149 %a = fcmp ule float %x, %y
166150 %b = zext i1 %a to i32
168152 }
169153
170154 ; CHECK-LABEL: ugt_f32:
171 ; CHECK: f32.gt push, (get_local 3), (get_local 2){{$}}
172 ; CHECK-NEXT: set_local 4, pop{{$}}
155 ; CHECK: f32.gt $push, (get_local 0), (get_local 1){{$}}
156 ; CHECK-NEXT: set_local 2, $pop{{$}}
173157 define i32 @ugt_f32(float %x, float %y) {
174158 %a = fcmp ugt float %x, %y
175159 %b = zext i1 %a to i32
177161 }
178162
179163 ; CHECK-LABEL: uge_f32:
180 ; CHECK: f32.ge push, (get_local 3), (get_local 2){{$}}
181 ; CHECK-NEXT: set_local 4, pop{{$}}
164 ; CHECK: f32.ge $push, (get_local 0), (get_local 1){{$}}
165 ; CHECK-NEXT: set_local 2, $pop{{$}}
182166 define i32 @uge_f32(float %x, float %y) {
183167 %a = fcmp uge float %x, %y
184168 %b = zext i1 %a to i32
1010 ; CHECK-NEXT: .param f64{{$}}
1111 ; CHECK-NEXT: .result i32{{$}}
1212 ; CHECK-NEXT: .local f64, f64, i32, i32, i32{{$}}
13 ; CHECK-NEXT: get_local push, 0{{$}}
14 ; CHECK-NEXT: set_local 2, pop{{$}}
15 ; CHECK-NEXT: get_local push, 1{{$}}
16 ; CHECK-NEXT: set_local 3, pop{{$}}
17 ; CHECK-NEXT: f64.eq push, (get_local 3), (get_local 3){{$}}
18 ; CHECK-NEXT: set_local 4, pop{{$}}
19 ; CHECK-NEXT: f64.eq push, (get_local 2), (get_local 2){{$}}
20 ; CHECK-NEXT: set_local 5, pop{{$}}
21 ; CHECK-NEXT: i32.and push, (get_local 5), (get_local 4){{$}}
22 ; CHECK-NEXT: set_local 6, pop{{$}}
23 ; CHECK-NEXT: return (get_local 6){{$}}
13 ; CHECK-NEXT: f64.eq $push, (get_local 1), (get_local 1){{$}}
14 ; CHECK-NEXT: set_local 2, $pop{{$}}
15 ; CHECK-NEXT: f64.eq $push, (get_local 0), (get_local 0){{$}}
16 ; CHECK-NEXT: set_local 3, $pop{{$}}
17 ; CHECK-NEXT: i32.and $push, (get_local 3), (get_local 2){{$}}
18 ; CHECK-NEXT: set_local 4, $pop{{$}}
19 ; CHECK-NEXT: return (get_local 4){{$}}
2420 define i32 @ord_f64(double %x, double %y) {
2521 %a = fcmp ord double %x, %y
2622 %b = zext i1 %a to i32
3228 ; CHECK-NEXT: .param f64{{$}}
3329 ; CHECK-NEXT: .result i32{{$}}
3430 ; CHECK-NEXT: .local f64, f64, i32, i32, i32{{$}}
35 ; CHECK-NEXT: get_local push, 0{{$}}
36 ; CHECK-NEXT: set_local 2, pop{{$}}
37 ; CHECK-NEXT: get_local push, 1{{$}}
38 ; CHECK-NEXT: set_local 3, pop{{$}}
39 ; CHECK-NEXT: f64.ne push, (get_local 3), (get_local 3){{$}}
40 ; CHECK-NEXT: set_local 4, pop{{$}}
41 ; CHECK-NEXT: f64.ne push, (get_local 2), (get_local 2){{$}}
42 ; CHECK-NEXT: set_local 5, pop{{$}}
43 ; CHECK-NEXT: i32.or push, (get_local 5), (get_local 4){{$}}
44 ; CHECK-NEXT: set_local 6, pop{{$}}
45 ; CHECK-NEXT: return (get_local 6){{$}}
31 ; CHECK-NEXT: f64.ne $push, (get_local 1), (get_local 1){{$}}
32 ; CHECK-NEXT: set_local 2, $pop{{$}}
33 ; CHECK-NEXT: f64.ne $push, (get_local 0), (get_local 0){{$}}
34 ; CHECK-NEXT: set_local 3, $pop{{$}}
35 ; CHECK-NEXT: i32.or $push, (get_local 3), (get_local 2){{$}}
36 ; CHECK-NEXT: set_local 4, $pop{{$}}
37 ; CHECK-NEXT: return (get_local 4){{$}}
4638 define i32 @uno_f64(double %x, double %y) {
4739 %a = fcmp uno double %x, %y
4840 %b = zext i1 %a to i32
5446 ; CHECK-NEXT: .param f64{{$}}
5547 ; CHECK-NEXT: .result i32{{$}}
5648 ; CHECK-NEXT: .local f64, f64, i32{{$}}
57 ; CHECK-NEXT: get_local push, 1{{$}}
58 ; CHECK-NEXT: set_local 2, pop{{$}}
59 ; CHECK-NEXT: get_local push, 0{{$}}
60 ; CHECK-NEXT: set_local 3, pop{{$}}
61 ; CHECK-NEXT: f64.eq push, (get_local 3), (get_local 2){{$}}
62 ; CHECK-NEXT: set_local 4, pop{{$}}
63 ; CHECK-NEXT: return (get_local 4){{$}}
49 ; CHECK-NEXT: f64.eq $push, (get_local 0), (get_local 1){{$}}
50 ; CHECK-NEXT: set_local 2, $pop{{$}}
51 ; CHECK-NEXT: return (get_local 2){{$}}
6452 define i32 @oeq_f64(double %x, double %y) {
6553 %a = fcmp oeq double %x, %y
6654 %b = zext i1 %a to i32
6856 }
6957
7058 ; CHECK-LABEL: une_f64:
71 ; CHECK: f64.ne push, (get_local 3), (get_local 2){{$}}
72 ; CHECK-NEXT: set_local 4, pop{{$}}
59 ; CHECK: f64.ne $push, (get_local 0), (get_local 1){{$}}
60 ; CHECK-NEXT: set_local 2, $pop{{$}}
7361 define i32 @une_f64(double %x, double %y) {
7462 %a = fcmp une double %x, %y
7563 %b = zext i1 %a to i32
7765 }
7866
7967 ; CHECK-LABEL: olt_f64:
80 ; CHECK: f64.lt push, (get_local 3), (get_local 2){{$}}
81 ; CHECK-NEXT: set_local 4, pop{{$}}
68 ; CHECK: f64.lt $push, (get_local 0), (get_local 1){{$}}
69 ; CHECK-NEXT: set_local 2, $pop{{$}}
8270 define i32 @olt_f64(double %x, double %y) {
8371 %a = fcmp olt double %x, %y
8472 %b = zext i1 %a to i32
8674 }
8775
8876 ; CHECK-LABEL: ole_f64:
89 ; CHECK: f64.le push, (get_local 3), (get_local 2){{$}}
90 ; CHECK-NEXT: set_local 4, pop{{$}}
77 ; CHECK: f64.le $push, (get_local 0), (get_local 1){{$}}
78 ; CHECK-NEXT: set_local 2, $pop{{$}}
9179 define i32 @ole_f64(double %x, double %y) {
9280 %a = fcmp ole double %x, %y
9381 %b = zext i1 %a to i32
9583 }
9684
9785 ; CHECK-LABEL: ogt_f64:
98 ; CHECK: f64.gt push, (get_local 3), (get_local 2){{$}}
99 ; CHECK-NEXT: set_local 4, pop{{$}}
86 ; CHECK: f64.gt $push, (get_local 0), (get_local 1){{$}}
87 ; CHECK-NEXT: set_local 2, $pop{{$}}
10088 define i32 @ogt_f64(double %x, double %y) {
10189 %a = fcmp ogt double %x, %y
10290 %b = zext i1 %a to i32
10492 }
10593
10694 ; CHECK-LABEL: oge_f64:
107 ; CHECK: f64.ge push, (get_local 3), (get_local 2){{$}}
108 ; CHECK-NEXT: set_local 4, pop{{$}}
95 ; CHECK: f64.ge $push, (get_local 0), (get_local 1){{$}}
96 ; CHECK-NEXT: set_local 2, $pop{{$}}
10997 define i32 @oge_f64(double %x, double %y) {
11098 %a = fcmp oge double %x, %y
11199 %b = zext i1 %a to i32
119107 ; CHECK-NEXT: .param f64{{$}}
120108 ; CHECK-NEXT: .result i32{{$}}
121109 ; CHECK-NEXT: .local f64, f64, i32, i32, i32, i32, i32{{$}}
122 ; CHECK-NEXT: get_local push, 1{{$}}
123 ; CHECK-NEXT: set_local 2, pop{{$}}
124 ; CHECK-NEXT: get_local push, 0{{$}}
125 ; CHECK-NEXT: set_local 3, pop{{$}}
126 ; CHECK-NEXT: f64.eq push, (get_local 3), (get_local 2){{$}}
127 ; CHECK-NEXT: set_local 4, pop{{$}}
128 ; CHECK-NEXT: f64.ne push, (get_local 2), (get_local 2){{$}}
129 ; CHECK-NEXT: set_local 5, pop{{$}}
130 ; CHECK-NEXT: f64.ne push, (get_local 3), (get_local 3){{$}}
131 ; CHECK-NEXT: set_local 6, pop{{$}}
132 ; CHECK-NEXT: i32.or push, (get_local 6), (get_local 5){{$}}
133 ; CHECK-NEXT: set_local 7, pop{{$}}
134 ; CHECK-NEXT: i32.or push, (get_local 4), (get_local 7){{$}}
135 ; CHECK-NEXT: set_local 8, pop{{$}}
136 ; CHECK-NEXT: return (get_local 8){{$}}
110 ; CHECK-NEXT: f64.eq $push, (get_local 0), (get_local 1){{$}}
111 ; CHECK-NEXT: set_local 2, $pop{{$}}
112 ; CHECK-NEXT: f64.ne $push, (get_local 1), (get_local 1){{$}}
113 ; CHECK-NEXT: set_local 3, $pop{{$}}
114 ; CHECK-NEXT: f64.ne $push, (get_local 0), (get_local 0){{$}}
115 ; CHECK-NEXT: set_local 4, $pop{{$}}
116 ; CHECK-NEXT: i32.or $push, (get_local 4), (get_local 3){{$}}
117 ; CHECK-NEXT: set_local 5, $pop{{$}}
118 ; CHECK-NEXT: i32.or $push, (get_local 2), (get_local 5){{$}}
119 ; CHECK-NEXT: set_local 6, $pop{{$}}
120 ; CHECK-NEXT: return (get_local 6){{$}}
137121 define i32 @ueq_f64(double %x, double %y) {
138122 %a = fcmp ueq double %x, %y
139123 %b = zext i1 %a to i32
141125 }
142126
143127 ; CHECK-LABEL: one_f64:
144 ; CHECK: f64.ne push, (get_local 3), (get_local 2){{$}}
145 ; CHECK-NEXT: set_local 4, pop{{$}}
128 ; CHECK: f64.ne $push, (get_local 0), (get_local 1){{$}}
129 ; CHECK-NEXT: set_local 2, $pop{{$}}
146130 define i32 @one_f64(double %x, double %y) {
147131 %a = fcmp one double %x, %y
148132 %b = zext i1 %a to i32
150134 }
151135
152136 ; CHECK-LABEL: ult_f64:
153 ; CHECK: f64.lt push, (get_local 3), (get_local 2){{$}}
154 ; CHECK-NEXT: set_local 4, pop{{$}}
137 ; CHECK: f64.lt $push, (get_local 0), (get_local 1){{$}}
138 ; CHECK-NEXT: set_local 2, $pop{{$}}
155139 define i32 @ult_f64(double %x, double %y) {
156140 %a = fcmp ult double %x, %y
157141 %b = zext i1 %a to i32
159143 }
160144
161145 ; CHECK-LABEL: ule_f64:
162 ; CHECK: f64.le push, (get_local 3), (get_local 2){{$}}
163 ; CHECK-NEXT: set_local 4, pop{{$}}
146 ; CHECK: f64.le $push, (get_local 0), (get_local 1){{$}}
147 ; CHECK-NEXT: set_local 2, $pop{{$}}
164148 define i32 @ule_f64(double %x, double %y) {
165149 %a = fcmp ule double %x, %y
166150 %b = zext i1 %a to i32
168152 }
169153
170154 ; CHECK-LABEL: ugt_f64:
171 ; CHECK: f64.gt push, (get_local 3), (get_local 2){{$}}
172 ; CHECK-NEXT: set_local 4, pop{{$}}
155 ; CHECK: f64.gt $push, (get_local 0), (get_local 1){{$}}
156 ; CHECK-NEXT: set_local 2, $pop{{$}}
173157 define i32 @ugt_f64(double %x, double %y) {
174158 %a = fcmp ugt double %x, %y
175159 %b = zext i1 %a to i32
177161 }
178162
179163 ; CHECK-LABEL: uge_f64:
180 ; CHECK: f64.ge push, (get_local 3), (get_local 2){{$}}
181 ; CHECK-NEXT: set_local 4, pop{{$}}
164 ; CHECK: f64.ge $push, (get_local 0), (get_local 1){{$}}
165 ; CHECK-NEXT: set_local 2, $pop{{$}}
182166 define i32 @uge_f64(double %x, double %y) {
183167 %a = fcmp uge double %x, %y
184168 %b = zext i1 %a to i32
99 ; CHECK-NEXT: .param i32{{$}}
1010 ; CHECK-NEXT: .result i32{{$}}
1111 ; CHECK-NEXT: .local i32, i32, i32{{$}}
12 ; CHECK-NEXT: get_local push, 1{{$}}
13 ; CHECK-NEXT: set_local 2, pop{{$}}
14 ; CHECK-NEXT: get_local push, 0{{$}}
15 ; CHECK-NEXT: set_local 3, pop{{$}}
16 ; CHECK-NEXT: i32.eq push, (get_local 3), (get_local 2){{$}}
17 ; CHECK-NEXT: set_local 4, pop{{$}}
18 ; CHECK-NEXT: return (get_local 4){{$}}
12 ; CHECK-NEXT: i32.eq $push, (get_local 0), (get_local 1){{$}}
13 ; CHECK-NEXT: set_local 2, $pop{{$}}
14 ; CHECK-NEXT: return (get_local 2){{$}}
1915 define i32 @eq_i32(i32 %x, i32 %y) {
2016 %a = icmp eq i32 %x, %y
2117 %b = zext i1 %a to i32
2319 }
2420
2521 ; CHECK-LABEL: ne_i32:
26 ; CHECK: i32.ne push, (get_local 3), (get_local 2){{$}}
27 ; CHECK-NEXT: set_local 4, pop{{$}}
22 ; CHECK: i32.ne $push, (get_local 0), (get_local 1){{$}}
23 ; CHECK-NEXT: set_local 2, $pop{{$}}
2824 define i32 @ne_i32(i32 %x, i32 %y) {
2925 %a = icmp ne i32 %x, %y
3026 %b = zext i1 %a to i32
3228 }
3329
3430 ; CHECK-LABEL: slt_i32:
35 ; CHECK: i32.lt_s push, (get_local 3), (get_local 2){{$}}
36 ; CHECK-NEXT: set_local 4, pop{{$}}
31 ; CHECK: i32.lt_s $push, (get_local 0), (get_local 1){{$}}
32 ; CHECK-NEXT: set_local 2, $pop{{$}}
3733 define i32 @slt_i32(i32 %x, i32 %y) {
3834 %a = icmp slt i32 %x, %y
3935 %b = zext i1 %a to i32
4137 }
4238
4339 ; CHECK-LABEL: sle_i32:
44 ; CHECK: i32.le_s push, (get_local 3), (get_local 2){{$}}
45 ; CHECK-NEXT: set_local 4, pop{{$}}
40 ; CHECK: i32.le_s $push, (get_local 0), (get_local 1){{$}}
41 ; CHECK-NEXT: set_local 2, $pop{{$}}
4642 define i32 @sle_i32(i32 %x, i32 %y) {
4743 %a = icmp sle i32 %x, %y
4844 %b = zext i1 %a to i32
5046 }
5147
5248 ; CHECK-LABEL: ult_i32:
53 ; CHECK: i32.lt_u push, (get_local 3), (get_local 2){{$}}
54 ; CHECK-NEXT: set_local 4, pop{{$}}
49 ; CHECK: i32.lt_u $push, (get_local 0), (get_local 1){{$}}
50 ; CHECK-NEXT: set_local 2, $pop{{$}}
5551 define i32 @ult_i32(i32 %x, i32 %y) {
5652 %a = icmp ult i32 %x, %y
5753 %b = zext i1 %a to i32
5955 }
6056
6157 ; CHECK-LABEL: ule_i32:
62 ; CHECK: i32.le_u push, (get_local 3), (get_local 2){{$}}
63 ; CHECK-NEXT: set_local 4, pop{{$}}
58 ; CHECK: i32.le_u $push, (get_local 0), (get_local 1){{$}}
59 ; CHECK-NEXT: set_local 2, $pop{{$}}
6460 define i32 @ule_i32(i32 %x, i32 %y) {
6561 %a = icmp ule i32 %x, %y
6662 %b = zext i1 %a to i32
6864 }
6965
7066 ; CHECK-LABEL: sgt_i32:
71 ; CHECK: i32.gt_s push, (get_local 3), (get_local 2){{$}}
72 ; CHECK-NEXT: set_local 4, pop{{$}}
67 ; CHECK: i32.gt_s $push, (get_local 0), (get_local 1){{$}}
68 ; CHECK-NEXT: set_local 2, $pop{{$}}
7369 define i32 @sgt_i32(i32 %x, i32 %y) {
7470 %a = icmp sgt i32 %x, %y
7571 %b = zext i1 %a to i32
7773 }
7874
7975 ; CHECK-LABEL: sge_i32:
80 ; CHECK: i32.ge_s push, (get_local 3), (get_local 2){{$}}
81 ; CHECK-NEXT: set_local 4, pop{{$}}
76 ; CHECK: i32.ge_s $push, (get_local 0), (get_local 1){{$}}
77 ; CHECK-NEXT: set_local 2, $pop{{$}}
8278 define i32 @sge_i32(i32 %x, i32 %y) {
8379 %a = icmp sge i32 %x, %y
8480 %b = zext i1 %a to i32
8682 }
8783
8884 ; CHECK-LABEL: ugt_i32:
89 ; CHECK: i32.gt_u push, (get_local 3), (get_local 2){{$}}
90 ; CHECK-NEXT: set_local 4, pop{{$}}
85 ; CHECK: i32.gt_u $push, (get_local 0), (get_local 1){{$}}
86 ; CHECK-NEXT: set_local 2, $pop{{$}}
9187 define i32 @ugt_i32(i32 %x, i32 %y) {
9288 %a = icmp ugt i32 %x, %y
9389 %b = zext i1 %a to i32
9591 }
9692
9793 ; CHECK-LABEL: uge_i32:
98 ; CHECK: i32.ge_u push, (get_local 3), (get_local 2){{$}}
99 ; CHECK-NEXT: set_local 4, pop{{$}}
94 ; CHECK: i32.ge_u $push, (get_local 0), (get_local 1){{$}}
95 ; CHECK-NEXT: set_local 2, $pop{{$}}
10096 define i32 @uge_i32(i32 %x, i32 %y) {
10197 %a = icmp uge i32 %x, %y
10298 %b = zext i1 %a to i32
99 ; CHECK-NEXT: .param i64{{$}}
1010 ; CHECK-NEXT: .result i32{{$}}
1111 ; CHECK-NEXT: .local i64, i64, i32{{$}}
12 ; CHECK-NEXT: get_local push, 1{{$}}
13 ; CHECK-NEXT: set_local 2, pop{{$}}
14 ; CHECK-NEXT: get_local push, 0{{$}}
15 ; CHECK-NEXT: set_local 3, pop{{$}}
16 ; CHECK-NEXT: i64.eq push, (get_local 3), (get_local 2){{$}}
17 ; CHECK-NEXT: set_local 4, pop{{$}}
18 ; CHECK-NEXT: return (get_local 4){{$}}
12 ; CHECK-NEXT: i64.eq $push, (get_local 0), (get_local 1){{$}}
13 ; CHECK-NEXT: set_local 2, $pop{{$}}
14 ; CHECK-NEXT: return (get_local 2){{$}}
1915 define i32 @eq_i64(i64 %x, i64 %y) {
2016 %a = icmp eq i64 %x, %y
2117 %b = zext i1 %a to i32
2319 }
2420
2521 ; CHECK-LABEL: ne_i64:
26 ; CHECK: i64.ne push, (get_local 3), (get_local 2){{$}}
27 ; CHECK-NEXT: set_local 4, pop{{$}}
22 ; CHECK: i64.ne $push, (get_local 0), (get_local 1){{$}}
23 ; CHECK-NEXT: set_local 2, $pop{{$}}
2824 define i32 @ne_i64(i64 %x, i64 %y) {
2925 %a = icmp ne i64 %x, %y
3026 %b = zext i1 %a to i32
3228 }
3329
3430 ; CHECK-LABEL: slt_i64:
35 ; CHECK: i64.lt_s push, (get_local 3), (get_local 2){{$}}
36 ; CHECK-NEXT: set_local 4, pop{{$}}
31 ; CHECK: i64.lt_s $push, (get_local 0), (get_local 1){{$}}
32 ; CHECK-NEXT: set_local 2, $pop{{$}}
3733 define i32 @slt_i64(i64 %x, i64 %y) {
3834 %a = icmp slt i64 %x, %y
3935 %b = zext i1 %a to i32
4137 }
4238
4339 ; CHECK-LABEL: sle_i64:
44 ; CHECK: i64.le_s push, (get_local 3), (get_local 2){{$}}
45 ; CHECK-NEXT: set_local 4, pop{{$}}
40 ; CHECK: i64.le_s $push, (get_local 0), (get_local 1){{$}}
41 ; CHECK-NEXT: set_local 2, $pop{{$}}
4642 define i32 @sle_i64(i64 %x, i64 %y) {
4743 %a = icmp sle i64 %x, %y
4844 %b = zext i1 %a to i32
5046 }
5147
5248 ; CHECK-LABEL: ult_i64:
53 ; CHECK: i64.lt_u push, (get_local 3), (get_local 2){{$}}
54 ; CHECK-NEXT: set_local 4, pop{{$}}
49 ; CHECK: i64.lt_u $push, (get_local 0), (get_local 1){{$}}
50 ; CHECK-NEXT: set_local 2, $pop{{$}}
5551 define i32 @ult_i64(i64 %x, i64 %y) {
5652 %a = icmp ult i64 %x, %y
5753 %b = zext i1 %a to i32
5955 }
6056
6157 ; CHECK-LABEL: ule_i64:
62 ; CHECK: i64.le_u push, (get_local 3), (get_local 2){{$}}
63 ; CHECK-NEXT: set_local 4, pop{{$}}
58 ; CHECK: i64.le_u $push, (get_local 0), (get_local 1){{$}}
59 ; CHECK-NEXT: set_local 2, $pop{{$}}
6460 define i32 @ule_i64(i64 %x, i64 %y) {
6561 %a = icmp ule i64 %x, %y
6662 %b = zext i1 %a to i32
6864 }
6965
7066 ; CHECK-LABEL: sgt_i64:
71 ; CHECK: i64.gt_s push, (get_local 3), (get_local 2){{$}}
72 ; CHECK-NEXT: set_local 4, pop{{$}}
67 ; CHECK: i64.gt_s $push, (get_local 0), (get_local 1){{$}}
68 ; CHECK-NEXT: set_local 2, $pop{{$}}
7369 define i32 @sgt_i64(i64 %x, i64 %y) {
7470 %a = icmp sgt i64 %x, %y
7571 %b = zext i1 %a to i32
7773 }
7874
7975 ; CHECK-LABEL: sge_i64:
80 ; CHECK: i64.ge_s push, (get_local 3), (get_local 2){{$}}
81 ; CHECK-NEXT: set_local 4, pop{{$}}
76 ; CHECK: i64.ge_s $push, (get_local 0), (get_local 1){{$}}
77 ; CHECK-NEXT: set_local 2, $pop{{$}}
8278 define i32 @sge_i64(i64 %x, i64 %y) {
8379 %a = icmp sge i64 %x, %y
8480 %b = zext i1 %a to i32
8682 }
8783
8884 ; CHECK-LABEL: ugt_i64:
89 ; CHECK: i64.gt_u push, (get_local 3), (get_local 2){{$}}
90 ; CHECK-NEXT: set_local 4, pop{{$}}
85 ; CHECK: i64.gt_u $push, (get_local 0), (get_local 1){{$}}
86 ; CHECK-NEXT: set_local 2, $pop{{$}}
9187 define i32 @ugt_i64(i64 %x, i64 %y) {
9288 %a = icmp ugt i64 %x, %y
9389 %b = zext i1 %a to i32
9591 }
9692
9793 ; CHECK-LABEL: uge_i64:
98 ; CHECK: i64.ge_u push, (get_local 3), (get_local 2){{$}}
99 ; CHECK-NEXT: set_local 4, pop{{$}}
94 ; CHECK: i64.ge_u $push, (get_local 0), (get_local 1){{$}}
95 ; CHECK-NEXT: set_local 2, $pop{{$}}
10096 define i32 @uge_i64(i64 %x, i64 %y) {
10197 %a = icmp uge i64 %x, %y
10298 %b = zext i1 %a to i32
88 ; CHECK-NEXT: .param i64{{$}}
99 ; CHECK-NEXT: .result i32{{$}}
1010 ; CHECK-NEXT: .local i64, i32{{$}}
11 ; CHECK-NEXT: get_local push, 0{{$}}
12 ; CHECK-NEXT: set_local 1, pop{{$}}
13 ; CHECK-NEXT: i32.wrap/i64 push, (get_local 1){{$}}
14 ; CHECK-NEXT: set_local 2, pop{{$}}
15 ; CHECK-NEXT: return (get_local 2){{$}}
11 ; CHECK-NEXT: i32.wrap/i64 $push, (get_local 0){{$}}
12 ; CHECK-NEXT: set_local 1, $pop{{$}}
13 ; CHECK-NEXT: return (get_local 1){{$}}
1614 define i32 @i32_wrap_i64(i64 %x) {
1715 %a = trunc i64 %x to i32
1816 ret i32 %a
2220 ; CHECK-NEXT: .param i32
2321 ; CHECK-NEXT: .result i64
2422 ; CHECK-NEXT: .local i32, i64{{$}}
25 ; CHECK-NEXT: get_local push, 0{{$}}
26 ; CHECK-NEXT: set_local 1, pop{{$}}
27 ; CHECK-NEXT: i64.extend_s/i32 push, (get_local 1){{$}}
28 ; CHECK-NEXT: set_local 2, pop{{$}}
29 ; CHECK-NEXT: return (get_local 2){{$}}
23 ; CHECK-NEXT: i64.extend_s/i32 $push, (get_local 0){{$}}
24 ; CHECK-NEXT: set_local 1, $pop{{$}}
25 ; CHECK-NEXT: return (get_local 1){{$}}
3026 define i64 @i64_extend_s_i32(i32 %x) {
3127 %a = sext i32 %x to i64
3228 ret i64 %a
3632 ; CHECK-NEXT: .param i32
3733 ; CHECK-NEXT: .result i64
3834 ; CHECK-NEXT: .local i32, i64{{$}}
39 ; CHECK-NEXT: get_local push, 0{{$}}
40 ; CHECK-NEXT: set_local 1, pop{{$}}
41 ; CHECK-NEXT: i64.extend_u/i32 push, (get_local 1){{$}}
42 ; CHECK-NEXT: set_local 2, pop{{$}}
43 ; CHECK-NEXT: return (get_local 2){{$}}
35 ; CHECK-NEXT: i64.extend_u/i32 $push, (get_local 0){{$}}
36 ; CHECK-NEXT: set_local 1, $pop{{$}}
37 ; CHECK-NEXT: return (get_local 1){{$}}
4438 define i64 @i64_extend_u_i32(i32 %x) {
4539 %a = zext i32 %x to i64
4640 ret i64 %a
5044 ; CHECK-NEXT: .param f32
5145 ; CHECK-NEXT: .result i32
5246 ; CHECK-NEXT: .local f32, i32{{$}}
53 ; CHECK-NEXT: get_local push, 0{{$}}
54 ; CHECK-NEXT: set_local 1, pop{{$}}
55 ; CHECK-NEXT: i32.trunc_s/f32 push, (get_local 1){{$}}
56 ; CHECK-NEXT: set_local 2, pop{{$}}
57 ; CHECK-NEXT: return (get_local 2){{$}}
47 ; CHECK-NEXT: i32.trunc_s/f32 $push, (get_local 0){{$}}
48 ; CHECK-NEXT: set_local 1, $pop{{$}}
49 ; CHECK-NEXT: return (get_local 1){{$}}
5850 define i32 @i32_trunc_s_f32(float %x) {
5951 %a = fptosi float %x to i32
6052 ret i32 %a
6456 ; CHECK-NEXT: .param f32
6557 ; CHECK-NEXT: .result i32
6658 ; CHECK-NEXT: .local f32, i32{{$}}
67 ; CHECK-NEXT: get_local push, 0{{$}}
68 ; CHECK-NEXT: set_local 1, pop{{$}}
69 ; CHECK-NEXT: i32.trunc_u/f32 push, (get_local 1){{$}}
70 ; CHECK-NEXT: set_local 2, pop{{$}}
71 ; CHECK-NEXT: return (get_local 2){{$}}
59 ; CHECK-NEXT: i32.trunc_u/f32 $push, (get_local 0){{$}}
60 ; CHECK-NEXT: set_local 1, $pop{{$}}
61 ; CHECK-NEXT: return (get_local 1){{$}}
7262 define i32 @i32_trunc_u_f32(float %x) {
7363 %a = fptoui float %x to i32
7464 ret i32 %a
7868 ; CHECK-NEXT: .param f64
7969 ; CHECK-NEXT: .result i32
8070 ; CHECK-NEXT: .local f64, i32{{$}}
81 ; CHECK-NEXT: get_local push, 0{{$}}
82 ; CHECK-NEXT: set_local 1, pop{{$}}
83 ; CHECK-NEXT: i32.trunc_s/f64 push, (get_local 1){{$}}
84 ; CHECK-NEXT: set_local 2, pop{{$}}
85 ; CHECK-NEXT: return (get_local 2){{$}}
71 ; CHECK-NEXT: i32.trunc_s/f64 $push, (get_local 0){{$}}
72 ; CHECK-NEXT: set_local 1, $pop{{$}}
73 ; CHECK-NEXT: return (get_local 1){{$}}
8674 define i32 @i32_trunc_s_f64(double %x) {
8775 %a = fptosi double %x to i32
8876 ret i32 %a
9280 ; CHECK-NEXT: .param f64
9381 ; CHECK-NEXT: .result i32
9482 ; CHECK-NEXT: .local f64, i32{{$}}
95 ; CHECK-NEXT: get_local push, 0{{$}}
96 ; CHECK-NEXT: set_local 1, pop{{$}}
97 ; CHECK-NEXT: i32.trunc_u/f64 push, (get_local 1){{$}}
98 ; CHECK-NEXT: set_local 2, pop{{$}}
99 ; CHECK-NEXT: return (get_local 2){{$}}
83 ; CHECK-NEXT: i32.trunc_u/f64 $push, (get_local 0){{$}}
84 ; CHECK-NEXT: set_local 1, $pop{{$}}
85 ; CHECK-NEXT: return (get_local 1){{$}}
10086 define i32 @i32_trunc_u_f64(double %x) {
10187 %a = fptoui double %x to i32
10288 ret i32 %a
10692 ; CHECK-NEXT: .param f32
10793 ; CHECK-NEXT: .result i64
10894 ; CHECK-NEXT: .local f32, i64{{$}}
109 ; CHECK-NEXT: get_local push, 0{{$}}
110 ; CHECK-NEXT: set_local 1, pop{{$}}
111 ; CHECK-NEXT: i64.trunc_s/f32 push, (get_local 1){{$}}
112 ; CHECK-NEXT: set_local 2, pop{{$}}
113 ; CHECK-NEXT: return (get_local 2){{$}}
95 ; CHECK-NEXT: i64.trunc_s/f32 $push, (get_local 0){{$}}
96 ; CHECK-NEXT: set_local 1, $pop{{$}}
97 ; CHECK-NEXT: return (get_local 1){{$}}
11498 define i64 @i64_trunc_s_f32(float %x) {
11599 %a = fptosi float %x to i64
116100 ret i64 %a
120104 ; CHECK-NEXT: .param f32
121105 ; CHECK-NEXT: .result i64
122106 ; CHECK-NEXT: .local f32, i64{{$}}
123 ; CHECK-NEXT: get_local push, 0{{$}}
124 ; CHECK-NEXT: set_local 1, pop{{$}}
125 ; CHECK-NEXT: i64.trunc_u/f32 push, (get_local 1){{$}}
126 ; CHECK-NEXT: set_local 2, pop{{$}}
127 ; CHECK-NEXT: return (get_local 2){{$}}
107 ; CHECK-NEXT: i64.trunc_u/f32 $push, (get_local 0){{$}}
108 ; CHECK-NEXT: set_local 1, $pop{{$}}
109 ; CHECK-NEXT: return (get_local 1){{$}}
128110 define i64 @i64_trunc_u_f32(float %x) {
129111 %a = fptoui float %x to i64
130112 ret i64 %a
134116 ; CHECK-NEXT: .param f64
135117 ; CHECK-NEXT: .result i64
136118 ; CHECK-NEXT: .local f64, i64{{$}}
137 ; CHECK-NEXT: get_local push, 0{{$}}
138 ; CHECK-NEXT: set_local 1, pop{{$}}
139 ; CHECK-NEXT: i64.trunc_s/f64 push, (get_local 1){{$}}
140 ; CHECK-NEXT: set_local 2, pop{{$}}
141 ; CHECK-NEXT: return (get_local 2){{$}}
119 ; CHECK-NEXT: i64.trunc_s/f64 $push, (get_local 0){{$}}
120 ; CHECK-NEXT: set_local 1, $pop{{$}}
121 ; CHECK-NEXT: return (get_local 1){{$}}
142122 define i64 @i64_trunc_s_f64(double %x) {
143123 %a = fptosi double %x to i64
144124 ret i64 %a
148128 ; CHECK-NEXT: .param f64
149129 ; CHECK-NEXT: .result i64
150130 ; CHECK-NEXT: .local f64, i64{{$}}
151 ; CHECK-NEXT: get_local push, 0{{$}}
152 ; CHECK-NEXT: set_local 1, pop{{$}}
153 ; CHECK-NEXT: i64.trunc_u/f64 push, (get_local 1){{$}}
154 ; CHECK-NEXT: set_local 2, pop{{$}}
155 ; CHECK-NEXT: return (get_local 2){{$}}
131 ; CHECK-NEXT: i64.trunc_u/f64 $push, (get_local 0){{$}}
132 ; CHECK-NEXT: set_local 1, $pop{{$}}
133 ; CHECK-NEXT: return (get_local 1){{$}}
156134 define i64 @i64_trunc_u_f64(double %x) {
157135 %a = fptoui double %x to i64
158136 ret i64 %a
162140 ; CHECK-NEXT: .param i32
163141 ; CHECK-NEXT: .result f32
164142 ; CHECK-NEXT: .local i32, f32{{$}}
165 ; CHECK-NEXT: get_local push, 0{{$}}
166 ; CHECK-NEXT: set_local 1, pop{{$}}
167 ; CHECK-NEXT: f32.convert_s/i32 push, (get_local 1){{$}}
168 ; CHECK-NEXT: set_local 2, pop{{$}}
169 ; CHECK-NEXT: return (get_local 2){{$}}
143 ; CHECK-NEXT: f32.convert_s/i32 $push, (get_local 0){{$}}
144 ; CHECK-NEXT: set_local 1, $pop{{$}}
145 ; CHECK-NEXT: return (get_local 1){{$}}
170146 define float @f32_convert_s_i32(i32 %x) {
171147 %a = sitofp i32 %x to float
172148 ret float %a
176152 ; CHECK-NEXT: .param i32
177153 ; CHECK-NEXT: .result f32
178154 ; CHECK-NEXT: .local i32, f32{{$}}
179 ; CHECK-NEXT: get_local push, 0{{$}}
180 ; CHECK-NEXT: set_local 1, pop{{$}}
181 ; CHECK-NEXT: f32.convert_u/i32 push, (get_local 1){{$}}
182 ; CHECK-NEXT: set_local 2, pop{{$}}
183 ; CHECK-NEXT: return (get_local 2){{$}}
155 ; CHECK-NEXT: f32.convert_u/i32 $push, (get_local 0){{$}}
156 ; CHECK-NEXT: set_local 1, $pop{{$}}
157 ; CHECK-NEXT: return (get_local 1){{$}}
184158 define float @f32_convert_u_i32(i32 %x) {
185159 %a = uitofp i32 %x to float
186160 ret float %a
190164 ; CHECK-NEXT: .param i32
191165 ; CHECK-NEXT: .result f64
192166 ; CHECK-NEXT: .local i32, f64{{$}}
193 ; CHECK-NEXT: get_local push, 0{{$}}
194 ; CHECK-NEXT: set_local 1, pop{{$}}
195 ; CHECK-NEXT: f64.convert_s/i32 push, (get_local 1){{$}}
196 ; CHECK-NEXT: set_local 2, pop{{$}}
197 ; CHECK-NEXT: return (get_local 2){{$}}
167 ; CHECK-NEXT: f64.convert_s/i32 $push, (get_local 0){{$}}
168 ; CHECK-NEXT: set_local 1, $pop{{$}}
169 ; CHECK-NEXT: return (get_local 1){{$}}
198170 define double @f64_convert_s_i32(i32 %x) {
199171 %a = sitofp i32 %x to double
200172 ret double %a
204176 ; CHECK-NEXT: .param i32
205177 ; CHECK-NEXT: .result f64
206178 ; CHECK-NEXT: .local i32, f64{{$}}
207 ; CHECK-NEXT: get_local push, 0{{$}}
208 ; CHECK-NEXT: set_local 1, pop{{$}}
209 ; CHECK-NEXT: f64.convert_u/i32 push, (get_local 1){{$}}
210 ; CHECK-NEXT: set_local 2, pop{{$}}
211 ; CHECK-NEXT: return (get_local 2){{$}}
179 ; CHECK-NEXT: f64.convert_u/i32 $push, (get_local 0){{$}}
180 ; CHECK-NEXT: set_local 1, $pop{{$}}
181 ; CHECK-NEXT: return (get_local 1){{$}}
212182 define double @f64_convert_u_i32(i32 %x) {
213183 %a = uitofp i32 %x to double
214184 ret double %a
218188 ; CHECK-NEXT: .param i64
219189 ; CHECK-NEXT: .result f32
220190 ; CHECK-NEXT: .local i64, f32{{$}}
221 ; CHECK-NEXT: get_local push, 0{{$}}
222 ; CHECK-NEXT: set_local 1, pop{{$}}
223 ; CHECK-NEXT: f32.convert_s/i64 push, (get_local 1){{$}}
224 ; CHECK-NEXT: set_local 2, pop{{$}}
225 ; CHECK-NEXT: return (get_local 2){{$}}
191 ; CHECK-NEXT: f32.convert_s/i64 $push, (get_local 0){{$}}
192 ; CHECK-NEXT: set_local 1, $pop{{$}}
193 ; CHECK-NEXT: return (get_local 1){{$}}
226194 define float @f32_convert_s_i64(i64 %x) {
227195 %a = sitofp i64 %x to float
228196 ret float %a
232200 ; CHECK-NEXT: .param i64
233201 ; CHECK-NEXT: .result f32
234202 ; CHECK-NEXT: .local i64, f32{{$}}
235 ; CHECK-NEXT: get_local push, 0{{$}}
236 ; CHECK-NEXT: set_local 1, pop{{$}}
237 ; CHECK-NEXT: f32.convert_u/i64 push, (get_local 1){{$}}
238 ; CHECK-NEXT: set_local 2, pop{{$}}
239 ; CHECK-NEXT: return (get_local 2){{$}}
203 ; CHECK-NEXT: f32.convert_u/i64 $push, (get_local 0){{$}}
204 ; CHECK-NEXT: set_local 1, $pop{{$}}
205 ; CHECK-NEXT: return (get_local 1){{$}}
240206 define float @f32_convert_u_i64(i64 %x) {
241207 %a = uitofp i64 %x to float
242208 ret float %a
246212 ; CHECK-NEXT: .param i64
247213 ; CHECK-NEXT: .result f64
248214 ; CHECK-NEXT: .local i64, f64{{$}}
249 ; CHECK-NEXT: get_local push, 0{{$}}
250 ; CHECK-NEXT: set_local 1, pop{{$}}
251 ; CHECK-NEXT: f64.convert_s/i64 push, (get_local 1){{$}}
252 ; CHECK-NEXT: set_local 2, pop{{$}}
253 ; CHECK-NEXT: return (get_local 2){{$}}
215 ; CHECK-NEXT: f64.convert_s/i64 $push, (get_local 0){{$}}
216 ; CHECK-NEXT: set_local 1, $pop{{$}}
217 ; CHECK-NEXT: return (get_local 1){{$}}
254218 define double @f64_convert_s_i64(i64 %x) {
255219 %a = sitofp i64 %x to double
256220 ret double %a
260224 ; CHECK-NEXT: .param i64
261225 ; CHECK-NEXT: .result f64
262226 ; CHECK-NEXT: .local i64, f64{{$}}
263 ; CHECK-NEXT: get_local push, 0{{$}}
264 ; CHECK-NEXT: set_local 1, pop{{$}}
265 ; CHECK-NEXT: f64.convert_u/i64 push, (get_local 1){{$}}
266 ; CHECK-NEXT: set_local 2, pop{{$}}
267 ; CHECK-NEXT: return (get_local 2){{$}}
227 ; CHECK-NEXT: f64.convert_u/i64 $push, (get_local 0){{$}}
228 ; CHECK-NEXT: set_local 1, $pop{{$}}
229 ; CHECK-NEXT: return (get_local 1){{$}}
268230 define double @f64_convert_u_i64(i64 %x) {
269231 %a = uitofp i64 %x to double
270232 ret double %a
274236 ; CHECK-NEXT: .param f32
275237 ; CHECK-NEXT: .result f64
276238 ; CHECK-NEXT: .local f32, f64{{$}}
277 ; CHECK-NEXT: get_local push, 0{{$}}
278 ; CHECK-NEXT: set_local 1, pop{{$}}
279 ; CHECK-NEXT: f64.promote/f32 push, (get_local 1){{$}}
280 ; CHECK-NEXT: set_local 2, pop{{$}}
281 ; CHECK-NEXT: return (get_local 2){{$}}
239 ; CHECK-NEXT: f64.promote/f32 $push, (get_local 0){{$}}
240 ; CHECK-NEXT: set_local 1, $pop{{$}}
241 ; CHECK-NEXT: return (get_local 1){{$}}
282242 define double @f64_promote_f32(float %x) {
283243 %a = fpext float %x to double
284244 ret double %a
288248 ; CHECK-NEXT: .param f64
289249 ; CHECK-NEXT: .result f32
290250 ; CHECK-NEXT: .local f64, f32{{$}}
291 ; CHECK-NEXT: get_local push, 0{{$}}
292 ; CHECK-NEXT: set_local 1, pop{{$}}
293 ; CHECK-NEXT: f32.demote/f64 push, (get_local 1){{$}}
294 ; CHECK-NEXT: set_local 2, pop{{$}}
295 ; CHECK-NEXT: return (get_local 2){{$}}
251 ; CHECK-NEXT: f32.demote/f64 $push, (get_local 0){{$}}
252 ; CHECK-NEXT: set_local 1, $pop{{$}}
253 ; CHECK-NEXT: return (get_local 1){{$}}
296254 define float @f32_demote_f64(double %x) {
297255 %a = fptrunc double %x to float
298256 ret float %a
0 ; RUN: llc < %s -asm-verbose=false | FileCheck %s
11
2 ; Check that unused vregs don't prevent locals from being numbered wrong.
3 ;
4 ; The test currently checks that the dead virtual registers still appear as
5 ; locals, which isn't what we want long term. Removing them from the list of
6 ; locals will require remapping the local numbers, and checking that the
7 ; get_/set_local have the right numbers.
2 ; Check that unused vregs aren't assigned registers.
83
94 target datalayout = "e-p:32:32-i64:64-n32:64-S128"
105 target triple = "wasm32-unknown-unknown"
149 ; CHECK-NEXT: .param i32
1510 ; CHECK-NEXT: .param i32
1611 ; CHECK-NEXT: .param i32
17 ; CHECK-NEXT: .local i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32{{$}}
12 ; CHECK-NEXT: .local i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32{{$}}
1813 entry:
1914 %cmp.19 = icmp sgt i32 %h, 0
2015 br i1 %cmp.19, label %for.cond.1.preheader.lr.ph, label %for.end.7
1818 ; CHECK-NEXT: .param f32{{$}}
1919 ; CHECK-NEXT: .result f32{{$}}
2020 ; CHECK-NEXT: .local f32, f32, f32{{$}}
21 ; CHECK-NEXT: get_local push, 1{{$}}
22 ; CHECK-NEXT: set_local 2, pop{{$}}
23 ; CHECK-NEXT: get_local push, 0{{$}}
24 ; CHECK-NEXT: set_local 3, pop{{$}}
25 ; CHECK-NEXT: f32.add push, (get_local 3), (get_local 2){{$}}
26 ; CHECK-NEXT: set_local 4, pop{{$}}
27 ; CHECK-NEXT: return (get_local 4){{$}}
21 ; CHECK-NEXT: f32.add $push, (get_local 0), (get_local 1){{$}}
22 ; CHECK-NEXT: set_local 2, $pop{{$}}
23 ; CHECK-NEXT: return (get_local 2){{$}}
2824 define float @fadd32(float %x, float %y) {
2925 %a = fadd float %x, %y
3026 ret float %a
3127 }
3228
3329 ; CHECK-LABEL: fsub32:
34 ; CHECK: f32.sub push, (get_local 3), (get_local 2){{$}}
35 ; CHECK-NEXT: set_local 4, pop{{$}}
30 ; CHECK: f32.sub $push, (get_local 0), (get_local 1){{$}}
31 ; CHECK-NEXT: set_local 2, $pop{{$}}
3632 define float @fsub32(float %x, float %y) {
3733 %a = fsub float %x, %y
3834 ret float %a
3935 }
4036
4137 ; CHECK-LABEL: fmul32:
42 ; CHECK: f32.mul push, (get_local 3), (get_local 2){{$}}
43 ; CHECK-NEXT: set_local 4, pop{{$}}
38 ; CHECK: f32.mul $push, (get_local 0), (get_local 1){{$}}
39 ; CHECK-NEXT: set_local 2, $pop{{$}}
4440 define float @fmul32(float %x, float %y) {
4541 %a = fmul float %x, %y
4642 ret float %a
4743 }
4844
4945 ; CHECK-LABEL: fdiv32:
50 ; CHECK: f32.div push, (get_local 3), (get_local 2){{$}}
51 ; CHECK-NEXT: set_local 4, pop{{$}}
46 ; CHECK: f32.div $push, (get_local 0), (get_local 1){{$}}
47 ; CHECK-NEXT: set_local 2, $pop{{$}}
5248 define float @fdiv32(float %x, float %y) {
5349 %a = fdiv float %x, %y
5450 ret float %a
5551 }
5652
5753 ; CHECK-LABEL: fabs32:
58 ; CHECK: f32.abs push, (get_local 1){{$}}
59 ; CHECK-NEXT: set_local 2, pop{{$}}
54 ; CHECK: f32.abs $push, (get_local 0){{$}}
55 ; CHECK-NEXT: set_local 1, $pop{{$}}
6056 define float @fabs32(float %x) {
6157 %a = call float @llvm.fabs.f32(float %x)
6258 ret float %a
6359 }
6460
6561 ; CHECK-LABEL: fneg32:
66 ; CHECK: f32.neg push, (get_local 1){{$}}
67 ; CHECK-NEXT: set_local 2, pop{{$}}
62 ; CHECK: f32.neg $push, (get_local 0){{$}}
63 ; CHECK-NEXT: set_local 1, $pop{{$}}
6864 define float @fneg32(float %x) {
6965 %a = fsub float -0., %x
7066 ret float %a
7167 }
7268
7369 ; CHECK-LABEL: copysign32:
74 ; CHECK: f32.copysign push, (get_local 3), (get_local 2){{$}}
75 ; CHECK-NEXT: set_local 4, pop{{$}}
70 ; CHECK: f32.copysign $push, (get_local 0), (get_local 1){{$}}
71 ; CHECK-NEXT: set_local 2, $pop{{$}}
7672 define float @copysign32(float %x, float %y) {
7773 %a = call float @llvm.copysign.f32(float %x, float %y)
7874 ret float %a
7975 }
8076
8177 ; CHECK-LABEL: sqrt32:
82 ; CHECK: f32.sqrt push, (get_local 1){{$}}
83 ; CHECK-NEXT: set_local 2, pop{{$}}
78 ; CHECK: f32.sqrt $push, (get_local 0){{$}}
79 ; CHECK-NEXT: set_local 1, $pop{{$}}
8480 define float @sqrt32(float %x) {
8581 %a = call float @llvm.sqrt.f32(float %x)
8682 ret float %a
8783 }
8884
8985 ; CHECK-LABEL: ceil32:
90 ; CHECK: f32.ceil push, (get_local 1){{$}}
91 ; CHECK-NEXT: set_local 2, pop{{$}}
86 ; CHECK: f32.ceil $push, (get_local 0){{$}}
87 ; CHECK-NEXT: set_local 1, $pop{{$}}
9288 define float @ceil32(float %x) {
9389 %a = call float @llvm.ceil.f32(float %x)
9490 ret float %a
9591 }
9692
9793 ; CHECK-LABEL: floor32:
98 ; CHECK: f32.floor push, (get_local 1){{$}}
99 ; CHECK-NEXT: set_local 2, pop{{$}}
94 ; CHECK: f32.floor $push, (get_local 0){{$}}
95 ; CHECK-NEXT: set_local 1, $pop{{$}}
10096 define float @floor32(float %x) {
10197 %a = call float @llvm.floor.f32(float %x)
10298 ret float %a
10399 }
104100
105101 ; CHECK-LABEL: trunc32:
106 ; CHECK: f32.trunc push, (get_local 1){{$}}
107 ; CHECK-NEXT: set_local 2, pop{{$}}
102 ; CHECK: f32.trunc $push, (get_local 0){{$}}
103 ; CHECK-NEXT: set_local 1, $pop{{$}}
108104 define float @trunc32(float %x) {
109105 %a = call float @llvm.trunc.f32(float %x)
110106 ret float %a
111107 }
112108
113109 ; CHECK-LABEL: nearest32:
114 ; CHECK: f32.nearest push, (get_local 1){{$}}
115 ; CHECK-NEXT: set_local 2, pop{{$}}
110 ; CHECK: f32.nearest $push, (get_local 0){{$}}
111 ; CHECK-NEXT: set_local 1, $pop{{$}}
116112 define float @nearest32(float %x) {
117113 %a = call float @llvm.nearbyint.f32(float %x)
118114 ret float %a
119115 }
120116
121117 ; CHECK-LABEL: nearest32_via_rint:
122 ; CHECK: f32.nearest push, (get_local 1){{$}}
123 ; CHECK-NEXT: set_local 2, pop{{$}}
118 ; CHECK: f32.nearest $push, (get_local 0){{$}}
119 ; CHECK-NEXT: set_local 1, $pop{{$}}
124120 define float @nearest32_via_rint(float %x) {
125121 %a = call float @llvm.rint.f32(float %x)
126122 ret float %a
133129 ; tests.
134130
135131 ; CHECK-LABEL: fmin32:
136 ; CHECK: f32.min push, (get_local 1), (get_local 2){{$}}
137 ; CHECK-NEXT: set_local 3, pop{{$}}
132 ; CHECK: f32.min $push, (get_local 0), (get_local 1){{$}}
133 ; CHECK-NEXT: set_local 2, $pop{{$}}
138134 define float @fmin32(float %x) {
139135 %a = fcmp ult float %x, 0.0
140136 %b = select i1 %a, float %x, float 0.0
142138 }
143139
144140 ; CHECK-LABEL: fmax32:
145 ; CHECK: f32.max push, (get_local 1), (get_local 2){{$}}
146 ; CHECK-NEXT: set_local 3, pop{{$}}
141 ; CHECK: f32.max $push, (get_local 0), (get_local 1){{$}}
142 ; CHECK-NEXT: set_local 2, $pop{{$}}
147143 define float @fmax32(float %x) {
148144 %a = fcmp ugt float %x, 0.0
149145 %b = select i1 %a, float %x, float 0.0
1818 ; CHECK-NEXT: .param f64{{$}}
1919 ; CHECK-NEXT: .result f64{{$}}
2020 ; CHECK-NEXT: .local f64, f64, f64{{$}}
21 ; CHECK-NEXT: get_local push, 1{{$}}
22 ; CHECK-NEXT: set_local 2, pop{{$}}
23 ; CHECK-NEXT: get_local push, 0{{$}}
24 ; CHECK-NEXT: set_local 3, pop{{$}}
25 ; CHECK-NEXT: f64.add push, (get_local 3), (get_local 2){{$}}
26 ; CHECK-NEXT: set_local 4, pop{{$}}
27 ; CHECK-NEXT: return (get_local 4){{$}}
21 ; CHECK-NEXT: f64.add $push, (get_local 0), (get_local 1){{$}}
22 ; CHECK-NEXT: set_local 2, $pop{{$}}
23 ; CHECK-NEXT: return (get_local 2){{$}}
2824 define double @fadd64(double %x, double %y) {
2925 %a = fadd double %x, %y
3026 ret double %a
3127 }
3228
3329 ; CHECK-LABEL: fsub64:
34 ; CHECK: f64.sub push, (get_local 3), (get_local 2){{$}}
35 ; CHECK-NEXT: set_local 4, pop{{$}}
30 ; CHECK: f64.sub $push, (get_local 0), (get_local 1){{$}}
31 ; CHECK-NEXT: set_local 2, $pop{{$}}
3632 define double @fsub64(double %x, double %y) {
3733 %a = fsub double %x, %y
3834 ret double %a
3935 }
4036
4137 ; CHECK-LABEL: fmul64:
42 ; CHECK: f64.mul push, (get_local 3), (get_local 2){{$}}
43 ; CHECK-NEXT: set_local 4, pop{{$}}
38 ; CHECK: f64.mul $push, (get_local 0), (get_local 1){{$}}
39 ; CHECK-NEXT: set_local 2, $pop{{$}}
4440 define double @fmul64(double %x, double %y) {
4541 %a = fmul double %x, %y
4642 ret double %a
4743 }
4844
4945 ; CHECK-LABEL: fdiv64:
50 ; CHECK: f64.div push, (get_local 3), (get_local 2){{$}}
51 ; CHECK-NEXT: set_local 4, pop{{$}}
46 ; CHECK: f64.div $push, (get_local 0), (get_local 1){{$}}
47 ; CHECK-NEXT: set_local 2, $pop{{$}}
5248 define double @fdiv64(double %x, double %y) {
5349 %a = fdiv double %x, %y
5450 ret double %a
5551 }
5652
5753 ; CHECK-LABEL: fabs64:
58 ; CHECK: f64.abs push, (get_local 1){{$}}
59 ; CHECK-NEXT: set_local 2, pop{{$}}
54 ; CHECK: f64.abs $push, (get_local 0){{$}}
55 ; CHECK-NEXT: set_local 1, $pop{{$}}
6056 define double @fabs64(double %x) {
6157 %a = call double @llvm.fabs.f64(double %x)
6258 ret double %a
6359 }
6460
6561 ; CHECK-LABEL: fneg64:
66 ; CHECK: f64.neg push, (get_local 1){{$}}
67 ; CHECK-NEXT: set_local 2, pop{{$}}
62 ; CHECK: f64.neg $push, (get_local 0){{$}}
63 ; CHECK-NEXT: set_local 1, $pop{{$}}
6864 define double @fneg64(double %x) {
6965 %a = fsub double -0., %x
7066 ret double %a
7167 }
7268
7369 ; CHECK-LABEL: copysign64:
74 ; CHECK: f64.copysign push, (get_local 3), (get_local 2){{$}}
75 ; CHECK-NEXT: set_local 4, pop{{$}}
70 ; CHECK: f64.copysign $push, (get_local 0), (get_local 1){{$}}
71 ; CHECK-NEXT: set_local 2, $pop{{$}}
7672 define double @copysign64(double %x, double %y) {
7773 %a = call double @llvm.copysign.f64(double %x, double %y)
7874 ret double %a
7975 }
8076
8177 ; CHECK-LABEL: sqrt64:
82 ; CHECK: f64.sqrt push, (get_local 1){{$}}
83 ; CHECK-NEXT: set_local 2, pop{{$}}
78 ; CHECK: f64.sqrt $push, (get_local 0){{$}}
79 ; CHECK-NEXT: set_local 1, $pop{{$}}
8480 define double @sqrt64(double %x) {
8581 %a = call double @llvm.sqrt.f64(double %x)
8682 ret double %a
8783 }
8884
8985 ; CHECK-LABEL: ceil64:
90 ; CHECK: f64.ceil push, (get_local 1){{$}}
91 ; CHECK-NEXT: set_local 2, pop{{$}}
86 ; CHECK: f64.ceil $push, (get_local 0){{$}}
87 ; CHECK-NEXT: set_local 1, $pop{{$}}
9288 define double @ceil64(double %x) {
9389 %a = call double @llvm.ceil.f64(double %x)
9490 ret double %a
9591 }
9692
9793 ; CHECK-LABEL: floor64:
98 ; CHECK: f64.floor push, (get_local 1){{$}}
99 ; CHECK-NEXT: set_local 2, pop{{$}}
94 ; CHECK: f64.floor $push, (get_local 0){{$}}
95 ; CHECK-NEXT: set_local 1, $pop{{$}}
10096 define double @floor64(double %x) {
10197 %a = call double @llvm.floor.f64(double %x)
10298 ret double %a
10399 }
104100
105101 ; CHECK-LABEL: trunc64:
106 ; CHECK: f64.trunc push, (get_local 1){{$}}
107 ; CHECK-NEXT: set_local 2, pop{{$}}
102 ; CHECK: f64.trunc $push, (get_local 0){{$}}
103 ; CHECK-NEXT: set_local 1, $pop{{$}}
108104 define double @trunc64(double %x) {
109105 %a = call double @llvm.trunc.f64(double %x)
110106 ret double %a
111107 }
112108
113109 ; CHECK-LABEL: nearest64:
114 ; CHECK: f64.nearest push, (get_local 1){{$}}
115 ; CHECK-NEXT: set_local 2, pop{{$}}
110 ; CHECK: f64.nearest $push, (get_local 0){{$}}
111 ; CHECK-NEXT: set_local 1, $pop{{$}}
116112 define double @nearest64(double %x) {
117113 %a = call double @llvm.nearbyint.f64(double %x)
118114 ret double %a
119115 }
120116
121117 ; CHECK-LABEL: nearest64_via_rint:
122 ; CHECK: f64.nearest push, (get_local 1){{$}}
123 ; CHECK-NEXT: set_local 2, pop{{$}}
118 ; CHECK: f64.nearest $push, (get_local 0){{$}}
119 ; CHECK-NEXT: set_local 1, $pop{{$}}
124120 define double @nearest64_via_rint(double %x) {
125121 %a = call double @llvm.rint.f64(double %x)
126122 ret double %a
133129 ; tests.
134130
135131 ; CHECK-LABEL: fmin64:
136 ; CHECK: f64.min push, (get_local 1), (get_local 2){{$}}
137 ; CHECK-NEXT: set_local 3, pop{{$}}
132 ; CHECK: f64.min $push, (get_local 0), (get_local 1){{$}}
133 ; CHECK-NEXT: set_local 2, $pop{{$}}
138134 define double @fmin64(double %x) {
139135 %a = fcmp ult double %x, 0.0
140136 %b = select i1 %a, double %x, double 0.0
142138 }
143139
144140 ; CHECK-LABEL: fmax64:
145 ; CHECK: f64.max push, (get_local 1), (get_local 2){{$}}
146 ; CHECK-NEXT: set_local 3, pop{{$}}
141 ; CHECK: f64.max $push, (get_local 0), (get_local 1){{$}}
142 ; CHECK-NEXT: set_local 2, $pop{{$}}
147143 define double @fmax64(double %x) {
148144 %a = fcmp ugt double %x, 0.0
149145 %b = select i1 %a, double %x, double 0.0
77 ; This tests very minimal fast-isel functionality.
88
99 ; CHECK-LABEL: immediate_f32:
10 ; CHECK: f32.const push, 0x1.4p1{{$}}
10 ; CHECK: f32.const $push, 0x1.4p1{{$}}
1111 define float @immediate_f32() {
1212 ret float 2.5
1313 }
1414
1515 ; CHECK-LABEL: immediate_f64:
16 ; CHECK: f64.const push, 0x1.4p1{{$}}
16 ; CHECK: f64.const $push, 0x1.4p1{{$}}
1717 define double @immediate_f64() {
1818 ret double 2.5
1919 }
1414 ; CHECK-LABEL: f1:
1515 ; CHECK-NEXT: .result i32{{$}}
1616 ; CHECK-NEXT: .local i32{{$}}
17 ; CHECK-NEXT: i32.const push, 0{{$}}
18 ; CHECK-NEXT: set_local 0, pop{{$}}
17 ; CHECK-NEXT: i32.const $push, 0{{$}}
18 ; CHECK-NEXT: set_local 0, $pop{{$}}
1919 ; CHECK-NEXT: return (get_local 0){{$}}
2020 ; CHECK: .size f1,
2121 define i32 @f1() {
2727 ; CHECK-NEXT: .param f32{{$}}
2828 ; CHECK-NEXT: .result i32{{$}}
2929 ; CHECK-NEXT: .local i32{{$}}
30 ; CHECK-NEXT: i32.const push, 0{{$}}
31 ; CHECK-NEXT: set_local 2, pop{{$}}
30 ; CHECK-NEXT: i32.const $push, 0{{$}}
31 ; CHECK-NEXT: set_local 2, $pop{{$}}
3232 ; CHECK-NEXT: return (get_local 2){{$}}
3333 ; CHECK: .size f2,
3434 define i32 @f2(i32 %p1, float %p2) {
1313 ; CHECK-NEXT: .param i32{{$}}
1414 ; CHECK-NEXT: .result i32{{$}}
1515 ; CHECK-NEXT: .local i32, i32, i32{{$}}
16 ; CHECK-NEXT: get_local push, 1{{$}}
17 ; CHECK-NEXT: set_local 2, pop{{$}}
18 ; CHECK-NEXT: get_local push, 0{{$}}
19 ; CHECK-NEXT: set_local 3, pop{{$}}
20 ; CHECK-NEXT: i32.add push, (get_local 3), (get_local 2){{$}}
21 ; CHECK-NEXT: set_local 4, pop{{$}}
22 ; CHECK-NEXT: return (get_local 4){{$}}
16 ; CHECK-NEXT: i32.add $push, (get_local 0), (get_local 1){{$}}
17 ; CHECK-NEXT: set_local 2, $pop{{$}}
18 ; CHECK-NEXT: return (get_local 2){{$}}
2319 define i32 @add32(i32 %x, i32 %y) {
2420 %a = add i32 %x, %y
2521 ret i32 %a
3026 ; CHECK-NEXT: .param i32{{$}}
3127 ; CHECK-NEXT: .result i32{{$}}
3228 ; CHECK-NEXT: .local i32, i32, i32{{$}}
33 ; CHECK-NEXT: get_local push, 1{{$}}
34 ; CHECK-NEXT: set_local 2, pop{{$}}
35 ; CHECK-NEXT: get_local push, 0{{$}}
36 ; CHECK-NEXT: set_local 3, pop{{$}}
37 ; CHECK-NEXT: i32.sub push, (get_local 3), (get_local 2){{$}}
38 ; CHECK-NEXT: set_local 4, pop{{$}}
39 ; CHECK-NEXT: return (get_local 4){{$}}
29 ; CHECK-NEXT: i32.sub $push, (get_local 0), (get_local 1){{$}}
30 ; CHECK-NEXT: set_local 2, $pop{{$}}
31 ; CHECK-NEXT: return (get_local 2){{$}}
4032 define i32 @sub32(i32 %x, i32 %y) {
4133 %a = sub i32 %x, %y
4234 ret i32 %a
4739 ; CHECK-NEXT: .param i32{{$}}
4840 ; CHECK-NEXT: .result i32{{$}}
4941 ; CHECK-NEXT: .local i32, i32, i32{{$}}
50 ; CHECK-NEXT: get_local push, 1{{$}}
51 ; CHECK-NEXT: set_local 2, pop{{$}}
52 ; CHECK-NEXT: get_local push, 0{{$}}
53 ; CHECK-NEXT: set_local 3, pop{{$}}
54 ; CHECK-NEXT: i32.mul push, (get_local 3), (get_local 2){{$}}
55 ; CHECK-NEXT: set_local 4, pop{{$}}
56 ; CHECK-NEXT: return (get_local 4){{$}}
42 ; CHECK-NEXT: i32.mul $push, (get_local 0), (get_local 1){{$}}
43 ; CHECK-NEXT: set_local 2, $pop{{$}}
44 ; CHECK-NEXT: return (get_local 2){{$}}
5745 define i32 @mul32(i32 %x, i32 %y) {
5846 %a = mul i32 %x, %y
5947 ret i32 %a
6452 ; CHECK-NEXT: .param i32{{$}}
6553 ; CHECK-NEXT: .result i32{{$}}
6654 ; CHECK-NEXT: .local i32, i32, i32{{$}}
67 ; CHECK-NEXT: get_local push, 1{{$}}
68 ; CHECK-NEXT: set_local 2, pop{{$}}
69 ; CHECK-NEXT: get_local push, 0{{$}}
70 ; CHECK-NEXT: set_local 3, pop{{$}}
71 ; CHECK-NEXT: i32.div_s push, (get_local 3), (get_local 2){{$}}
72 ; CHECK-NEXT: set_local 4, pop{{$}}
73 ; CHECK-NEXT: return (get_local 4){{$}}
55 ; CHECK-NEXT: i32.div_s $push, (get_local 0), (get_local 1){{$}}
56 ; CHECK-NEXT: set_local 2, $pop{{$}}
57 ; CHECK-NEXT: return (get_local 2){{$}}
7458 define i32 @sdiv32(i32 %x, i32 %y) {
7559 %a = sdiv i32 %x, %y
7660 ret i32 %a
8165 ; CHECK-NEXT: .param i32{{$}}
8266 ; CHECK-NEXT: .result i32{{$}}
8367 ; CHECK-NEXT: .local i32, i32, i32{{$}}
84 ; CHECK-NEXT: get_local push, 1{{$}}
85 ; CHECK-NEXT: set_local 2, pop{{$}}
86 ; CHECK-NEXT: get_local push, 0{{$}}
87 ; CHECK-NEXT: set_local 3, pop{{$}}
88 ; CHECK-NEXT: i32.div_u push, (get_local 3), (get_local 2){{$}}
89 ; CHECK-NEXT: set_local 4, pop{{$}}
90 ; CHECK-NEXT: return (get_local 4){{$}}
68 ; CHECK-NEXT: i32.div_u $push, (get_local 0), (get_local 1){{$}}
69 ; CHECK-NEXT: set_local 2, $pop{{$}}
70 ; CHECK-NEXT: return (get_local 2){{$}}
9171 define i32 @udiv32(i32 %x, i32 %y) {
9272 %a = udiv i32 %x, %y
9373 ret i32 %a
9878 ; CHECK-NEXT: .param i32{{$}}
9979 ; CHECK-NEXT: .result i32{{$}}
10080 ; CHECK-NEXT: .local i32, i32, i32{{$}}
101 ; CHECK-NEXT: get_local push, 1{{$}}
102 ; CHECK-NEXT: set_local 2, pop{{$}}
103 ; CHECK-NEXT: get_local push, 0{{$}}
104 ; CHECK-NEXT: set_local 3, pop{{$}}
105 ; CHECK-NEXT: i32.rem_s push, (get_local 3), (get_local 2){{$}}
106 ; CHECK-NEXT: set_local 4, pop{{$}}
107 ; CHECK-NEXT: return (get_local 4){{$}}
81 ; CHECK-NEXT: i32.rem_s $push, (get_local 0), (get_local 1){{$}}
82 ; CHECK-NEXT: set_local 2, $pop{{$}}
83 ; CHECK-NEXT: return (get_local 2){{$}}
10884 define i32 @srem32(i32 %x, i32 %y) {
10985 %a = srem i32 %x, %y
11086 ret i32 %a
11591 ; CHECK-NEXT: .param i32{{$}}
11692 ; CHECK-NEXT: .result i32{{$}}
11793 ; CHECK-NEXT: .local i32, i32, i32{{$}}
118 ; CHECK-NEXT: get_local push, 1{{$}}
119 ; CHECK-NEXT: set_local 2, pop{{$}}
120 ; CHECK-NEXT: get_local push, 0{{$}}
121 ; CHECK-NEXT: set_local 3, pop{{$}}
122 ; CHECK-NEXT: i32.rem_u push, (get_local 3), (get_local 2){{$}}
123 ; CHECK-NEXT: set_local 4, pop{{$}}
124 ; CHECK-NEXT: return (get_local 4){{$}}
94 ; CHECK-NEXT: i32.rem_u $push, (get_local 0), (get_local 1){{$}}
95 ; CHECK-NEXT: set_local 2, $pop{{$}}
96 ; CHECK-NEXT: return (get_local 2){{$}}
12597 define i32 @urem32(i32 %x, i32 %y) {
12698 %a = urem i32 %x, %y
12799 ret i32 %a
132104 ; CHECK-NEXT: .param i32{{$}}
133105 ; CHECK-NEXT: .result i32{{$}}
134106 ; CHECK-NEXT: .local i32, i32, i32{{$}}
135 ; CHECK-NEXT: get_local push, 1{{$}}
136 ; CHECK-NEXT: set_local 2, pop{{$}}
137 ; CHECK-NEXT: get_local push, 0{{$}}
138 ; CHECK-NEXT: set_local 3, pop{{$}}
139 ; CHECK-NEXT: i32.and push, (get_local 3), (get_local 2){{$}}
140 ; CHECK-NEXT: set_local 4, pop{{$}}
141 ; CHECK-NEXT: return (get_local 4){{$}}
107 ; CHECK-NEXT: i32.and $push, (get_local 0), (get_local 1){{$}}
108 ; CHECK-NEXT: set_local 2, $pop{{$}}
109 ; CHECK-NEXT: return (get_local 2){{$}}
142110 define i32 @and32(i32 %x, i32 %y) {
143111 %a = and i32 %x, %y
144112 ret i32 %a
149117 ; CHECK-NEXT: .param i32{{$}}
150118 ; CHECK-NEXT: .result i32{{$}}
151119 ; CHECK-NEXT: .local i32, i32, i32{{$}}
152 ; CHECK-NEXT: get_local push, 1{{$}}
153 ; CHECK-NEXT: set_local 2, pop{{$}}
154 ; CHECK-NEXT: get_local push, 0{{$}}
155 ; CHECK-NEXT: set_local 3, pop{{$}}
156 ; CHECK-NEXT: i32.or push, (get_local 3), (get_local 2){{$}}
157 ; CHECK-NEXT: set_local 4, pop{{$}}
158 ; CHECK-NEXT: return (get_local 4){{$}}
120 ; CHECK-NEXT: i32.or $push, (get_local 0), (get_local 1){{$}}
121 ; CHECK-NEXT: set_local 2, $pop{{$}}
122 ; CHECK-NEXT: return (get_local 2){{$}}
159123 define i32 @or32(i32 %x, i32 %y) {
160124 %a = or i32 %x, %y
161125 ret i32 %a
166130 ; CHECK-NEXT: .param i32{{$}}
167131 ; CHECK-NEXT: .result i32{{$}}
168132 ; CHECK-NEXT: .local i32, i32, i32{{$}}
169 ; CHECK-NEXT: get_local push, 1{{$}}
170 ; CHECK-NEXT: set_local 2, pop{{$}}
171 ; CHECK-NEXT: get_local push, 0{{$}}
172 ; CHECK-NEXT: set_local 3, pop{{$}}
173 ; CHECK-NEXT: i32.xor push, (get_local 3), (get_local 2){{$}}
174 ; CHECK-NEXT: set_local 4, pop{{$}}
175 ; CHECK-NEXT: return (get_local 4){{$}}
133 ; CHECK-NEXT: i32.xor $push, (get_local 0), (get_local 1){{$}}
134 ; CHECK-NEXT: set_local 2, $pop{{$}}
135 ; CHECK-NEXT: return (get_local 2){{$}}
176136 define i32 @xor32(i32 %x, i32 %y) {
177137 %a = xor i32 %x, %y
178138 ret i32 %a
183143 ; CHECK-NEXT: .param i32{{$}}
184144 ; CHECK-NEXT: .result i32{{$}}
185145 ; CHECK-NEXT: .local i32, i32, i32{{$}}
186 ; CHECK-NEXT: get_local push, 1{{$}}
187 ; CHECK-NEXT: set_local 2, pop{{$}}
188 ; CHECK-NEXT: get_local push, 0{{$}}
189 ; CHECK-NEXT: set_local 3, pop{{$}}
190 ; CHECK-NEXT: i32.shl push, (get_local 3), (get_local 2){{$}}
191 ; CHECK-NEXT: set_local 4, pop{{$}}
192 ; CHECK-NEXT: return (get_local 4){{$}}
146 ; CHECK-NEXT: i32.shl $push, (get_local 0), (get_local 1){{$}}
147 ; CHECK-NEXT: set_local 2, $pop{{$}}
148 ; CHECK-NEXT: return (get_local 2){{$}}
193149 define i32 @shl32(i32 %x, i32 %y) {
194150 %a = shl i32 %x, %y
195151 ret i32 %a
200156 ; CHECK-NEXT: .param i32{{$}}
201157 ; CHECK-NEXT: .result i32{{$}}
202158 ; CHECK-NEXT: .local i32, i32, i32{{$}}
203 ; CHECK-NEXT: get_local push, 1{{$}}
204 ; CHECK-NEXT: set_local 2, pop{{$}}
205 ; CHECK-NEXT: get_local push, 0{{$}}
206 ; CHECK-NEXT: set_local 3, pop{{$}}
207 ; CHECK-NEXT: i32.shr_u push, (get_local 3), (get_local 2){{$}}
208 ; CHECK-NEXT: set_local 4, pop{{$}}
209 ; CHECK-NEXT: return (get_local 4){{$}}
159 ; CHECK-NEXT: i32.shr_u $push, (get_local 0), (get_local 1){{$}}
160 ; CHECK-NEXT: set_local 2, $pop{{$}}
161 ; CHECK-NEXT: return (get_local 2){{$}}
210162 define i32 @shr32(i32 %x, i32 %y) {
211163 %a = lshr i32 %x, %y
212164 ret i32 %a
217169 ; CHECK-NEXT: .param i32{{$}}
218170 ; CHECK-NEXT: .result i32{{$}}
219171 ; CHECK-NEXT: .local i32, i32, i32{{$}}
220 ; CHECK-NEXT: get_local push, 1{{$}}
221 ; CHECK-NEXT: set_local 2, pop{{$}}
222 ; CHECK-NEXT: get_local push, 0{{$}}
223 ; CHECK-NEXT: set_local 3, pop{{$}}
224 ; CHECK-NEXT: i32.shr_s push, (get_local 3), (get_local 2){{$}}
225 ; CHECK-NEXT: set_local 4, pop{{$}}
226 ; CHECK-NEXT: return (get_local 4){{$}}
172 ; CHECK-NEXT: i32.shr_s $push, (get_local 0), (get_local 1){{$}}
173 ; CHECK-NEXT: set_local 2, $pop{{$}}
174 ; CHECK-NEXT: return (get_local 2){{$}}
227175 define i32 @sar32(i32 %x, i32 %y) {
228176 %a = ashr i32 %x, %y
229177 ret i32 %a
233181 ; CHECK-NEXT: .param i32{{$}}
234182 ; CHECK-NEXT: .result i32{{$}}
235183 ; CHECK-NEXT: .local i32, i32{{$}}
236 ; CHECK-NEXT: get_local push, 0{{$}}
237 ; CHECK-NEXT: set_local 1, pop{{$}}
238 ; CHECK-NEXT: i32.clz push, (get_local 1){{$}}
239 ; CHECK-NEXT: set_local 2, pop{{$}}
240 ; CHECK-NEXT: return (get_local 2){{$}}
184 ; CHECK-NEXT: i32.clz $push, (get_local 0){{$}}
185 ; CHECK-NEXT: set_local 1, $pop{{$}}
186 ; CHECK-NEXT: return (get_local 1){{$}}
241187 define i32 @clz32(i32 %x) {
242188 %a = call i32 @llvm.ctlz.i32(i32 %x, i1 false)
243189 ret i32 %a
247193 ; CHECK-NEXT: .param i32{{$}}
248194 ; CHECK-NEXT: .result i32{{$}}
249195 ; CHECK-NEXT: .local i32, i32{{$}}
250 ; CHECK-NEXT: get_local push, 0{{$}}
251 ; CHECK-NEXT: set_local 1, pop{{$}}
252 ; CHECK-NEXT: i32.clz push, (get_local 1){{$}}
253 ; CHECK-NEXT: set_local 2, pop{{$}}
254 ; CHECK-NEXT: return (get_local 2){{$}}
196 ; CHECK-NEXT: i32.clz $push, (get_local 0){{$}}
197 ; CHECK-NEXT: set_local 1, $pop{{$}}
198 ; CHECK-NEXT: return (get_local 1){{$}}
255199 define i32 @clz32_zero_undef(i32 %x) {
256200 %a = call i32 @llvm.ctlz.i32(i32 %x, i1 true)
257201 ret i32 %a
261205 ; CHECK-NEXT: .param i32{{$}}
262206 ; CHECK-NEXT: .result i32{{$}}
263207 ; CHECK-NEXT: .local i32, i32{{$}}
264 ; CHECK-NEXT: get_local push, 0{{$}}
265 ; CHECK-NEXT: set_local 1, pop{{$}}
266 ; CHECK-NEXT: i32.ctz push, (get_local 1){{$}}
267 ; CHECK-NEXT: set_local 2, pop{{$}}
268 ; CHECK-NEXT: return (get_local 2){{$}}
208 ; CHECK-NEXT: i32.ctz $push, (get_local 0){{$}}
209 ; CHECK-NEXT: set_local 1, $pop{{$}}
210 ; CHECK-NEXT: return (get_local 1){{$}}
269211 define i32 @ctz32(i32 %x) {
270212 %a = call i32 @llvm.cttz.i32(i32 %x, i1 false)
271213 ret i32 %a
275217 ; CHECK-NEXT: .param i32{{$}}
276218 ; CHECK-NEXT: .result i32{{$}}
277219 ; CHECK-NEXT: .local i32, i32{{$}}
278 ; CHECK-NEXT: get_local push, 0{{$}}
279 ; CHECK-NEXT: set_local 1, pop{{$}}
280 ; CHECK-NEXT: i32.ctz push, (get_local 1){{$}}
281 ; CHECK-NEXT: set_local 2, pop{{$}}
282 ; CHECK-NEXT: return (get_local 2){{$}}
220 ; CHECK-NEXT: i32.ctz $push, (get_local 0){{$}}
221 ; CHECK-NEXT: set_local 1, $pop{{$}}
222 ; CHECK-NEXT: return (get_local 1){{$}}
283223 define i32 @ctz32_zero_undef(i32 %x) {
284224 %a = call i32 @llvm.cttz.i32(i32 %x, i1 true)
285225 ret i32 %a
289229 ; CHECK-NEXT: .param i32{{$}}
290230 ; CHECK-NEXT: .result i32{{$}}
291231 ; CHECK-NEXT: .local i32, i32{{$}}
292 ; CHECK-NEXT: get_local push, 0{{$}}
293 ; CHECK-NEXT: set_local 1, pop{{$}}
294 ; CHECK-NEXT: i32.popcnt push, (get_local 1){{$}}
295 ; CHECK-NEXT: set_local 2, pop{{$}}
296 ; CHECK-NEXT: return (get_local 2){{$}}
232 ; CHECK-NEXT: i32.popcnt $push, (get_local 0){{$}}
233 ; CHECK-NEXT: set_local 1, $pop{{$}}
234 ; CHECK-NEXT: return (get_local 1){{$}}
297235 define i32 @popcnt32(i32 %x) {
298236 %a = call i32 @llvm.ctpop.i32(i32 %x)
299237 ret i32 %a
1313 ; CHECK-NEXT: .param i64{{$}}
1414 ; CHECK-NEXT: .result i64{{$}}
1515 ; CHECK-NEXT: .local i64, i64, i64{{$}}
16 ; CHECK-NEXT: get_local push, 1{{$}}
17 ; CHECK-NEXT: set_local 2, pop{{$}}
18 ; CHECK-NEXT: get_local push, 0{{$}}
19 ; CHECK-NEXT: set_local 3, pop{{$}}
20 ; CHECK-NEXT: i64.add push, (get_local 3), (get_local 2){{$}}
21 ; CHECK-NEXT: set_local 4, pop{{$}}
22 ; CHECK-NEXT: return (get_local 4){{$}}
16 ; CHECK-NEXT: i64.add $push, (get_local 0), (get_local 1){{$}}
17 ; CHECK-NEXT: set_local 2, $pop{{$}}
18 ; CHECK-NEXT: return (get_local 2){{$}}
2319 define i64 @add64(i64 %x, i64 %y) {
2420 %a = add i64 %x, %y
2521 ret i64 %a
3026 ; CHECK-NEXT: .param i64{{$}}
3127 ; CHECK-NEXT: .result i64{{$}}
3228 ; CHECK-NEXT: .local i64, i64, i64{{$}}
33 ; CHECK-NEXT: get_local push, 1{{$}}
34 ; CHECK-NEXT: set_local 2, pop{{$}}
35 ; CHECK-NEXT: get_local push, 0{{$}}
36 ; CHECK-NEXT: set_local 3, pop{{$}}
37 ; CHECK-NEXT: i64.sub push, (get_local 3), (get_local 2){{$}}
38 ; CHECK-NEXT: set_local 4, pop{{$}}
39 ; CHECK-NEXT: return (get_local 4){{$}}
29 ; CHECK-NEXT: i64.sub $push, (get_local 0), (get_local 1){{$}}
30 ; CHECK-NEXT: set_local 2, $pop{{$}}
31 ; CHECK-NEXT: return (get_local 2){{$}}
4032 define i64 @sub64(i64 %x, i64 %y) {
4133 %a = sub i64 %x, %y
4234 ret i64 %a
4739 ; CHECK-NEXT: .param i64{{$}}
4840 ; CHECK-NEXT: .result i64{{$}}
4941 ; CHECK-NEXT: .local i64, i64, i64{{$}}
50 ; CHECK-NEXT: get_local push, 1{{$}}
51 ; CHECK-NEXT: set_local 2, pop{{$}}
52 ; CHECK-NEXT: get_local push, 0{{$}}
53 ; CHECK-NEXT: set_local 3, pop{{$}}
54 ; CHECK-NEXT: i64.mul push, (get_local 3), (get_local 2){{$}}
55 ; CHECK-NEXT: set_local 4, pop{{$}}
56 ; CHECK-NEXT: return (get_local 4){{$}}
42 ; CHECK-NEXT: i64.mul $push, (get_local 0), (get_local 1){{$}}
43 ; CHECK-NEXT: set_local 2, $pop{{$}}
44 ; CHECK-NEXT: return (get_local 2){{$}}
5745 define i64 @mul64(i64 %x, i64 %y) {
5846 %a = mul i64 %x, %y
5947 ret i64 %a
6452 ; CHECK-NEXT: .param i64{{$}}
6553 ; CHECK-NEXT: .result i64{{$}}
6654 ; CHECK-NEXT: .local i64, i64, i64{{$}}
67 ; CHECK-NEXT: get_local push, 1{{$}}
68 ; CHECK-NEXT: set_local 2, pop{{$}}
69 ; CHECK-NEXT: get_local push, 0{{$}}
70 ; CHECK-NEXT: set_local 3, pop{{$}}
71 ; CHECK-NEXT: i64.div_s push, (get_local 3), (get_local 2){{$}}
72 ; CHECK-NEXT: set_local 4, pop{{$}}
73 ; CHECK-NEXT: return (get_local 4){{$}}
55 ; CHECK-NEXT: i64.div_s $push, (get_local 0), (get_local 1){{$}}
56 ; CHECK-NEXT: set_local 2, $pop{{$}}
57 ; CHECK-NEXT: return (get_local 2){{$}}
7458 define i64 @sdiv64(i64 %x, i64 %y) {
7559 %a = sdiv i64 %x, %y
7660 ret i64 %a
8165 ; CHECK-NEXT: .param i64{{$}}
8266 ; CHECK-NEXT: .result i64{{$}}
8367 ; CHECK-NEXT: .local i64, i64, i64{{$}}
84 ; CHECK-NEXT: get_local push, 1{{$}}
85 ; CHECK-NEXT: set_local 2, pop{{$}}
86 ; CHECK-NEXT: get_local push, 0{{$}}
87 ; CHECK-NEXT: set_local 3, pop{{$}}
88 ; CHECK-NEXT: i64.div_u push, (get_local 3), (get_local 2){{$}}
89 ; CHECK-NEXT: set_local 4, pop{{$}}
90 ; CHECK-NEXT: return (get_local 4){{$}}
68 ; CHECK-NEXT: i64.div_u $push, (get_local 0), (get_local 1){{$}}
69 ; CHECK-NEXT: set_local 2, $pop{{$}}
70 ; CHECK-NEXT: return (get_local 2){{$}}
9171 define i64 @udiv64(i64 %x, i64 %y) {
9272 %a = udiv i64 %x, %y
9373 ret i64 %a
9878 ; CHECK-NEXT: .param i64{{$}}
9979 ; CHECK-NEXT: .result i64{{$}}
10080 ; CHECK-NEXT: .local i64, i64, i64{{$}}
101 ; CHECK-NEXT: get_local push, 1{{$}}
102 ; CHECK-NEXT: set_local 2, pop{{$}}
103 ; CHECK-NEXT: get_local push, 0{{$}}
104 ; CHECK-NEXT: set_local 3, pop{{$}}
105 ; CHECK-NEXT: i64.rem_s push, (get_local 3), (get_local 2){{$}}
106 ; CHECK-NEXT: set_local 4, pop{{$}}
107 ; CHECK-NEXT: return (get_local 4){{$}}
81 ; CHECK-NEXT: i64.rem_s $push, (get_local 0), (get_local 1){{$}}
82 ; CHECK-NEXT: set_local 2, $pop{{$}}
83 ; CHECK-NEXT: return (get_local 2){{$}}
10884 define i64 @srem64(i64 %x, i64 %y) {
10985 %a = srem i64 %x, %y
11086 ret i64 %a
11591 ; CHECK-NEXT: .param i64{{$}}
11692 ; CHECK-NEXT: .result i64{{$}}
11793 ; CHECK-NEXT: .local i64, i64, i64{{$}}
118 ; CHECK-NEXT: get_local push, 1{{$}}
119 ; CHECK-NEXT: set_local 2, pop{{$}}
120 ; CHECK-NEXT: get_local push, 0{{$}}
121 ; CHECK-NEXT: set_local 3, pop{{$}}
122 ; CHECK-NEXT: i64.rem_u push, (get_local 3), (get_local 2){{$}}
123 ; CHECK-NEXT: set_local 4, pop{{$}}
124 ; CHECK-NEXT: return (get_local 4){{$}}
94 ; CHECK-NEXT: i64.rem_u $push, (get_local 0), (get_local 1){{$}}
95 ; CHECK-NEXT: set_local 2, $pop{{$}}
96 ; CHECK-NEXT: return (get_local 2){{$}}
12597 define i64 @urem64(i64 %x, i64 %y) {
12698 %a = urem i64 %x, %y
12799 ret i64 %a
132104 ; CHECK-NEXT: .param i64{{$}}
133105 ; CHECK-NEXT: .result i64{{$}}
134106 ; CHECK-NEXT: .local i64, i64, i64{{$}}
135 ; CHECK-NEXT: get_local push, 1{{$}}
136 ; CHECK-NEXT: set_local 2, pop{{$}}
137 ; CHECK-NEXT: get_local push, 0{{$}}
138 ; CHECK-NEXT: set_local 3, pop{{$}}
139 ; CHECK-NEXT: i64.and push, (get_local 3), (get_local 2){{$}}
140 ; CHECK-NEXT: set_local 4, pop{{$}}
141 ; CHECK-NEXT: return (get_local 4){{$}}
107 ; CHECK-NEXT: i64.and $push, (get_local 0), (get_local 1){{$}}
108 ; CHECK-NEXT: set_local 2, $pop{{$}}
109 ; CHECK-NEXT: return (get_local 2){{$}}
142110 define i64 @and64(i64 %x, i64 %y) {
143111 %a = and i64 %x, %y
144112 ret i64 %a
149117 ; CHECK-NEXT: .param i64{{$}}
150118 ; CHECK-NEXT: .result i64{{$}}
151119 ; CHECK-NEXT: .local i64, i64, i64{{$}}
152 ; CHECK-NEXT: get_local push, 1{{$}}
153 ; CHECK-NEXT: set_local 2, pop{{$}}
154 ; CHECK-NEXT: get_local push, 0{{$}}
155 ; CHECK-NEXT: set_local 3, pop{{$}}
156 ; CHECK-NEXT: i64.or push, (get_local 3), (get_local 2){{$}}
157 ; CHECK-NEXT: set_local 4, pop{{$}}
158 ; CHECK-NEXT: return (get_local 4){{$}}
120 ; CHECK-NEXT: i64.or $push, (get_local 0), (get_local 1){{$}}
121 ; CHECK-NEXT: set_local 2, $pop{{$}}
122 ; CHECK-NEXT: return (get_local 2){{$}}
159123 define i64 @or64(i64 %x, i64 %y) {
160124 %a = or i64 %x, %y
161125 ret i64 %a
166130 ; CHECK-NEXT: .param i64{{$}}
167131 ; CHECK-NEXT: .result i64{{$}}
168132 ; CHECK-NEXT: .local i64, i64, i64{{$}}
169 ; CHECK-NEXT: get_local push, 1{{$}}
170 ; CHECK-NEXT: set_local 2, pop{{$}}
171 ; CHECK-NEXT: get_local push, 0{{$}}
172 ; CHECK-NEXT: set_local 3, pop{{$}}
173 ; CHECK-NEXT: i64.xor push, (get_local 3), (get_local 2){{$}}
174 ; CHECK-NEXT: set_local 4, pop{{$}}
175 ; CHECK-NEXT: return (get_local 4){{$}}
133 ; CHECK-NEXT: i64.xor $push, (get_local 0), (get_local 1){{$}}
134 ; CHECK-NEXT: set_local 2, $pop{{$}}
135 ; CHECK-NEXT: return (get_local 2){{$}}
176136 define i64 @xor64(i64 %x, i64 %y) {
177137 %a = xor i64 %x, %y
178138 ret i64 %a
183143 ; CHECK-NEXT: .param i64{{$}}
184144 ; CHECK-NEXT: .result i64{{$}}
185145 ; CHECK-NEXT: .local i64, i64, i64{{$}}
186 ; CHECK-NEXT: get_local push, 1{{$}}
187 ; CHECK-NEXT: set_local 2, pop{{$}}
188 ; CHECK-NEXT: get_local push, 0{{$}}
189 ; CHECK-NEXT: set_local 3, pop{{$}}
190 ; CHECK-NEXT: i64.shl push, (get_local 3), (get_local 2){{$}}
191 ; CHECK-NEXT: set_local 4, pop{{$}}
192 ; CHECK-NEXT: return (get_local 4){{$}}
146 ; CHECK-NEXT: i64.shl $push, (get_local 0), (get_local 1){{$}}
147 ; CHECK-NEXT: set_local 2, $pop{{$}}
148 ; CHECK-NEXT: return (get_local 2){{$}}
193149 define i64 @shl64(i64 %x, i64 %y) {
194150 %a = shl i64 %x, %y
195151 ret i64 %a
200156 ; CHECK-NEXT: .param i64{{$}}
201157 ; CHECK-NEXT: .result i64{{$}}
202158 ; CHECK-NEXT: .local i64, i64, i64{{$}}
203 ; CHECK-NEXT: get_local push, 1{{$}}
204 ; CHECK-NEXT: set_local 2, pop{{$}}
205 ; CHECK-NEXT: get_local push, 0{{$}}
206 ; CHECK-NEXT: set_local 3, pop{{$}}
207 ; CHECK-NEXT: i64.shr_u push, (get_local 3), (get_local 2){{$}}
208 ; CHECK-NEXT: set_local 4, pop{{$}}
209 ; CHECK-NEXT: return (get_local 4){{$}}
159 ; CHECK-NEXT: i64.shr_u $push, (get_local 0), (get_local 1){{$}}
160 ; CHECK-NEXT: set_local 2, $pop{{$}}
161 ; CHECK-NEXT: return (get_local 2){{$}}
210162 define i64 @shr64(i64 %x, i64 %y) {
211163 %a = lshr i64 %x, %y
212164 ret i64 %a
217169 ; CHECK-NEXT: .param i64{{$}}
218170 ; CHECK-NEXT: .result i64{{$}}
219171 ; CHECK-NEXT: .local i64, i64, i64{{$}}
220 ; CHECK-NEXT: get_local push, 1{{$}}
221 ; CHECK-NEXT: set_local 2, pop{{$}}
222 ; CHECK-NEXT: get_local push, 0{{$}}
223 ; CHECK-NEXT: set_local 3, pop{{$}}
224 ; CHECK-NEXT: i64.shr_s push, (get_local 3), (get_local 2){{$}}
225 ; CHECK-NEXT: set_local 4, pop{{$}}
226 ; CHECK-NEXT: return (get_local 4){{$}}
172 ; CHECK-NEXT: i64.shr_s $push, (get_local 0), (get_local 1){{$}}
173 ; CHECK-NEXT: set_local 2, $pop{{$}}
174 ; CHECK-NEXT: return (get_local 2){{$}}
227175 define i64 @sar64(i64 %x, i64 %y) {
228176 %a = ashr i64 %x, %y
229177 ret i64 %a
233181 ; CHECK-NEXT: .param i64{{$}}
234182 ; CHECK-NEXT: .result i64{{$}}
235183 ; CHECK-NEXT: .local i64, i64{{$}}
236 ; CHECK-NEXT: get_local push, 0{{$}}
237 ; CHECK-NEXT: set_local 1, pop{{$}}
238 ; CHECK-NEXT: i64.clz push, (get_local 1){{$}}
239 ; CHECK-NEXT: set_local 2, pop{{$}}
240 ; CHECK-NEXT: return (get_local 2){{$}}
184 ; CHECK-NEXT: i64.clz $push, (get_local 0){{$}}
185 ; CHECK-NEXT: set_local 1, $pop{{$}}
186 ; CHECK-NEXT: return (get_local 1){{$}}
241187 define i64 @clz64(i64 %x) {
242188 %a = call i64 @llvm.ctlz.i64(i64 %x, i1 false)
243189 ret i64 %a
247193 ; CHECK-NEXT: .param i64{{$}}
248194 ; CHECK-NEXT: .result i64{{$}}
249195 ; CHECK-NEXT: .local i64, i64{{$}}
250 ; CHECK-NEXT: get_local push, 0{{$}}
251 ; CHECK-NEXT: set_local 1, pop{{$}}
252 ; CHECK-NEXT: i64.clz push, (get_local 1){{$}}
253 ; CHECK-NEXT: set_local 2, pop{{$}}
254 ; CHECK-NEXT: return (get_local 2){{$}}
196 ; CHECK-NEXT: i64.clz $push, (get_local 0){{$}}
197 ; CHECK-NEXT: set_local 1, $pop{{$}}
198 ; CHECK-NEXT: return (get_local 1){{$}}
255199 define i64 @clz64_zero_undef(i64 %x) {
256200 %a = call i64 @llvm.ctlz.i64(i64 %x, i1 true)
257201 ret i64 %a
261205 ; CHECK-NEXT: .param i64{{$}}
262206 ; CHECK-NEXT: .result i64{{$}}
263207 ; CHECK-NEXT: .local i64, i64{{$}}
264 ; CHECK-NEXT: get_local push, 0{{$}}
265 ; CHECK-NEXT: set_local 1, pop{{$}}
266 ; CHECK-NEXT: i64.ctz push, (get_local 1){{$}}
267 ; CHECK-NEXT: set_local 2, pop{{$}}
268 ; CHECK-NEXT: return (get_local 2){{$}}
208 ; CHECK-NEXT: i64.ctz $push, (get_local 0){{$}}
209 ; CHECK-NEXT: set_local 1, $pop{{$}}
210 ; CHECK-NEXT: return (get_local 1){{$}}
269211 define i64 @ctz64(i64 %x) {
270212 %a = call i64 @llvm.cttz.i64(i64 %x, i1 false)
271213 ret i64 %a
275217 ; CHECK-NEXT: .param i64{{$}}
276218 ; CHECK-NEXT: .result i64{{$}}
277219 ; CHECK-NEXT: .local i64, i64{{$}}
278 ; CHECK-NEXT: get_local push, 0{{$}}
279 ; CHECK-NEXT: set_local 1, pop{{$}}
280 ; CHECK-NEXT: i64.ctz push, (get_local 1){{$}}
281 ; CHECK-NEXT: set_local 2, pop{{$}}
282 ; CHECK-NEXT: return (get_local 2){{$}}
220 ; CHECK-NEXT: i64.ctz $push, (get_local 0){{$}}
221 ; CHECK-NEXT: set_local 1, $pop{{$}}
222 ; CHECK-NEXT: return (get_local 1){{$}}
283223 define i64 @ctz64_zero_undef(i64 %x) {
284224 %a = call i64 @llvm.cttz.i64(i64 %x, i1 true)
285225 ret i64 %a
289229 ; CHECK-NEXT: .param i64{{$}}
290230 ; CHECK-NEXT: .result i64{{$}}
291231 ; CHECK-NEXT: .local i64, i64{{$}}
292 ; CHECK-NEXT: get_local push, 0{{$}}
293 ; CHECK-NEXT: set_local 1, pop{{$}}
294 ; CHECK-NEXT: i64.popcnt push, (get_local 1){{$}}
295 ; CHECK-NEXT: set_local 2, pop{{$}}
296 ; CHECK-NEXT: return (get_local 2){{$}}
232 ; CHECK-NEXT: i64.popcnt $push, (get_local 0){{$}}
233 ; CHECK-NEXT: set_local 1, $pop{{$}}
234 ; CHECK-NEXT: return (get_local 1){{$}}
297235 define i64 @popcnt64(i64 %x) {
298236 %a = call i64 @llvm.ctpop.i64(i64 %x)
299237 ret i64 %a
77 ; CHECK-LABEL: zero_i32:
88 ; CHECK-NEXT: .result i32{{$}}
99 ; CHECK-NEXT: .local
10 ; CHECK-NEXT: i32.const push, 0{{$}}
11 ; CHECK-NEXT: set_local 0, pop{{$}}
10 ; CHECK-NEXT: i32.const $push, 0{{$}}
11 ; CHECK-NEXT: set_local 0, $pop{{$}}
1212 ; CHECK-NEXT: return (get_local 0){{$}}
1313 define i32 @zero_i32() {
1414 ret i32 0
1717 ; CHECK-LABEL: one_i32:
1818 ; CHECK-NEXT: .result i32{{$}}
1919 ; CHECK-NEXT: .local
20 ; CHECK-NEXT: i32.const push, 1{{$}}
21 ; CHECK-NEXT: set_local 0, pop{{$}}
20 ; CHECK-NEXT: i32.const $push, 1{{$}}
21 ; CHECK-NEXT: set_local 0, $pop{{$}}
2222 ; CHECK-NEXT: return (get_local 0){{$}}
2323 define i32 @one_i32() {
2424 ret i32 1
2727 ; CHECK-LABEL: max_i32:
2828 ; CHECK-NEXT: .result i32{{$}}
2929 ; CHECK-NEXT: .local
30 ; CHECK-NEXT: i32.const push, 2147483647{{$}}
31 ; CHECK-NEXT: set_local 0, pop{{$}}
30 ; CHECK-NEXT: i32.const $push, 2147483647{{$}}
31 ; CHECK-NEXT: set_local 0, $pop{{$}}
3232 ; CHECK-NEXT: return (get_local 0){{$}}
3333 define i32 @max_i32() {
3434 ret i32 2147483647
3737 ; CHECK-LABEL: min_i32:
3838 ; CHECK-NEXT: .result i32{{$}}
3939 ; CHECK-NEXT: .local
40 ; CHECK-NEXT: i32.const push, -2147483648{{$}}
41 ; CHECK-NEXT: set_local 0, pop{{$}}
40 ; CHECK-NEXT: i32.const $push, -2147483648{{$}}
41 ; CHECK-NEXT: set_local 0, $pop{{$}}
4242 ; CHECK-NEXT: return (get_local 0){{$}}
4343 define i32 @min_i32() {
4444 ret i32 -2147483648
4747 ; CHECK-LABEL: zero_i64:
4848 ; CHECK-NEXT: .result i64{{$}}
4949 ; CHECK-NEXT: .local
50 ; CHECK-NEXT: i64.const push, 0{{$}}
51 ; CHECK-NEXT: set_local 0, pop{{$}}
50 ; CHECK-NEXT: i64.const $push, 0{{$}}
51 ; CHECK-NEXT: set_local 0, $pop{{$}}
5252 ; CHECK-NEXT: return (get_local 0){{$}}
5353 define i64 @zero_i64() {
5454 ret i64 0
5757 ; CHECK-LABEL: one_i64:
5858 ; CHECK-NEXT: .result i64{{$}}
5959 ; CHECK-NEXT: .local
60 ; CHECK-NEXT: i64.const push, 1{{$}}
61 ; CHECK-NEXT: set_local 0, pop{{$}}
60 ; CHECK-NEXT: i64.const $push, 1{{$}}
61 ; CHECK-NEXT: set_local 0, $pop{{$}}
6262 ; CHECK-NEXT: return (get_local 0){{$}}
6363 define i64 @one_i64() {
6464 ret i64 1
6767 ; CHECK-LABEL: max_i64:
6868 ; CHECK-NEXT: .result i64{{$}}
6969 ; CHECK-NEXT: .local
70 ; CHECK-NEXT: i64.const push, 9223372036854775807{{$}}
71 ; CHECK-NEXT: set_local 0, pop{{$}}
70 ; CHECK-NEXT: i64.const $push, 9223372036854775807{{$}}
71 ; CHECK-NEXT: set_local 0, $pop{{$}}
7272 ; CHECK-NEXT: return (get_local 0){{$}}
7373 define i64 @max_i64() {
7474 ret i64 9223372036854775807
7777 ; CHECK-LABEL: min_i64:
7878 ; CHECK-NEXT: .result i64{{$}}
7979 ; CHECK-NEXT: .local
80 ; CHECK-NEXT: i64.const push, -9223372036854775808{{$}}
81 ; CHECK-NEXT: set_local 0, pop{{$}}
80 ; CHECK-NEXT: i64.const $push, -9223372036854775808{{$}}
81 ; CHECK-NEXT: set_local 0, $pop{{$}}
8282 ; CHECK-NEXT: return (get_local 0){{$}}
8383 define i64 @min_i64() {
8484 ret i64 -9223372036854775808
8787 ; CHECK-LABEL: negzero_f32:
8888 ; CHECK-NEXT: .result f32{{$}}
8989 ; CHECK-NEXT: .local
90 ; CHECK-NEXT: f32.const push, -0x0p0{{$}}
91 ; CHECK-NEXT: set_local 0, pop{{$}}
90 ; CHECK-NEXT: f32.const $push, -0x0p0{{$}}
91 ; CHECK-NEXT: set_local 0, $pop{{$}}
9292 ; CHECK-NEXT: return (get_local 0){{$}}
9393 define float @negzero_f32() {
9494 ret float -0.0
9797 ; CHECK-LABEL: zero_f32:
9898 ; CHECK-NEXT: .result f32{{$}}
9999 ; CHECK-NEXT: .local
100 ; CHECK-NEXT: f32.const push, 0x0p0{{$}}
101 ; CHECK-NEXT: set_local 0, pop{{$}}
100 ; CHECK-NEXT: f32.const $push, 0x0p0{{$}}
101 ; CHECK-NEXT: set_local 0, $pop{{$}}
102102 ; CHECK-NEXT: return (get_local 0){{$}}
103103 define float @zero_f32() {
104104 ret float 0.0
107107 ; CHECK-LABEL: one_f32:
108108 ; CHECK-NEXT: .result f32{{$}}
109109 ; CHECK-NEXT: .local
110 ; CHECK-NEXT: f32.const push, 0x1p0{{$}}
111 ; CHECK-NEXT: set_local 0, pop{{$}}
110 ; CHECK-NEXT: f32.const $push, 0x1p0{{$}}
111 ; CHECK-NEXT: set_local 0, $pop{{$}}
112112 ; CHECK-NEXT: return (get_local 0){{$}}
113113 define float @one_f32() {
114114 ret float 1.0
117117 ; CHECK-LABEL: two_f32:
118118 ; CHECK-NEXT: .result f32{{$}}
119119 ; CHECK-NEXT: .local
120 ; CHECK-NEXT: f32.const push, 0x1p1{{$}}
121 ; CHECK-NEXT: set_local 0, pop{{$}}
120 ; CHECK-NEXT: f32.const $push, 0x1p1{{$}}
121 ; CHECK-NEXT: set_local 0, $pop{{$}}
122122 ; CHECK-NEXT: return (get_local 0){{$}}
123123 define float @two_f32() {
124124 ret float 2.0
127127 ; CHECK-LABEL: nan_f32:
128128 ; CHECK-NEXT: .result f32{{$}}
129129 ; CHECK-NEXT: .local
130 ; CHECK-NEXT: f32.const push, nan
131 ; CHECK-NEXT: set_local 0, pop{{$}}
130 ; CHECK-NEXT: f32.const $push, nan
131 ; CHECK-NEXT: set_local 0, $pop{{$}}
132132 ; CHECK-NEXT: return (get_local 0){{$}}
133133 define float @nan_f32() {
134134 ret float 0x7FF8000000000000
137137 ; CHECK-LABEL: negnan_f32:
138138 ; CHECK-NEXT: .result f32{{$}}
139139 ; CHECK-NEXT: .local
140 ; CHECK-NEXT: f32.const push, -nan
141 ; CHECK-NEXT: set_local 0, pop{{$}}
140 ; CHECK-NEXT: f32.const $push, -nan
141 ; CHECK-NEXT: set_local 0, $pop{{$}}
142142 ; CHECK-NEXT: return (get_local 0){{$}}
143143 define float @negnan_f32() {
144144 ret float 0xFFF8000000000000
147147 ; CHECK-LABEL: inf_f32:
148148 ; CHECK-NEXT: .result f32{{$}}
149149 ; CHECK-NEXT: .local
150 ; CHECK-NEXT: f32.const push, infinity
151 ; CHECK-NEXT: set_local 0, pop{{$}}
150 ; CHECK-NEXT: f32.const $push, infinity
151 ; CHECK-NEXT: set_local 0, $pop{{$}}
152152 ; CHECK-NEXT: return (get_local 0){{$}}
153153 define float @inf_f32() {
154154 ret float 0x7FF0000000000000
157157 ; CHECK-LABEL: neginf_f32:
158158 ; CHECK-NEXT: .result f32{{$}}
159159 ; CHECK-NEXT: .local
160 ; CHECK-NEXT: f32.const push, -infinity
161 ; CHECK-NEXT: set_local 0, pop{{$}}
160 ; CHECK-NEXT: f32.const $push, -infinity
161 ; CHECK-NEXT: set_local 0, $pop{{$}}
162162 ; CHECK-NEXT: return (get_local 0){{$}}
163163 define float @neginf_f32() {
164164 ret float 0xFFF0000000000000
167167 ; CHECK-LABEL: negzero_f64:
168168 ; CHECK-NEXT: .result f64{{$}}
169169 ; CHECK-NEXT: .local
170 ; CHECK-NEXT: f64.const push, -0x0p0{{$}}
171 ; CHECK-NEXT: set_local 0, pop{{$}}
170 ; CHECK-NEXT: f64.const $push, -0x0p0{{$}}
171 ; CHECK-NEXT: set_local 0, $pop{{$}}
172172 ; CHECK-NEXT: return (get_local 0){{$}}
173173 define double @negzero_f64() {
174174 ret double -0.0
177177 ; CHECK-LABEL: zero_f64:
178178 ; CHECK-NEXT: .result f64{{$}}
179179 ; CHECK-NEXT: .local
180 ; CHECK-NEXT: f64.const push, 0x0p0{{$}}
181 ; CHECK-NEXT: set_local 0, pop{{$}}
180 ; CHECK-NEXT: f64.const $push, 0x0p0{{$}}
181 ; CHECK-NEXT: set_local 0, $pop{{$}}
182182 ; CHECK-NEXT: return (get_local 0){{$}}
183183 define double @zero_f64() {
184184 ret double 0.0
187187 ; CHECK-LABEL: one_f64:
188188 ; CHECK-NEXT: .result f64{{$}}
189189 ; CHECK-NEXT: .local
190 ; CHECK-NEXT: f64.const push, 0x1p0{{$}}
191 ; CHECK-NEXT: set_local 0, pop{{$}}
190 ; CHECK-NEXT: f64.const $push, 0x1p0{{$}}
191 ; CHECK-NEXT: set_local 0, $pop{{$}}
192192 ; CHECK-NEXT: return (get_local 0){{$}}
193193 define double @one_f64() {
194194 ret double 1.0
197197 ; CHECK-LABEL: two_f64:
198198 ; CHECK-NEXT: .result f64{{$}}
199199 ; CHECK-NEXT: .local
200 ; CHECK-NEXT: f64.const push, 0x1p1{{$}}
201 ; CHECK-NEXT: set_local 0, pop{{$}}
200 ; CHECK-NEXT: f64.const $push, 0x1p1{{$}}
201 ; CHECK-NEXT: set_local 0, $pop{{$}}
202202 ; CHECK-NEXT: return (get_local 0){{$}}
203203 define double @two_f64() {
204204 ret double 2.0
207207 ; CHECK-LABEL: nan_f64:
208208 ; CHECK-NEXT: .result f64{{$}}
209209 ; CHECK-NEXT: .local
210 ; CHECK-NEXT: f64.const push, nan
211 ; CHECK-NEXT: set_local 0, pop{{$}}
210 ; CHECK-NEXT: f64.const $push, nan
211 ; CHECK-NEXT: set_local 0, $pop{{$}}
212212 ; CHECK-NEXT: return (get_local 0){{$}}
213213 define double @nan_f64() {
214214 ret double 0x7FF8000000000000
217217 ; CHECK-LABEL: negnan_f64:
218218 ; CHECK-NEXT: .result f64{{$}}
219219 ; CHECK-NEXT: .local
220 ; CHECK-NEXT: f64.const push, -nan
221 ; CHECK-NEXT: set_local 0, pop{{$}}
220 ; CHECK-NEXT: f64.const $push, -nan
221 ; CHECK-NEXT: set_local 0, $pop{{$}}
222222 ; CHECK-NEXT: return (get_local 0){{$}}
223223 define double @negnan_f64() {
224224 ret double 0xFFF8000000000000
227227 ; CHECK-LABEL: inf_f64:
228228 ; CHECK-NEXT: .result f64{{$}}
229229 ; CHECK-NEXT: .local
230 ; CHECK-NEXT: f64.const push, infinity
231 ; CHECK-NEXT: set_local 0, pop{{$}}
230 ; CHECK-NEXT: f64.const $push, infinity
231 ; CHECK-NEXT: set_local 0, $pop{{$}}
232232 ; CHECK-NEXT: return (get_local 0){{$}}
233233 define double @inf_f64() {
234234 ret double 0x7FF0000000000000
237237 ; CHECK-LABEL: neginf_f64:
238238 ; CHECK-NEXT: .result f64{{$}}
239239 ; CHECK-NEXT: .local
240 ; CHECK-NEXT: f64.const push, -infinity
241 ; CHECK-NEXT: set_local 0, pop{{$}}
240 ; CHECK-NEXT: f64.const $push, -infinity
241 ; CHECK-NEXT: set_local 0, $pop{{$}}
242242 ; CHECK-NEXT: return (get_local 0){{$}}
243243 define double @neginf_f64() {
244244 ret double 0xFFF0000000000000
1515 }
1616
1717 ; CHECK-LABEL: .imports
18 ; CHECK-NEXT: .import $printi "" "printi" (param i32) (result i32){{$}}
19 ; CHECK-NEXT: .import $printf "" "printf" (param f32) (result f32){{$}}
20 ; CHECK-NEXT: .import $printv "" "printv"{{$}}
21 ; CHECK-NEXT: .import $add2 "" "add2" (param i32 i32) (result i32){{$}}
22 ; CHECK-NEXT: .import $split_arg "" "split_arg" (param i64 i64){{$}}
23 ; CHECK-NEXT: .import $expanded_arg "" "expanded_arg" (param i32){{$}}
24 ; CHECK-NEXT: .import $lowered_result "" "lowered_result" (result i32){{$}}
18 ; CHECK-NEXT: .import printi "" printi (param i32) (result i32){{$}}
19 ; CHECK-NEXT: .import printf "" printf (param f32) (result f32){{$}}
20 ; CHECK-NEXT: .import printv "" printv{{$}}
21 ; CHECK-NEXT: .import add2 "" add2 (param i32 i32) (result i32){{$}}
22 ; CHECK-NEXT: .import split_arg "" split_arg (param i64 i64){{$}}
23 ; CHECK-NEXT: .import expanded_arg "" expanded_arg (param i32){{$}}
24 ; CHECK-NEXT: .import lowered_result "" lowered_result (result i32){{$}}
2525 declare i32 @printi(i32)
2626 declare float @printf(float)
2727 declare void @printv()
55 target triple = "wasm32-unknown-unknown"
66
77 ; CHECK-LABEL: sext_i8_i32:
8 ; CHECK: i32.load8_s push, (get_local 1){{$}}
9 ; CHECK-NEXT: set_local 2, pop{{$}}
8 ; CHECK: i32.load8_s $push, (get_local 0){{$}}
9 ; CHECK-NEXT: set_local 1, $pop{{$}}
1010 define i32 @sext_i8_i32(i8 *%p) {
1111 %v = load i8, i8* %p
1212 %e = sext i8 %v to i32
1414 }
1515
1616 ; CHECK-LABEL: zext_i8_i32:
17 ; CHECK: i32.load8_u push, (get_local 1){{$}}
18 ; CHECK-NEXT: set_local 2, pop{{$}}
17 ; CHECK: i32.load8_u $push, (get_local 0){{$}}
18 ; CHECK-NEXT: set_local 1, $pop{{$}}
1919 define i32 @zext_i8_i32(i8 *%p) {
2020 %v = load i8, i8* %p
2121 %e = zext i8 %v to i32
2323 }
2424
2525 ; CHECK-LABEL: sext_i16_i32:
26 ; CHECK: i32.load16_s push, (get_local 1){{$}}
27 ; CHECK-NEXT: set_local 2, pop{{$}}
26 ; CHECK: i32.load16_s $push, (get_local 0){{$}}
27 ; CHECK-NEXT: set_local 1, $pop{{$}}
2828 define i32 @sext_i16_i32(i16 *%p) {
2929 %v = load i16, i16* %p
3030 %e = sext i16 %v to i32
3232 }
3333
3434 ; CHECK-LABEL: zext_i16_i32:
35 ; CHECK: i32.load16_u push, (get_local 1){{$}}
36 ; CHECK-NEXT: set_local 2, pop{{$}}
35 ; CHECK: i32.load16_u $push, (get_local 0){{$}}
36 ; CHECK-NEXT: set_local 1, $pop{{$}}
3737 define i32 @zext_i16_i32(i16 *%p) {
3838 %v = load i16, i16* %p
3939 %e = zext i16 %v to i32
4141 }
4242
4343 ; CHECK-LABEL: sext_i8_i64:
44 ; CHECK: i64.load8_s push, (get_local 1){{$}}
45 ; CHECK-NEXT: set_local 2, pop{{$}}
44 ; CHECK: i64.load8_s $push, (get_local 0){{$}}
45 ; CHECK-NEXT: set_local 1, $pop{{$}}
4646 define i64 @sext_i8_i64(i8 *%p) {
4747 %v = load i8, i8* %p
4848 %e = sext i8 %v to i64
5050 }
5151
5252 ; CHECK-LABEL: zext_i8_i64:
53 ; CHECK: i64.load8_u push, (get_local 1){{$}}
54 ; CHECK-NEXT: set_local 2, pop{{$}}
53 ; CHECK: i64.load8_u $push, (get_local 0){{$}}
54 ; CHECK-NEXT: set_local 1, $pop{{$}}
5555 define i64 @zext_i8_i64(i8 *%p) {
5656 %v = load i8, i8* %p
5757 %e = zext i8 %v to i64
5959 }
6060
6161 ; CHECK-LABEL: sext_i16_i64:
62 ; CHECK: i64.load16_s push, (get_local 1){{$}}
63 ; CHECK-NEXT: set_local 2, pop{{$}}
62 ; CHECK: i64.load16_s $push, (get_local 0){{$}}
63 ; CHECK-NEXT: set_local 1, $pop{{$}}
6464 define i64 @sext_i16_i64(i16 *%p) {
6565 %v = load i16, i16* %p
6666 %e = sext i16 %v to i64
6868 }
6969
7070 ; CHECK-LABEL: zext_i16_i64:
71 ; CHECK: i64.load16_u push, (get_local 1){{$}}
72 ; CHECK-NEXT: set_local 2, pop{{$}}
71 ; CHECK: i64.load16_u $push, (get_local 0){{$}}
72 ; CHECK-NEXT: set_local 1, $pop{{$}}
7373 define i64 @zext_i16_i64(i16 *%p) {
7474 %v = load i16, i16* %p
7575 %e = zext i16 %v to i64
7777 }
7878
7979 ; CHECK-LABEL: sext_i32_i64:
80 ; CHECK: i64.load32_s push, (get_local 1){{$}}
81 ; CHECK-NEXT: set_local 2, pop{{$}}
80 ; CHECK: i64.load32_s $push, (get_local 0){{$}}
81 ; CHECK-NEXT: set_local 1, $pop{{$}}
8282 define i64 @sext_i32_i64(i32 *%p) {
8383 %v = load i32, i32* %p
8484 %e = sext i32 %v to i64
8686 }
8787
8888 ; CHECK-LABEL: zext_i32_i64:
89 ; CHECK: i64.load32_u push, (get_local 1){{$}}
90 ; CHECK: set_local 2, pop{{$}}
89 ; CHECK: i64.load32_u $push, (get_local 0){{$}}
90 ; CHECK: set_local 1, $pop{{$}}
9191 define i64 @zext_i32_i64(i32 *%p) {
9292 %v = load i32, i32* %p
9393 %e = zext i32 %v to i64
55 target triple = "wasm32-unknown-unknown"
66
77 ; CHECK-LABEL: load_u_i1_i32:
8 ; CHECK: i32.load8_u push, (get_local 1){{$}}
9 ; CHECK-NEXT: set_local 2, pop{{$}}
10 ; CHECK-NEXT: return (get_local 2){{$}}
8 ; CHECK: i32.load8_u $push, (get_local 0){{$}}
9 ; CHECK-NEXT: set_local 1, $pop{{$}}
10 ; CHECK-NEXT: return (get_local 1){{$}}
1111 define i32 @load_u_i1_i32(i1* %p) {
1212 %v = load i1, i1* %p
1313 %e = zext i1 %v to i32
1515 }
1616
1717 ; CHECK-LABEL: load_s_i1_i32:
18 ; CHECK: i32.load8_u push, (get_local 1){{$}}
19 ; CHECK-NEXT: set_local 2, pop{{$}}
20 ; CHECK-NEXT: i32.const push, 31{{$}}
21 ; CHECK-NEXT: set_local 3, pop{{$}}
22 ; CHECK-NEXT: shl push, (get_local 2), (get_local 3){{$}}
23 ; CHECK-NEXT: set_local 4, pop{{$}}
24 ; CHECK-NEXT: shr_s push, (get_local 4), (get_local 3){{$}}
25 ; CHECK-NEXT: set_local 5, pop{{$}}
26 ; CHECK-NEXT: return (get_local 5){{$}}
18 ; CHECK: i32.load8_u $push, (get_local 0){{$}}
19 ; CHECK-NEXT: set_local 1, $pop{{$}}
20 ; CHECK-NEXT: i32.const $push, 31{{$}}
21 ; CHECK-NEXT: set_local 2, $pop{{$}}
22 ; CHECK-NEXT: shl $push, (get_local 1), (get_local 2){{$}}
23 ; CHECK-NEXT: set_local 3, $pop{{$}}
24 ; CHECK-NEXT: shr_s $push, (get_local 3), (get_local 2){{$}}
25 ; CHECK-NEXT: set_local 4, $pop{{$}}
26 ; CHECK-NEXT: return (get_local 4){{$}}
2727 define i32 @load_s_i1_i32(i1* %p) {
2828 %v = load i1, i1* %p
2929 %e = sext i1 %v to i32
3131 }
3232
3333 ; CHECK-LABEL: load_u_i1_i64:
34 ; CHECK: i64.load8_u push, (get_local 1){{$}}
35 ; CHECK-NEXT: set_local 2, pop{{$}}
36 ; CHECK-NEXT: return (get_local 2){{$}}
34 ; CHECK: i64.load8_u $push, (get_local 0){{$}}
35 ; CHECK-NEXT: set_local 1, $pop{{$}}
36 ; CHECK-NEXT: return (get_local 1){{$}}
3737 define i64 @load_u_i1_i64(i1* %p) {
3838 %v = load i1, i1* %p
3939 %e = zext i1 %v to i64
4141 }
4242
4343 ; CHECK-LABEL: load_s_i1_i64:
44 ; CHECK: i64.load8_u push, (get_local 1){{$}}
45 ; CHECK-NEXT: set_local 2, pop{{$}}
46 ; CHECK-NEXT: i64.const push, 63{{$}}
47 ; CHECK-NEXT: set_local 3, pop{{$}}
48 ; CHECK-NEXT: shl push, (get_local 2), (get_local 3){{$}}
49 ; CHECK-NEXT: set_local 4, pop{{$}}
50 ; CHECK-NEXT: shr_s push, (get_local 4), (get_local 3){{$}}
51 ; CHECK-NEXT: set_local 5, pop{{$}}
52 ; CHECK-NEXT: return (get_local 5){{$}}
44 ; CHECK: i64.load8_u $push, (get_local 0){{$}}
45 ; CHECK-NEXT: set_local 1, $pop{{$}}
46 ; CHECK-NEXT: i64.const $push, 63{{$}}
47 ; CHECK-NEXT: set_local 2, $pop{{$}}
48 ; CHECK-NEXT: shl $push, (get_local 1), (get_local 2){{$}}
49 ; CHECK-NEXT: set_local 3, $pop{{$}}
50 ; CHECK-NEXT: shr_s $push, (get_local 3), (get_local 2){{$}}
51 ; CHECK-NEXT: set_local 4, $pop{{$}}
52 ; CHECK-NEXT: return (get_local 4){{$}}
5353 define i64 @load_s_i1_i64(i1* %p) {
5454 %v = load i1, i1* %p
5555 %e = sext i1 %v to i64
5757 }
5858
5959 ; CHECK-LABEL: store_i32_i1:
60 ; CHECK: i32.const push, 1{{$}}
61 ; CHECK-NEXT: set_local 4, pop{{$}}
62 ; CHECK-NEXT: i32.and push, (get_local 3), (get_local 4){{$}}
63 ; CHECK-NEXT: set_local 5, pop{{$}}
64 ; CHECK-NEXT: i32.store8 (get_local 2), (get_local 5){{$}}
60 ; CHECK: i32.const $push, 1{{$}}
61 ; CHECK-NEXT: set_local 2, $pop{{$}}
62 ; CHECK-NEXT: i32.and $push, (get_local 1), (get_local 2){{$}}
63 ; CHECK-NEXT: set_local 3, $pop{{$}}
64 ; CHECK-NEXT: i32.store8 (get_local 0), (get_local 3){{$}}
6565 define void @store_i32_i1(i1* %p, i32 %v) {
6666 %t = trunc i32 %v to i1
6767 store i1 %t, i1* %p
6969 }
7070
7171 ; CHECK-LABEL: store_i64_i1:
72 ; CHECK: i64.const push, 1{{$}}
73 ; CHECK-NEXT: set_local 4, pop{{$}}
74 ; CHECK-NEXT: i64.and push, (get_local 3), (get_local 4){{$}}
75 ; CHECK-NEXT: set_local 5, pop{{$}}
76 ; CHECK-NEXT: i64.store8 (get_local 2), (get_local 5){{$}}
72 ; CHECK: i64.const $push, 1{{$}}
73 ; CHECK-NEXT: set_local 2, $pop{{$}}
74 ; CHECK-NEXT: i64.and $push, (get_local 1), (get_local 2){{$}}
75 ; CHECK-NEXT: set_local 3, $pop{{$}}
76 ; CHECK-NEXT: i64.store8 (get_local 0), (get_local 3){{$}}
7777 define void @store_i64_i1(i1* %p, i64 %v) {
7878 %t = trunc i64 %v to i1
7979 store i1 %t, i1* %p
88 ; CHECK-NEXT: .param i32{{$}}
99 ; CHECK-NEXT: .result i32{{$}}
1010 ; CHECK-NEXT: .local i32, i32{{$}}
11 ; CHECK-NEXT: get_local push, 0{{$}}
12 ; CHECK-NEXT: set_local 1, pop{{$}}
13 ; CHECK-NEXT: i32.load push, (get_local 1){{$}}
14 ; CHECK-NEXT: set_local 2, pop{{$}}
15 ; CHECK-NEXT: return (get_local 2){{$}}
11 ; CHECK-NEXT: i32.load $push, (get_local 0){{$}}
12 ; CHECK-NEXT: set_local 1, $pop{{$}}
13 ; CHECK-NEXT: return (get_local 1){{$}}
1614 define i32 @ldi32(i32 *%p) {
1715 %v = load i32, i32* %p
1816 ret i32 %v
2220 ; CHECK-NEXT: .param i32{{$}}
2321 ; CHECK-NEXT: .result i64{{$}}
2422 ; CHECK-NEXT: .local i32, i64{{$}}
25 ; CHECK-NEXT: get_local push, 0{{$}}
26 ; CHECK-NEXT: set_local 1, pop{{$}}
27 ; CHECK-NEXT: i64.load push, (get_local 1){{$}}
28 ; CHECK-NEXT: set_local 2, pop{{$}}
29 ; CHECK-NEXT: return (get_local 2){{$}}
23 ; CHECK-NEXT: i64.load $push, (get_local 0){{$}}
24 ; CHECK-NEXT: set_local 1, $pop{{$}}
25 ; CHECK-NEXT: return (get_local 1){{$}}
3026 define i64 @ldi64(i64 *%p) {
3127 %v = load i64, i64* %p
3228 ret i64 %v
3632 ; CHECK-NEXT: .param i32{{$}}
3733 ; CHECK-NEXT: .result f32{{$}}
3834 ; CHECK-NEXT: .local i32, f32{{$}}
39 ; CHECK-NEXT: get_local push, 0{{$}}
40 ; CHECK-NEXT: set_local 1, pop{{$}}
41 ; CHECK-NEXT: f32.load push, (get_local 1){{$}}
42 ; CHECK-NEXT: set_local 2, pop{{$}}
43 ; CHECK-NEXT: return (get_local 2){{$}}
35 ; CHECK-NEXT: f32.load $push, (get_local 0){{$}}
36 ; CHECK-NEXT: set_local 1, $pop{{$}}
37 ; CHECK-NEXT: return (get_local 1){{$}}
4438 define float @ldf32(float *%p) {
4539 %v = load float, float* %p
4640 ret float %v
5044 ; CHECK-NEXT: .param i32{{$}}
5145 ; CHECK-NEXT: .result f64{{$}}
5246 ; CHECK-NEXT: .local i32, f64{{$}}
53 ; CHECK-NEXT: get_local push, 0{{$}}
54 ; CHECK-NEXT: set_local 1, pop{{$}}
55 ; CHECK-NEXT: f64.load push, (get_local 1){{$}}
56 ; CHECK-NEXT: set_local 2, pop{{$}}
57 ; CHECK-NEXT: return (get_local 2){{$}}
47 ; CHECK-NEXT: f64.load $push, (get_local 0){{$}}
48 ; CHECK-NEXT: set_local 1, $pop{{$}}
49 ; CHECK-NEXT: return (get_local 1){{$}}
5850 define double @ldf64(double *%p) {
5951 %v = load double, double* %p
6052 ret double %v
1111 ; CHECK-NEXT: .result i32{{$}}
1212 ; CHECK-NEXT: .local i32{{$}}
1313 ; CHECK-NEXT: memory_size
14 ; CHECK-NEXT: set_local 0, pop{{$}}
14 ; CHECK-NEXT: set_local 0, $pop{{$}}
1515 ; CHECK-NEXT: return (get_local 0){{$}}
1616 define i32 @memory_size() {
1717 %a = call i32 @llvm.wasm.memory.size.i32()
2121 ; CHECK-LABEL: grow_memory:
2222 ; CHECK-NEXT: .param i32
2323 ; CHECK-NEXT: .local i32{{$}}
24 ; CHECK: grow_memory (get_local 1)
24 ; CHECK: grow_memory (get_local 0)
2525 ; CHECK-NEXT: return
2626 define void @grow_memory(i32 %n) {
2727 call void @llvm.wasm.grow.memory.i32(i32 %n)
1111 ; CHECK-NEXT: .result i64{{$}}
1212 ; CHECK-NEXT: .local i64{{$}}
1313 ; CHECK-NEXT: memory_size
14 ; CHECK-NEXT: set_local 0, pop{{$}}
14 ; CHECK-NEXT: set_local 0, $pop{{$}}
1515 ; CHECK-NEXT: return (get_local 0){{$}}
1616 define i64 @memory_size() {
1717 %a = call i64 @llvm.wasm.memory.size.i64()
2121 ; CHECK-LABEL: grow_memory:
2222 ; CHECK-NEXT: .param i64
2323 ; CHECK-NEXT: .local i64{{$}}
24 ; CHECK: grow_memory (get_local 1)
24 ; CHECK: grow_memory (get_local 0)
2525 ; CHECK-NEXT: return
2626 define void @grow_memory(i64 %n) {
2727 call void @llvm.wasm.grow.memory.i64(i64 %n)
77 ; Basic phi triangle.
88
99 ; CHECK-LABEL: test0:
10 ; CHECK: get_local push, 0{{$}}
11 ; CHECK: set_local [[REG:.*]], pop
12 ; CHECK: div_s push, (get_local [[REG]]), {{.*}}
13 ; CHECK: set_local [[REG]], pop
14 ; CHECK: return (get_local [[REG]])
10 ; CHECK: div_s $push, (get_local 0), (get_local 3){{$}}
11 ; CHECK: set_local 0, $pop
12 ; CHECK: return (get_local 0)
1513 define i32 @test0(i32 %p) {
1614 entry:
1715 %t = icmp slt i32 %p, 0
2826
2927 ; CHECK-LABEL: test1:
3028 ; CHECK: BB1_1:
31 ; CHECK: get_local push, [[REG1:.*]]
32 ; CHECK: set_local [[REG0:.*]], pop
33 ; CHECK: get_local push, [[REG2:.*]]
34 ; CHECK: set_local [[REG1]], pop
35 ; CHECK: [[REG0]]
36 ; CHECK: set_local [[REG2]], pop
29 ; CHECK: set_local [[REG0:.*]], (get_local [[REG1:.*]])
30 ; CHECK: set_local [[REG1]], (get_local [[REG2:.*]])
31 ; CHECK: set_local [[REG2]], (get_local [[REG0]])
3732 define i32 @test1(i32 %n) {
3833 entry:
3934 br label %loop
33 target triple = "wasm32-unknown-unknown"
44
55 ; CHECK-LABEL: return_i32:
6 ; CHECK: return (get_local 1){{$}}
6 ; CHECK: return (get_local 0){{$}}
77 define i32 @return_i32(i32 %p) {
88 ret i32 %p
99 }
66 target triple = "wasm32-unknown-unknown"
77 <