llvm.org GIT mirror llvm / e807393
Revert r252858: "[WebAssembly] Switch to MC for instruction printing." It broke the CMake build: "Cannot find source file: WebAssemblyRegNumbering.cpp" git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@252897 91177308-0d34-0410-b5e6-96231b3b80d8 Hans Wennborg 4 years ago
38 changed file(s) with 1074 addition(s) and 744 deletion(s). Raw diff Collapse all Expand all
2020 WebAssemblyMachineFunctionInfo.cpp
2121 WebAssemblyMCInstLower.cpp
2222 WebAssemblyRegisterInfo.cpp
23 WebAssemblyRegNumbering.cpp
2423 WebAssemblySelectionDAGInfo.cpp
2524 WebAssemblySubtarget.cpp
2625 WebAssemblyTargetMachine.cpp
3535
3636 void WebAssemblyInstPrinter::printRegName(raw_ostream &OS,
3737 unsigned RegNo) const {
38 // FIXME: Revisit whether we actually print the get_local explicitly.
39 OS << "(get_local " << RegNo << ")";
38 if (TargetRegisterInfo::isPhysicalRegister(RegNo))
39 OS << getRegisterName(RegNo);
40 else
41 OS << TargetRegisterInfo::virtReg2Index(RegNo);
4042 }
4143
4244 void WebAssemblyInstPrinter::printInst(const MCInst *MI, raw_ostream &OS,
4345 StringRef Annot,
4446 const MCSubtargetInfo &STI) {
4547 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
5548 printAnnotation(OS, Annot);
5649
5750 unsigned NumDefs = MII.get(MI->getOpcode()).getNumDefs();
5851 assert(NumDefs <= 1 &&
5952 "Instructions with multiple result values not implemented");
6053
61 // FIXME: Revisit whether we actually print the set_local explicitly.
62 if (NumDefs != 0)
54 if (NumDefs != 0) {
6355 OS << "\n"
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;
56 "\t" "set_local ";
57 printRegName(OS, MI->getOperand(0).getReg());
58 OS << ", pop";
59 }
8260 }
8361
8462 void WebAssemblyInstPrinter::printOperand(const MCInst *MI, unsigned OpNo,
8664 const MCOperand &Op = MI->getOperand(OpNo);
8765 if (Op.isReg()) {
8866 if (OpNo < MII.get(MI->getOpcode()).getNumDefs())
89 O << "$push";
67 O << "push";
9068 else
9169 printRegName(O, Op.getReg());
9270 } else if (Op.isImm())
93 O << Op.getImm();
71 O << '#' << Op.getImm();
9472 else if (Op.isFPImm())
95 O << toString(APFloat(Op.getFPImm()));
73 O << '#' << Op.getFPImm();
9674 else {
9775 assert(Op.isExpr() && "unknown operand kind in printOperand");
9876 Op.getExpr()->print(O, &MAI);
2626 CodeGenOpt::Level OptLevel);
2727
2828 FunctionPass *createWebAssemblyCFGStackify();
29 FunctionPass *createWebAssemblyRegNumbering();
3029
3130 FunctionPass *createWebAssemblyRelooper();
3231
1414 //===----------------------------------------------------------------------===//
1515
1616 #include "WebAssembly.h"
17 #include "InstPrinter/WebAssemblyInstPrinter.h"
18 #include "MCTargetDesc/WebAssemblyMCTargetDesc.h"
19 #include "WebAssemblyMCInstLower.h"
2017 #include "WebAssemblyMachineFunctionInfo.h"
2118 #include "WebAssemblyRegisterInfo.h"
2219 #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/MC/MCContext.h"
30 #include "llvm/IR/DebugInfo.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;
4445 const MachineRegisterInfo *MRI;
45 const WebAssemblyFunctionInfo *MFI;
46 unsigned NumArgs;
4647
4748 public:
4849 WebAssemblyAsmPrinter(TargetMachine &TM, std::unique_ptr Streamer)
49 : AsmPrinter(TM, std::move(Streamer)), MRI(nullptr), MFI(nullptr) {}
50 : AsmPrinter(TM, std::move(Streamer)), TII(nullptr), MRI(nullptr) {}
5051
5152 private:
5253 const char *getPassName() const override {
6263 }
6364
6465 bool runOnMachineFunction(MachineFunction &MF) override {
66 const auto &Subtarget = MF.getSubtarget();
67 TII = Subtarget.getInstrInfo();
6568 MRI = &MF.getRegInfo();
66 MFI = MF.getInfo();
69 NumArgs = MF.getInfo()->getParams().size();
6770 return AsmPrinter::runOnMachineFunction(MF);
6871 }
6972
7881 void EmitEndOfAsmFile(Module &M) override;
7982
8083 std::string getRegTypeName(unsigned RegNo) const;
84 static std::string toString(const APFloat &APF);
8185 const char *toString(MVT VT) const;
8286 std::string regToString(const MachineOperand &MO);
87 std::string argToString(const MachineOperand &MO);
8388 };
8489
8590 } // end anonymous namespace
8792 //===----------------------------------------------------------------------===//
8893 // Helpers.
8994 //===----------------------------------------------------------------------===//
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(); }
90125
91126 std::string WebAssemblyAsmPrinter::getRegTypeName(unsigned RegNo) const {
92127 const TargetRegisterClass *TRC = MRI->getRegClass(RegNo);
98133 return "?";
99134 }
100135
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
101153 std::string WebAssemblyAsmPrinter::regToString(const MachineOperand &MO) {
102154 unsigned RegNo = MO.getReg();
103155 if (TargetRegisterInfo::isPhysicalRegister(RegNo))
104156 return WebAssemblyInstPrinter::getRegisterName(RegNo);
105157
106 return utostr(MFI->getWAReg(RegNo));
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);
107168 }
108169
109170 const char *WebAssemblyAsmPrinter::toString(MVT VT) const {
141202 SmallString<128> Str;
142203 raw_svector_ostream OS(Str);
143204
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';
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';
148211
149212 bool FirstVReg = true;
150213 for (unsigned Idx = 0, IdxE = MRI->getNumVirtRegs(); Idx != IdxE; ++Idx) {
151214 unsigned VReg = TargetRegisterInfo::index2VirtReg(Idx);
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 }
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 //}
160225 }
161226 if (!FirstVReg)
162227 OS << '\n';
170235
171236 void WebAssemblyAsmPrinter::EmitInstruction(const MachineInstr *MI) {
172237 DEBUG(dbgs() << "EmitInstruction: " << *MI << '\n');
238 SmallString<128> Str;
239 raw_svector_ostream OS(Str);
173240
174241 unsigned NumDefs = MI->getDesc().getNumDefs();
175242 assert(NumDefs <= 1 &&
176243 "Instructions with multiple result values not implemented");
177244
245 OS << '\t';
246
178247 switch (MI->getOpcode()) {
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());
248 case TargetOpcode::COPY:
249 OS << "get_local push, " << regToString(MI->getOperand(1));
186250 break;
187 }
188251 case WebAssembly::ARGUMENT_I32:
189252 case WebAssembly::ARGUMENT_I64:
190253 case WebAssembly::ARGUMENT_F32:
191254 case WebAssembly::ARGUMENT_F64:
192 // These represent values which are live into the function entry, so there's
193 // no instruction to emit.
255 OS << "get_local push, " << argToString(MI->getOperand(1));
194256 break;
195257 default: {
196 WebAssemblyMCInstLower MCInstLowering(OutContext, *this);
197 MCInst TmpInst;
198 MCInstLowering.Lower(MI, TmpInst);
199 EmitToStreamer(*OutStreamer, TmpInst);
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 }
200299 break;
201300 }
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());
202311 }
203312 }
204313
230339 if (Str.empty())
231340 OS << "\t.imports\n";
232341
233 MCSymbol *Sym = OutStreamer->getContext().getOrCreateSymbol(F.getName());
234 OS << "\t.import " << *Sym << " \"\" " << *Sym;
342 OS << "\t.import " << toSymbol(F.getName()) << " \"\" \"" << F.getName()
343 << "\"";
235344
236345 const WebAssemblyTargetLowering &TLI =
237346 *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)))],
26 "call $callee, $dst">;
25 [(set vt:$dst, (WebAssemblycall1 (WebAssemblywrapper tglobaladdr:$callee)))]>;
2726 def CALL_INDIRECT_#vt : I<(outs vt:$dst), (ins I32:$callee, variable_ops),
28 [(set vt:$dst, (WebAssemblycall1 I32:$callee))],
29 "call_indirect $callee, $dst">;
27 [(set vt:$dst, (WebAssemblycall1 I32:$callee))]>;
3028 }
3129 let Uses = [SP32, SP64], isCall = 1 in {
3230 defm : CALL;
3533 defm : CALL;
3634
3735 def CALL_VOID : I<(outs), (ins global:$callee, variable_ops),
38 [(WebAssemblycall0 (WebAssemblywrapper tglobaladdr:$callee))],
39 "call $callee">;
36 [(WebAssemblycall0 (WebAssemblywrapper tglobaladdr:$callee))]>;
4037 def CALL_INDIRECT_VOID : I<(outs), (ins I32:$callee, variable_ops),
41 [(WebAssemblycall0 I32:$callee)],
42 "call_indirect $callee">;
38 [(WebAssemblycall0 I32:$callee)]>;
4339 } // Uses = [SP32,SP64], isCall = 1
4440
4541 /*
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)],
44 "switch $index">;
43 [(WebAssemblyswitch I32:$index)]>;
4544 def SWITCH_I64 : I<(outs), (ins I64:$index, variable_ops),
46 [(WebAssemblyswitch I64:$index)],
47 "switch $index">;
45 [(WebAssemblyswitch I64:$index)]>;
4846 } // isTerminator = 1, hasCtrlDep = 1, isBarrier = 1
4947
5048 // Placemarkers to indicate the start of a block or loop scope.
1313 //===----------------------------------------------------------------------===//
1414
1515 #include "WebAssemblyMCInstLower.h"
16 #include "WebAssemblyMachineFunctionInfo.h"
1716 #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"
2120 #include "llvm/CodeGen/MachineInstr.h"
22 #include "llvm/IR/Constants.h"
2321 #include "llvm/MC/MCAsmInfo.h"
2422 #include "llvm/MC/MCContext.h"
2523 #include "llvm/MC/MCExpr.h"
5654 default:
5755 MI->dump();
5856 llvm_unreachable("unknown operand type");
59 case MachineOperand::MO_Register: {
57 case MachineOperand::MO_Register:
6058 // Ignore all implicit register operands.
6159 if (MO.isImplicit())
6260 continue;
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);
61 MCOp = MCOperand::createReg(MO.getReg());
6862 break;
69 }
7063 case MachineOperand::MO_Immediate:
7164 MCOp = MCOperand::createImm(MO.getImm());
7265 break;
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");
66 case MachineOperand::MO_FPImmediate:
67 MCOp = MCOperand::createFPImm(
68 MO.getFPImm()->getValueAPF().convertToDouble());
8369 break;
84 }
8570 case MachineOperand::MO_MachineBasicBlock:
8671 MCOp = MCOperand::createExpr(
8772 MCSymbolRefExpr::create(MO.getMBB()->getSymbol(), Ctx));
8873 break;
74 case MachineOperand::MO_RegisterMask:
75 continue;
8976 case MachineOperand::MO_GlobalAddress:
9077 MCOp = LowerSymbolOperand(MO, GetGlobalAddressSymbol(MO));
9178 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
3532 public:
36 explicit WebAssemblyFunctionInfo(MachineFunction &MF) : MF(MF) {}
33 explicit WebAssemblyFunctionInfo(MachineFunction &MF)
34 : MF(MF) {}
3735 ~WebAssemblyFunctionInfo() override;
3836
3937 void addParam(MVT VT) { Params.push_back(VT); }
4139
4240 void addResult(MVT VT) { Results.push_back(VT); }
4341 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 }
5542 };
5643
5744 } // end namespace llvm
174174
175175 void WebAssemblyPassConfig::addPreEmitPass() {
176176 addPass(createWebAssemblyCFGStackify());
177 addPass(createWebAssemblyRegNumbering());
178177 }
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: call i32_unary, $push, (get_local 0){{$}}
72 ; CHECK-NEXT: set_local 1, $pop
73 ; CHECK-NEXT: return (get_local 1)
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)
7476 define i32 @call_i32_unary(i32 %a) {
7577 %r = call i32 @i32_unary(i32 %a)
7678 ret i32 %r
8183 ; CHECK-NEXT: .param i32
8284 ; CHECK-NEXT: .result i32
8385 ; CHECK-NEXT: .local i32, i32, i32
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)
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)
8793 define i32 @call_i32_binary(i32 %a, i32 %b) {
8894 %r = call i32 @i32_binary(i32 %a, i32 %b)
8995 ret i32 %r
9298 ; CHECK-LABEL: call_indirect_void:
9399 ; CHECK-NEXT: .param i32
94100 ; CHECK-NEXT: .local i32
95 ; CHECK-NEXT: call_indirect (get_local 0){{$}}
101 ; CHECK-NEXT: get_local push, 0
102 ; CHECK-NEXT: set_local 1, pop
103 ; CHECK-NEXT: call_indirect (get_local 1){{$}}
96104 ; CHECK-NEXT: return
97105 define void @call_indirect_void(void ()* %callee) {
98106 call void %callee()
103111 ; CHECK-NEXT: .param i32
104112 ; CHECK-NEXT: .result i32
105113 ; CHECK-NEXT: .local i32, i32
106 ; CHECK-NEXT: call_indirect (get_local 0), $push{{$}}
107 ; CHECK-NEXT: set_local 1, $pop
108 ; CHECK-NEXT: return (get_local 1)
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)
109119 define i32 @call_indirect_i32(i32 ()* %callee) {
110120 %t = call i32 %callee()
111121 ret i32 %t
112122 }
113123
114124 ; CHECK-LABEL: tail_call_void_nullary:
115 ; CHECK-NEXT: call void_nullary{{$}}
125 ; CHECK-NEXT: call $void_nullary{{$}}
116126 ; CHECK-NEXT: return{{$}}
117127 define void @tail_call_void_nullary() {
118128 tail call void @void_nullary()
120130 }
121131
122132 ; CHECK-LABEL: fastcc_tail_call_void_nullary:
123 ; CHECK-NEXT: call void_nullary{{$}}
133 ; CHECK-NEXT: call $void_nullary{{$}}
124134 ; CHECK-NEXT: return{{$}}
125135 define void @fastcc_tail_call_void_nullary() {
126136 tail call fastcc void @void_nullary()
128138 }
129139
130140 ; CHECK-LABEL: coldcc_tail_call_void_nullary:
131 ; CHECK-NEXT: call void_nullary
141 ; CHECK-NEXT: call $void_nullary
132142 ; CHECK-NEXT: return{{$}}
133143 define void @coldcc_tail_call_void_nullary() {
134144 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 10){{$}}
71 ; CHECK: br_if $BB2_1, (get_local 16){{$}}
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 4){{$}}
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 7){{$}}
104 ; CHECK: br $BB3_5{{$}}
105105 ; CHECK: BB3_2:
106 ; CHECK: br_if BB3_4, (get_local 6){{$}}
107 ; CHECK: br BB3_5{{$}}
106 ; CHECK: br_if $BB3_4, (get_local 10){{$}}
107 ; CHECK: br $BB3_5{{$}}
108108 ; CHECK: BB3_4:
109109 ; CHECK: BB3_5:
110 ; CHECK: return (get_local 3){{$}}
110 ; CHECK: return (get_local 6){{$}}
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 3){{$}}
135 ; CHECK: block $BB4_2{{$}}
136 ; CHECK: br_if $BB4_2, (get_local 5){{$}}
137137 ; CHECK: BB4_2:
138 ; CHECK: return (get_local 2){{$}}
138 ; CHECK: return (get_local 4){{$}}
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 3){{$}}
156 ; CHECK: br BB5_3{{$}}
153 ; CHECK: block $BB5_3{{$}}
154 ; CHECK: block $BB5_2{{$}}
155 ; CHECK: br_if $BB5_2, (get_local 5){{$}}
156 ; CHECK: br $BB5_3{{$}}
157157 ; CHECK: BB5_2:
158158 ; CHECK: BB5_3:
159 ; CHECK: return (get_local 2){{$}}
159 ; CHECK: return (get_local 4){{$}}
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 1){{$}}
178 ; CHECK: return (get_local 2){{$}}
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 0), (get_local 2){{$}}
189 ; CHECK: br BB7_1{{$}}
188 ; CHECK: i32.store (get_local 1), (get_local 3){{$}}
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 3){{$}}
204 ; CHECK: return (get_local 2){{$}}
202 ; CHECK: loop $BB8_2{{$}}
203 ; CHECK: br_if $BB8_1, (get_local 6){{$}}
204 ; CHECK: return (get_local 4){{$}}
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 4){{$}}
222 ; CHECK: br_if BB9_3, (get_local 6){{$}}
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){{$}}
223223 ; CHECK: BB9_3:
224224 ; CHECK: BB9_4:
225 ; CHECK: return (get_local 3){{$}}
225 ; CHECK: return (get_local 6){{$}}
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 4){{$}}
250 ; CHECK: br BB10_4{{$}}
247 ; CHECK: block $BB10_4{{$}}
248 ; CHECK: block $BB10_2{{$}}
249 ; CHECK: br_if $BB10_2, (get_local 7){{$}}
250 ; CHECK: br $BB10_4{{$}}
251251 ; CHECK: BB10_2:
252 ; CHECK: br_if BB10_4, (get_local 6){{$}}
252 ; CHECK: br_if $BB10_4, (get_local 10){{$}}
253253 ; CHECK: BB10_4:
254 ; CHECK: return (get_local 3){{$}}
254 ; CHECK: return (get_local 6){{$}}
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: 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){{$}}
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){{$}}
2024 define i32 @ord_f32(float %x, float %y) {
2125 %a = fcmp ord float %x, %y
2226 %b = zext i1 %a to i32
2832 ; CHECK-NEXT: .param f32{{$}}
2933 ; CHECK-NEXT: .result i32{{$}}
3034 ; CHECK-NEXT: .local f32, f32, i32, i32, i32{{$}}
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){{$}}
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){{$}}
3846 define i32 @uno_f32(float %x, float %y) {
3947 %a = fcmp uno float %x, %y
4048 %b = zext i1 %a to i32
4654 ; CHECK-NEXT: .param f32{{$}}
4755 ; CHECK-NEXT: .result i32{{$}}
4856 ; CHECK-NEXT: .local f32, f32, i32{{$}}
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){{$}}
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){{$}}
5264 define i32 @oeq_f32(float %x, float %y) {
5365 %a = fcmp oeq float %x, %y
5466 %b = zext i1 %a to i32
5668 }
5769
5870 ; CHECK-LABEL: une_f32:
59 ; CHECK: f32.ne $push, (get_local 0), (get_local 1){{$}}
60 ; CHECK-NEXT: set_local 2, $pop{{$}}
71 ; CHECK: f32.ne push, (get_local 3), (get_local 2){{$}}
72 ; CHECK-NEXT: set_local 4, pop{{$}}
6173 define i32 @une_f32(float %x, float %y) {
6274 %a = fcmp une float %x, %y
6375 %b = zext i1 %a to i32
6577 }
6678
6779 ; CHECK-LABEL: olt_f32:
68 ; CHECK: f32.lt $push, (get_local 0), (get_local 1){{$}}
69 ; CHECK-NEXT: set_local 2, $pop{{$}}
80 ; CHECK: f32.lt push, (get_local 3), (get_local 2){{$}}
81 ; CHECK-NEXT: set_local 4, pop{{$}}
7082 define i32 @olt_f32(float %x, float %y) {
7183 %a = fcmp olt float %x, %y
7284 %b = zext i1 %a to i32
7486 }
7587
7688 ; CHECK-LABEL: ole_f32:
77 ; CHECK: f32.le $push, (get_local 0), (get_local 1){{$}}
78 ; CHECK-NEXT: set_local 2, $pop{{$}}
89 ; CHECK: f32.le push, (get_local 3), (get_local 2){{$}}
90 ; CHECK-NEXT: set_local 4, pop{{$}}
7991 define i32 @ole_f32(float %x, float %y) {
8092 %a = fcmp ole float %x, %y
8193 %b = zext i1 %a to i32
8395 }
8496
8597 ; CHECK-LABEL: ogt_f32:
86 ; CHECK: f32.gt $push, (get_local 0), (get_local 1){{$}}
87 ; CHECK-NEXT: set_local 2, $pop{{$}}
98 ; CHECK: f32.gt push, (get_local 3), (get_local 2){{$}}
99 ; CHECK-NEXT: set_local 4, pop{{$}}
88100 define i32 @ogt_f32(float %x, float %y) {
89101 %a = fcmp ogt float %x, %y
90102 %b = zext i1 %a to i32
92104 }
93105
94106 ; CHECK-LABEL: oge_f32:
95 ; CHECK: f32.ge $push, (get_local 0), (get_local 1){{$}}
96 ; CHECK-NEXT: set_local 2, $pop{{$}}
107 ; CHECK: f32.ge push, (get_local 3), (get_local 2){{$}}
108 ; CHECK-NEXT: set_local 4, pop{{$}}
97109 define i32 @oge_f32(float %x, float %y) {
98110 %a = fcmp oge float %x, %y
99111 %b = zext i1 %a to i32
107119 ; CHECK-NEXT: .param f32{{$}}
108120 ; CHECK-NEXT: .result i32{{$}}
109121 ; CHECK-NEXT: .local f32, f32, i32, i32, i32, i32, i32{{$}}
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){{$}}
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){{$}}
121137 define i32 @ueq_f32(float %x, float %y) {
122138 %a = fcmp ueq float %x, %y
123139 %b = zext i1 %a to i32
125141 }
126142
127143 ; CHECK-LABEL: one_f32:
128 ; CHECK: f32.ne $push, (get_local 0), (get_local 1){{$}}
129 ; CHECK-NEXT: set_local 2, $pop{{$}}
144 ; CHECK: f32.ne push, (get_local 3), (get_local 2){{$}}
145 ; CHECK-NEXT: set_local 4, pop{{$}}
130146 define i32 @one_f32(float %x, float %y) {
131147 %a = fcmp one float %x, %y
132148 %b = zext i1 %a to i32
134150 }
135151
136152 ; CHECK-LABEL: ult_f32:
137 ; CHECK: f32.lt $push, (get_local 0), (get_local 1){{$}}
138 ; CHECK-NEXT: set_local 2, $pop{{$}}
153 ; CHECK: f32.lt push, (get_local 3), (get_local 2){{$}}
154 ; CHECK-NEXT: set_local 4, pop{{$}}
139155 define i32 @ult_f32(float %x, float %y) {
140156 %a = fcmp ult float %x, %y
141157 %b = zext i1 %a to i32
143159 }
144160
145161 ; CHECK-LABEL: ule_f32:
146 ; CHECK: f32.le $push, (get_local 0), (get_local 1){{$}}
147 ; CHECK-NEXT: set_local 2, $pop{{$}}
162 ; CHECK: f32.le push, (get_local 3), (get_local 2){{$}}
163 ; CHECK-NEXT: set_local 4, pop{{$}}
148164 define i32 @ule_f32(float %x, float %y) {
149165 %a = fcmp ule float %x, %y
150166 %b = zext i1 %a to i32
152168 }
153169
154170 ; CHECK-LABEL: ugt_f32:
155 ; CHECK: f32.gt $push, (get_local 0), (get_local 1){{$}}
156 ; CHECK-NEXT: set_local 2, $pop{{$}}
171 ; CHECK: f32.gt push, (get_local 3), (get_local 2){{$}}
172 ; CHECK-NEXT: set_local 4, pop{{$}}
157173 define i32 @ugt_f32(float %x, float %y) {
158174 %a = fcmp ugt float %x, %y
159175 %b = zext i1 %a to i32
161177 }
162178
163179 ; CHECK-LABEL: uge_f32:
164 ; CHECK: f32.ge $push, (get_local 0), (get_local 1){{$}}
165 ; CHECK-NEXT: set_local 2, $pop{{$}}
180 ; CHECK: f32.ge push, (get_local 3), (get_local 2){{$}}
181 ; CHECK-NEXT: set_local 4, pop{{$}}
166182 define i32 @uge_f32(float %x, float %y) {
167183 %a = fcmp uge float %x, %y
168184 %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: 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){{$}}
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){{$}}
2024 define i32 @ord_f64(double %x, double %y) {
2125 %a = fcmp ord double %x, %y
2226 %b = zext i1 %a to i32
2832 ; CHECK-NEXT: .param f64{{$}}
2933 ; CHECK-NEXT: .result i32{{$}}
3034 ; CHECK-NEXT: .local f64, f64, i32, i32, i32{{$}}
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){{$}}
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){{$}}
3846 define i32 @uno_f64(double %x, double %y) {
3947 %a = fcmp uno double %x, %y
4048 %b = zext i1 %a to i32
4654 ; CHECK-NEXT: .param f64{{$}}
4755 ; CHECK-NEXT: .result i32{{$}}
4856 ; CHECK-NEXT: .local f64, f64, i32{{$}}
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){{$}}
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){{$}}
5264 define i32 @oeq_f64(double %x, double %y) {
5365 %a = fcmp oeq double %x, %y
5466 %b = zext i1 %a to i32
5668 }
5769
5870 ; CHECK-LABEL: une_f64:
59 ; CHECK: f64.ne $push, (get_local 0), (get_local 1){{$}}
60 ; CHECK-NEXT: set_local 2, $pop{{$}}
71 ; CHECK: f64.ne push, (get_local 3), (get_local 2){{$}}
72 ; CHECK-NEXT: set_local 4, pop{{$}}
6173 define i32 @une_f64(double %x, double %y) {
6274 %a = fcmp une double %x, %y
6375 %b = zext i1 %a to i32
6577 }
6678
6779 ; CHECK-LABEL: olt_f64:
68 ; CHECK: f64.lt $push, (get_local 0), (get_local 1){{$}}
69 ; CHECK-NEXT: set_local 2, $pop{{$}}
80 ; CHECK: f64.lt push, (get_local 3), (get_local 2){{$}}
81 ; CHECK-NEXT: set_local 4, pop{{$}}
7082 define i32 @olt_f64(double %x, double %y) {
7183 %a = fcmp olt double %x, %y
7284 %b = zext i1 %a to i32
7486 }
7587
7688 ; CHECK-LABEL: ole_f64:
77 ; CHECK: f64.le $push, (get_local 0), (get_local 1){{$}}
78 ; CHECK-NEXT: set_local 2, $pop{{$}}
89 ; CHECK: f64.le push, (get_local 3), (get_local 2){{$}}
90 ; CHECK-NEXT: set_local 4, pop{{$}}
7991 define i32 @ole_f64(double %x, double %y) {
8092 %a = fcmp ole double %x, %y
8193 %b = zext i1 %a to i32
8395 }
8496
8597 ; CHECK-LABEL: ogt_f64:
86 ; CHECK: f64.gt $push, (get_local 0), (get_local 1){{$}}
87 ; CHECK-NEXT: set_local 2, $pop{{$}}
98 ; CHECK: f64.gt push, (get_local 3), (get_local 2){{$}}
99 ; CHECK-NEXT: set_local 4, pop{{$}}
88100 define i32 @ogt_f64(double %x, double %y) {
89101 %a = fcmp ogt double %x, %y
90102 %b = zext i1 %a to i32
92104 }
93105
94106 ; CHECK-LABEL: oge_f64:
95 ; CHECK: f64.ge $push, (get_local 0), (get_local 1){{$}}
96 ; CHECK-NEXT: set_local 2, $pop{{$}}
107 ; CHECK: f64.ge push, (get_local 3), (get_local 2){{$}}
108 ; CHECK-NEXT: set_local 4, pop{{$}}
97109 define i32 @oge_f64(double %x, double %y) {
98110 %a = fcmp oge double %x, %y
99111 %b = zext i1 %a to i32
107119 ; CHECK-NEXT: .param f64{{$}}
108120 ; CHECK-NEXT: .result i32{{$}}
109121 ; CHECK-NEXT: .local f64, f64, i32, i32, i32, i32, i32{{$}}
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){{$}}
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){{$}}
121137 define i32 @ueq_f64(double %x, double %y) {
122138 %a = fcmp ueq double %x, %y
123139 %b = zext i1 %a to i32
125141 }
126142
127143 ; CHECK-LABEL: one_f64:
128 ; CHECK: f64.ne $push, (get_local 0), (get_local 1){{$}}
129 ; CHECK-NEXT: set_local 2, $pop{{$}}
144 ; CHECK: f64.ne push, (get_local 3), (get_local 2){{$}}
145 ; CHECK-NEXT: set_local 4, pop{{$}}
130146 define i32 @one_f64(double %x, double %y) {
131147 %a = fcmp one double %x, %y
132148 %b = zext i1 %a to i32
134150 }
135151
136152 ; CHECK-LABEL: ult_f64:
137 ; CHECK: f64.lt $push, (get_local 0), (get_local 1){{$}}
138 ; CHECK-NEXT: set_local 2, $pop{{$}}
153 ; CHECK: f64.lt push, (get_local 3), (get_local 2){{$}}
154 ; CHECK-NEXT: set_local 4, pop{{$}}
139155 define i32 @ult_f64(double %x, double %y) {
140156 %a = fcmp ult double %x, %y
141157 %b = zext i1 %a to i32
143159 }
144160
145161 ; CHECK-LABEL: ule_f64:
146 ; CHECK: f64.le $push, (get_local 0), (get_local 1){{$}}
147 ; CHECK-NEXT: set_local 2, $pop{{$}}
162 ; CHECK: f64.le push, (get_local 3), (get_local 2){{$}}
163 ; CHECK-NEXT: set_local 4, pop{{$}}
148164 define i32 @ule_f64(double %x, double %y) {
149165 %a = fcmp ule double %x, %y
150166 %b = zext i1 %a to i32
152168 }
153169
154170 ; CHECK-LABEL: ugt_f64:
155 ; CHECK: f64.gt $push, (get_local 0), (get_local 1){{$}}
156 ; CHECK-NEXT: set_local 2, $pop{{$}}
171 ; CHECK: f64.gt push, (get_local 3), (get_local 2){{$}}
172 ; CHECK-NEXT: set_local 4, pop{{$}}
157173 define i32 @ugt_f64(double %x, double %y) {
158174 %a = fcmp ugt double %x, %y
159175 %b = zext i1 %a to i32
161177 }
162178
163179 ; CHECK-LABEL: uge_f64:
164 ; CHECK: f64.ge $push, (get_local 0), (get_local 1){{$}}
165 ; CHECK-NEXT: set_local 2, $pop{{$}}
180 ; CHECK: f64.ge push, (get_local 3), (get_local 2){{$}}
181 ; CHECK-NEXT: set_local 4, pop{{$}}
166182 define i32 @uge_f64(double %x, double %y) {
167183 %a = fcmp uge double %x, %y
168184 %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: i32.eq $push, (get_local 0), (get_local 1){{$}}
13 ; CHECK-NEXT: set_local 2, $pop{{$}}
14 ; CHECK-NEXT: return (get_local 2){{$}}
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){{$}}
1519 define i32 @eq_i32(i32 %x, i32 %y) {
1620 %a = icmp eq i32 %x, %y
1721 %b = zext i1 %a to i32
1923 }
2024
2125 ; CHECK-LABEL: ne_i32:
22 ; CHECK: i32.ne $push, (get_local 0), (get_local 1){{$}}
23 ; CHECK-NEXT: set_local 2, $pop{{$}}
26 ; CHECK: i32.ne push, (get_local 3), (get_local 2){{$}}
27 ; CHECK-NEXT: set_local 4, pop{{$}}
2428 define i32 @ne_i32(i32 %x, i32 %y) {
2529 %a = icmp ne i32 %x, %y
2630 %b = zext i1 %a to i32
2832 }
2933
3034 ; CHECK-LABEL: slt_i32:
31 ; CHECK: i32.lt_s $push, (get_local 0), (get_local 1){{$}}
32 ; CHECK-NEXT: set_local 2, $pop{{$}}
35 ; CHECK: i32.lt_s push, (get_local 3), (get_local 2){{$}}
36 ; CHECK-NEXT: set_local 4, pop{{$}}
3337 define i32 @slt_i32(i32 %x, i32 %y) {
3438 %a = icmp slt i32 %x, %y
3539 %b = zext i1 %a to i32
3741 }
3842
3943 ; CHECK-LABEL: sle_i32:
40 ; CHECK: i32.le_s $push, (get_local 0), (get_local 1){{$}}
41 ; CHECK-NEXT: set_local 2, $pop{{$}}
44 ; CHECK: i32.le_s push, (get_local 3), (get_local 2){{$}}
45 ; CHECK-NEXT: set_local 4, pop{{$}}
4246 define i32 @sle_i32(i32 %x, i32 %y) {
4347 %a = icmp sle i32 %x, %y
4448 %b = zext i1 %a to i32
4650 }
4751
4852 ; CHECK-LABEL: ult_i32:
49 ; CHECK: i32.lt_u $push, (get_local 0), (get_local 1){{$}}
50 ; CHECK-NEXT: set_local 2, $pop{{$}}
53 ; CHECK: i32.lt_u push, (get_local 3), (get_local 2){{$}}
54 ; CHECK-NEXT: set_local 4, pop{{$}}
5155 define i32 @ult_i32(i32 %x, i32 %y) {
5256 %a = icmp ult i32 %x, %y
5357 %b = zext i1 %a to i32
5559 }
5660
5761 ; CHECK-LABEL: ule_i32:
58 ; CHECK: i32.le_u $push, (get_local 0), (get_local 1){{$}}
59 ; CHECK-NEXT: set_local 2, $pop{{$}}
62 ; CHECK: i32.le_u push, (get_local 3), (get_local 2){{$}}
63 ; CHECK-NEXT: set_local 4, pop{{$}}
6064 define i32 @ule_i32(i32 %x, i32 %y) {
6165 %a = icmp ule i32 %x, %y
6266 %b = zext i1 %a to i32
6468 }
6569
6670 ; CHECK-LABEL: sgt_i32:
67 ; CHECK: i32.gt_s $push, (get_local 0), (get_local 1){{$}}
68 ; CHECK-NEXT: set_local 2, $pop{{$}}
71 ; CHECK: i32.gt_s push, (get_local 3), (get_local 2){{$}}
72 ; CHECK-NEXT: set_local 4, pop{{$}}
6973 define i32 @sgt_i32(i32 %x, i32 %y) {
7074 %a = icmp sgt i32 %x, %y
7175 %b = zext i1 %a to i32
7377 }
7478
7579 ; CHECK-LABEL: sge_i32:
76 ; CHECK: i32.ge_s $push, (get_local 0), (get_local 1){{$}}
77 ; CHECK-NEXT: set_local 2, $pop{{$}}
80 ; CHECK: i32.ge_s push, (get_local 3), (get_local 2){{$}}
81 ; CHECK-NEXT: set_local 4, pop{{$}}
7882 define i32 @sge_i32(i32 %x, i32 %y) {
7983 %a = icmp sge i32 %x, %y
8084 %b = zext i1 %a to i32
8286 }
8387
8488 ; CHECK-LABEL: ugt_i32:
85 ; CHECK: i32.gt_u $push, (get_local 0), (get_local 1){{$}}
86 ; CHECK-NEXT: set_local 2, $pop{{$}}
89 ; CHECK: i32.gt_u push, (get_local 3), (get_local 2){{$}}
90 ; CHECK-NEXT: set_local 4, pop{{$}}
8791 define i32 @ugt_i32(i32 %x, i32 %y) {
8892 %a = icmp ugt i32 %x, %y
8993 %b = zext i1 %a to i32
9195 }
9296
9397 ; CHECK-LABEL: uge_i32:
94 ; CHECK: i32.ge_u $push, (get_local 0), (get_local 1){{$}}
95 ; CHECK-NEXT: set_local 2, $pop{{$}}
98 ; CHECK: i32.ge_u push, (get_local 3), (get_local 2){{$}}
99 ; CHECK-NEXT: set_local 4, pop{{$}}
96100 define i32 @uge_i32(i32 %x, i32 %y) {
97101 %a = icmp uge i32 %x, %y
98102 %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: i64.eq $push, (get_local 0), (get_local 1){{$}}
13 ; CHECK-NEXT: set_local 2, $pop{{$}}
14 ; CHECK-NEXT: return (get_local 2){{$}}
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){{$}}
1519 define i32 @eq_i64(i64 %x, i64 %y) {
1620 %a = icmp eq i64 %x, %y
1721 %b = zext i1 %a to i32
1923 }
2024
2125 ; CHECK-LABEL: ne_i64:
22 ; CHECK: i64.ne $push, (get_local 0), (get_local 1){{$}}
23 ; CHECK-NEXT: set_local 2, $pop{{$}}
26 ; CHECK: i64.ne push, (get_local 3), (get_local 2){{$}}
27 ; CHECK-NEXT: set_local 4, pop{{$}}
2428 define i32 @ne_i64(i64 %x, i64 %y) {
2529 %a = icmp ne i64 %x, %y
2630 %b = zext i1 %a to i32
2832 }
2933
3034 ; CHECK-LABEL: slt_i64:
31 ; CHECK: i64.lt_s $push, (get_local 0), (get_local 1){{$}}
32 ; CHECK-NEXT: set_local 2, $pop{{$}}
35 ; CHECK: i64.lt_s push, (get_local 3), (get_local 2){{$}}
36 ; CHECK-NEXT: set_local 4, pop{{$}}
3337 define i32 @slt_i64(i64 %x, i64 %y) {
3438 %a = icmp slt i64 %x, %y
3539 %b = zext i1 %a to i32
3741 }
3842
3943 ; CHECK-LABEL: sle_i64:
40 ; CHECK: i64.le_s $push, (get_local 0), (get_local 1){{$}}
41 ; CHECK-NEXT: set_local 2, $pop{{$}}
44 ; CHECK: i64.le_s push, (get_local 3), (get_local 2){{$}}
45 ; CHECK-NEXT: set_local 4, pop{{$}}
4246 define i32 @sle_i64(i64 %x, i64 %y) {
4347 %a = icmp sle i64 %x, %y
4448 %b = zext i1 %a to i32
4650 }
4751
4852 ; CHECK-LABEL: ult_i64:
49 ; CHECK: i64.lt_u $push, (get_local 0), (get_local 1){{$}}
50 ; CHECK-NEXT: set_local 2, $pop{{$}}
53 ; CHECK: i64.lt_u push, (get_local 3), (get_local 2){{$}}
54 ; CHECK-NEXT: set_local 4, pop{{$}}
5155 define i32 @ult_i64(i64 %x, i64 %y) {
5256 %a = icmp ult i64 %x, %y
5357 %b = zext i1 %a to i32
5559 }
5660
5761 ; CHECK-LABEL: ule_i64:
58 ; CHECK: i64.le_u $push, (get_local 0), (get_local 1){{$}}
59 ; CHECK-NEXT: set_local 2, $pop{{$}}
62 ; CHECK: i64.le_u push, (get_local 3), (get_local 2){{$}}
63 ; CHECK-NEXT: set_local 4, pop{{$}}
6064 define i32 @ule_i64(i64 %x, i64 %y) {
6165 %a = icmp ule i64 %x, %y
6266 %b = zext i1 %a to i32
6468 }
6569
6670 ; CHECK-LABEL: sgt_i64:
67 ; CHECK: i64.gt_s $push, (get_local 0), (get_local 1){{$}}
68 ; CHECK-NEXT: set_local 2, $pop{{$}}
71 ; CHECK: i64.gt_s push, (get_local 3), (get_local 2){{$}}
72 ; CHECK-NEXT: set_local 4, pop{{$}}
6973 define i32 @sgt_i64(i64 %x, i64 %y) {
7074 %a = icmp sgt i64 %x, %y
7175 %b = zext i1 %a to i32
7377 }
7478
7579 ; CHECK-LABEL: sge_i64:
76 ; CHECK: i64.ge_s $push, (get_local 0), (get_local 1){{$}}
77 ; CHECK-NEXT: set_local 2, $pop{{$}}
80 ; CHECK: i64.ge_s push, (get_local 3), (get_local 2){{$}}
81 ; CHECK-NEXT: set_local 4, pop{{$}}
7882 define i32 @sge_i64(i64 %x, i64 %y) {
7983 %a = icmp sge i64 %x, %y
8084 %b = zext i1 %a to i32
8286 }
8387
8488 ; CHECK-LABEL: ugt_i64:
85 ; CHECK: i64.gt_u $push, (get_local 0), (get_local 1){{$}}
86 ; CHECK-NEXT: set_local 2, $pop{{$}}
89 ; CHECK: i64.gt_u push, (get_local 3), (get_local 2){{$}}
90 ; CHECK-NEXT: set_local 4, pop{{$}}
8791 define i32 @ugt_i64(i64 %x, i64 %y) {
8892 %a = icmp ugt i64 %x, %y
8993 %b = zext i1 %a to i32
9195 }
9296
9397 ; CHECK-LABEL: uge_i64:
94 ; CHECK: i64.ge_u $push, (get_local 0), (get_local 1){{$}}
95 ; CHECK-NEXT: set_local 2, $pop{{$}}
98 ; CHECK: i64.ge_u push, (get_local 3), (get_local 2){{$}}
99 ; CHECK-NEXT: set_local 4, pop{{$}}
96100 define i32 @uge_i64(i64 %x, i64 %y) {
97101 %a = icmp uge i64 %x, %y
98102 %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: i32.wrap/i64 $push, (get_local 0){{$}}
12 ; CHECK-NEXT: set_local 1, $pop{{$}}
13 ; CHECK-NEXT: return (get_local 1){{$}}
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){{$}}
1416 define i32 @i32_wrap_i64(i64 %x) {
1517 %a = trunc i64 %x to i32
1618 ret i32 %a
2022 ; CHECK-NEXT: .param i32
2123 ; CHECK-NEXT: .result i64
2224 ; CHECK-NEXT: .local i32, i64{{$}}
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){{$}}
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){{$}}
2630 define i64 @i64_extend_s_i32(i32 %x) {
2731 %a = sext i32 %x to i64
2832 ret i64 %a
3236 ; CHECK-NEXT: .param i32
3337 ; CHECK-NEXT: .result i64
3438 ; CHECK-NEXT: .local i32, i64{{$}}
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){{$}}
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){{$}}
3844 define i64 @i64_extend_u_i32(i32 %x) {
3945 %a = zext i32 %x to i64
4046 ret i64 %a
4450 ; CHECK-NEXT: .param f32
4551 ; CHECK-NEXT: .result i32
4652 ; CHECK-NEXT: .local f32, i32{{$}}
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){{$}}
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){{$}}
5058 define i32 @i32_trunc_s_f32(float %x) {
5159 %a = fptosi float %x to i32
5260 ret i32 %a
5664 ; CHECK-NEXT: .param f32
5765 ; CHECK-NEXT: .result i32
5866 ; CHECK-NEXT: .local f32, i32{{$}}
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){{$}}
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){{$}}
6272 define i32 @i32_trunc_u_f32(float %x) {
6373 %a = fptoui float %x to i32
6474 ret i32 %a
6878 ; CHECK-NEXT: .param f64
6979 ; CHECK-NEXT: .result i32
7080 ; CHECK-NEXT: .local f64, i32{{$}}
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){{$}}
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){{$}}
7486 define i32 @i32_trunc_s_f64(double %x) {
7587 %a = fptosi double %x to i32
7688 ret i32 %a
8092 ; CHECK-NEXT: .param f64
8193 ; CHECK-NEXT: .result i32
8294 ; CHECK-NEXT: .local f64, i32{{$}}
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){{$}}
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){{$}}
86100 define i32 @i32_trunc_u_f64(double %x) {
87101 %a = fptoui double %x to i32
88102 ret i32 %a
92106 ; CHECK-NEXT: .param f32
93107 ; CHECK-NEXT: .result i64
94108 ; CHECK-NEXT: .local f32, i64{{$}}
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){{$}}
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){{$}}
98114 define i64 @i64_trunc_s_f32(float %x) {
99115 %a = fptosi float %x to i64
100116 ret i64 %a
104120 ; CHECK-NEXT: .param f32
105121 ; CHECK-NEXT: .result i64
106122 ; CHECK-NEXT: .local f32, i64{{$}}
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){{$}}
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){{$}}
110128 define i64 @i64_trunc_u_f32(float %x) {
111129 %a = fptoui float %x to i64
112130 ret i64 %a
116134 ; CHECK-NEXT: .param f64
117135 ; CHECK-NEXT: .result i64
118136 ; CHECK-NEXT: .local f64, i64{{$}}
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){{$}}
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){{$}}
122142 define i64 @i64_trunc_s_f64(double %x) {
123143 %a = fptosi double %x to i64
124144 ret i64 %a
128148 ; CHECK-NEXT: .param f64
129149 ; CHECK-NEXT: .result i64
130150 ; CHECK-NEXT: .local f64, i64{{$}}
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){{$}}
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){{$}}
134156 define i64 @i64_trunc_u_f64(double %x) {
135157 %a = fptoui double %x to i64
136158 ret i64 %a
140162 ; CHECK-NEXT: .param i32
141163 ; CHECK-NEXT: .result f32
142164 ; CHECK-NEXT: .local i32, f32{{$}}
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){{$}}
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){{$}}
146170 define float @f32_convert_s_i32(i32 %x) {
147171 %a = sitofp i32 %x to float
148172 ret float %a
152176 ; CHECK-NEXT: .param i32
153177 ; CHECK-NEXT: .result f32
154178 ; CHECK-NEXT: .local i32, f32{{$}}
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){{$}}
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){{$}}
158184 define float @f32_convert_u_i32(i32 %x) {
159185 %a = uitofp i32 %x to float
160186 ret float %a
164190 ; CHECK-NEXT: .param i32
165191 ; CHECK-NEXT: .result f64
166192 ; CHECK-NEXT: .local i32, f64{{$}}
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){{$}}
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){{$}}
170198 define double @f64_convert_s_i32(i32 %x) {
171199 %a = sitofp i32 %x to double
172200 ret double %a
176204 ; CHECK-NEXT: .param i32
177205 ; CHECK-NEXT: .result f64
178206 ; CHECK-NEXT: .local i32, f64{{$}}
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){{$}}
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){{$}}
182212 define double @f64_convert_u_i32(i32 %x) {
183213 %a = uitofp i32 %x to double
184214 ret double %a
188218 ; CHECK-NEXT: .param i64
189219 ; CHECK-NEXT: .result f32
190220 ; CHECK-NEXT: .local i64, f32{{$}}
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){{$}}
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){{$}}
194226 define float @f32_convert_s_i64(i64 %x) {
195227 %a = sitofp i64 %x to float
196228 ret float %a
200232 ; CHECK-NEXT: .param i64
201233 ; CHECK-NEXT: .result f32
202234 ; CHECK-NEXT: .local i64, f32{{$}}
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){{$}}
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){{$}}
206240 define float @f32_convert_u_i64(i64 %x) {
207241 %a = uitofp i64 %x to float
208242 ret float %a
212246 ; CHECK-NEXT: .param i64
213247 ; CHECK-NEXT: .result f64
214248 ; CHECK-NEXT: .local i64, f64{{$}}
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){{$}}
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){{$}}
218254 define double @f64_convert_s_i64(i64 %x) {
219255 %a = sitofp i64 %x to double
220256 ret double %a
224260 ; CHECK-NEXT: .param i64
225261 ; CHECK-NEXT: .result f64
226262 ; CHECK-NEXT: .local i64, f64{{$}}
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){{$}}
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){{$}}
230268 define double @f64_convert_u_i64(i64 %x) {
231269 %a = uitofp i64 %x to double
232270 ret double %a
236274 ; CHECK-NEXT: .param f32
237275 ; CHECK-NEXT: .result f64
238276 ; CHECK-NEXT: .local f32, f64{{$}}
239 ; CHECK-NEXT: f64.promote/f32 $push, (get_local 0){{$}}
240 ; CHECK-NEXT: set_local 1, $pop{{$}}
241 ; CHECK-NEXT: return (get_local 1){{$}}
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){{$}}
242282 define double @f64_promote_f32(float %x) {
243283 %a = fpext float %x to double
244284 ret double %a
248288 ; CHECK-NEXT: .param f64
249289 ; CHECK-NEXT: .result f32
250290 ; CHECK-NEXT: .local f64, f32{{$}}
251 ; CHECK-NEXT: f32.demote/f64 $push, (get_local 0){{$}}
252 ; CHECK-NEXT: set_local 1, $pop{{$}}
253 ; CHECK-NEXT: return (get_local 1){{$}}
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){{$}}
254296 define float @f32_demote_f64(double %x) {
255297 %a = fptrunc double %x to float
256298 ret float %a
0 ; RUN: llc < %s -asm-verbose=false | FileCheck %s
11
2 ; Check that unused vregs aren't assigned registers.
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.
38
49 target datalayout = "e-p:32:32-i64:64-n32:64-S128"
510 target triple = "wasm32-unknown-unknown"
914 ; CHECK-NEXT: .param i32
1015 ; CHECK-NEXT: .param i32
1116 ; CHECK-NEXT: .param i32
12 ; CHECK-NEXT: .local i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, 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{{$}}
1318 entry:
1419 %cmp.19 = icmp sgt i32 %h, 0
1520 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: f32.add $push, (get_local 0), (get_local 1){{$}}
22 ; CHECK-NEXT: set_local 2, $pop{{$}}
23 ; CHECK-NEXT: return (get_local 2){{$}}
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){{$}}
2428 define float @fadd32(float %x, float %y) {
2529 %a = fadd float %x, %y
2630 ret float %a
2731 }
2832
2933 ; CHECK-LABEL: fsub32:
30 ; CHECK: f32.sub $push, (get_local 0), (get_local 1){{$}}
31 ; CHECK-NEXT: set_local 2, $pop{{$}}
34 ; CHECK: f32.sub push, (get_local 3), (get_local 2){{$}}
35 ; CHECK-NEXT: set_local 4, pop{{$}}
3236 define float @fsub32(float %x, float %y) {
3337 %a = fsub float %x, %y
3438 ret float %a
3539 }
3640
3741 ; CHECK-LABEL: fmul32:
38 ; CHECK: f32.mul $push, (get_local 0), (get_local 1){{$}}
39 ; CHECK-NEXT: set_local 2, $pop{{$}}
42 ; CHECK: f32.mul push, (get_local 3), (get_local 2){{$}}
43 ; CHECK-NEXT: set_local 4, pop{{$}}
4044 define float @fmul32(float %x, float %y) {
4145 %a = fmul float %x, %y
4246 ret float %a
4347 }
4448
4549 ; CHECK-LABEL: fdiv32:
46 ; CHECK: f32.div $push, (get_local 0), (get_local 1){{$}}
47 ; CHECK-NEXT: set_local 2, $pop{{$}}
50 ; CHECK: f32.div push, (get_local 3), (get_local 2){{$}}
51 ; CHECK-NEXT: set_local 4, pop{{$}}
4852 define float @fdiv32(float %x, float %y) {
4953 %a = fdiv float %x, %y
5054 ret float %a
5155 }
5256
5357 ; CHECK-LABEL: fabs32:
54 ; CHECK: f32.abs $push, (get_local 0){{$}}
55 ; CHECK-NEXT: set_local 1, $pop{{$}}
58 ; CHECK: f32.abs push, (get_local 1){{$}}
59 ; CHECK-NEXT: set_local 2, pop{{$}}
5660 define float @fabs32(float %x) {
5761 %a = call float @llvm.fabs.f32(float %x)
5862 ret float %a
5963 }
6064
6165 ; CHECK-LABEL: fneg32:
62 ; CHECK: f32.neg $push, (get_local 0){{$}}
63 ; CHECK-NEXT: set_local 1, $pop{{$}}
66 ; CHECK: f32.neg push, (get_local 1){{$}}
67 ; CHECK-NEXT: set_local 2, pop{{$}}
6468 define float @fneg32(float %x) {
6569 %a = fsub float -0., %x
6670 ret float %a
6771 }
6872
6973 ; CHECK-LABEL: copysign32:
70 ; CHECK: f32.copysign $push, (get_local 0), (get_local 1){{$}}
71 ; CHECK-NEXT: set_local 2, $pop{{$}}
74 ; CHECK: f32.copysign push, (get_local 3), (get_local 2){{$}}
75 ; CHECK-NEXT: set_local 4, pop{{$}}
7276 define float @copysign32(float %x, float %y) {
7377 %a = call float @llvm.copysign.f32(float %x, float %y)
7478 ret float %a
7579 }
7680
7781 ; CHECK-LABEL: sqrt32:
78 ; CHECK: f32.sqrt $push, (get_local 0){{$}}
79 ; CHECK-NEXT: set_local 1, $pop{{$}}
82 ; CHECK: f32.sqrt push, (get_local 1){{$}}
83 ; CHECK-NEXT: set_local 2, pop{{$}}
8084 define float @sqrt32(float %x) {
8185 %a = call float @llvm.sqrt.f32(float %x)
8286 ret float %a
8387 }
8488
8589 ; CHECK-LABEL: ceil32:
86 ; CHECK: f32.ceil $push, (get_local 0){{$}}
87 ; CHECK-NEXT: set_local 1, $pop{{$}}
90 ; CHECK: f32.ceil push, (get_local 1){{$}}
91 ; CHECK-NEXT: set_local 2, pop{{$}}
8892 define float @ceil32(float %x) {
8993 %a = call float @llvm.ceil.f32(float %x)
9094 ret float %a
9195 }
9296
9397 ; CHECK-LABEL: floor32:
94 ; CHECK: f32.floor $push, (get_local 0){{$}}
95 ; CHECK-NEXT: set_local 1, $pop{{$}}
98 ; CHECK: f32.floor push, (get_local 1){{$}}
99 ; CHECK-NEXT: set_local 2, pop{{$}}
96100 define float @floor32(float %x) {
97101 %a = call float @llvm.floor.f32(float %x)
98102 ret float %a
99103 }
100104
101105 ; CHECK-LABEL: trunc32:
102 ; CHECK: f32.trunc $push, (get_local 0){{$}}
103 ; CHECK-NEXT: set_local 1, $pop{{$}}
106 ; CHECK: f32.trunc push, (get_local 1){{$}}
107 ; CHECK-NEXT: set_local 2, pop{{$}}
104108 define float @trunc32(float %x) {
105109 %a = call float @llvm.trunc.f32(float %x)
106110 ret float %a
107111 }
108112
109113 ; CHECK-LABEL: nearest32:
110 ; CHECK: f32.nearest $push, (get_local 0){{$}}
111 ; CHECK-NEXT: set_local 1, $pop{{$}}
114 ; CHECK: f32.nearest push, (get_local 1){{$}}
115 ; CHECK-NEXT: set_local 2, pop{{$}}
112116 define float @nearest32(float %x) {
113117 %a = call float @llvm.nearbyint.f32(float %x)
114118 ret float %a
115119 }
116120
117121 ; CHECK-LABEL: nearest32_via_rint:
118 ; CHECK: f32.nearest $push, (get_local 0){{$}}
119 ; CHECK-NEXT: set_local 1, $pop{{$}}
122 ; CHECK: f32.nearest push, (get_local 1){{$}}
123 ; CHECK-NEXT: set_local 2, pop{{$}}
120124 define float @nearest32_via_rint(float %x) {
121125 %a = call float @llvm.rint.f32(float %x)
122126 ret float %a
129133 ; tests.
130134
131135 ; CHECK-LABEL: fmin32:
132 ; CHECK: f32.min $push, (get_local 0), (get_local 1){{$}}
133 ; CHECK-NEXT: set_local 2, $pop{{$}}
136 ; CHECK: f32.min push, (get_local 1), (get_local 2){{$}}
137 ; CHECK-NEXT: set_local 3, pop{{$}}
134138 define float @fmin32(float %x) {
135139 %a = fcmp ult float %x, 0.0
136140 %b = select i1 %a, float %x, float 0.0
138142 }
139143
140144 ; CHECK-LABEL: fmax32:
141 ; CHECK: f32.max $push, (get_local 0), (get_local 1){{$}}
142 ; CHECK-NEXT: set_local 2, $pop{{$}}
145 ; CHECK: f32.max push, (get_local 1), (get_local 2){{$}}
146 ; CHECK-NEXT: set_local 3, pop{{$}}
143147 define float @fmax32(float %x) {
144148 %a = fcmp ugt float %x, 0.0
145149 %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: f64.add $push, (get_local 0), (get_local 1){{$}}
22 ; CHECK-NEXT: set_local 2, $pop{{$}}
23 ; CHECK-NEXT: return (get_local 2){{$}}
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){{$}}
2428 define double @fadd64(double %x, double %y) {
2529 %a = fadd double %x, %y
2630 ret double %a
2731 }
2832
2933 ; CHECK-LABEL: fsub64:
30 ; CHECK: f64.sub $push, (get_local 0), (get_local 1){{$}}
31 ; CHECK-NEXT: set_local 2, $pop{{$}}
34 ; CHECK: f64.sub push, (get_local 3), (get_local 2){{$}}
35 ; CHECK-NEXT: set_local 4, pop{{$}}
3236 define double @fsub64(double %x, double %y) {
3337 %a = fsub double %x, %y
3438 ret double %a
3539 }
3640
3741 ; CHECK-LABEL: fmul64:
38 ; CHECK: f64.mul $push, (get_local 0), (get_local 1){{$}}
39 ; CHECK-NEXT: set_local 2, $pop{{$}}
42 ; CHECK: f64.mul push, (get_local 3), (get_local 2){{$}}
43 ; CHECK-NEXT: set_local 4, pop{{$}}
4044 define double @fmul64(double %x, double %y) {
4145 %a = fmul double %x, %y
4246 ret double %a
4347 }
4448
4549 ; CHECK-LABEL: fdiv64:
46 ; CHECK: f64.div $push, (get_local 0), (get_local 1){{$}}
47 ; CHECK-NEXT: set_local 2, $pop{{$}}
50 ; CHECK: f64.div push, (get_local 3), (get_local 2){{$}}
51 ; CHECK-NEXT: set_local 4, pop{{$}}
4852 define double @fdiv64(double %x, double %y) {
4953 %a = fdiv double %x, %y
5054 ret double %a
5155 }
5256
5357 ; CHECK-LABEL: fabs64:
54 ; CHECK: f64.abs $push, (get_local 0){{$}}
55 ; CHECK-NEXT: set_local 1, $pop{{$}}
58 ; CHECK: f64.abs push, (get_local 1){{$}}
59 ; CHECK-NEXT: set_local 2, pop{{$}}
5660 define double @fabs64(double %x) {
5761 %a = call double @llvm.fabs.f64(double %x)
5862 ret double %a
5963 }
6064
6165 ; CHECK-LABEL: fneg64:
62 ; CHECK: f64.neg $push, (get_local 0){{$}}
63 ; CHECK-NEXT: set_local 1, $pop{{$}}
66 ; CHECK: f64.neg push, (get_local 1){{$}}
67 ; CHECK-NEXT: set_local 2, pop{{$}}
6468 define double @fneg64(double %x) {
6569 %a = fsub double -0., %x
6670 ret double %a
6771 }
6872
6973 ; CHECK-LABEL: copysign64:
70 ; CHECK: f64.copysign $push, (get_local 0), (get_local 1){{$}}
71 ; CHECK-NEXT: set_local 2, $pop{{$}}
74 ; CHECK: f64.copysign push, (get_local 3), (get_local 2){{$}}
75 ; CHECK-NEXT: set_local 4, pop{{$}}
7276 define double @copysign64(double %x, double %y) {
7377 %a = call double @llvm.copysign.f64(double %x, double %y)
7478 ret double %a
7579 }
7680
7781 ; CHECK-LABEL: sqrt64:
78 ; CHECK: f64.sqrt $push, (get_local 0){{$}}
79 ; CHECK-NEXT: set_local 1, $pop{{$}}
82 ; CHECK: f64.sqrt push, (get_local 1){{$}}
83 ; CHECK-NEXT: set_local 2, pop{{$}}
8084 define double @sqrt64(double %x) {
8185 %a = call double @llvm.sqrt.f64(double %x)
8286 ret double %a
8387 }
8488
8589 ; CHECK-LABEL: ceil64:
86 ; CHECK: f64.ceil $push, (get_local 0){{$}}
87 ; CHECK-NEXT: set_local 1, $pop{{$}}
90 ; CHECK: f64.ceil push, (get_local 1){{$}}
91 ; CHECK-NEXT: set_local 2, pop{{$}}
8892 define double @ceil64(double %x) {
8993 %a = call double @llvm.ceil.f64(double %x)
9094 ret double %a
9195 }
9296
9397 ; CHECK-LABEL: floor64:
94 ; CHECK: f64.floor $push, (get_local 0){{$}}
95 ; CHECK-NEXT: set_local 1, $pop{{$}}
98 ; CHECK: f64.floor push, (get_local 1){{$}}
99 ; CHECK-NEXT: set_local 2, pop{{$}}
96100 define double @floor64(double %x) {
97101 %a = call double @llvm.floor.f64(double %x)
98102 ret double %a
99103 }
100104
101105 ; CHECK-LABEL: trunc64:
102 ; CHECK: f64.trunc $push, (get_local 0){{$}}
103 ; CHECK-NEXT: set_local 1, $pop{{$}}
106 ; CHECK: f64.trunc push, (get_local 1){{$}}
107 ; CHECK-NEXT: set_local 2, pop{{$}}
104108 define double @trunc64(double %x) {
105109 %a = call double @llvm.trunc.f64(double %x)
106110 ret double %a
107111 }
108112
109113 ; CHECK-LABEL: nearest64:
110 ; CHECK: f64.nearest $push, (get_local 0){{$}}
111 ; CHECK-NEXT: set_local 1, $pop{{$}}
114 ; CHECK: f64.nearest push, (get_local 1){{$}}
115 ; CHECK-NEXT: set_local 2, pop{{$}}
112116 define double @nearest64(double %x) {
113117 %a = call double @llvm.nearbyint.f64(double %x)
114118 ret double %a
115119 }
116120
117121 ; CHECK-LABEL: nearest64_via_rint:
118 ; CHECK: f64.nearest $push, (get_local 0){{$}}
119 ; CHECK-NEXT: set_local 1, $pop{{$}}
122 ; CHECK: f64.nearest push, (get_local 1){{$}}
123 ; CHECK-NEXT: set_local 2, pop{{$}}
120124 define double @nearest64_via_rint(double %x) {
121125 %a = call double @llvm.rint.f64(double %x)
122126 ret double %a
129133 ; tests.
130134
131135 ; CHECK-LABEL: fmin64:
132 ; CHECK: f64.min $push, (get_local 0), (get_local 1){{$}}
133 ; CHECK-NEXT: set_local 2, $pop{{$}}
136 ; CHECK: f64.min push, (get_local 1), (get_local 2){{$}}
137 ; CHECK-NEXT: set_local 3, pop{{$}}
134138 define double @fmin64(double %x) {
135139 %a = fcmp ult double %x, 0.0
136140 %b = select i1 %a, double %x, double 0.0
138142 }
139143
140144 ; CHECK-LABEL: fmax64:
141 ; CHECK: f64.max $push, (get_local 0), (get_local 1){{$}}
142 ; CHECK-NEXT: set_local 2, $pop{{$}}
145 ; CHECK: f64.max push, (get_local 1), (get_local 2){{$}}
146 ; CHECK-NEXT: set_local 3, pop{{$}}
143147 define double @fmax64(double %x) {
144148 %a = fcmp ugt double %x, 0.0
145149 %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: i32.add $push, (get_local 0), (get_local 1){{$}}
17 ; CHECK-NEXT: set_local 2, $pop{{$}}
18 ; CHECK-NEXT: return (get_local 2){{$}}
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){{$}}
1923 define i32 @add32(i32 %x, i32 %y) {
2024 %a = add i32 %x, %y
2125 ret i32 %a
2630 ; CHECK-NEXT: .param i32{{$}}
2731 ; CHECK-NEXT: .result i32{{$}}
2832 ; CHECK-NEXT: .local i32, i32, i32{{$}}
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){{$}}
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){{$}}
3240 define i32 @sub32(i32 %x, i32 %y) {
3341 %a = sub i32 %x, %y
3442 ret i32 %a
3947 ; CHECK-NEXT: .param i32{{$}}
4048 ; CHECK-NEXT: .result i32{{$}}
4149 ; CHECK-NEXT: .local i32, i32, i32{{$}}
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){{$}}
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){{$}}
4557 define i32 @mul32(i32 %x, i32 %y) {
4658 %a = mul i32 %x, %y
4759 ret i32 %a
5264 ; CHECK-NEXT: .param i32{{$}}
5365 ; CHECK-NEXT: .result i32{{$}}
5466 ; CHECK-NEXT: .local i32, i32, i32{{$}}
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){{$}}
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){{$}}
5874 define i32 @sdiv32(i32 %x, i32 %y) {
5975 %a = sdiv i32 %x, %y
6076 ret i32 %a
6581 ; CHECK-NEXT: .param i32{{$}}
6682 ; CHECK-NEXT: .result i32{{$}}
6783 ; CHECK-NEXT: .local i32, i32, i32{{$}}
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){{$}}
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){{$}}
7191 define i32 @udiv32(i32 %x, i32 %y) {
7292 %a = udiv i32 %x, %y
7393 ret i32 %a
7898 ; CHECK-NEXT: .param i32{{$}}
7999 ; CHECK-NEXT: .result i32{{$}}
80100 ; CHECK-NEXT: .local i32, i32, i32{{$}}
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){{$}}
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){{$}}
84108 define i32 @srem32(i32 %x, i32 %y) {
85109 %a = srem i32 %x, %y
86110 ret i32 %a
91115 ; CHECK-NEXT: .param i32{{$}}
92116 ; CHECK-NEXT: .result i32{{$}}
93117 ; CHECK-NEXT: .local i32, i32, i32{{$}}
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){{$}}
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){{$}}
97125 define i32 @urem32(i32 %x, i32 %y) {
98126 %a = urem i32 %x, %y
99127 ret i32 %a
104132 ; CHECK-NEXT: .param i32{{$}}
105133 ; CHECK-NEXT: .result i32{{$}}
106134 ; CHECK-NEXT: .local i32, i32, i32{{$}}
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){{$}}
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){{$}}
110142 define i32 @and32(i32 %x, i32 %y) {
111143 %a = and i32 %x, %y
112144 ret i32 %a
117149 ; CHECK-NEXT: .param i32{{$}}
118150 ; CHECK-NEXT: .result i32{{$}}
119151 ; CHECK-NEXT: .local i32, i32, i32{{$}}
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){{$}}
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){{$}}
123159 define i32 @or32(i32 %x, i32 %y) {
124160 %a = or i32 %x, %y
125161 ret i32 %a
130166 ; CHECK-NEXT: .param i32{{$}}
131167 ; CHECK-NEXT: .result i32{{$}}
132168 ; CHECK-NEXT: .local i32, i32, i32{{$}}
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){{$}}
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){{$}}
136176 define i32 @xor32(i32 %x, i32 %y) {
137177 %a = xor i32 %x, %y
138178 ret i32 %a
143183 ; CHECK-NEXT: .param i32{{$}}
144184 ; CHECK-NEXT: .result i32{{$}}
145185 ; CHECK-NEXT: .local i32, i32, i32{{$}}
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){{$}}
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){{$}}
149193 define i32 @shl32(i32 %x, i32 %y) {
150194 %a = shl i32 %x, %y
151195 ret i32 %a
156200 ; CHECK-NEXT: .param i32{{$}}
157201 ; CHECK-NEXT: .result i32{{$}}
158202 ; CHECK-NEXT: .local i32, i32, i32{{$}}
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){{$}}
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){{$}}
162210 define i32 @shr32(i32 %x, i32 %y) {
163211 %a = lshr i32 %x, %y
164212 ret i32 %a
169217 ; CHECK-NEXT: .param i32{{$}}
170218 ; CHECK-NEXT: .result i32{{$}}
171219 ; CHECK-NEXT: .local i32, i32, i32{{$}}
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){{$}}
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){{$}}
175227 define i32 @sar32(i32 %x, i32 %y) {
176228 %a = ashr i32 %x, %y
177229 ret i32 %a
181233 ; CHECK-NEXT: .param i32{{$}}
182234 ; CHECK-NEXT: .result i32{{$}}
183235 ; CHECK-NEXT: .local i32, i32{{$}}
184 ; CHECK-NEXT: i32.clz $push, (get_local 0){{$}}
185 ; CHECK-NEXT: set_local 1, $pop{{$}}
186 ; CHECK-NEXT: return (get_local 1){{$}}
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){{$}}
187241 define i32 @clz32(i32 %x) {
188242 %a = call i32 @llvm.ctlz.i32(i32 %x, i1 false)
189243 ret i32 %a
193247 ; CHECK-NEXT: .param i32{{$}}
194248 ; CHECK-NEXT: .result i32{{$}}
195249 ; CHECK-NEXT: .local i32, i32{{$}}
196 ; CHECK-NEXT: i32.clz $push, (get_local 0){{$}}
197 ; CHECK-NEXT: set_local 1, $pop{{$}}
198 ; CHECK-NEXT: return (get_local 1){{$}}
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){{$}}
199255 define i32 @clz32_zero_undef(i32 %x) {
200256 %a = call i32 @llvm.ctlz.i32(i32 %x, i1 true)
201257 ret i32 %a
205261 ; CHECK-NEXT: .param i32{{$}}
206262 ; CHECK-NEXT: .result i32{{$}}
207263 ; CHECK-NEXT: .local i32, i32{{$}}
208 ; CHECK-NEXT: i32.ctz $push, (get_local 0){{$}}
209 ; CHECK-NEXT: set_local 1, $pop{{$}}
210 ; CHECK-NEXT: return (get_local 1){{$}}
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){{$}}
211269 define i32 @ctz32(i32 %x) {
212270 %a = call i32 @llvm.cttz.i32(i32 %x, i1 false)
213271 ret i32 %a
217275 ; CHECK-NEXT: .param i32{{$}}
218276 ; CHECK-NEXT: .result i32{{$}}
219277 ; CHECK-NEXT: .local i32, i32{{$}}
220 ; CHECK-NEXT: i32.ctz $push, (get_local 0){{$}}
221 ; CHECK-NEXT: set_local 1, $pop{{$}}
222 ; CHECK-NEXT: return (get_local 1){{$}}
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){{$}}
223283 define i32 @ctz32_zero_undef(i32 %x) {
224284 %a = call i32 @llvm.cttz.i32(i32 %x, i1 true)
225285 ret i32 %a
229289 ; CHECK-NEXT: .param i32{{$}}
230290 ; CHECK-NEXT: .result i32{{$}}
231291 ; CHECK-NEXT: .local i32, i32{{$}}
232 ; CHECK-NEXT: i32.popcnt $push, (get_local 0){{$}}
233 ; CHECK-NEXT: set_local 1, $pop{{$}}
234 ; CHECK-NEXT: return (get_local 1){{$}}
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){{$}}
235297 define i32 @popcnt32(i32 %x) {
236298 %a = call i32 @llvm.ctpop.i32(i32 %x)
237299 ret i32 %a
1313 ; CHECK-NEXT: .param i64{{$}}
1414 ; CHECK-NEXT: .result i64{{$}}
1515 ; CHECK-NEXT: .local i64, i64, i64{{$}}
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){{$}}
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){{$}}
1923 define i64 @add64(i64 %x, i64 %y) {
2024 %a = add i64 %x, %y
2125 ret i64 %a
2630 ; CHECK-NEXT: .param i64{{$}}
2731 ; CHECK-NEXT: .result i64{{$}}
2832 ; CHECK-NEXT: .local i64, i64, i64{{$}}
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){{$}}
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){{$}}
3240 define i64 @sub64(i64 %x, i64 %y) {
3341 %a = sub i64 %x, %y
3442 ret i64 %a
3947 ; CHECK-NEXT: .param i64{{$}}
4048 ; CHECK-NEXT: .result i64{{$}}
4149 ; CHECK-NEXT: .local i64, i64, i64{{$}}
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){{$}}
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){{$}}
4557 define i64 @mul64(i64 %x, i64 %y) {
4658 %a = mul i64 %x, %y
4759 ret i64 %a
5264 ; CHECK-NEXT: .param i64{{$}}
5365 ; CHECK-NEXT: .result i64{{$}}
5466 ; CHECK-NEXT: .local i64, i64, i64{{$}}
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){{$}}
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){{$}}
5874 define i64 @sdiv64(i64 %x, i64 %y) {
5975 %a = sdiv i64 %x, %y
6076 ret i64 %a
6581 ; CHECK-NEXT: .param i64{{$}}
6682 ; CHECK-NEXT: .result i64{{$}}
6783 ; CHECK-NEXT: .local i64, i64, i64{{$}}
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){{$}}
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){{$}}
7191 define i64 @udiv64(i64 %x, i64 %y) {
7292 %a = udiv i64 %x, %y
7393 ret i64 %a
7898 ; CHECK-NEXT: .param i64{{$}}
7999 ; CHECK-NEXT: .result i64{{$}}
80100 ; CHECK-NEXT: .local i64, i64, i64{{$}}
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){{$}}
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){{$}}
84108 define i64 @srem64(i64 %x, i64 %y) {
85109 %a = srem i64 %x, %y
86110 ret i64 %a
91115 ; CHECK-NEXT: .param i64{{$}}
92116 ; CHECK-NEXT: .result i64{{$}}
93117 ; CHECK-NEXT: .local i64, i64, i64{{$}}
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){{$}}
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){{$}}
97125 define i64 @urem64(i64 %x, i64 %y) {
98126 %a = urem i64 %x, %y
99127 ret i64 %a
104132 ; CHECK-NEXT: .param i64{{$}}
105133 ; CHECK-NEXT: .result i64{{$}}
106134 ; CHECK-NEXT: .local i64, i64, i64{{$}}
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){{$}}
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){{$}}
110142 define i64 @and64(i64 %x, i64 %y) {
111143 %a = and i64 %x, %y
112144 ret i64 %a
117149 ; CHECK-NEXT: .param i64{{$}}
118150 ; CHECK-NEXT: .result i64{{$}}
119151 ; CHECK-NEXT: .local i64, i64, i64{{$}}
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){{$}}
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){{$}}
123159 define i64 @or64(i64 %x, i64 %y) {
124160 %a = or i64 %x, %y
125161 ret i64 %a
130166 ; CHECK-NEXT: .param i64{{$}}
131167 ; CHECK-NEXT: .result i64{{$}}
132168 ; CHECK-NEXT: .local i64, i64, i64{{$}}
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){{$}}
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){{$}}
136176 define i64 @xor64(i64 %x, i64 %y) {
137177 %a = xor i64 %x, %y
138178 ret i64 %a
143183 ; CHECK-NEXT: .param i64{{$}}
144184 ; CHECK-NEXT: .result i64{{$}}
145185 ; CHECK-NEXT: .local i64, i64, i64{{$}}
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){{$}}
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){{$}}
149193 define i64 @shl64(i64 %x, i64 %y) {
150194 %a = shl i64 %x, %y
151195 ret i64 %a
156200 ; CHECK-NEXT: .param i64{{$}}
157201 ; CHECK-NEXT: .result i64{{$}}
158202 ; CHECK-NEXT: .local i64, i64, i64{{$}}
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){{$}}
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){{$}}
162210 define i64 @shr64(i64 %x, i64 %y) {
163211 %a = lshr i64 %x, %y
164212 ret i64 %a
169217 ; CHECK-NEXT: .param i64{{$}}
170218 ; CHECK-NEXT: .result i64{{$}}
171219 ; CHECK-NEXT: .local i64, i64, i64{{$}}
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){{$}}
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){{$}}
175227 define i64 @sar64(i64 %x, i64 %y) {
176228 %a = ashr i64 %x, %y
177229 ret i64 %a
181233 ; CHECK-NEXT: .param i64{{$}}
182234 ; CHECK-NEXT: .result i64{{$}}
183235 ; CHECK-NEXT: .local i64, i64{{$}}
184 ; CHECK-NEXT: i64.clz $push, (get_local 0){{$}}
185 ; CHECK-NEXT: set_local 1, $pop{{$}}
186 ; CHECK-NEXT: return (get_local 1){{$}}
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){{$}}
187241 define i64 @clz64(i64 %x) {
188242 %a = call i64 @llvm.ctlz.i64(i64 %x, i1 false)
189243 ret i64 %a
193247 ; CHECK-NEXT: .param i64{{$}}
194248 ; CHECK-NEXT: .result i64{{$}}
195249 ; CHECK-NEXT: .local i64, i64{{$}}
196 ; CHECK-NEXT: i64.clz $push, (get_local 0){{$}}
197 ; CHECK-NEXT: set_local 1, $pop{{$}}
198 ; CHECK-NEXT: return (get_local 1){{$}}
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){{$}}
199255 define i64 @clz64_zero_undef(i64 %x) {
200256 %a = call i64 @llvm.ctlz.i64(i64 %x, i1 true)
201257 ret i64 %a
205261 ; CHECK-NEXT: .param i64{{$}}
206262 ; CHECK-NEXT: .result i64{{$}}
207263 ; CHECK-NEXT: .local i64, i64{{$}}
208 ; CHECK-NEXT: i64.ctz $push, (get_local 0){{$}}
209 ; CHECK-NEXT: set_local 1, $pop{{$}}
210 ; CHECK-NEXT: return (get_local 1){{$}}
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){{$}}
211269 define i64 @ctz64(i64 %x) {
212270 %a = call i64 @llvm.cttz.i64(i64 %x, i1 false)
213271 ret i64 %a
217275 ; CHECK-NEXT: .param i64{{$}}
218276 ; CHECK-NEXT: .result i64{{$}}
219277 ; CHECK-NEXT: .local i64, i64{{$}}
220 ; CHECK-NEXT: i64.ctz $push, (get_local 0){{$}}
221 ; CHECK-NEXT: set_local 1, $pop{{$}}
222 ; CHECK-NEXT: return (get_local 1){{$}}
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){{$}}
223283 define i64 @ctz64_zero_undef(i64 %x) {
224284 %a = call i64 @llvm.cttz.i64(i64 %x, i1 true)
225285 ret i64 %a
229289 ; CHECK-NEXT: .param i64{{$}}
230290 ; CHECK-NEXT: .result i64{{$}}
231291 ; CHECK-NEXT: .local i64, i64{{$}}
232 ; CHECK-NEXT: i64.popcnt $push, (get_local 0){{$}}
233 ; CHECK-NEXT: set_local 1, $pop{{$}}
234 ; CHECK-NEXT: return (get_local 1){{$}}
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){{$}}
235297 define i64 @popcnt64(i64 %x) {
236298 %a = call i64 @llvm.ctpop.i64(i64 %x)
237299 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 0){{$}}
9 ; CHECK-NEXT: set_local 1, $pop{{$}}
8 ; CHECK: i32.load8_s push, (get_local 1){{$}}
9 ; CHECK-NEXT: set_local 2, 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 0){{$}}
18 ; CHECK-NEXT: set_local 1, $pop{{$}}
17 ; CHECK: i32.load8_u push, (get_local 1){{$}}
18 ; CHECK-NEXT: set_local 2, 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 0){{$}}
27 ; CHECK-NEXT: set_local 1, $pop{{$}}
26 ; CHECK: i32.load16_s push, (get_local 1){{$}}
27 ; CHECK-NEXT: set_local 2, 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 0){{$}}
36 ; CHECK-NEXT: set_local 1, $pop{{$}}
35 ; CHECK: i32.load16_u push, (get_local 1){{$}}
36 ; CHECK-NEXT: set_local 2, 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 0){{$}}
45 ; CHECK-NEXT: set_local 1, $pop{{$}}
44 ; CHECK: i64.load8_s push, (get_local 1){{$}}
45 ; CHECK-NEXT: set_local 2, 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 0){{$}}
54 ; CHECK-NEXT: set_local 1, $pop{{$}}
53 ; CHECK: i64.load8_u push, (get_local 1){{$}}
54 ; CHECK-NEXT: set_local 2, 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 0){{$}}
63 ; CHECK-NEXT: set_local 1, $pop{{$}}
62 ; CHECK: i64.load16_s push, (get_local 1){{$}}
63 ; CHECK-NEXT: set_local 2, 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 0){{$}}
72 ; CHECK-NEXT: set_local 1, $pop{{$}}
71 ; CHECK: i64.load16_u push, (get_local 1){{$}}
72 ; CHECK-NEXT: set_local 2, 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 0){{$}}
81 ; CHECK-NEXT: set_local 1, $pop{{$}}
80 ; CHECK: i64.load32_s push, (get_local 1){{$}}
81 ; CHECK-NEXT: set_local 2, 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 0){{$}}
90 ; CHECK: set_local 1, $pop{{$}}
89 ; CHECK: i64.load32_u push, (get_local 1){{$}}
90 ; CHECK: set_local 2, 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 0){{$}}
9 ; CHECK-NEXT: set_local 1, $pop{{$}}
10 ; CHECK-NEXT: return (get_local 1){{$}}
8 ; CHECK: i32.load8_u push, (get_local 1){{$}}
9 ; CHECK-NEXT: set_local 2, pop{{$}}
10 ; CHECK-NEXT: return (get_local 2){{$}}
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 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){{$}}
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){{$}}
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 0){{$}}
35 ; CHECK-NEXT: set_local 1, $pop{{$}}
36 ; CHECK-NEXT: return (get_local 1){{$}}
34 ; CHECK: i64.load8_u push, (get_local 1){{$}}
35 ; CHECK-NEXT: set_local 2, pop{{$}}
36 ; CHECK-NEXT: return (get_local 2){{$}}
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 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){{$}}
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){{$}}
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 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){{$}}
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){{$}}
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 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){{$}}
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){{$}}
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: i32.load $push, (get_local 0){{$}}
12 ; CHECK-NEXT: set_local 1, $pop{{$}}
13 ; CHECK-NEXT: return (get_local 1){{$}}
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){{$}}
1416 define i32 @ldi32(i32 *%p) {
1517 %v = load i32, i32* %p
1618 ret i32 %v
2022 ; CHECK-NEXT: .param i32{{$}}
2123 ; CHECK-NEXT: .result i64{{$}}
2224 ; CHECK-NEXT: .local i32, i64{{$}}
23 ; CHECK-NEXT: i64.load $push, (get_local 0){{$}}
24 ; CHECK-NEXT: set_local 1, $pop{{$}}
25 ; CHECK-NEXT: return (get_local 1){{$}}
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){{$}}
2630 define i64 @ldi64(i64 *%p) {
2731 %v = load i64, i64* %p
2832 ret i64 %v
3236 ; CHECK-NEXT: .param i32{{$}}
3337 ; CHECK-NEXT: .result f32{{$}}
3438 ; CHECK-NEXT: .local i32, f32{{$}}
35 ; CHECK-NEXT: f32.load $push, (get_local 0){{$}}
36 ; CHECK-NEXT: set_local 1, $pop{{$}}
37 ; CHECK-NEXT: return (get_local 1){{$}}
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){{$}}
3844 define float @ldf32(float *%p) {
3945 %v = load float, float* %p
4046 ret float %v
4450 ; CHECK-NEXT: .param i32{{$}}
4551 ; CHECK-NEXT: .result f64{{$}}
4652 ; CHECK-NEXT: .local i32, f64{{$}}
47 ; CHECK-NEXT: f64.load $push, (get_local 0){{$}}
48 ; CHECK-NEXT: set_local 1, $pop{{$}}
49 ; CHECK-NEXT: return (get_local 1){{$}}
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){{$}}
5058 define double @ldf64(double *%p) {
5159 %v = load double, double* %p
5260 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 0)
24 ; CHECK: grow_memory (get_local 1)
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 0)
24 ; CHECK: grow_memory (get_local 1)
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: div_s $push, (get_local 0), (get_local 3){{$}}
11 ; CHECK: set_local 0, $pop
12 ; CHECK: return (get_local 0)
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]])
1315 define i32 @test0(i32 %p) {
1416 entry:
1517 %t = icmp slt i32 %p, 0
2628
2729 ; CHECK-LABEL: test1:
2830 ; CHECK: BB1_1:
29 ; CHECK: set_local [[REG0:.*]], (get_local [[REG1:.*]])
30 ; CHECK: set_local [[REG1]], (get_local [[REG2:.*]])
31 ; CHECK: set_local [[REG2]], (get_local [[REG0]])
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
3237 define i32 @test1(i32 %n) {
3338 entry:
3439 br label %loop
33 target triple = "wasm32-unknown-unknown"
44
55