llvm.org GIT mirror llvm / 2d3e3ef
[WebAssembly] Switch to a more traditional assembly syntax This new syntax is built around putting each instruction on its own line in a "mnemonic op, op, op" like syntax. It also uses conventional data section directives like ".byte" and so on rather than requiring everything to be in hierarchical S-expression format. This is a more natural syntax for a ".s" file format from the perspective of LLVM MC and related tools, while remaining easy to translate into other forms as needed. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@249364 91177308-0d34-0410-b5e6-96231b3b80d8 Dan Gohman 4 years ago
31 changed file(s) with 1635 addition(s) and 1100 deletion(s). Raw diff Collapse all Expand all
2626
2727 // TODO: What should MaxInstLength be?
2828
29 // The s-expression format of WebAssembly uses LISP-style comments.
30 CommentString = ";;";
31
3229 PrivateGlobalPrefix = "";
3330 PrivateLabelPrefix = "";
3431
4340 COMMDirectiveAlignmentIsInBytes = false;
4441 LCOMMDirectiveAlignmentType = LCOMM::Log2Alignment;
4542
46 HasDotTypeDotSizeDirective = false;
47 HasSingleParameterDotFile = false;
48
4943 SupportsDebugInformation = true;
5044
5145 // For now, WebAssembly does not support exceptions.
5246 ExceptionsType = ExceptionHandling::None;
5347
54 // FIXME: modify AsmPrinter to be more flexible, and fix other virtual ISAs.
55 WeakDirective = "\t;; .weak\t";
56 GlobalDirective = "\t;; .globl\t";
57
5848 // TODO: UseIntegratedAssembler?
5949 }
2121 #include "MCTargetDesc/WebAssemblyMCTargetDesc.h"
2222
2323 #include "llvm/ADT/SmallString.h"
24 #include "llvm/ADT/StringExtras.h"
2425 #include "llvm/CodeGen/AsmPrinter.h"
2526 #include "llvm/CodeGen/MachineConstantPool.h"
2627 #include "llvm/CodeGen/MachineInstr.h"
4041
4142 class WebAssemblyAsmPrinter final : public AsmPrinter {
4243 const WebAssemblyInstrInfo *TII;
44 unsigned NumArgs;
4345
4446 public:
4547 WebAssemblyAsmPrinter(TargetMachine &TM, std::unique_ptr Streamer)
6163 bool runOnMachineFunction(MachineFunction &MF) override {
6264 const auto &Subtarget = MF.getSubtarget();
6365 TII = Subtarget.getInstrInfo();
66 NumArgs = MF.getInfo()->getNumArguments();
6467 return AsmPrinter::runOnMachineFunction(MF);
6568 }
6669
6871 // AsmPrinter Implementation.
6972 //===------------------------------------------------------------------===//
7073
71 void EmitGlobalVariable(const GlobalVariable *GV) override;
72
7374 void EmitJumpTableInfo() override;
7475 void EmitConstantPool() override;
75 void EmitFunctionEntryLabel() override;
7676 void EmitFunctionBodyStart() override;
77 void EmitFunctionBodyEnd() override;
7877
7978 void EmitInstruction(const MachineInstr *MI) override;
8079
8180 static std::string toString(const APFloat &APF);
8281 const char *toString(Type *Ty) const;
82 std::string regToString(unsigned RegNo);
83 std::string argToString(unsigned ArgNo);
8384 };
8485
8586 } // end anonymous namespace
116117 assert(Written != 0);
117118 assert(Written < BufBytes);
118119 return buf;
120 }
121
122 std::string WebAssemblyAsmPrinter::regToString(unsigned RegNo) {
123 if (TargetRegisterInfo::isPhysicalRegister(RegNo))
124 return WebAssemblyInstPrinter::getRegisterName(RegNo);
125
126 // WebAssembly arguments and local variables are in the same index space, and
127 // there are no explicit varargs, so we just add the number of arguments to
128 // the virtual register number to get the local variable number.
129 return '@' + utostr(TargetRegisterInfo::virtReg2Index(RegNo) + NumArgs);
130 }
131
132 std::string WebAssemblyAsmPrinter::argToString(unsigned ArgNo) {
133 // Same as above, but we don't need to add NumArgs here.
134 return '@' + utostr(ArgNo);
119135 }
120136
121137 const char *WebAssemblyAsmPrinter::toString(Type *Ty) const {
160176 // WebAssemblyAsmPrinter Implementation.
161177 //===----------------------------------------------------------------------===//
162178
163 void WebAssemblyAsmPrinter::EmitGlobalVariable(const GlobalVariable *GV) {
164 SmallString<128> Str;
165 raw_svector_ostream OS(Str);
166 StringRef Name = GV->getName();
167 DEBUG(dbgs() << "Global " << Name << '\n');
168
169 if (!GV->hasInitializer()) {
170 DEBUG(dbgs() << " Skipping declaration.\n");
171 return;
172 }
173
174 // Check to see if this is a special global used by LLVM.
175 static const char *Ignored[] = {"llvm.used", "llvm.metadata"};
176 for (const char *I : Ignored)
177 if (Name == I)
178 return;
179 // FIXME: Handle the following globals.
180 static const char *Unhandled[] = {"llvm.global_ctors", "llvm.global_dtors"};
181 for (const char *U : Unhandled)
182 if (Name == U)
183 report_fatal_error("Unhandled global");
184 if (Name.startswith("llvm."))
185 report_fatal_error("Unknown LLVM-internal global");
186
187 if (GV->isThreadLocal())
188 report_fatal_error("TLS isn't yet supported by WebAssembly");
189
190 const DataLayout &DL = getDataLayout();
191 const Constant *Init = GV->getInitializer();
192 if (isa(Init))
193 Init = Constant::getNullValue(Init->getType());
194 unsigned Align = DL.getPrefTypeAlignment(Init->getType());
195
196 switch (GV->getLinkage()) {
197 case GlobalValue::InternalLinkage:
198 case GlobalValue::PrivateLinkage:
199 break;
200 case GlobalValue::AppendingLinkage:
201 case GlobalValue::LinkOnceAnyLinkage:
202 case GlobalValue::LinkOnceODRLinkage:
203 case GlobalValue::WeakAnyLinkage:
204 case GlobalValue::WeakODRLinkage:
205 case GlobalValue::ExternalLinkage:
206 case GlobalValue::CommonLinkage:
207 report_fatal_error("Linkage types other than internal and private aren't "
208 "supported by WebAssembly yet");
209 default:
210 llvm_unreachable("Unknown linkage type");
211 return;
212 }
213
214 OS << "(global " << toSymbol(Name) << ' ' << toString(Init->getType()) << ' ';
215 if (const auto *C = dyn_cast(Init)) {
216 assert(C->getBitWidth() <= 64 && "Printing wider types unimplemented");
217 OS << C->getZExtValue();
218 } else if (const auto *C = dyn_cast(Init)) {
219 OS << toString(C->getValueAPF());
220 } else {
221 assert(false && "Only integer and floating-point constants are supported");
222 }
223 OS << ") ;; align " << Align;
224 OutStreamer->EmitRawText(OS.str());
225 }
226
227179 void WebAssemblyAsmPrinter::EmitConstantPool() {
228180 assert(MF->getConstantPool()->getConstants().empty() &&
229181 "WebAssembly disables constant pools");
233185 // Nothing to do; jump tables are incorporated into the instruction stream.
234186 }
235187
236 void WebAssemblyAsmPrinter::EmitFunctionEntryLabel() {
237 SmallString<128> Str;
238 raw_svector_ostream OS(Str);
239
240 CurrentFnSym->redefineIfPossible();
241
242 // The function label could have already been emitted if two symbols end up
243 // conflicting due to asm renaming. Detect this and emit an error.
244 if (CurrentFnSym->isVariable())
245 report_fatal_error("'" + Twine(CurrentFnSym->getName()) +
246 "' is a protected alias");
247 if (CurrentFnSym->isDefined())
248 report_fatal_error("'" + Twine(CurrentFnSym->getName()) +
249 "' label emitted multiple times to assembly file");
250
251 OS << "(func " << toSymbol(CurrentFnSym->getName());
252 OutStreamer->EmitRawText(OS.str());
253 }
254
255188 void WebAssemblyAsmPrinter::EmitFunctionBodyStart() {
256 SmallString<128> Str;
257 raw_svector_ostream OS(Str);
258189 const Function *F = MF->getFunction();
259190 Type *Rt = F->getReturnType();
191
260192 if (!Rt->isVoidTy() || !F->arg_empty()) {
261 for (const Argument &A : F->args())
262 OS << " (param " << toString(A.getType()) << ')';
263 if (!Rt->isVoidTy())
264 OS << " (result " << toString(Rt) << ')';
193 SmallString<128> Str;
194 raw_svector_ostream OS(Str);
195 bool First = true;
196 for (const Argument &A : F->args()) {
197 OS << (First ? "" : "\n") << "\t"
198 ".param "
199 << toString(A.getType());
200 First = false;
201 }
202 if (!Rt->isVoidTy()) {
203 OS << (First ? "" : "\n") << "\t"
204 ".result "
205 << toString(Rt);
206 First = false;
207 }
265208 OutStreamer->EmitRawText(OS.str());
266209 }
267 }
268
269 void WebAssemblyAsmPrinter::EmitFunctionBodyEnd() {
270 SmallString<128> Str;
271 raw_svector_ostream OS(Str);
272 OS << ") ;; end func " << toSymbol(CurrentFnSym->getName());
273 OutStreamer->EmitRawText(OS.str());
210
211 AsmPrinter::EmitFunctionBodyStart();
274212 }
275213
276214 void WebAssemblyAsmPrinter::EmitInstruction(const MachineInstr *MI) {
284222
285223 OS << '\t';
286224
287 if (NumDefs != 0) {
288 const MachineOperand &MO = MI->getOperand(0);
289 unsigned Reg = MO.getReg();
290 OS << "(set_local @" << TargetRegisterInfo::virtReg2Index(Reg) << ' ';
291 }
292
293 if (MI->getOpcode() == WebAssembly::COPY) {
294 OS << '@' << TargetRegisterInfo::virtReg2Index(MI->getOperand(1).getReg());
295 } else {
296 OS << '(' << OpcodeName(TII, MI);
297 for (const MachineOperand &MO : MI->uses())
225 switch (MI->getOpcode()) {
226 case TargetOpcode::COPY:
227 OS << regToString(MI->getOperand(1).getReg());
228 break;
229 case WebAssembly::GLOBAL:
230 // TODO: wasm64
231 OS << "i32.const " << toSymbol(MI->getOperand(1).getGlobal()->getName());
232 break;
233 case WebAssembly::ARGUMENT_I32:
234 case WebAssembly::ARGUMENT_I64:
235 case WebAssembly::ARGUMENT_F32:
236 case WebAssembly::ARGUMENT_F64:
237 OS << argToString(MI->getOperand(1).getImm());
238 break;
239 case WebAssembly::Immediate_I32:
240 OS << "i32.const " << MI->getOperand(1).getImm();
241 break;
242 case WebAssembly::Immediate_I64:
243 OS << "i64.const " << MI->getOperand(1).getImm();
244 break;
245 case WebAssembly::Immediate_F32:
246 OS << "f32.const " << toString(MI->getOperand(1).getFPImm()->getValueAPF());
247 break;
248 case WebAssembly::Immediate_F64:
249 OS << "f64.const " << toString(MI->getOperand(1).getFPImm()->getValueAPF());
250 break;
251 default: {
252 OS << OpcodeName(TII, MI);
253 bool NeedComma = false;
254 for (const MachineOperand &MO : MI->uses()) {
255 if (MO.isReg() && MO.isImplicit())
256 continue;
257 if (NeedComma)
258 OS << ',';
259 NeedComma = true;
260 OS << ' ';
298261 switch (MO.getType()) {
299262 default:
300263 llvm_unreachable("unexpected machine operand type");
301 case MachineOperand::MO_Register: {
302 if (MO.isImplicit())
303 continue;
304 unsigned Reg = MO.getReg();
305 OS << " @" << TargetRegisterInfo::virtReg2Index(Reg);
306 } break;
307 case MachineOperand::MO_Immediate: {
308 OS << ' ' << MO.getImm();
309 } break;
310 case MachineOperand::MO_FPImmediate: {
311 OS << ' ' << toString(MO.getFPImm()->getValueAPF());
312 } break;
313 case MachineOperand::MO_GlobalAddress: {
314 OS << ' ' << toSymbol(MO.getGlobal()->getName());
315 } break;
316 case MachineOperand::MO_MachineBasicBlock: {
317 OS << ' ' << toSymbol(MO.getMBB()->getSymbol()->getName());
318 } break;
264 case MachineOperand::MO_Register:
265 OS << regToString(MO.getReg());
266 break;
267 case MachineOperand::MO_Immediate:
268 OS << MO.getImm();
269 break;
270 case MachineOperand::MO_FPImmediate:
271 OS << toString(MO.getFPImm()->getValueAPF());
272 break;
273 case MachineOperand::MO_GlobalAddress:
274 OS << toSymbol(MO.getGlobal()->getName());
275 break;
276 case MachineOperand::MO_MachineBasicBlock:
277 OS << toSymbol(MO.getMBB()->getSymbol()->getName());
278 break;
319279 }
320 OS << ')';
321 }
322
323 if (NumDefs != 0)
324 OS << ')';
280 }
281 break;
282 }
283 }
325284
326285 OutStreamer->EmitRawText(OS.str());
286
287 if (NumDefs != 0) {
288 SmallString<128> Str;
289 raw_svector_ostream OS(Str);
290 OS << "\t" "set_local "
291 << regToString(MI->getOperand(0).getReg()) << ", "
292 "pop";
293 OutStreamer->EmitRawText(OS.str());
294 }
327295 }
328296
329297 // Force static initialization.
369369 ++ArgNo;
370370 }
371371
372 // Record the number of arguments, since argument indices and local variable
373 // indices are in the same index space.
374 MF.getInfo()->setNumArguments(ArgNo);
375
372376 return Chain;
373377 }
374378
449453 MCSection *WebAssemblyTargetObjectFile::SelectSectionForGlobal(
450454 const GlobalValue *GV, SectionKind Kind, Mangler &Mang,
451455 const TargetMachine &TM) const {
452 return getDataSection();
453 }
456 // TODO: Be more sophisticated than this.
457 return isa(GV) ? getTextSection() : getDataSection();
458 }
2626 class WebAssemblyFunctionInfo final : public MachineFunctionInfo {
2727 MachineFunction &MF;
2828
29 unsigned NumArguments;
30
2931 public:
30 explicit WebAssemblyFunctionInfo(MachineFunction &MF) : MF(MF) {}
32 explicit WebAssemblyFunctionInfo(MachineFunction &MF)
33 : MF(MF), NumArguments(0) {}
3134 ~WebAssemblyFunctionInfo() override;
35
36 void setNumArguments(unsigned N) { NumArguments = N; }
37 unsigned getNumArguments() const { return NumArguments; }
3238 };
3339
3440 } // end namespace llvm
1212 declare double @double_nullary()
1313 declare void @void_nullary()
1414
15 ; CHECK-LABEL: (func $call_i32_nullary
16 ; CHECK-NEXT: (result i32)
17 ; CHECK-NEXT: (set_local @0 (call $i32_nullary))
18 ; CHECK-NEXT: (return @0)
15 ; CHECK-LABEL: call_i32_nullary:
16 ; CHECK-NEXT: .result i32
17 ; CHECK-NEXT: call $i32_nullary
18 ; CHECK-NEXT: set_local @0, pop
19 ; CHECK-NEXT: return @0
1920 define i32 @call_i32_nullary() {
2021 %r = call i32 @i32_nullary()
2122 ret i32 %r
2223 }
2324
24 ; CHECK-LABEL: (func $call_i64_nullary
25 ; CHECK-NEXT: (result i64)
26 ; CHECK-NEXT: (set_local @0 (call $i64_nullary))
27 ; CHECK-NEXT: (return @0)
25 ; CHECK-LABEL: call_i64_nullary:
26 ; CHECK-NEXT: .result i64
27 ; CHECK-NEXT: call $i64_nullary
28 ; CHECK-NEXT: set_local @0, pop
29 ; CHECK-NEXT: return @0
2830 define i64 @call_i64_nullary() {
2931 %r = call i64 @i64_nullary()
3032 ret i64 %r
3133 }
3234
33 ; CHECK-LABEL: (func $call_float_nullary
34 ; CHECK-NEXT: (result f32)
35 ; CHECK-NEXT: (set_local @0 (call $float_nullary))
36 ; CHECK-NEXT: (return @0)
35 ; CHECK-LABEL: call_float_nullary:
36 ; CHECK-NEXT: .result f32
37 ; CHECK-NEXT: call $float_nullary
38 ; CHECK-NEXT: set_local @0, pop
39 ; CHECK-NEXT: return @0
3740 define float @call_float_nullary() {
3841 %r = call float @float_nullary()
3942 ret float %r
4043 }
4144
42 ; CHECK-LABEL: (func $call_double_nullary
43 ; CHECK-NEXT: (result f64)
44 ; CHECK-NEXT: (set_local @0 (call $double_nullary))
45 ; CHECK-NEXT: (return @0)
45 ; CHECK-LABEL: call_double_nullary:
46 ; CHECK-NEXT: .result f64
47 ; CHECK-NEXT: call $double_nullary
48 ; CHECK-NEXT: set_local @0, pop
49 ; CHECK-NEXT: return @0
4650 define double @call_double_nullary() {
4751 %r = call double @double_nullary()
4852 ret double %r
4953 }
5054
51 ; CHECK-LABEL: (func $call_void_nullary
52 ; CHECK-NEXT: (call $void_nullary)
53 ; CHECK-NEXT: (return)
55 ; CHECK-LABEL: call_void_nullary:
56 ; CHECK-NEXT: call $void_nullary
57 ; CHECK-NEXT: return
5458 define void @call_void_nullary() {
5559 call void @void_nullary()
5660 ret void
5761 }
5862
59 ; CHECK-LABEL: (func $call_i32_unary
60 ; CHECK-NEXT: (param i32) (result i32)
61 ; CHECK-NEXT: (set_local @0 (argument 0))
62 ; CHECK-NEXT: (set_local @1 (call $i32_unary @0))
63 ; CHECK-NEXT: (return @1)
63 ; CHECK-LABEL: call_i32_unary:
64 ; CHECK-NEXT: .param i32
65 ; CHECK-NEXT: .result i32
66 ; CHECK-NEXT: @0
67 ; CHECK-NEXT: set_local @1, pop
68 ; CHECK-NEXT: call $i32_unary, @1
69 ; CHECK-NEXT: set_local @2, pop
70 ; CHECK-NEXT: return @2
6471 define i32 @call_i32_unary(i32 %a) {
6572 %r = call i32 @i32_unary(i32 %a)
6673 ret i32 %r
6774 }
6875
69 ; CHECK-LABEL: (func $call_i32_binary
70 ; CHECK-NEXT: (param i32) (param i32) (result i32)
71 ; CHECK-NEXT: (set_local @0 (argument 1))
72 ; CHECK-NEXT: (set_local @1 (argument 0))
73 ; CHECK-NEXT: (set_local @2 (call $i32_binary @1 @0))
74 ; CHECK-NEXT: (return @2)
76 ; CHECK-LABEL: call_i32_binary:
77 ; CHECK-NEXT: .param i32
78 ; CHECK-NEXT: .param i32
79 ; CHECK-NEXT: .result i32
80 ; CHECK-NEXT: @1
81 ; CHECK-NEXT: set_local @2, pop
82 ; CHECK-NEXT: @0
83 ; CHECK-NEXT: set_local @3, pop
84 ; CHECK-NEXT: call $i32_binary, @3, @2
85 ; CHECK-NEXT: set_local @4, pop
86 ; CHECK-NEXT: return @4
7587 define i32 @call_i32_binary(i32 %a, i32 %b) {
7688 %r = call i32 @i32_binary(i32 %a, i32 %b)
7789 ret i32 %r
7890 }
7991
80 ; CHECK-LABEL: (func $call_indirect_void
81 ; CHECK-NEXT: (param i32)
82 ; CHECK-NEXT: (set_local @0 (argument 0))
83 ; CHECK-NEXT: (call_indirect @0)
84 ; CHECK-NEXT: (return)
92 ; CHECK-LABEL: call_indirect_void:
93 ; CHECK-NEXT: .param i32
94 ; CHECK-NEXT: @0
95 ; CHECK-NEXT: set_local @1, pop
96 ; CHECK-NEXT: call_indirect @1
97 ; CHECK-NEXT: return
8598 define void @call_indirect_void(void ()* %callee) {
8699 call void %callee()
87100 ret void
88101 }
89102
90 ; CHECK-LABEL: (func $call_indirect_i32
91 ; CHECK-NEXT: (param i32)
92 ; CHECK-NEXT: (set_local @0 (argument 0))
93 ; CHECK-NEXT: (set_local @1 (call_indirect @0))
94 ; CHECK-NEXT: (return @1)
103 ; CHECK-LABEL: call_indirect_i32:
104 ; CHECK-NEXT: .param i32
105 ; CHECK-NEXT: .result i32
106 ; CHECK-NEXT: @0
107 ; CHECK-NEXT: set_local @1, pop
108 ; CHECK-NEXT: call_indirect @1
109 ; CHECK-NEXT: set_local @2, pop
110 ; CHECK-NEXT: return @2
95111 define i32 @call_indirect_i32(i32 ()* %callee) {
96112 %t = call i32 %callee()
97113 ret i32 %t
98114 }
99115
100 ; CHECK-LABEL: (func $tail_call_void_nullary
101 ; CHECK-NEXT: (call $void_nullary)
102 ; CHECK-NEXT: (return)
116 ; CHECK-LABEL: tail_call_void_nullary:
117 ; CHECK-NEXT: call $void_nullary
118 ; CHECK-NEXT: return{{$}}
103119 define void @tail_call_void_nullary() {
104120 tail call void @void_nullary()
105121 ret void
106122 }
107123
108 ; CHECK-LABEL: (func $fastcc_tail_call_void_nullary
109 ; CHECK-NEXT: (call $void_nullary)
110 ; CHECK-NEXT: (return)
124 ; CHECK-LABEL: fastcc_tail_call_void_nullary:
125 ; CHECK-NEXT: call $void_nullary
126 ; CHECK-NEXT: return{{$}}
111127 define void @fastcc_tail_call_void_nullary() {
112128 tail call fastcc void @void_nullary()
113129 ret void
114130 }
115131
116 ; CHECK-LABEL: (func $coldcc_tail_call_void_nullary
117 ; CHECK-NEXT: (call $void_nullary)
118 ; CHECK-NEXT: (return)
132 ; CHECK-LABEL: coldcc_tail_call_void_nullary:
133 ; CHECK-NEXT: call $void_nullary
134 ; CHECK-NEXT: return{{$}}
119135 define void @coldcc_tail_call_void_nullary() {
120136 tail call coldcc void @void_nullary()
121137 ret void
88
99 ; Test that loops are made contiguous, even in the presence of split backedges.
1010
11 ; CHECK-LABEL: test0
12 ; CHECK: (loop
13 ; CHECK: (add
14 ; CHECK: (brif
15 ; CHECK: (call
16 ; CHECK: (br $BB0_1)
17 ; CHECK: (return)
11 ; CHECK-LABEL: test0:
12 ; CHECK: loop
13 ; CHECK: add
14 ; CHECK: brif
15 ; CHECK: call
16 ; CHECK: br $BB0_1{{$}}
17 ; CHECK: return{{$}}
1818 define void @test0(i32 %n) {
1919 entry:
2020 br label %header
3636
3737 ; Same as test0, but the branch condition is reversed.
3838
39 ; CHECK-LABEL: test1
40 ; CHECK: (loop
41 ; CHECK: (add
42 ; CHECK: (brif
43 ; CHECK: (call
44 ; CHECK: (br $BB1_1)
45 ; CHECK: (return)
39 ; CHECK-LABEL: test1:
40 ; CHECK: loop
41 ; CHECK: add
42 ; CHECK: brif
43 ; CHECK: call
44 ; CHECK: br $BB1_1{{$}}
45 ; CHECK: return{{$}}
4646 define void @test1(i32 %n) {
4747 entry:
4848 br label %header
6464
6565 ; Test that a simple loop is handled as expected.
6666
67 ; CHECK-LABEL: test2
68 ; CHECK: (block $BB2_2)
69 ; CHECK: (brif $BB2_2 {{.*}})
67 ; CHECK-LABEL: test2:
68 ; CHECK: block $BB2_2{{$}}
69 ; CHECK: brif $BB2_2, {{.*}}
7070 ; CHECK: BB2_1:
71 ; CHECK: (brif $BB2_1 @14)
71 ; CHECK: brif $BB2_1, @16{{$}}
7272 ; CHECK: BB2_2:
73 ; CHECK: (return)
73 ; CHECK: return{{$}}
7474 define void @test2(double* nocapture %p, i32 %n) {
7575 entry:
7676 %cmp.4 = icmp sgt i32 %n, 0
9696 ret void
9797 }
9898
99 ; CHECK-LABEL: doublediamond
100 ; CHECK: (block $BB3_5)
101 ; CHECK: (block $BB3_4)
102 ; CHECK: (block $BB3_2)
103 ; CHECK: (brif $BB3_2 @4)
104 ; CHECK: (br $BB3_5)
99 ; CHECK-LABEL: doublediamond:
100 ; CHECK: block $BB3_5{{$}}
101 ; CHECK: block $BB3_4{{$}}
102 ; CHECK: block $BB3_2{{$}}
103 ; CHECK: brif $BB3_2, @7{{$}}
104 ; CHECK: br $BB3_5{{$}}
105105 ; CHECK: BB3_2:
106 ; CHECK: (brif $BB3_4 @7)
107 ; CHECK: (br $BB3_5)
106 ; CHECK: brif $BB3_4, @10{{$}}
107 ; CHECK: br $BB3_5{{$}}
108108 ; CHECK: BB3_4:
109109 ; CHECK: BB3_5:
110 ; CHECK: (return @3)
110 ; CHECK: return @6{{$}}
111111 define i32 @doublediamond(i32 %a, i32 %b, i32* %p) {
112112 entry:
113113 %c = icmp eq i32 %a, 0
131131 ret i32 0
132132 }
133133
134 ; CHECK-LABEL: triangle
135 ; CHECK: (block $BB4_2)
136 ; CHECK: (brif $BB4_2 @3)
134 ; CHECK-LABEL: triangle:
135 ; CHECK: block $BB4_2{{$}}
136 ; CHECK: brif $BB4_2, @5{{$}}
137137 ; CHECK: BB4_2:
138 ; CHECK: (return @2)
138 ; CHECK: return @4{{$}}
139139 define i32 @triangle(i32* %p, i32 %a) {
140140 entry:
141141 %c = icmp eq i32 %a, 0
149149 ret i32 0
150150 }
151151
152 ; CHECK-LABEL: diamond
153 ; CHECK: (block $BB5_3)
154 ; CHECK: (block $BB5_2)
155 ; CHECK: (brif $BB5_2 @3)
156 ; CHECK: (br $BB5_3)
152 ; CHECK-LABEL: diamond:
153 ; CHECK: block $BB5_3{{$}}
154 ; CHECK: block $BB5_2{{$}}
155 ; CHECK: brif $BB5_2, @5{{$}}
156 ; CHECK: br $BB5_3{{$}}
157157 ; CHECK: BB5_2:
158158 ; CHECK: BB5_3:
159 ; CHECK: (return @2)
159 ; CHECK: return @4{{$}}
160160 define i32 @diamond(i32* %p, i32 %a) {
161161 entry:
162162 %c = icmp eq i32 %a, 0
173173 ret i32 0
174174 }
175175
176 ; CHECK-LABEL: single_block
176 ; CHECK-LABEL: single_block:
177177 ; CHECK-NOT: br
178 ; CHECK: (return @1)
178 ; CHECK: return @2{{$}}
179179 define i32 @single_block(i32* %p) {
180180 entry:
181181 store volatile i32 0, i32* %p
182182 ret i32 0
183183 }
184184
185 ; CHECK-LABEL: minimal_loop
185 ; CHECK-LABEL: minimal_loop:
186186 ; CHECK-NOT: br
187187 ; CHECK: BB7_1:
188 ; CHECK: (store_i32 @0 @2)
189 ; CHECK: (br $BB7_1)
188 ; CHECK: store_i32 @1, @3{{$}}
189 ; CHECK: br $BB7_1{{$}}
190190 define i32 @minimal_loop(i32* %p) {
191191 entry:
192192 store volatile i32 0, i32* %p
196196 br label %loop
197197 }
198198
199 ; CHECK-LABEL: simple_loop
199 ; CHECK-LABEL: simple_loop:
200200 ; CHECK-NOT: br
201201 ; CHECK: BB8_1:
202 ; CHECK: (loop $BB8_2)
203 ; CHECK: (brif $BB8_1 @4)
204 ; CHECK: (return @2)
202 ; CHECK: loop $BB8_2{{$}}
203 ; CHECK: brif $BB8_1, @6{{$}}
204 ; CHECK: return @4{{$}}
205205 define i32 @simple_loop(i32* %p, i32 %a) {
206206 entry:
207207 %c = icmp eq i32 %a, 0
215215 ret i32 0
216216 }
217217
218 ; CHECK-LABEL: doubletriangle
219 ; CHECK: (block $BB9_4)
220 ; CHECK: (block $BB9_3)
221 ; CHECK: (brif $BB9_4 @4)
222 ; CHECK: (brif $BB9_3 @7)
218 ; CHECK-LABEL: doubletriangle:
219 ; CHECK: block $BB9_4{{$}}
220 ; CHECK: block $BB9_3{{$}}
221 ; CHECK: brif $BB9_4, @7{{$}}
222 ; CHECK: brif $BB9_3, @10{{$}}
223223 ; CHECK: BB9_3:
224224 ; CHECK: BB9_4:
225 ; CHECK: (return @3)
225 ; CHECK: return @6{{$}}
226226 define i32 @doubletriangle(i32 %a, i32 %b, i32* %p) {
227227 entry:
228228 %c = icmp eq i32 %a, 0
243243 ret i32 0
244244 }
245245
246 ; CHECK-LABEL: ifelse_earlyexits
247 ; CHECK: (block $BB10_4)
248 ; CHECK: (block $BB10_2)
249 ; CHECK: (brif $BB10_2 @4)
250 ; CHECK: (br $BB10_4)
246 ; CHECK-LABEL: ifelse_earlyexits:
247 ; CHECK: block $BB10_4{{$}}
248 ; CHECK: block $BB10_2{{$}}
249 ; CHECK: brif $BB10_2, @7{{$}}
250 ; CHECK: br $BB10_4{{$}}
251251 ; CHECK: BB10_2:
252 ; CHECK: (brif $BB10_4 @7)
252 ; CHECK: brif $BB10_4, @10{{$}}
253253 ; CHECK: BB10_4:
254 ; CHECK: (return @3)
254 ; CHECK: return @6{{$}}
255255 define i32 @ifelse_earlyexits(i32 %a, i32 %b, i32* %p) {
256256 entry:
257257 %c = icmp eq i32 %a, 0
55 target datalayout = "e-p:32:32-i64:64-n32:64-S128"
66 target triple = "wasm32-unknown-unknown"
77
8 ; CHECK-LABEL: (func $ord_f32
9 ; CHECK-NEXT: (param f32) (param f32) (result i32)
10 ; CHECK-NEXT: (set_local @0 (argument 0))
11 ; CHECK-NEXT: (set_local @1 (argument 1))
12 ; CHECK-NEXT: (set_local @2 (eq @1 @1))
13 ; CHECK-NEXT: (set_local @3 (eq @0 @0))
14 ; CHECK-NEXT: (set_local @4 (and @3 @2))
15 ; CHECK-NEXT: (return @4)
8 ; CHECK-LABEL: ord_f32:
9 ; CHECK-NEXT: .param f32{{$}}
10 ; CHECK-NEXT: .param f32{{$}}
11 ; CHECK-NEXT: .result i32{{$}}
12 ; CHECK-NEXT: @0{{$}}
13 ; CHECK-NEXT: set_local @2, pop{{$}}
14 ; CHECK-NEXT: @1{{$}}
15 ; CHECK-NEXT: set_local @3, pop{{$}}
16 ; CHECK-NEXT: eq @3, @3{{$}}
17 ; CHECK-NEXT: set_local @4, pop{{$}}
18 ; CHECK-NEXT: eq @2, @2{{$}}
19 ; CHECK-NEXT: set_local @5, pop{{$}}
20 ; CHECK-NEXT: and @5, @4{{$}}
21 ; CHECK-NEXT: set_local @6, pop{{$}}
22 ; CHECK-NEXT: return @6{{$}}
1623 define i32 @ord_f32(float %x, float %y) {
1724 %a = fcmp ord float %x, %y
1825 %b = zext i1 %a to i32
1926 ret i32 %b
2027 }
2128
22 ; CHECK-LABEL: (func $uno_f32
23 ; CHECK-NEXT: (param f32) (param f32) (result i32)
24 ; CHECK-NEXT: (set_local @0 (argument 0))
25 ; CHECK-NEXT: (set_local @1 (argument 1))
26 ; CHECK-NEXT: (set_local @2 (ne @1 @1))
27 ; CHECK-NEXT: (set_local @3 (ne @0 @0))
28 ; CHECK-NEXT: (set_local @4 (ior @3 @2))
29 ; CHECK-NEXT: (return @4)
29 ; CHECK-LABEL: uno_f32:
30 ; CHECK-NEXT: .param f32{{$}}
31 ; CHECK-NEXT: .param f32{{$}}
32 ; CHECK-NEXT: .result i32{{$}}
33 ; CHECK-NEXT: @0{{$}}
34 ; CHECK-NEXT: set_local @2, pop{{$}}
35 ; CHECK-NEXT: @1{{$}}
36 ; CHECK-NEXT: set_local @3, pop{{$}}
37 ; CHECK-NEXT: ne @3, @3{{$}}
38 ; CHECK-NEXT: set_local @4, pop{{$}}
39 ; CHECK-NEXT: ne @2, @2{{$}}
40 ; CHECK-NEXT: set_local @5, pop{{$}}
41 ; CHECK-NEXT: ior @5, @4{{$}}
42 ; CHECK-NEXT: set_local @6, pop{{$}}
43 ; CHECK-NEXT: return @6{{$}}
3044 define i32 @uno_f32(float %x, float %y) {
3145 %a = fcmp uno float %x, %y
3246 %b = zext i1 %a to i32
3347 ret i32 %b
3448 }
3549
36 ; CHECK-LABEL: (func $oeq_f32
37 ; CHECK-NEXT: (param f32) (param f32) (result i32)
38 ; CHECK-NEXT: (set_local @0 (argument 1))
39 ; CHECK-NEXT: (set_local @1 (argument 0))
40 ; CHECK-NEXT: (set_local @2 (eq @1 @0))
41 ; CHECK-NEXT: (return @2)
50 ; CHECK-LABEL: oeq_f32:
51 ; CHECK-NEXT: .param f32{{$}}
52 ; CHECK-NEXT: .param f32{{$}}
53 ; CHECK-NEXT: .result i32{{$}}
54 ; CHECK-NEXT: @1{{$}}
55 ; CHECK-NEXT: set_local @2, pop{{$}}
56 ; CHECK-NEXT: @0{{$}}
57 ; CHECK-NEXT: set_local @3, pop{{$}}
58 ; CHECK-NEXT: eq @3, @2{{$}}
59 ; CHECK-NEXT: set_local @4, pop{{$}}
60 ; CHECK-NEXT: return @4{{$}}
4261 define i32 @oeq_f32(float %x, float %y) {
4362 %a = fcmp oeq float %x, %y
4463 %b = zext i1 %a to i32
4564 ret i32 %b
4665 }
4766
48 ; CHECK-LABEL: (func $une_f32
49 ; CHECK: (set_local @2 (ne @1 @0))
67 ; CHECK-LABEL: une_f32:
68 ; CHECK: ne @3, @2{{$}}
69 ; CHECK-NEXT: set_local @4, pop{{$}}
5070 define i32 @une_f32(float %x, float %y) {
5171 %a = fcmp une float %x, %y
5272 %b = zext i1 %a to i32
5373 ret i32 %b
5474 }
5575
56 ; CHECK-LABEL: (func $olt_f32
57 ; CHECK: (set_local @2 (lt @1 @0))
76 ; CHECK-LABEL: olt_f32:
77 ; CHECK: lt @3, @2{{$}}
78 ; CHECK-NEXT: set_local @4, pop{{$}}
5879 define i32 @olt_f32(float %x, float %y) {
5980 %a = fcmp olt float %x, %y
6081 %b = zext i1 %a to i32
6182 ret i32 %b
6283 }
6384
64 ; CHECK-LABEL: (func $ole_f32
65 ; CHECK: (set_local @2 (le @1 @0))
85 ; CHECK-LABEL: ole_f32:
86 ; CHECK: le @3, @2{{$}}
87 ; CHECK-NEXT: set_local @4, pop{{$}}
6688 define i32 @ole_f32(float %x, float %y) {
6789 %a = fcmp ole float %x, %y
6890 %b = zext i1 %a to i32
6991 ret i32 %b
7092 }
7193
72 ; CHECK-LABEL: (func $ogt_f32
73 ; CHECK: (set_local @2 (gt @1 @0))
94 ; CHECK-LABEL: ogt_f32:
95 ; CHECK: gt @3, @2{{$}}
96 ; CHECK-NEXT: set_local @4, pop{{$}}
7497 define i32 @ogt_f32(float %x, float %y) {
7598 %a = fcmp ogt float %x, %y
7699 %b = zext i1 %a to i32
77100 ret i32 %b
78101 }
79102
80 ; CHECK-LABEL: (func $oge_f32
81 ; CHECK: (set_local @2 (ge @1 @0))
103 ; CHECK-LABEL: oge_f32:
104 ; CHECK: ge @3, @2{{$}}
105 ; CHECK-NEXT: set_local @4, pop{{$}}
82106 define i32 @oge_f32(float %x, float %y) {
83107 %a = fcmp oge float %x, %y
84108 %b = zext i1 %a to i32
87111
88112 ; Expanded comparisons, which also check for NaN.
89113
90 ; CHECK-LABEL: (func $ueq_f32
91 ; CHECK-NEXT: (param f32) (param f32) (result i32)
92 ; CHECK-NEXT: (set_local @0 (argument 1))
93 ; CHECK-NEXT: (set_local @1 (argument 0))
94 ; CHECK-NEXT: (set_local @2 (eq @1 @0))
95 ; CHECK-NEXT: (set_local @3 (ne @0 @0))
96 ; CHECK-NEXT: (set_local @4 (ne @1 @1))
97 ; CHECK-NEXT: (set_local @5 (ior @4 @3))
98 ; CHECK-NEXT: (set_local @6 (ior @2 @5))
99 ; CHECK-NEXT: (return @6)
114 ; CHECK-LABEL: ueq_f32:
115 ; CHECK-NEXT: .param f32{{$}}
116 ; CHECK-NEXT: .param f32{{$}}
117 ; CHECK-NEXT: .result i32{{$}}
118 ; CHECK-NEXT: @1{{$}}
119 ; CHECK-NEXT: set_local @2, pop{{$}}
120 ; CHECK-NEXT: @0{{$}}
121 ; CHECK-NEXT: set_local @3, pop{{$}}
122 ; CHECK-NEXT: eq @3, @2{{$}}
123 ; CHECK-NEXT: set_local @4, pop{{$}}
124 ; CHECK-NEXT: ne @2, @2{{$}}
125 ; CHECK-NEXT: set_local @5, pop{{$}}
126 ; CHECK-NEXT: ne @3, @3{{$}}
127 ; CHECK-NEXT: set_local @6, pop{{$}}
128 ; CHECK-NEXT: ior @6, @5{{$}}
129 ; CHECK-NEXT: set_local @7, pop{{$}}
130 ; CHECK-NEXT: ior @4, @7{{$}}
131 ; CHECK-NEXT: set_local @8, pop{{$}}
132 ; CHECK-NEXT: return @8{{$}}
100133 define i32 @ueq_f32(float %x, float %y) {
101134 %a = fcmp ueq float %x, %y
102135 %b = zext i1 %a to i32
103136 ret i32 %b
104137 }
105138
106 ; CHECK-LABEL: (func $one_f32
107 ; CHECK: (set_local @2 (ne @1 @0))
139 ; CHECK-LABEL: one_f32:
140 ; CHECK: ne @3, @2{{$}}
141 ; CHECK-NEXT: set_local @4, pop{{$}}
108142 define i32 @one_f32(float %x, float %y) {
109143 %a = fcmp one float %x, %y
110144 %b = zext i1 %a to i32
111145 ret i32 %b
112146 }
113147
114 ; CHECK-LABEL: (func $ult_f32
115 ; CHECK: (set_local @2 (lt @1 @0))
148 ; CHECK-LABEL: ult_f32:
149 ; CHECK: lt @3, @2{{$}}
150 ; CHECK-NEXT: set_local @4, pop{{$}}
116151 define i32 @ult_f32(float %x, float %y) {
117152 %a = fcmp ult float %x, %y
118153 %b = zext i1 %a to i32
119154 ret i32 %b
120155 }
121156
122 ; CHECK-LABEL: (func $ule_f32
123 ; CHECK: (set_local @2 (le @1 @0))
157 ; CHECK-LABEL: ule_f32:
158 ; CHECK: le @3, @2{{$}}
159 ; CHECK-NEXT: set_local @4, pop{{$}}
124160 define i32 @ule_f32(float %x, float %y) {
125161 %a = fcmp ule float %x, %y
126162 %b = zext i1 %a to i32
127163 ret i32 %b
128164 }
129165
130 ; CHECK-LABEL: (func $ugt_f32
131 ; CHECK: (set_local @2 (gt @1 @0))
166 ; CHECK-LABEL: ugt_f32:
167 ; CHECK: gt @3, @2{{$}}
168 ; CHECK-NEXT: set_local @4, pop{{$}}
132169 define i32 @ugt_f32(float %x, float %y) {
133170 %a = fcmp ugt float %x, %y
134171 %b = zext i1 %a to i32
135172 ret i32 %b
136173 }
137174
138 ; CHECK-LABEL: (func $uge_f32
139 ; CHECK: (set_local @2 (ge @1 @0))
175 ; CHECK-LABEL: uge_f32:
176 ; CHECK: ge @3, @2{{$}}
177 ; CHECK-NEXT: set_local @4, pop{{$}}
140178 define i32 @uge_f32(float %x, float %y) {
141179 %a = fcmp uge float %x, %y
142180 %b = zext i1 %a to i32
55 target datalayout = "e-p:32:32-i64:64-n32:64-S128"
66 target triple = "wasm32-unknown-unknown"
77
8 ; CHECK-LABEL: (func $ord_f64
9 ; CHECK-NEXT: (param f64) (param f64) (result i32)
10 ; CHECK-NEXT: (set_local @0 (argument 0))
11 ; CHECK-NEXT: (set_local @1 (argument 1))
12 ; CHECK-NEXT: (set_local @2 (eq @1 @1))
13 ; CHECK-NEXT: (set_local @3 (eq @0 @0))
14 ; CHECK-NEXT: (set_local @4 (and @3 @2))
15 ; CHECK-NEXT: (return @4)
8 ; CHECK-LABEL: ord_f64:
9 ; CHECK-NEXT: .param f64{{$}}
10 ; CHECK-NEXT: .param f64{{$}}
11 ; CHECK-NEXT: .result i32{{$}}
12 ; CHECK-NEXT: @0{{$}}
13 ; CHECK-NEXT: set_local @2, pop{{$}}
14 ; CHECK-NEXT: @1{{$}}
15 ; CHECK-NEXT: set_local @3, pop{{$}}
16 ; CHECK-NEXT: eq @3, @3{{$}}
17 ; CHECK-NEXT: set_local @4, pop{{$}}
18 ; CHECK-NEXT: eq @2, @2{{$}}
19 ; CHECK-NEXT: set_local @5, pop{{$}}
20 ; CHECK-NEXT: and @5, @4{{$}}
21 ; CHECK-NEXT: set_local @6, pop{{$}}
22 ; CHECK-NEXT: return @6{{$}}
1623 define i32 @ord_f64(double %x, double %y) {
1724 %a = fcmp ord double %x, %y
1825 %b = zext i1 %a to i32
1926 ret i32 %b
2027 }
2128
22 ; CHECK-LABEL: (func $uno_f64
23 ; CHECK-NEXT: (param f64) (param f64) (result i32)
24 ; CHECK-NEXT: (set_local @0 (argument 0))
25 ; CHECK-NEXT: (set_local @1 (argument 1))
26 ; CHECK-NEXT: (set_local @2 (ne @1 @1))
27 ; CHECK-NEXT: (set_local @3 (ne @0 @0))
28 ; CHECK-NEXT: (set_local @4 (ior @3 @2))
29 ; CHECK-NEXT: (return @4)
29 ; CHECK-LABEL: uno_f64:
30 ; CHECK-NEXT: .param f64{{$}}
31 ; CHECK-NEXT: .param f64{{$}}
32 ; CHECK-NEXT: .result i32{{$}}
33 ; CHECK-NEXT: @0{{$}}
34 ; CHECK-NEXT: set_local @2, pop{{$}}
35 ; CHECK-NEXT: @1{{$}}
36 ; CHECK-NEXT: set_local @3, pop{{$}}
37 ; CHECK-NEXT: ne @3, @3{{$}}
38 ; CHECK-NEXT: set_local @4, pop{{$}}
39 ; CHECK-NEXT: ne @2, @2{{$}}
40 ; CHECK-NEXT: set_local @5, pop{{$}}
41 ; CHECK-NEXT: ior @5, @4{{$}}
42 ; CHECK-NEXT: set_local @6, pop{{$}}
43 ; CHECK-NEXT: return @6{{$}}
3044 define i32 @uno_f64(double %x, double %y) {
3145 %a = fcmp uno double %x, %y
3246 %b = zext i1 %a to i32
3347 ret i32 %b
3448 }
3549
36 ; CHECK-LABEL: (func $oeq_f64
37 ; CHECK-NEXT: (param f64) (param f64) (result i32)
38 ; CHECK-NEXT: (set_local @0 (argument 1))
39 ; CHECK-NEXT: (set_local @1 (argument 0))
40 ; CHECK-NEXT: (set_local @2 (eq @1 @0))
41 ; CHECK-NEXT: (return @2)
50 ; CHECK-LABEL: oeq_f64:
51 ; CHECK-NEXT: .param f64{{$}}
52 ; CHECK-NEXT: .param f64{{$}}
53 ; CHECK-NEXT: .result i32{{$}}
54 ; CHECK-NEXT: @1{{$}}
55 ; CHECK-NEXT: set_local @2, pop{{$}}
56 ; CHECK-NEXT: @0{{$}}
57 ; CHECK-NEXT: set_local @3, pop{{$}}
58 ; CHECK-NEXT: eq @3, @2{{$}}
59 ; CHECK-NEXT: set_local @4, pop{{$}}
60 ; CHECK-NEXT: return @4{{$}}
4261 define i32 @oeq_f64(double %x, double %y) {
4362 %a = fcmp oeq double %x, %y
4463 %b = zext i1 %a to i32
4564 ret i32 %b
4665 }
4766
48 ; CHECK-LABEL: (func $une_f64
49 ; CHECK: (set_local @2 (ne @1 @0))
67 ; CHECK-LABEL: une_f64:
68 ; CHECK: ne @3, @2{{$}}
69 ; CHECK-NEXT: set_local @4, pop{{$}}
5070 define i32 @une_f64(double %x, double %y) {
5171 %a = fcmp une double %x, %y
5272 %b = zext i1 %a to i32
5373 ret i32 %b
5474 }
5575
56 ; CHECK-LABEL: (func $olt_f64
57 ; CHECK: (set_local @2 (lt @1 @0))
76 ; CHECK-LABEL: olt_f64:
77 ; CHECK: lt @3, @2{{$}}
78 ; CHECK-NEXT: set_local @4, pop{{$}}
5879 define i32 @olt_f64(double %x, double %y) {
5980 %a = fcmp olt double %x, %y
6081 %b = zext i1 %a to i32
6182 ret i32 %b
6283 }
6384
64 ; CHECK-LABEL: (func $ole_f64
65 ; CHECK: (set_local @2 (le @1 @0))
85 ; CHECK-LABEL: ole_f64:
86 ; CHECK: le @3, @2{{$}}
87 ; CHECK-NEXT: set_local @4, pop{{$}}
6688 define i32 @ole_f64(double %x, double %y) {
6789 %a = fcmp ole double %x, %y
6890 %b = zext i1 %a to i32
6991 ret i32 %b
7092 }
7193
72 ; CHECK-LABEL: (func $ogt_f64
73 ; CHECK: (set_local @2 (gt @1 @0))
94 ; CHECK-LABEL: ogt_f64:
95 ; CHECK: gt @3, @2{{$}}
96 ; CHECK-NEXT: set_local @4, pop{{$}}
7497 define i32 @ogt_f64(double %x, double %y) {
7598 %a = fcmp ogt double %x, %y
7699 %b = zext i1 %a to i32
77100 ret i32 %b
78101 }
79102
80 ; CHECK-LABEL: (func $oge_f64
81 ; CHECK: (set_local @2 (ge @1 @0))
103 ; CHECK-LABEL: oge_f64:
104 ; CHECK: ge @3, @2{{$}}
105 ; CHECK-NEXT: set_local @4, pop{{$}}
82106 define i32 @oge_f64(double %x, double %y) {
83107 %a = fcmp oge double %x, %y
84108 %b = zext i1 %a to i32
87111
88112 ; Expanded comparisons, which also check for NaN.
89113
90 ; CHECK-LABEL: (func $ueq_f64
91 ; CHECK-NEXT: (param f64) (param f64) (result i32)
92 ; CHECK-NEXT: (set_local @0 (argument 1))
93 ; CHECK-NEXT: (set_local @1 (argument 0))
94 ; CHECK-NEXT: (set_local @2 (eq @1 @0))
95 ; CHECK-NEXT: (set_local @3 (ne @0 @0))
96 ; CHECK-NEXT: (set_local @4 (ne @1 @1))
97 ; CHECK-NEXT: (set_local @5 (ior @4 @3))
98 ; CHECK-NEXT: (set_local @6 (ior @2 @5))
99 ; CHECK-NEXT: (return @6)
114 ; CHECK-LABEL: ueq_f64:
115 ; CHECK-NEXT: .param f64{{$}}
116 ; CHECK-NEXT: .param f64{{$}}
117 ; CHECK-NEXT: .result i32{{$}}
118 ; CHECK-NEXT: @1{{$}}
119 ; CHECK-NEXT: set_local @2, pop{{$}}
120 ; CHECK-NEXT: @0{{$}}
121 ; CHECK-NEXT: set_local @3, pop{{$}}
122 ; CHECK-NEXT: eq @3, @2{{$}}
123 ; CHECK-NEXT: set_local @4, pop{{$}}
124 ; CHECK-NEXT: ne @2, @2{{$}}
125 ; CHECK-NEXT: set_local @5, pop{{$}}
126 ; CHECK-NEXT: ne @3, @3{{$}}
127 ; CHECK-NEXT: set_local @6, pop{{$}}
128 ; CHECK-NEXT: ior @6, @5{{$}}
129 ; CHECK-NEXT: set_local @7, pop{{$}}
130 ; CHECK-NEXT: ior @4, @7{{$}}
131 ; CHECK-NEXT: set_local @8, pop{{$}}
132 ; CHECK-NEXT: return @8{{$}}
100133 define i32 @ueq_f64(double %x, double %y) {
101134 %a = fcmp ueq double %x, %y
102135 %b = zext i1 %a to i32
103136 ret i32 %b
104137 }
105138
106 ; CHECK-LABEL: (func $one_f64
107 ; CHECK: (set_local @2 (ne @1 @0))
139 ; CHECK-LABEL: one_f64:
140 ; CHECK: ne @3, @2{{$}}
141 ; CHECK-NEXT: set_local @4, pop{{$}}
108142 define i32 @one_f64(double %x, double %y) {
109143 %a = fcmp one double %x, %y
110144 %b = zext i1 %a to i32
111145 ret i32 %b
112146 }
113147
114 ; CHECK-LABEL: (func $ult_f64
115 ; CHECK: (set_local @2 (lt @1 @0))
148 ; CHECK-LABEL: ult_f64:
149 ; CHECK: lt @3, @2{{$}}
150 ; CHECK-NEXT: set_local @4, pop{{$}}
116151 define i32 @ult_f64(double %x, double %y) {
117152 %a = fcmp ult double %x, %y
118153 %b = zext i1 %a to i32
119154 ret i32 %b
120155 }
121156
122 ; CHECK-LABEL: (func $ule_f64
123 ; CHECK: (set_local @2 (le @1 @0))
157 ; CHECK-LABEL: ule_f64:
158 ; CHECK: le @3, @2{{$}}
159 ; CHECK-NEXT: set_local @4, pop{{$}}
124160 define i32 @ule_f64(double %x, double %y) {
125161 %a = fcmp ule double %x, %y
126162 %b = zext i1 %a to i32
127163 ret i32 %b
128164 }
129165
130 ; CHECK-LABEL: (func $ugt_f64
131 ; CHECK: (set_local @2 (gt @1 @0))
166 ; CHECK-LABEL: ugt_f64:
167 ; CHECK: gt @3, @2{{$}}
168 ; CHECK-NEXT: set_local @4, pop{{$}}
132169 define i32 @ugt_f64(double %x, double %y) {
133170 %a = fcmp ugt double %x, %y
134171 %b = zext i1 %a to i32
135172 ret i32 %b
136173 }
137174
138 ; CHECK-LABEL: (func $uge_f64
139 ; CHECK: (set_local @2 (ge @1 @0))
175 ; CHECK-LABEL: uge_f64:
176 ; CHECK: ge @3, @2{{$}}
177 ; CHECK-NEXT: set_local @4, pop{{$}}
140178 define i32 @uge_f64(double %x, double %y) {
141179 %a = fcmp uge double %x, %y
142180 %b = zext i1 %a to i32
44 target datalayout = "e-p:32:32-i64:64-n32:64-S128"
55 target triple = "wasm32-unknown-unknown"
66
7 ; CHECK-LABEL: (func $eq_i32
8 ; CHECK-NEXT: (param i32) (param i32) (result i32)
9 ; CHECK-NEXT: (set_local @0 (argument 1))
10 ; CHECK-NEXT: (set_local @1 (argument 0))
11 ; CHECK-NEXT: (set_local @2 (eq @1 @0))
12 ; CHECK-NEXT: (return @2)
7 ; CHECK-LABEL: eq_i32:
8 ; CHECK-NEXT: .param i32{{$}}
9 ; CHECK-NEXT: .param i32{{$}}
10 ; CHECK-NEXT: .result i32{{$}}
11 ; CHECK-NEXT: @1{{$}}
12 ; CHECK-NEXT: set_local @2, pop{{$}}
13 ; CHECK-NEXT: @0{{$}}
14 ; CHECK-NEXT: set_local @3, pop{{$}}
15 ; CHECK-NEXT: eq @3, @2{{$}}
16 ; CHECK-NEXT: set_local @4, pop{{$}}
17 ; CHECK-NEXT: return @4{{$}}
1318 define i32 @eq_i32(i32 %x, i32 %y) {
1419 %a = icmp eq i32 %x, %y
1520 %b = zext i1 %a to i32
1621 ret i32 %b
1722 }
1823
19 ; CHECK-LABEL: (func $ne_i32
20 ; CHECK: (set_local @2 (ne @1 @0))
24 ; CHECK-LABEL: ne_i32:
25 ; CHECK: ne @3, @2{{$}}
26 ; CHECK-NEXT: set_local @4, pop{{$}}
2127 define i32 @ne_i32(i32 %x, i32 %y) {
2228 %a = icmp ne i32 %x, %y
2329 %b = zext i1 %a to i32
2430 ret i32 %b
2531 }
2632
27 ; CHECK-LABEL: (func $slt_i32
28 ; CHECK: (set_local @2 (slt @1 @0))
33 ; CHECK-LABEL: slt_i32:
34 ; CHECK: slt @3, @2{{$}}
35 ; CHECK-NEXT: set_local @4, pop{{$}}
2936 define i32 @slt_i32(i32 %x, i32 %y) {
3037 %a = icmp slt i32 %x, %y
3138 %b = zext i1 %a to i32
3239 ret i32 %b
3340 }
3441
35 ; CHECK-LABEL: (func $sle_i32
36 ; CHECK: (set_local @2 (sle @1 @0))
42 ; CHECK-LABEL: sle_i32:
43 ; CHECK: sle @3, @2{{$}}
44 ; CHECK-NEXT: set_local @4, pop{{$}}
3745 define i32 @sle_i32(i32 %x, i32 %y) {
3846 %a = icmp sle i32 %x, %y
3947 %b = zext i1 %a to i32
4048 ret i32 %b
4149 }
4250
43 ; CHECK-LABEL: (func $ult_i32
44 ; CHECK: (set_local @2 (ult @1 @0))
51 ; CHECK-LABEL: ult_i32:
52 ; CHECK: ult @3, @2{{$}}
53 ; CHECK-NEXT: set_local @4, pop{{$}}
4554 define i32 @ult_i32(i32 %x, i32 %y) {
4655 %a = icmp ult i32 %x, %y
4756 %b = zext i1 %a to i32
4857 ret i32 %b
4958 }
5059
51 ; CHECK-LABEL: (func $ule_i32
52 ; CHECK: (set_local @2 (ule @1 @0))
60 ; CHECK-LABEL: ule_i32:
61 ; CHECK: ule @3, @2{{$}}
62 ; CHECK-NEXT: set_local @4, pop{{$}}
5363 define i32 @ule_i32(i32 %x, i32 %y) {
5464 %a = icmp ule i32 %x, %y
5565 %b = zext i1 %a to i32
5666 ret i32 %b
5767 }
5868
59 ; CHECK-LABEL: (func $sgt_i32
60 ; CHECK: (set_local @2 (sgt @1 @0))
69 ; CHECK-LABEL: sgt_i32:
70 ; CHECK: sgt @3, @2{{$}}
71 ; CHECK-NEXT: set_local @4, pop{{$}}
6172 define i32 @sgt_i32(i32 %x, i32 %y) {
6273 %a = icmp sgt i32 %x, %y
6374 %b = zext i1 %a to i32
6475 ret i32 %b
6576 }
6677
67 ; CHECK-LABEL: (func $sge_i32
68 ; CHECK: (set_local @2 (sge @1 @0))
78 ; CHECK-LABEL: sge_i32:
79 ; CHECK: sge @3, @2{{$}}
80 ; CHECK-NEXT: set_local @4, pop{{$}}
6981 define i32 @sge_i32(i32 %x, i32 %y) {
7082 %a = icmp sge i32 %x, %y
7183 %b = zext i1 %a to i32
7284 ret i32 %b
7385 }
7486
75 ; CHECK-LABEL: (func $ugt_i32
76 ; CHECK: (set_local @2 (ugt @1 @0))
87 ; CHECK-LABEL: ugt_i32:
88 ; CHECK: ugt @3, @2{{$}}
89 ; CHECK-NEXT: set_local @4, pop{{$}}
7790 define i32 @ugt_i32(i32 %x, i32 %y) {
7891 %a = icmp ugt i32 %x, %y
7992 %b = zext i1 %a to i32
8093 ret i32 %b
8194 }
8295
83 ; CHECK-LABEL: (func $uge_i32
84 ; CHECK: (set_local @2 (uge @1 @0))
96 ; CHECK-LABEL: uge_i32:
97 ; CHECK: uge @3, @2{{$}}
98 ; CHECK-NEXT: set_local @4, pop{{$}}
8599 define i32 @uge_i32(i32 %x, i32 %y) {
86100 %a = icmp uge i32 %x, %y
87101 %b = zext i1 %a to i32
44 target datalayout = "e-p:32:32-i64:64-n32:64-S128"
55 target triple = "wasm32-unknown-unknown"
66
7 ; CHECK-LABEL: (func $eq_i64
8 ; CHECK-NEXT: (param i64) (param i64) (result i32)
9 ; CHECK-NEXT: (set_local @0 (argument 1))
10 ; CHECK-NEXT: (set_local @1 (argument 0))
11 ; CHECK-NEXT: (set_local @2 (eq @1 @0))
12 ; CHECK-NEXT: (return @2)
7 ; CHECK-LABEL: eq_i64:
8 ; CHECK-NEXT: .param i64{{$}}
9 ; CHECK-NEXT: .param i64{{$}}
10 ; CHECK-NEXT: .result i32{{$}}
11 ; CHECK-NEXT: @1{{$}}
12 ; CHECK-NEXT: set_local @2, pop{{$}}
13 ; CHECK-NEXT: @0{{$}}
14 ; CHECK-NEXT: set_local @3, pop{{$}}
15 ; CHECK-NEXT: eq @3, @2{{$}}
16 ; CHECK-NEXT: set_local @4, pop{{$}}
17 ; CHECK-NEXT: return @4{{$}}
1318 define i32 @eq_i64(i64 %x, i64 %y) {
1419 %a = icmp eq i64 %x, %y
1520 %b = zext i1 %a to i32
1621 ret i32 %b
1722 }
1823
19 ; CHECK-LABEL: (func $ne_i64
20 ; CHECK: (set_local @2 (ne @1 @0))
24 ; CHECK-LABEL: ne_i64:
25 ; CHECK: ne @3, @2{{$}}
26 ; CHECK-NEXT: set_local @4, pop{{$}}
2127 define i32 @ne_i64(i64 %x, i64 %y) {
2228 %a = icmp ne i64 %x, %y
2329 %b = zext i1 %a to i32
2430 ret i32 %b
2531 }
2632
27 ; CHECK-LABEL: (func $slt_i64
28 ; CHECK: (set_local @2 (slt @1 @0))
33 ; CHECK-LABEL: slt_i64:
34 ; CHECK: slt @3, @2{{$}}
35 ; CHECK-NEXT: set_local @4, pop{{$}}
2936 define i32 @slt_i64(i64 %x, i64 %y) {
3037 %a = icmp slt i64 %x, %y
3138 %b = zext i1 %a to i32
3239 ret i32 %b
3340 }
3441
35 ; CHECK-LABEL: (func $sle_i64
36 ; CHECK: (set_local @2 (sle @1 @0))
42 ; CHECK-LABEL: sle_i64:
43 ; CHECK: sle @3, @2{{$}}
44 ; CHECK-NEXT: set_local @4, pop{{$}}
3745 define i32 @sle_i64(i64 %x, i64 %y) {
3846 %a = icmp sle i64 %x, %y
3947 %b = zext i1 %a to i32
4048 ret i32 %b
4149 }
4250
43 ; CHECK-LABEL: (func $ult_i64
44 ; CHECK: (set_local @2 (ult @1 @0))
51 ; CHECK-LABEL: ult_i64:
52 ; CHECK: ult @3, @2{{$}}
53 ; CHECK-NEXT: set_local @4, pop{{$}}
4554 define i32 @ult_i64(i64 %x, i64 %y) {
4655 %a = icmp ult i64 %x, %y
4756 %b = zext i1 %a to i32
4857 ret i32 %b
4958 }
5059
51 ; CHECK-LABEL: (func $ule_i64
52 ; CHECK: (set_local @2 (ule @1 @0))
60 ; CHECK-LABEL: ule_i64:
61 ; CHECK: ule @3, @2{{$}}
62 ; CHECK-NEXT: set_local @4, pop{{$}}
5363 define i32 @ule_i64(i64 %x, i64 %y) {
5464 %a = icmp ule i64 %x, %y
5565 %b = zext i1 %a to i32
5666 ret i32 %b
5767 }
5868
59 ; CHECK-LABEL: (func $sgt_i64
60 ; CHECK: (set_local @2 (sgt @1 @0))
69 ; CHECK-LABEL: sgt_i64:
70 ; CHECK: sgt @3, @2{{$}}
71 ; CHECK-NEXT: set_local @4, pop{{$}}
6172 define i32 @sgt_i64(i64 %x, i64 %y) {
6273 %a = icmp sgt i64 %x, %y
6374 %b = zext i1 %a to i32
6475 ret i32 %b
6576 }
6677
67 ; CHECK-LABEL: (func $sge_i64
68 ; CHECK: (set_local @2 (sge @1 @0))
78 ; CHECK-LABEL: sge_i64:
79 ; CHECK: sge @3, @2{{$}}
80 ; CHECK-NEXT: set_local @4, pop{{$}}
6981 define i32 @sge_i64(i64 %x, i64 %y) {
7082 %a = icmp sge i64 %x, %y
7183 %b = zext i1 %a to i32
7284 ret i32 %b
7385 }
7486
75 ; CHECK-LABEL: (func $ugt_i64
76 ; CHECK: (set_local @2 (ugt @1 @0))
87 ; CHECK-LABEL: ugt_i64:
88 ; CHECK: ugt @3, @2{{$}}
89 ; CHECK-NEXT: set_local @4, pop{{$}}
7790 define i32 @ugt_i64(i64 %x, i64 %y) {
7891 %a = icmp ugt i64 %x, %y
7992 %b = zext i1 %a to i32
8093 ret i32 %b
8194 }
8295
83 ; CHECK-LABEL: (func $uge_i64
84 ; CHECK: (set_local @2 (uge @1 @0))
96 ; CHECK-LABEL: uge_i64:
97 ; CHECK: uge @3, @2{{$}}
98 ; CHECK-NEXT: set_local @4, pop{{$}}
8599 define i32 @uge_i64(i64 %x, i64 %y) {
86100 %a = icmp uge i64 %x, %y
87101 %b = zext i1 %a to i32
44 target datalayout = "e-p:32:32-i64:64-n32:64-S128"
55 target triple = "wasm32-unknown-unknown"
66
7 ; CHECK-LABEL: $i32_wrap_i64
8 ; CHECK-NEXT: (param i64) (result i32)
9 ; CHECK-NEXT: (set_local @0 (argument 0))
10 ; CHECK-NEXT: (set_local @1 (i32_wrap @0))
11 ; CHECK-NEXT: (return @1)
7 ; CHECK-LABEL: i32_wrap_i64:
8 ; CHECK-NEXT: .param i64{{$}}
9 ; CHECK-NEXT: .result i32{{$}}
10 ; CHECK-NEXT: @0{{$}}
11 ; CHECK-NEXT: set_local @1, pop{{$}}
12 ; CHECK-NEXT: i32_wrap @1{{$}}
13 ; CHECK-NEXT: set_local @2, pop{{$}}
14 ; CHECK-NEXT: return @2{{$}}
1215 define i32 @i32_wrap_i64(i64 %x) {
1316 %a = trunc i64 %x to i32
1417 ret i32 %a
1518 }
1619
17 ; CHECK-LABEL: $i64_extend_s_i32
18 ; CHECK-NEXT: (param i32) (result i64)
19 ; CHECK-NEXT: (set_local @0 (argument 0))
20 ; CHECK-NEXT: (set_local @1 (i64_extend_s @0))
21 ; CHECK-NEXT: (return @1)
20 ; CHECK-LABEL: i64_extend_s_i32:
21 ; CHECK-NEXT: .param i32
22 ; CHECK-NEXT: .result i64
23 ; CHECK-NEXT: @0{{$}}
24 ; CHECK-NEXT: set_local @1, pop{{$}}
25 ; CHECK-NEXT: i64_extend_s @1{{$}}
26 ; CHECK-NEXT: set_local @2, pop{{$}}
27 ; CHECK-NEXT: return @2{{$}}
2228 define i64 @i64_extend_s_i32(i32 %x) {
2329 %a = sext i32 %x to i64
2430 ret i64 %a
2531 }
2632
27 ; CHECK-LABEL: $i64_extend_u_i32
28 ; CHECK-NEXT: (param i32) (result i64)
29 ; CHECK-NEXT: (set_local @0 (argument 0))
30 ; CHECK-NEXT: (set_local @1 (i64_extend_u @0))
31 ; CHECK-NEXT: (return @1)
33 ; CHECK-LABEL: i64_extend_u_i32:
34 ; CHECK-NEXT: .param i32
35 ; CHECK-NEXT: .result i64
36 ; CHECK-NEXT: @0{{$}}
37 ; CHECK-NEXT: set_local @1, pop{{$}}
38 ; CHECK-NEXT: i64_extend_u @1{{$}}
39 ; CHECK-NEXT: set_local @2, pop{{$}}
40 ; CHECK-NEXT: return @2{{$}}
3241 define i64 @i64_extend_u_i32(i32 %x) {
3342 %a = zext i32 %x to i64
3443 ret i64 %a
3544 }
3645
37 ; CHECK-LABEL: $i32_trunc_s_f32
38 ; CHECK-NEXT: (param f32) (result i32)
39 ; CHECK-NEXT: (set_local @0 (argument 0))
40 ; CHECK-NEXT: (set_local @1 (i32_trunc_s @0))
41 ; CHECK-NEXT: (return @1)
46 ; CHECK-LABEL: i32_trunc_s_f32:
47 ; CHECK-NEXT: .param f32
48 ; CHECK-NEXT: .result i32
49 ; CHECK-NEXT: @0{{$}}
50 ; CHECK-NEXT: set_local @1, pop{{$}}
51 ; CHECK-NEXT: i32_trunc_s @1{{$}}
52 ; CHECK-NEXT: set_local @2, pop{{$}}
53 ; CHECK-NEXT: return @2{{$}}
4254 define i32 @i32_trunc_s_f32(float %x) {
4355 %a = fptosi float %x to i32
4456 ret i32 %a
4557 }
4658
47 ; CHECK-LABEL: $i32_trunc_u_f32
48 ; CHECK-NEXT: (param f32) (result i32)
49 ; CHECK-NEXT: (set_local @0 (argument 0))
50 ; CHECK-NEXT: (set_local @1 (i32_trunc_u @0))
51 ; CHECK-NEXT: (return @1)
59 ; CHECK-LABEL: i32_trunc_u_f32:
60 ; CHECK-NEXT: .param f32
61 ; CHECK-NEXT: .result i32
62 ; CHECK-NEXT: @0{{$}}
63 ; CHECK-NEXT: set_local @1, pop{{$}}
64 ; CHECK-NEXT: i32_trunc_u @1{{$}}
65 ; CHECK-NEXT: set_local @2, pop{{$}}
66 ; CHECK-NEXT: return @2{{$}}
5267 define i32 @i32_trunc_u_f32(float %x) {
5368 %a = fptoui float %x to i32
5469 ret i32 %a
5570 }
5671
57 ; CHECK-LABEL: $i32_trunc_s_f64
58 ; CHECK-NEXT: (param f64) (result i32)
59 ; CHECK-NEXT: (set_local @0 (argument 0))
60 ; CHECK-NEXT: (set_local @1 (i32_trunc_s @0))
61 ; CHECK-NEXT: (return @1)
72 ; CHECK-LABEL: i32_trunc_s_f64:
73 ; CHECK-NEXT: .param f64
74 ; CHECK-NEXT: .result i32
75 ; CHECK-NEXT: @0{{$}}
76 ; CHECK-NEXT: set_local @1, pop{{$}}
77 ; CHECK-NEXT: i32_trunc_s @1{{$}}
78 ; CHECK-NEXT: set_local @2, pop{{$}}
79 ; CHECK-NEXT: return @2{{$}}
6280 define i32 @i32_trunc_s_f64(double %x) {
6381 %a = fptosi double %x to i32
6482 ret i32 %a
6583 }
6684
67 ; CHECK-LABEL: $i32_trunc_u_f64
68 ; CHECK-NEXT: (param f64) (result i32)
69 ; CHECK-NEXT: (set_local @0 (argument 0))
70 ; CHECK-NEXT: (set_local @1 (i32_trunc_u @0))
71 ; CHECK-NEXT: (return @1)
85 ; CHECK-LABEL: i32_trunc_u_f64:
86 ; CHECK-NEXT: .param f64
87 ; CHECK-NEXT: .result i32
88 ; CHECK-NEXT: @0{{$}}
89 ; CHECK-NEXT: set_local @1, pop{{$}}
90 ; CHECK-NEXT: i32_trunc_u @1{{$}}
91 ; CHECK-NEXT: set_local @2, pop{{$}}
92 ; CHECK-NEXT: return @2{{$}}
7293 define i32 @i32_trunc_u_f64(double %x) {
7394 %a = fptoui double %x to i32
7495 ret i32 %a
7596 }
7697
77 ; CHECK-LABEL: $i64_trunc_s_f32
78 ; CHECK-NEXT: (param f32) (result i64)
79 ; CHECK-NEXT: (set_local @0 (argument 0))
80 ; CHECK-NEXT: (set_local @1 (i64_trunc_s @0))
81 ; CHECK-NEXT: (return @1)
98 ; CHECK-LABEL: i64_trunc_s_f32:
99 ; CHECK-NEXT: .param f32
100 ; CHECK-NEXT: .result i64
101 ; CHECK-NEXT: @0{{$}}
102 ; CHECK-NEXT: set_local @1, pop{{$}}
103 ; CHECK-NEXT: i64_trunc_s @1{{$}}
104 ; CHECK-NEXT: set_local @2, pop{{$}}
105 ; CHECK-NEXT: return @2{{$}}
82106 define i64 @i64_trunc_s_f32(float %x) {
83107 %a = fptosi float %x to i64
84108 ret i64 %a
85109 }
86110
87 ; CHECK-LABEL: $i64_trunc_u_f32
88 ; CHECK-NEXT: (param f32) (result i64)
89 ; CHECK-NEXT: (set_local @0 (argument 0))
90 ; CHECK-NEXT: (set_local @1 (i64_trunc_u @0))
91 ; CHECK-NEXT: (return @1)
111 ; CHECK-LABEL: i64_trunc_u_f32:
112 ; CHECK-NEXT: .param f32
113 ; CHECK-NEXT: .result i64
114 ; CHECK-NEXT: @0{{$}}
115 ; CHECK-NEXT: set_local @1, pop{{$}}
116 ; CHECK-NEXT: i64_trunc_u @1{{$}}
117 ; CHECK-NEXT: set_local @2, pop{{$}}
118 ; CHECK-NEXT: return @2{{$}}
92119 define i64 @i64_trunc_u_f32(float %x) {
93120 %a = fptoui float %x to i64
94121 ret i64 %a
95122 }
96123
97 ; CHECK-LABEL: $i64_trunc_s_f64
98 ; CHECK-NEXT: (param f64) (result i64)
99 ; CHECK-NEXT: (set_local @0 (argument 0))
100 ; CHECK-NEXT: (set_local @1 (i64_trunc_s @0))
101 ; CHECK-NEXT: (return @1)
124 ; CHECK-LABEL: i64_trunc_s_f64:
125 ; CHECK-NEXT: .param f64
126 ; CHECK-NEXT: .result i64
127 ; CHECK-NEXT: @0{{$}}
128 ; CHECK-NEXT: set_local @1, pop{{$}}
129 ; CHECK-NEXT: i64_trunc_s @1{{$}}
130 ; CHECK-NEXT: set_local @2, pop{{$}}
131 ; CHECK-NEXT: return @2{{$}}
102132 define i64 @i64_trunc_s_f64(double %x) {
103133 %a = fptosi double %x to i64
104134 ret i64 %a
105135 }
106136
107 ; CHECK-LABEL: $i64_trunc_u_f64
108 ; CHECK-NEXT: (param f64) (result i64)
109 ; CHECK-NEXT: (set_local @0 (argument 0))
110 ; CHECK-NEXT: (set_local @1 (i64_trunc_u @0))
111 ; CHECK-NEXT: (return @1)
137 ; CHECK-LABEL: i64_trunc_u_f64:
138 ; CHECK-NEXT: .param f64
139 ; CHECK-NEXT: .result i64
140 ; CHECK-NEXT: @0{{$}}
141 ; CHECK-NEXT: set_local @1, pop{{$}}
142 ; CHECK-NEXT: i64_trunc_u @1{{$}}
143 ; CHECK-NEXT: set_local @2, pop{{$}}
144 ; CHECK-NEXT: return @2{{$}}
112145 define i64 @i64_trunc_u_f64(double %x) {
113146 %a = fptoui double %x to i64
114147 ret i64 %a
115148 }
116149
117 ; CHECK-LABEL: $f32_convert_s_i32
118 ; CHECK-NEXT: (param i32) (result f32)
119 ; CHECK-NEXT: (set_local @0 (argument 0))
120 ; CHECK-NEXT: (set_local @1 (f32_convert_s @0))
121 ; CHECK-NEXT: (return @1)
150 ; CHECK-LABEL: f32_convert_s_i32:
151 ; CHECK-NEXT: .param i32
152 ; CHECK-NEXT: .result f32
153 ; CHECK-NEXT: @0{{$}}
154 ; CHECK-NEXT: set_local @1, pop{{$}}
155 ; CHECK-NEXT: f32_convert_s @1{{$}}
156 ; CHECK-NEXT: set_local @2, pop{{$}}
157 ; CHECK-NEXT: return @2{{$}}
122158 define float @f32_convert_s_i32(i32 %x) {
123159 %a = sitofp i32 %x to float
124160 ret float %a
125161 }
126162
127 ; CHECK-LABEL: $f32_convert_u_i32
128 ; CHECK-NEXT: (param i32) (result f32)
129 ; CHECK-NEXT: (set_local @0 (argument 0))
130 ; CHECK-NEXT: (set_local @1 (f32_convert_u @0))
131 ; CHECK-NEXT: (return @1)
163 ; CHECK-LABEL: f32_convert_u_i32:
164 ; CHECK-NEXT: .param i32
165 ; CHECK-NEXT: .result f32
166 ; CHECK-NEXT: @0{{$}}
167 ; CHECK-NEXT: set_local @1, pop{{$}}
168 ; CHECK-NEXT: f32_convert_u @1{{$}}
169 ; CHECK-NEXT: set_local @2, pop{{$}}
170 ; CHECK-NEXT: return @2{{$}}
132171 define float @f32_convert_u_i32(i32 %x) {
133172 %a = uitofp i32 %x to float
134173 ret float %a
135174 }
136175
137 ; CHECK-LABEL: $f64_convert_s_i32
138 ; CHECK-NEXT: (param i32) (result f64)
139 ; CHECK-NEXT: (set_local @0 (argument 0))
140 ; CHECK-NEXT: (set_local @1 (f64_convert_s @0))
141 ; CHECK-NEXT: (return @1)
176 ; CHECK-LABEL: f64_convert_s_i32:
177 ; CHECK-NEXT: .param i32
178 ; CHECK-NEXT: .result f64
179 ; CHECK-NEXT: @0{{$}}
180 ; CHECK-NEXT: set_local @1, pop{{$}}
181 ; CHECK-NEXT: f64_convert_s @1{{$}}
182 ; CHECK-NEXT: set_local @2, pop{{$}}
183 ; CHECK-NEXT: return @2{{$}}
142184 define double @f64_convert_s_i32(i32 %x) {
143185 %a = sitofp i32 %x to double
144186 ret double %a
145187 }
146188
147 ; CHECK-LABEL: $f64_convert_u_i32
148 ; CHECK-NEXT: (param i32) (result f64)
149 ; CHECK-NEXT: (set_local @0 (argument 0))
150 ; CHECK-NEXT: (set_local @1 (f64_convert_u @0))
151 ; CHECK-NEXT: (return @1)
189 ; CHECK-LABEL: f64_convert_u_i32:
190 ; CHECK-NEXT: .param i32
191 ; CHECK-NEXT: .result f64
192 ; CHECK-NEXT: @0{{$}}
193 ; CHECK-NEXT: set_local @1, pop{{$}}
194 ; CHECK-NEXT: f64_convert_u @1{{$}}
195 ; CHECK-NEXT: set_local @2, pop{{$}}
196 ; CHECK-NEXT: return @2{{$}}
152197 define double @f64_convert_u_i32(i32 %x) {
153198 %a = uitofp i32 %x to double
154199 ret double %a
155200 }
156201
157 ; CHECK-LABEL: $f32_convert_s_i64
158 ; CHECK-NEXT: (param i64) (result f32)
159 ; CHECK-NEXT: (set_local @0 (argument 0))
160 ; CHECK-NEXT: (set_local @1 (f32_convert_s @0))
161 ; CHECK-NEXT: (return @1)
202 ; CHECK-LABEL: f32_convert_s_i64:
203 ; CHECK-NEXT: .param i64
204 ; CHECK-NEXT: .result f32
205 ; CHECK-NEXT: @0{{$}}
206 ; CHECK-NEXT: set_local @1, pop{{$}}
207 ; CHECK-NEXT: f32_convert_s @1{{$}}
208 ; CHECK-NEXT: set_local @2, pop{{$}}
209 ; CHECK-NEXT: return @2{{$}}
162210 define float @f32_convert_s_i64(i64 %x) {
163211 %a = sitofp i64 %x to float
164212 ret float %a
165213 }
166214
167 ; CHECK-LABEL: $f32_convert_u_i64
168 ; CHECK-NEXT: (param i64) (result f32)
169 ; CHECK-NEXT: (set_local @0 (argument 0))
170 ; CHECK-NEXT: (set_local @1 (f32_convert_u @0))
171 ; CHECK-NEXT: (return @1)
215 ; CHECK-LABEL: f32_convert_u_i64:
216 ; CHECK-NEXT: .param i64
217 ; CHECK-NEXT: .result f32
218 ; CHECK-NEXT: @0{{$}}
219 ; CHECK-NEXT: set_local @1, pop{{$}}
220 ; CHECK-NEXT: f32_convert_u @1{{$}}
221 ; CHECK-NEXT: set_local @2, pop{{$}}
222 ; CHECK-NEXT: return @2{{$}}
172223 define float @f32_convert_u_i64(i64 %x) {
173224 %a = uitofp i64 %x to float
174225 ret float %a
175226 }
176227
177 ; CHECK-LABEL: $f64_convert_s_i64
178 ; CHECK-NEXT: (param i64) (result f64)
179 ; CHECK-NEXT: (set_local @0 (argument 0))
180 ; CHECK-NEXT: (set_local @1 (f64_convert_s @0))
181 ; CHECK-NEXT: (return @1)
228 ; CHECK-LABEL: f64_convert_s_i64:
229 ; CHECK-NEXT: .param i64
230 ; CHECK-NEXT: .result f64
231 ; CHECK-NEXT: @0{{$}}
232 ; CHECK-NEXT: set_local @1, pop{{$}}
233 ; CHECK-NEXT: f64_convert_s @1{{$}}
234 ; CHECK-NEXT: set_local @2, pop{{$}}
235 ; CHECK-NEXT: return @2{{$}}
182236 define double @f64_convert_s_i64(i64 %x) {
183237 %a = sitofp i64 %x to double
184238 ret double %a
185239 }
186240
187 ; CHECK-LABEL: $f64_convert_u_i64
188 ; CHECK-NEXT: (param i64) (result f64)
189 ; CHECK-NEXT: (set_local @0 (argument 0))
190 ; CHECK-NEXT: (set_local @1 (f64_convert_u @0))
191 ; CHECK-NEXT: (return @1)
241 ; CHECK-LABEL: f64_convert_u_i64:
242 ; CHECK-NEXT: .param i64
243 ; CHECK-NEXT: .result f64
244 ; CHECK-NEXT: @0{{$}}
245 ; CHECK-NEXT: set_local @1, pop{{$}}
246 ; CHECK-NEXT: f64_convert_u @1{{$}}
247 ; CHECK-NEXT: set_local @2, pop{{$}}
248 ; CHECK-NEXT: return @2{{$}}
192249 define double @f64_convert_u_i64(i64 %x) {
193250 %a = uitofp i64 %x to double
194251 ret double %a
195252 }
196253
197 ; CHECK-LABEL: $f64_promote_f32
198 ; CHECK-NEXT: (param f32) (result f64)
199 ; CHECK-NEXT: (set_local @0 (argument 0))
200 ; CHECK-NEXT: (set_local @1 (f64_promote @0))
201 ; CHECK-NEXT: (return @1)
254 ; CHECK-LABEL: f64_promote_f32:
255 ; CHECK-NEXT: .param f32
256 ; CHECK-NEXT: .result f64
257 ; CHECK-NEXT: @0{{$}}
258 ; CHECK-NEXT: set_local @1, pop{{$}}
259 ; CHECK-NEXT: f64_promote @1{{$}}
260 ; CHECK-NEXT: set_local @2, pop{{$}}
261 ; CHECK-NEXT: return @2{{$}}
202262 define double @f64_promote_f32(float %x) {
203263 %a = fpext float %x to double
204264 ret double %a
205265 }
206266
207 ; CHECK-LABEL: $f32_demote_f64
208 ; CHECK-NEXT: (param f64) (result f32)
209 ; CHECK-NEXT: (set_local @0 (argument 0))
210 ; CHECK-NEXT: (set_local @1 (f32_demote @0))
211 ; CHECK-NEXT: (return @1)
267 ; CHECK-LABEL: f32_demote_f64:
268 ; CHECK-NEXT: .param f64
269 ; CHECK-NEXT: .result f32
270 ; CHECK-NEXT: @0{{$}}
271 ; CHECK-NEXT: set_local @1, pop{{$}}
272 ; CHECK-NEXT: f32_demote @1{{$}}
273 ; CHECK-NEXT: set_local @2, pop{{$}}
274 ; CHECK-NEXT: return @2{{$}}
212275 define float @f32_demote_f64(double %x) {
213276 %a = fptrunc double %x to float
214277 ret float %a
1313 declare float @llvm.nearbyint.f32(float)
1414 declare float @llvm.rint.f32(float)
1515
16 ; CHECK-LABEL: (func $fadd32
17 ; CHECK-NEXT: (param f32) (param f32) (result f32)
18 ; CHECK-NEXT: (set_local @0 (argument 1))
19 ; CHECK-NEXT: (set_local @1 (argument 0))
20 ; CHECK-NEXT: (set_local @2 (fadd @1 @0))
21 ; CHECK-NEXT: (return @2)
16 ; CHECK-LABEL: fadd32:
17 ; CHECK-NEXT: .param f32{{$}}
18 ; CHECK-NEXT: .param f32{{$}}
19 ; CHECK-NEXT: .result f32{{$}}
20 ; CHECK-NEXT: @1{{$}}
21 ; CHECK-NEXT: set_local @2, pop{{$}}
22 ; CHECK-NEXT: @0{{$}}
23 ; CHECK-NEXT: set_local @3, pop{{$}}
24 ; CHECK-NEXT: fadd @3, @2{{$}}
25 ; CHECK-NEXT: set_local @4, pop{{$}}
26 ; CHECK-NEXT: return @4{{$}}
2227 define float @fadd32(float %x, float %y) {
2328 %a = fadd float %x, %y
2429 ret float %a
2530 }
2631
27 ; CHECK-LABEL: (func $fsub32
28 ; CHECK: (set_local @2 (fsub @1 @0))
32 ; CHECK-LABEL: fsub32:
33 ; CHECK: fsub @3, @2{{$}}
34 ; CHECK-NEXT: set_local @4, pop{{$}}
2935 define float @fsub32(float %x, float %y) {
3036 %a = fsub float %x, %y
3137 ret float %a
3238 }
3339
34 ; CHECK-LABEL: (func $fmul32
35 ; CHECK: (set_local @2 (fmul @1 @0))
40 ; CHECK-LABEL: fmul32:
41 ; CHECK: fmul @3, @2{{$}}
42 ; CHECK-NEXT: set_local @4, pop{{$}}
3643 define float @fmul32(float %x, float %y) {
3744 %a = fmul float %x, %y
3845 ret float %a
3946 }
4047
41 ; CHECK-LABEL: (func $fdiv32
42 ; CHECK: (set_local @2 (fdiv @1 @0))
48 ; CHECK-LABEL: fdiv32:
49 ; CHECK: fdiv @3, @2{{$}}
50 ; CHECK-NEXT: set_local @4, pop{{$}}
4351 define float @fdiv32(float %x, float %y) {
4452 %a = fdiv float %x, %y
4553 ret float %a
4654 }
4755
48 ; CHECK-LABEL: (func $fabs32
49 ; CHECK: (set_local @1 (fabs @0))
56 ; CHECK-LABEL: fabs32:
57 ; CHECK: fabs @1{{$}}
58 ; CHECK-NEXT: set_local @2, pop{{$}}
5059 define float @fabs32(float %x) {
5160 %a = call float @llvm.fabs.f32(float %x)
5261 ret float %a
5362 }
5463
55 ; CHECK-LABEL: (func $fneg32
56 ; CHECK: (set_local @1 (fneg @0))
64 ; CHECK-LABEL: fneg32:
65 ; CHECK: fneg @1{{$}}
66 ; CHECK-NEXT: set_local @2, pop{{$}}
5767 define float @fneg32(float %x) {
5868 %a = fsub float -0., %x
5969 ret float %a
6070 }
6171
62 ; CHECK-LABEL: (func $copysign32
63 ; CHECK: (set_local @2 (copysign @1 @0))
72 ; CHECK-LABEL: copysign32:
73 ; CHECK: copysign @3, @2{{$}}
74 ; CHECK-NEXT: set_local @4, pop{{$}}
6475 define float @copysign32(float %x, float %y) {
6576 %a = call float @llvm.copysign.f32(float %x, float %y)
6677 ret float %a
6778 }
6879
69 ; CHECK-LABEL: (func $sqrt32
70 ; CHECK: (set_local @1 (sqrt @0))
80 ; CHECK-LABEL: sqrt32:
81 ; CHECK: sqrt @1{{$}}
82 ; CHECK-NEXT: set_local @2, pop{{$}}
7183 define float @sqrt32(float %x) {
7284 %a = call float @llvm.sqrt.f32(float %x)
7385 ret float %a
7486 }
7587
76 ; CHECK-LABEL: (func $ceil32
77 ; CHECK: (set_local @1 (ceil @0))
88 ; CHECK-LABEL: ceil32:
89 ; CHECK: ceil @1{{$}}
90 ; CHECK-NEXT: set_local @2, pop{{$}}
7891 define float @ceil32(float %x) {
7992 %a = call float @llvm.ceil.f32(float %x)
8093 ret float %a
8194 }
8295
83 ; CHECK-LABEL: (func $floor32
84 ; CHECK: (set_local @1 (floor @0))
96 ; CHECK-LABEL: floor32:
97 ; CHECK: floor @1{{$}}
98 ; CHECK-NEXT: set_local @2, pop{{$}}
8599 define float @floor32(float %x) {
86100 %a = call float @llvm.floor.f32(float %x)
87101 ret float %a
88102 }
89103
90 ; CHECK-LABEL: (func $trunc32
91 ; CHECK: (set_local @1 (trunc @0))
104 ; CHECK-LABEL: trunc32:
105 ; CHECK: trunc @1{{$}}
106 ; CHECK-NEXT: set_local @2, pop{{$}}
92107 define float @trunc32(float %x) {
93108 %a = call float @llvm.trunc.f32(float %x)
94109 ret float %a
95110 }
96111
97 ; CHECK-LABEL: (func $nearest32
98 ; CHECK: (set_local @1 (nearest @0))
112 ; CHECK-LABEL: nearest32:
113 ; CHECK: nearest @1{{$}}
114 ; CHECK-NEXT: set_local @2, pop{{$}}
99115 define float @nearest32(float %x) {
100116 %a = call float @llvm.nearbyint.f32(float %x)
101117 ret float %a
102118 }
103119
104 ; CHECK-LABEL: (func $nearest32_via_rint
105 ; CHECK: (set_local @1 (nearest @0))
120 ; CHECK-LABEL: nearest32_via_rint:
121 ; CHECK: nearest @1{{$}}
122 ; CHECK-NEXT: set_local @2, pop{{$}}
106123 define float @nearest32_via_rint(float %x) {
107124 %a = call float @llvm.rint.f32(float %x)
108125 ret float %a
1313 declare double @llvm.nearbyint.f64(double)
1414 declare double @llvm.rint.f64(double)
1515
16 ; CHECK-LABEL: (func $fadd64
17 ; CHECK-NEXT: (param f64) (param f64) (result f64)
18 ; CHECK-NEXT: (set_local @0 (argument 1))
19 ; CHECK-NEXT: (set_local @1 (argument 0))
20 ; CHECK-NEXT: (set_local @2 (fadd @1 @0))
21 ; CHECK-NEXT: (return @2)
16 ; CHECK-LABEL: fadd64:
17 ; CHECK-NEXT: .param f64{{$}}
18 ; CHECK-NEXT: .param f64{{$}}
19 ; CHECK-NEXT: .result f64{{$}}
20 ; CHECK-NEXT: @1{{$}}
21 ; CHECK-NEXT: set_local @2, pop{{$}}
22 ; CHECK-NEXT: @0{{$}}
23 ; CHECK-NEXT: set_local @3, pop{{$}}
24 ; CHECK-NEXT: fadd @3, @2{{$}}
25 ; CHECK-NEXT: set_local @4, pop{{$}}
26 ; CHECK-NEXT: return @4{{$}}
2227 define double @fadd64(double %x, double %y) {
2328 %a = fadd double %x, %y
2429 ret double %a
2530 }
2631
27 ; CHECK-LABEL: (func $fsub64
28 ; CHECK: (set_local @2 (fsub @1 @0))
32 ; CHECK-LABEL: fsub64:
33 ; CHECK: fsub @3, @2{{$}}
34 ; CHECK-NEXT: set_local @4, pop{{$}}
2935 define double @fsub64(double %x, double %y) {
3036 %a = fsub double %x, %y
3137 ret double %a
3238 }
3339
34 ; CHECK-LABEL: (func $fmul64
35 ; CHECK: (set_local @2 (fmul @1 @0))
40 ; CHECK-LABEL: fmul64:
41 ; CHECK: fmul @3, @2{{$}}
42 ; CHECK-NEXT: set_local @4, pop{{$}}
3643 define double @fmul64(double %x, double %y) {
3744 %a = fmul double %x, %y
3845 ret double %a
3946 }
4047
41 ; CHECK-LABEL: (func $fdiv64
42 ; CHECK: (set_local @2 (fdiv @1 @0))
48 ; CHECK-LABEL: fdiv64:
49 ; CHECK: fdiv @3, @2{{$}}
50 ; CHECK-NEXT: set_local @4, pop{{$}}
4351 define double @fdiv64(double %x, double %y) {
4452 %a = fdiv double %x, %y
4553 ret double %a
4654 }
4755
48 ; CHECK-LABEL: (func $fabs64
49 ; CHECK: (set_local @1 (fabs @0))
56 ; CHECK-LABEL: fabs64:
57 ; CHECK: fabs @1{{$}}
58 ; CHECK-NEXT: set_local @2, pop{{$}}
5059 define double @fabs64(double %x) {
5160 %a = call double @llvm.fabs.f64(double %x)
5261 ret double %a
5362 }
5463
55 ; CHECK-LABEL: (func $fneg64
56 ; CHECK: (set_local @1 (fneg @0))
64 ; CHECK-LABEL: fneg64:
65 ; CHECK: fneg @1{{$}}
66 ; CHECK-NEXT: set_local @2, pop{{$}}
5767 define double @fneg64(double %x) {
5868 %a = fsub double -0., %x
5969 ret double %a
6070 }
6171
62 ; CHECK-LABEL: (func $copysign64
63 ; CHECK: (set_local @2 (copysign @1 @0))
72 ; CHECK-LABEL: copysign64:
73 ; CHECK: copysign @3, @2{{$}}
74 ; CHECK-NEXT: set_local @4, pop{{$}}
6475 define double @copysign64(double %x, double %y) {
6576 %a = call double @llvm.copysign.f64(double %x, double %y)
6677 ret double %a
6778 }
6879
69 ; CHECK-LABEL: (func $sqrt64
70 ; CHECK: (set_local @1 (sqrt @0))
80 ; CHECK-LABEL: sqrt64:
81 ; CHECK: sqrt @1{{$}}
82 ; CHECK-NEXT: set_local @2, pop{{$}}
7183 define double @sqrt64(double %x) {
7284 %a = call double @llvm.sqrt.f64(double %x)
7385 ret double %a
7486 }
7587
76 ; CHECK-LABEL: (func $ceil64
77 ; CHECK: (set_local @1 (ceil @0))
88 ; CHECK-LABEL: ceil64:
89 ; CHECK: ceil @1{{$}}
90 ; CHECK-NEXT: set_local @2, pop{{$}}
7891 define double @ceil64(double %x) {
7992 %a = call double @llvm.ceil.f64(double %x)
8093 ret double %a
8194 }
8295
83 ; CHECK-LABEL: (func $floor64
84 ; CHECK: (set_local @1 (floor @0))
96 ; CHECK-LABEL: floor64:
97 ; CHECK: floor @1{{$}}
98 ; CHECK-NEXT: set_local @2, pop{{$}}
8599 define double @floor64(double %x) {
86100 %a = call double @llvm.floor.f64(double %x)
87101 ret double %a
88102 }
89103
90 ; CHECK-LABEL: (func $trunc64
91 ; CHECK: (set_local @1 (trunc @0))
104 ; CHECK-LABEL: trunc64:
105 ; CHECK: trunc @1{{$}}
106 ; CHECK-NEXT: set_local @2, pop{{$}}
92107 define double @trunc64(double %x) {
93108 %a = call double @llvm.trunc.f64(double %x)
94109 ret double %a
95110 }
96111
97 ; CHECK-LABEL: (func $nearest64
98 ; CHECK: (set_local @1 (nearest @0))
112 ; CHECK-LABEL: nearest64:
113 ; CHECK: nearest @1{{$}}
114 ; CHECK-NEXT: set_local @2, pop{{$}}
99115 define double @nearest64(double %x) {
100116 %a = call double @llvm.nearbyint.f64(double %x)
101117 ret double %a
102118 }
103119
104 ; CHECK-LABEL: (func $nearest64_via_rint
105 ; CHECK: (set_local @1 (nearest @0))
120 ; CHECK-LABEL: nearest64_via_rint:
121 ; CHECK: nearest @1{{$}}
122 ; CHECK-NEXT: set_local @2, pop{{$}}
106123 define double @nearest64_via_rint(double %x) {
107124 %a = call double @llvm.rint.f64(double %x)
108125 ret double %a
66
77 ; This tests very minimal fast-isel functionality.
88
9 ; CHECK-LABEL: (func $immediate_f32
10 ; CHECK: (immediate 0x1.4p1)
9 ; CHECK-LABEL: immediate_f32:
10 ; CHECK: f32.const 0x1.4p1{{$}}
1111 define float @immediate_f32() {
1212 ret float 2.5
1313 }
1414
15 ; CHECK-LABEL: (func $immediate_f64
16 ; CHECK: (immediate 0x1.4p1)
15 ; CHECK-LABEL: immediate_f64:
16 ; CHECK: f64.const 0x1.4p1{{$}}
1717 define double @immediate_f64() {
1818 ret double 2.5
1919 }
44 target datalayout = "e-p:32:32-i64:64-n32:64-S128"
55 target triple = "wasm32-unknown-unknown"
66
7 ; CHECK-LABEL: (func $f0{{$}}
8 ; CHECK: (return){{$}}
9 ; CHECK-NEXT: ) ;; end func $f0{{$}}
7 ; CHECK-LABEL: f0:
8 ; CHECK: return{{$}}
9 ; CHECK: .size f0,
1010 define void @f0() {
1111 ret void
1212 }
1313
14 ; CHECK-LABEL: (func $f1{{$}}
15 ; CHECK-NEXT: (result i32){{$}}
16 ; CHECK-NEXT: (set_local @0 (immediate 0)){{$}}
17 ; CHECK-NEXT: (return @0){{$}}
18 ; CHECK-NEXT: ) ;; end func $f1{{$}}
14 ; CHECK-LABEL: f1:
15 ; CHECK-NEXT: .result i32{{$}}
16 ; CHECK-NEXT: i32.const 0{{$}}
17 ; CHECK-NEXT: set_local @0, pop{{$}}
18 ; CHECK-NEXT: return @0{{$}}
19 ; CHECK: .size f1,
1920 define i32 @f1() {
2021 ret i32 0
2122 }
2223
23 ; CHECK-LABEL: (func $f2{{$}}
24 ; CHECK-NEXT: (param i32) (param f32) (result i32){{$}}
25 ; CHECK-NEXT: (set_local @0 (immediate 0)){{$}}
26 ; CHECK-NEXT: (return @0){{$}}
27 ; CHECK-NEXT: ) ;; end func $f2{{$}}
24 ; CHECK-LABEL: f2:
25 ; CHECK-NEXT: .param i32{{$}}
26 ; CHECK-NEXT: .param f32{{$}}
27 ; CHECK-NEXT: .result i32{{$}}
28 ; CHECK-NEXT: i32.const 0{{$}}
29 ; CHECK-NEXT: set_local @2, pop{{$}}
30 ; CHECK-NEXT: return @2{{$}}
31 ; CHECK: .size f2,
2832 define i32 @f2(i32 %p1, float %p2) {
2933 ret i32 0
3034 }
3135
32 ; CHECK-LABEL: (func $f3{{$}}
33 ; CHECK-NEXT: (param i32) (param f32){{$}}
34 ; CHECK-NEXT: (return){{$}}
35 ; CHECK-NEXT: ) ;; end func $f3{{$}}
36 ; CHECK-LABEL: f3:
37 ; CHECK-NEXT: .param i32{{$}}
38 ; CHECK-NEXT: .param f32{{$}}
39 ; CHECK-NEXT: return{{$}}
40 ; CHECK: .size f3,
3641 define void @f3(i32 %p1, float %p2) {
3742 ret void
3843 }
88 ; CHECK-NOT: llvm.metadata
99 @llvm.used = appending global [1 x i32*] [i32* @g], section "llvm.metadata"
1010
11 @g = private global i32 1337; ; CHECK: (global $g i32 1337)
11 ; CHECK: .type g,@object
12 ; CHECK: .align 2{{$}}
13 ; CHECK-NEXT: g:
14 ; CHECK-NEXT: .int32 1337{{$}}
15 ; CHECK-NEXT: .size g, 4{{$}}
16 @g = private global i32 1337
1217
13 @ud = internal global i32 undef; ; CHECK: (global $ud i32 0)
14 @nil = internal global i32 zeroinitializer; ; CHECK: (global $nil i32 0)
15 @z = internal global i32 0; ; CHECK: (global $z i32 0)
16 @one = internal global i32 1; ; CHECK: (global $one i32 1)
17 @answer = internal global i32 42; ; CHECK: (global $answer i32 42)
18 @u32max = internal global i32 -1; ; CHECK: (global $u32max i32 4294967295)
18 ; CHECK-LABEL: ud:
19 ; CHECK-NEXT: .zero 4{{$}}
20 ; CHECK-NEXT: .size ud, 4{{$}}
21 @ud = internal global i32 undef
1922
20 @ud64 = internal global i64 undef; ; CHECK: (global $ud64 i64 0)
21 @nil64 = internal global i64 zeroinitializer; ; CHECK: (global $nil64 i64 0)
22 @z64 = internal global i64 0; ; CHECK: (global $z64 i64 0)
23 @twoP32 = internal global i64 4294967296; ; CHECK: (global $twoP32 i64 4294967296)
24 @u64max = internal global i64 -1; ; CHECK: (global $u64max i64 18446744073709551615)
23 ; CHECK: .type nil,@object
24 ; CHECK-NEXT: .lcomm nil,4,2{{$}}
25 @nil = internal global i32 zeroinitializer
2526
26 @f32ud = internal global float undef; ; CHECK: (global $f32ud f32 0x0p0)
27 @f32nil = internal global float zeroinitializer; ; CHECK: (global $f32nil f32 0x0p0)
28 @f32z = internal global float 0.0; ; CHECK: (global $f32z f32 0x0p0)
29 @f32nz = internal global float -0.0; ; CHECK: (global $f32nz f32 -0x0p0)
30 @f32two = internal global float 2.0; ; CHECK: (global $f32two f32 0x1p1)
27 ; CHECK: .type z,@object
28 ; CHECK-NEXT: .lcomm z,4,2{{$}}
29 @z = internal global i32 0
3130
32 @f64ud = internal global double undef; ; CHECK: (global $f64ud f64 0x0p0)
33 @f64nil = internal global double zeroinitializer; ; CHECK: (global $f64nil f64 0x0p0)
34 @f64z = internal global double 0.0; ; CHECK: (global $f64z f64 0x0p0)
35 @f64nz = internal global double -0.0; ; CHECK: (global $f64nz f64 -0x0p0)
36 @f64two = internal global double 2.0; ; CHECK: (global $f64two f64 0x1p1)
31 ; CHECK-NEXT: .type one,@object
32 ; CHECK-NEXT: .align 2{{$}}
33 ; CHECK-NEXT: one:
34 ; CHECK-NEXT: .int32 1{{$}}
35 ; CHECK-NEXT: .size one, 4{{$}}
36 @one = internal global i32 1
37
38 ; CHECK: .type answer,@object
39 ; CHECK: .align 2{{$}}
40 ; CHECK-NEXT: answer:
41 ; CHECK-NEXT: .int32 42{{$}}
42 ; CHECK-NEXT: .size answer, 4{{$}}
43 @answer = internal global i32 42
44
45 ; CHECK: .type u32max,@object
46 ; CHECK: .align 2{{$}}
47 ; CHECK-NEXT: u32max:
48 ; CHECK-NEXT: .int32 4294967295{{$}}
49 ; CHECK-NEXT: .size u32max, 4{{$}}
50 @u32max = internal global i32 -1
51
52 ; CHECK: .type ud64,@object
53 ; CHECK: .align 3{{$}}
54 ; CHECK-NEXT: ud64:
55 ; CHECK-NEXT: .zero 8{{$}}
56 ; CHECK-NEXT: .size ud64, 8{{$}}
57 @ud64 = internal global i64 undef
58
59 ; CHECK: .type nil64,@object
60 ; CHECK: .lcomm nil64,8,3{{$}}
61 @nil64 = internal global i64 zeroinitializer
62
63 ; CHECK: .type z64,@object
64 ; CHECK: .lcomm z64,8,3{{$}}
65 @z64 = internal global i64 0
66
67 ; CHECK: .type twoP32,@object
68 ; CHECK: .align 3{{$}}
69 ; CHECK-NEXT: twoP32:
70 ; CHECK-NEXT: .int64 4294967296{{$}}
71 ; CHECK-NEXT: .size twoP32, 8{{$}}
72 @twoP32 = internal global i64 4294967296
73
74 ; CHECK: .type u64max,@object
75 ; CHECK: .align 3{{$}}
76 ; CHECK-NEXT: u64max:
77 ; CHECK-NEXT: .int64 -1{{$}}
78 ; CHECK-NEXT: .size u64max, 8{{$}}
79 @u64max = internal global i64 -1
80
81 ; CHECK: .type f32ud,@object
82 ; CHECK: .align 2{{$}}
83 ; CHECK-NEXT: f32ud:
84 ; CHECK-NEXT: .zero 4{{$}}
85 ; CHECK-NEXT: .size f32ud, 4{{$}}
86 @f32ud = internal global float undef
87
88 ; CHECK: .type f32nil,@object
89 ; CHECK: .lcomm f32nil,4,2{{$}}
90 @f32nil = internal global float zeroinitializer
91
92 ; CHECK: .type f32z,@object
93 ; CHECK: .lcomm f32z,4,2{{$}}
94 @f32z = internal global float 0.0
95
96 ; CHECK: .type f32nz,@object
97 ; CHECK: .align 2{{$}}
98 ; CHECK: f32nz:
99 ; CHECK: .int32 2147483648{{$}}
100 ; CHECK: .size f32nz, 4{{$}}
101 @f32nz = internal global float -0.0
102
103 ; CHECK: .type f32two,@object
104 ; CHECK: .align 2{{$}}
105 ; CHECK-NEXT: f32two:
106 ; CHECK-NEXT: .int32 1073741824{{$}}
107 ; CHECK-NEXT: .size f32two, 4{{$}}
108 @f32two = internal global float 2.0
109
110 ; CHECK: .type f64ud,@object
111 ; CHECK: .align 3{{$}}
112 ; CHECK-NEXT: f64ud:
113 ; CHECK-NEXT: .zero 8{{$}}
114 ; CHECK-NEXT: .size f64ud, 8{{$}}
115 @f64ud = internal global double undef
116
117 ; CHECK: .type f64nil,@object
118 ; CHECK: .lcomm f64nil,8,3{{$}}
119 @f64nil = internal global double zeroinitializer
120
121 ; CHECK: .type f64z,@object
122 ; CHECK: .lcomm f64z,8,3{{$}}
123 @f64z = internal global double 0.0
124
125 ; CHECK: .type f64nz,@object
126 ; CHECK: .align 3{{$}}
127 ; CHECK-NEXT: f64nz:
128 ; CHECK-NEXT: .int64 -9223372036854775808{{$}}
129 ; CHECK-NEXT: .size f64nz, 8{{$}}
130 @f64nz = internal global double -0.0
131
132 ; CHECK: .type f64two,@object
133 ; CHECK: .align 3{{$}}
134 ; CHECK-NEXT: f64two:
135 ; CHECK-NEXT: .int64 4611686018427387904{{$}}
136 ; CHECK-NEXT: .size f64two, 8{{$}}
137 @f64two = internal global double 2.0
0 ; RUN: llc < %s -asm-verbose=false | FileCheck %s
1
2 ; Test that the `.globl` directive is commented out.
31
42 target datalayout = "e-p:32:32-i64:64-n32:64-S128"
53 target triple = "wasm32-unknown-unknown"
64
7 ; CHECK-NOT: globl
8 ; CHECK: ;; .globl foo
9 ; CHECK-NOT: globl
10 ; CHECK-LABEL: (func $foo
5 ; CHECK: .globl foo
6 ; CHECK-LABEL: foo:
117 define void @foo() {
128 ret void
139 }
88 declare i32 @llvm.cttz.i32(i32, i1)
99 declare i32 @llvm.ctpop.i32(i32)
1010
11 ; CHECK-LABEL: (func $add32
12 ; CHECK-NEXT: (param i32) (param i32) (result i32)
13 ; CHECK-NEXT: (set_local @0 (argument 1))
14 ; CHECK-NEXT: (set_local @1 (argument 0))
15 ; CHECK-NEXT: (set_local @2 (add @1 @0))
16 ; CHECK-NEXT: (return @2)
11 ; CHECK-LABEL: add32:
12 ; CHECK-NEXT: .param i32{{$}}
13 ; CHECK-NEXT: .param i32{{$}}
14 ; CHECK-NEXT: .result i32{{$}}
15 ; CHECK-NEXT: @1{{$}}
16 ; CHECK-NEXT: set_local @2, pop{{$}}
17 ; CHECK-NEXT: @0{{$}}
18 ; CHECK-NEXT: set_local @3, pop{{$}}
19 ; CHECK-NEXT: add @3, @2{{$}}
20 ; CHECK-NEXT: set_local @4, pop{{$}}
21 ; CHECK-NEXT: return @4{{$}}
1722 define i32 @add32(i32 %x, i32 %y) {
1823 %a = add i32 %x, %y
1924 ret i32 %a
2025 }
2126
22 ; CHECK-LABEL: (func $sub32
23 ; CHECK-NEXT: (param i32) (param i32) (result i32)
24 ; CHECK-NEXT: (set_local @0 (argument 1))
25 ; CHECK-NEXT: (set_local @1 (argument 0))
26 ; CHECK-NEXT: (set_local @2 (sub @1 @0))
27 ; CHECK-NEXT: (return @2)
27 ; CHECK-LABEL: sub32:
28 ; CHECK-NEXT: .param i32{{$}}
29 ; CHECK-NEXT: .param i32{{$}}
30 ; CHECK-NEXT: .result i32{{$}}
31 ; CHECK-NEXT: @1{{$}}
32 ; CHECK-NEXT: set_local @2, pop{{$}}
33 ; CHECK-NEXT: @0{{$}}
34 ; CHECK-NEXT: set_local @3, pop{{$}}
35 ; CHECK-NEXT: sub @3, @2{{$}}
36 ; CHECK-NEXT: set_local @4, pop{{$}}
37 ; CHECK-NEXT: return @4{{$}}
2838 define i32 @sub32(i32 %x, i32 %y) {
2939 %a = sub i32 %x, %y
3040 ret i32 %a
3141 }
3242
33 ; CHECK-LABEL: (func $mul32
34 ; CHECK-NEXT: (param i32) (param i32) (result i32)
35 ; CHECK-NEXT: (set_local @0 (argument 1))
36 ; CHECK-NEXT: (set_local @1 (argument 0))
37 ; CHECK-NEXT: (set_local @2 (mul @1 @0))
38 ; CHECK-NEXT: (return @2)
43 ; CHECK-LABEL: mul32:
44 ; CHECK-NEXT: .param i32{{$}}
45 ; CHECK-NEXT: .param i32{{$}}
46 ; CHECK-NEXT: .result i32{{$}}
47 ; CHECK-NEXT: @1{{$}}
48 ; CHECK-NEXT: set_local @2, pop{{$}}
49 ; CHECK-NEXT: @0{{$}}
50 ; CHECK-NEXT: set_local @3, pop{{$}}
51 ; CHECK-NEXT: mul @3, @2{{$}}
52 ; CHECK-NEXT: set_local @4, pop{{$}}
53 ; CHECK-NEXT: return @4{{$}}
3954 define i32 @mul32(i32 %x, i32 %y) {
4055 %a = mul i32 %x, %y
4156 ret i32 %a
4257 }
4358
44 ; CHECK-LABEL: (func $sdiv32
45 ; CHECK-NEXT: (param i32) (param i32) (result i32)
46 ; CHECK-NEXT: (set_local @0 (argument 1))
47 ; CHECK-NEXT: (set_local @1 (argument 0))
48 ; CHECK-NEXT: (set_local @2 (sdiv @1 @0))
49 ; CHECK-NEXT: (return @2)
59 ; CHECK-LABEL: sdiv32:
60 ; CHECK-NEXT: .param i32{{$}}
61 ; CHECK-NEXT: .param i32{{$}}
62 ; CHECK-NEXT: .result i32{{$}}
63 ; CHECK-NEXT: @1{{$}}
64 ; CHECK-NEXT: set_local @2, pop{{$}}
65 ; CHECK-NEXT: @0{{$}}
66 ; CHECK-NEXT: set_local @3, pop{{$}}
67 ; CHECK-NEXT: sdiv @3, @2{{$}}
68 ; CHECK-NEXT: set_local @4, pop{{$}}
69 ; CHECK-NEXT: return @4{{$}}
5070 define i32 @sdiv32(i32 %x, i32 %y) {
5171 %a = sdiv i32 %x, %y
5272 ret i32 %a
5373 }
5474
55 ; CHECK-LABEL: (func $udiv32
56 ; CHECK-NEXT: (param i32) (param i32) (result i32)
57 ; CHECK-NEXT: (set_local @0 (argument 1))
58 ; CHECK-NEXT: (set_local @1 (argument 0))
59 ; CHECK-NEXT: (set_local @2 (udiv @1 @0))
60 ; CHECK-NEXT: (return @2)
75 ; CHECK-LABEL: udiv32:
76 ; CHECK-NEXT: .param i32{{$}}
77 ; CHECK-NEXT: .param i32{{$}}
78 ; CHECK-NEXT: .result i32{{$}}
79 ; CHECK-NEXT: @1{{$}}
80 ; CHECK-NEXT: set_local @2, pop{{$}}
81 ; CHECK-NEXT: @0{{$}}
82 ; CHECK-NEXT: set_local @3, pop{{$}}
83 ; CHECK-NEXT: udiv @3, @2{{$}}
84 ; CHECK-NEXT: set_local @4, pop{{$}}
85 ; CHECK-NEXT: return @4{{$}}
6186 define i32 @udiv32(i32 %x, i32 %y) {
6287 %a = udiv i32 %x, %y
6388 ret i32 %a
6489 }
6590
66 ; CHECK-LABEL: (func $srem32
67 ; CHECK-NEXT: (param i32) (param i32) (result i32)
68 ; CHECK-NEXT: (set_local @0 (argument 1))
69 ; CHECK-NEXT: (set_local @1 (argument 0))
70 ; CHECK-NEXT: (set_local @2 (srem @1 @0))
71 ; CHECK-NEXT: (return @2)
91 ; CHECK-LABEL: srem32:
92 ; CHECK-NEXT: .param i32{{$}}
93 ; CHECK-NEXT: .param i32{{$}}
94 ; CHECK-NEXT: .result i32{{$}}
95 ; CHECK-NEXT: @1{{$}}
96 ; CHECK-NEXT: set_local @2, pop{{$}}
97 ; CHECK-NEXT: @0{{$}}
98 ; CHECK-NEXT: set_local @3, pop{{$}}
99 ; CHECK-NEXT: srem @3, @2{{$}}
100 ; CHECK-NEXT: set_local @4, pop{{$}}
101 ; CHECK-NEXT: return @4{{$}}
72102 define i32 @srem32(i32 %x, i32 %y) {
73103 %a = srem i32 %x, %y
74104 ret i32 %a
75105 }
76106
77 ; CHECK-LABEL: (func $urem32
78 ; CHECK-NEXT: (param i32) (param i32) (result i32)
79 ; CHECK-NEXT: (set_local @0 (argument 1))
80 ; CHECK-NEXT: (set_local @1 (argument 0))
81 ; CHECK-NEXT: (set_local @2 (urem @1 @0))
82 ; CHECK-NEXT: (return @2)
107 ; CHECK-LABEL: urem32:
108 ; CHECK-NEXT: .param i32{{$}}
109 ; CHECK-NEXT: .param i32{{$}}
110 ; CHECK-NEXT: .result i32{{$}}
111 ; CHECK-NEXT: @1{{$}}
112 ; CHECK-NEXT: set_local @2, pop{{$}}
113 ; CHECK-NEXT: @0{{$}}
114 ; CHECK-NEXT: set_local @3, pop{{$}}
115 ; CHECK-NEXT: urem @3, @2{{$}}
116 ; CHECK-NEXT: set_local @4, pop{{$}}
117 ; CHECK-NEXT: return @4{{$}}
83118 define i32 @urem32(i32 %x, i32 %y) {
84119 %a = urem i32 %x, %y
85120 ret i32 %a
86121 }
87122
88 ; CHECK-LABEL: (func $and32
89 ; CHECK-NEXT: (param i32) (param i32) (result i32)
90 ; CHECK-NEXT: (set_local @0 (argument 1))
91 ; CHECK-NEXT: (set_local @1 (argument 0))
92 ; CHECK-NEXT: (set_local @2 (and @1 @0))
93 ; CHECK-NEXT: (return @2)
123 ; CHECK-LABEL: and32:
124 ; CHECK-NEXT: .param i32{{$}}
125 ; CHECK-NEXT: .param i32{{$}}
126 ; CHECK-NEXT: .result i32{{$}}
127 ; CHECK-NEXT: @1{{$}}
128 ; CHECK-NEXT: set_local @2, pop{{$}}
129 ; CHECK-NEXT: @0{{$}}
130 ; CHECK-NEXT: set_local @3, pop{{$}}
131 ; CHECK-NEXT: and @3, @2{{$}}
132 ; CHECK-NEXT: set_local @4, pop{{$}}
133 ; CHECK-NEXT: return @4{{$}}
94134 define i32 @and32(i32 %x, i32 %y) {
95135 %a = and i32 %x, %y
96136 ret i32 %a
97137 }
98138
99 ; CHECK-LABEL: (func $ior32
100 ; CHECK-NEXT: (param i32) (param i32) (result i32)
101 ; CHECK-NEXT: (set_local @0 (argument 1))
102 ; CHECK-NEXT: (set_local @1 (argument 0))
103 ; CHECK-NEXT: (set_local @2 (ior @1 @0))
104 ; CHECK-NEXT: (return @2)
139 ; CHECK-LABEL: ior32:
140 ; CHECK-NEXT: .param i32{{$}}
141 ; CHECK-NEXT: .param i32{{$}}
142 ; CHECK-NEXT: .result i32{{$}}
143 ; CHECK-NEXT: @1{{$}}
144 ; CHECK-NEXT: set_local @2, pop{{$}}
145 ; CHECK-NEXT: @0{{$}}
146 ; CHECK-NEXT: set_local @3, pop{{$}}
147 ; CHECK-NEXT: ior @3, @2{{$}}
148 ; CHECK-NEXT: set_local @4, pop{{$}}
149 ; CHECK-NEXT: return @4{{$}}
105150 define i32 @ior32(i32 %x, i32 %y) {
106151 %a = or i32 %x, %y
107152 ret i32 %a
108153 }
109154
110 ; CHECK-LABEL: (func $xor32
111 ; CHECK-NEXT: (param i32) (param i32) (result i32)
112 ; CHECK-NEXT: (set_local @0 (argument 1))
113 ; CHECK-NEXT: (set_local @1 (argument 0))
114 ; CHECK-NEXT: (set_local @2 (xor @1 @0))
115 ; CHECK-NEXT: (return @2)
155 ; CHECK-LABEL: xor32:
156 ; CHECK-NEXT: .param i32{{$}}
157 ; CHECK-NEXT: .param i32{{$}}
158 ; CHECK-NEXT: .result i32{{$}}
159 ; CHECK-NEXT: @1{{$}}
160 ; CHECK-NEXT: set_local @2, pop{{$}}
161 ; CHECK-NEXT: @0{{$}}
162 ; CHECK-NEXT: set_local @3, pop{{$}}
163 ; CHECK-NEXT: xor @3, @2{{$}}
164 ; CHECK-NEXT: set_local @4, pop{{$}}
165 ; CHECK-NEXT: return @4{{$}}
116166 define i32 @xor32(i32 %x, i32 %y) {
117167 %a = xor i32 %x, %y
118168 ret i32 %a
119169 }
120170
121 ; CHECK-LABEL: (func $shl32
122 ; CHECK-NEXT: (param i32) (param i32) (result i32)
123 ; CHECK-NEXT: (set_local @0 (argument 1))
124 ; CHECK-NEXT: (set_local @1 (argument 0))
125 ; CHECK-NEXT: (set_local @2 (shl @1 @0))
126 ; CHECK-NEXT: (return @2)
171 ; CHECK-LABEL: shl32:
172 ; CHECK-NEXT: .param i32{{$}}
173 ; CHECK-NEXT: .param i32{{$}}
174 ; CHECK-NEXT: .result i32{{$}}
175 ; CHECK-NEXT: @1{{$}}
176 ; CHECK-NEXT: set_local @2, pop{{$}}
177 ; CHECK-NEXT: @0{{$}}
178 ; CHECK-NEXT: set_local @3, pop{{$}}
179 ; CHECK-NEXT: shl @3, @2{{$}}
180 ; CHECK-NEXT: set_local @4, pop{{$}}
181 ; CHECK-NEXT: return @4{{$}}
127182 define i32 @shl32(i32 %x, i32 %y) {
128183 %a = shl i32 %x, %y
129184 ret i32 %a
130185 }
131186
132 ; CHECK-LABEL: (func $shr32
133 ; CHECK-NEXT: (param i32) (param i32) (result i32)
134 ; CHECK-NEXT: (set_local @0 (argument 1))
135 ; CHECK-NEXT: (set_local @1 (argument 0))
136 ; CHECK-NEXT: (set_local @2 (shr_u @1 @0))
137 ; CHECK-NEXT: (return @2)
187 ; CHECK-LABEL: shr32:
188 ; CHECK-NEXT: .param i32{{$}}
189 ; CHECK-NEXT: .param i32{{$}}
190 ; CHECK-NEXT: .result i32{{$}}
191 ; CHECK-NEXT: @1{{$}}
192 ; CHECK-NEXT: set_local @2, pop{{$}}
193 ; CHECK-NEXT: @0{{$}}
194 ; CHECK-NEXT: set_local @3, pop{{$}}
195 ; CHECK-NEXT: shr_u @3, @2{{$}}
196 ; CHECK-NEXT: set_local @4, pop{{$}}
197 ; CHECK-NEXT: return @4{{$}}
138198 define i32 @shr32(i32 %x, i32 %y) {
139199 %a = lshr i32 %x, %y
140200 ret i32 %a
141201 }
142202
143 ; CHECK-LABEL: (func $sar32
144 ; CHECK-NEXT: (param i32) (param i32) (result i32)
145 ; CHECK-NEXT: (set_local @0 (argument 1))
146 ; CHECK-NEXT: (set_local @1 (argument 0))
147 ; CHECK-NEXT: (set_local @2 (shr_s @1 @0))
148 ; CHECK-NEXT: (return @2)
203 ; CHECK-LABEL: sar32:
204 ; CHECK-NEXT: .param i32{{$}}
205 ; CHECK-NEXT: .param i32{{$}}
206 ; CHECK-NEXT: .result i32{{$}}
207 ; CHECK-NEXT: @1{{$}}
208 ; CHECK-NEXT: set_local @2, pop{{$}}
209 ; CHECK-NEXT: @0{{$}}
210 ; CHECK-NEXT: set_local @3, pop{{$}}
211 ; CHECK-NEXT: shr_s @3, @2{{$}}
212 ; CHECK-NEXT: set_local @4, pop{{$}}
213 ; CHECK-NEXT: return @4{{$}}
149214 define i32 @sar32(i32 %x, i32 %y) {
150215 %a = ashr i32 %x, %y
151216 ret i32 %a
152217 }
153218
154 ; CHECK-LABEL: (func $clz32
155 ; CHECK-NEXT: (param i32) (result i32)
156 ; CHECK-NEXT: (set_local @0 (argument 0))
157 ; CHECK-NEXT: (set_local @1 (clz @0))
158 ; CHECK-NEXT: (return @1)
219 ; CHECK-LABEL: clz32:
220 ; CHECK-NEXT: .param i32{{$}}
221 ; CHECK-NEXT: .result i32{{$}}
222 ; CHECK-NEXT: @0{{$}}
223 ; CHECK-NEXT: set_local @1, pop{{$}}
224 ; CHECK-NEXT: clz @1{{$}}
225 ; CHECK-NEXT: set_local @2, pop{{$}}
226 ; CHECK-NEXT: return @2{{$}}
159227 define i32 @clz32(i32 %x) {
160228 %a = call i32 @llvm.ctlz.i32(i32 %x, i1 false)
161229 ret i32 %a
162230 }
163231
164 ; CHECK-LABEL: (func $clz32_zero_undef
165 ; CHECK-NEXT: (param i32) (result i32)
166 ; CHECK-NEXT: (set_local @0 (argument 0))
167 ; CHECK-NEXT: (set_local @1 (clz @0))
168 ; CHECK-NEXT: (return @1)
232 ; CHECK-LABEL: clz32_zero_undef:
233 ; CHECK-NEXT: .param i32{{$}}
234 ; CHECK-NEXT: .result i32{{$}}
235 ; CHECK-NEXT: @0{{$}}
236 ; CHECK-NEXT: set_local @1, pop{{$}}
237 ; CHECK-NEXT: clz @1{{$}}
238 ; CHECK-NEXT: set_local @2, pop{{$}}
239 ; CHECK-NEXT: return @2{{$}}
169240 define i32 @clz32_zero_undef(i32 %x) {
170241 %a = call i32 @llvm.ctlz.i32(i32 %x, i1 true)
171242 ret i32 %a
172243 }
173244
174 ; CHECK-LABEL: (func $ctz32
175 ; CHECK-NEXT: (param i32) (result i32)
176 ; CHECK-NEXT: (set_local @0 (argument 0))
177 ; CHECK-NEXT: (set_local @1 (ctz @0))
178 ; CHECK-NEXT: (return @1)
245 ; CHECK-LABEL: ctz32:
246 ; CHECK-NEXT: .param i32{{$}}
247 ; CHECK-NEXT: .result i32{{$}}
248 ; CHECK-NEXT: @0{{$}}
249 ; CHECK-NEXT: set_local @1, pop{{$}}
250 ; CHECK-NEXT: ctz @1{{$}}
251 ; CHECK-NEXT: set_local @2, pop{{$}}
252 ; CHECK-NEXT: return @2{{$}}
179253 define i32 @ctz32(i32 %x) {
180254 %a = call i32 @llvm.cttz.i32(i32 %x, i1 false)
181255 ret i32 %a
182256 }
183257
184 ; CHECK-LABEL: (func $ctz32_zero_undef
185 ; CHECK-NEXT: (param i32) (result i32)
186 ; CHECK-NEXT: (set_local @0 (argument 0))
187 ; CHECK-NEXT: (set_local @1 (ctz @0))
188 ; CHECK-NEXT: (return @1)
258 ; CHECK-LABEL: ctz32_zero_undef:
259 ; CHECK-NEXT: .param i32{{$}}
260 ; CHECK-NEXT: .result i32{{$}}
261 ; CHECK-NEXT: @0{{$}}
262 ; CHECK-NEXT: set_local @1, pop{{$}}
263 ; CHECK-NEXT: ctz @1{{$}}
264 ; CHECK-NEXT: set_local @2, pop{{$}}
265 ; CHECK-NEXT: return @2{{$}}
189266 define i32 @ctz32_zero_undef(i32 %x) {
190267 %a = call i32 @llvm.cttz.i32(i32 %x, i1 true)
191268 ret i32 %a
192269 }
193270
194 ; CHECK-LABEL: (func $popcnt32
195 ; CHECK-NEXT: (param i32) (result i32)
196 ; CHECK-NEXT: (set_local @0 (argument 0))
197 ; CHECK-NEXT: (set_local @1 (popcnt @0))
198 ; CHECK-NEXT: (return @1)
271 ; CHECK-LABEL: popcnt32:
272 ; CHECK-NEXT: .param i32{{$}}
273 ; CHECK-NEXT: .result i32{{$}}
274 ; CHECK-NEXT: @0{{$}}
275 ; CHECK-NEXT: set_local @1, pop{{$}}
276 ; CHECK-NEXT: popcnt @1{{$}}
277 ; CHECK-NEXT: set_local @2, pop{{$}}
278 ; CHECK-NEXT: return @2{{$}}
199279 define i32 @popcnt32(i32 %x) {
200280 %a = call i32 @llvm.ctpop.i32(i32 %x)
201281 ret i32 %a
88 declare i64 @llvm.cttz.i64(i64, i1)
99 declare i64 @llvm.ctpop.i64(i64)
1010
11 ; CHECK-LABEL: (func $add64
12 ; CHECK-NEXT: (param i64) (param i64) (result i64)
13 ; CHECK-NEXT: (set_local @0 (argument 1))
14 ; CHECK-NEXT: (set_local @1 (argument 0))
15 ; CHECK-NEXT: (set_local @2 (add @1 @0))
16 ; CHECK-NEXT: (return @2)
11 ; CHECK-LABEL: add64:
12 ; CHECK-NEXT: .param i64{{$}}
13 ; CHECK-NEXT: .param i64{{$}}
14 ; CHECK-NEXT: .result i64{{$}}
15 ; CHECK-NEXT: @1{{$}}
16 ; CHECK-NEXT: set_local @2, pop{{$}}
17 ; CHECK-NEXT: @0{{$}}
18 ; CHECK-NEXT: set_local @3, pop{{$}}
19 ; CHECK-NEXT: add @3, @2{{$}}
20 ; CHECK-NEXT: set_local @4, pop{{$}}
21 ; CHECK-NEXT: return @4{{$}}
1722 define i64 @add64(i64 %x, i64 %y) {
1823 %a = add i64 %x, %y
1924 ret i64 %a
2025 }
2126
22 ; CHECK-LABEL: (func $sub64
23 ; CHECK-NEXT: (param i64) (param i64) (result i64)
24 ; CHECK-NEXT: (set_local @0 (argument 1))
25 ; CHECK-NEXT: (set_local @1 (argument 0))
26 ; CHECK-NEXT: (set_local @2 (sub @1 @0))
27 ; CHECK-NEXT: (return @2)
27 ; CHECK-LABEL: sub64:
28 ; CHECK-NEXT: .param i64{{$}}
29 ; CHECK-NEXT: .param i64{{$}}
30 ; CHECK-NEXT: .result i64{{$}}
31 ; CHECK-NEXT: @1{{$}}
32 ; CHECK-NEXT: set_local @2, pop{{$}}
33 ; CHECK-NEXT: @0{{$}}
34 ; CHECK-NEXT: set_local @3, pop{{$}}
35 ; CHECK-NEXT: sub @3, @2{{$}}
36 ; CHECK-NEXT: set_local @4, pop{{$}}
37 ; CHECK-NEXT: return @4{{$}}
2838 define i64 @sub64(i64 %x, i64 %y) {
2939 %a = sub i64 %x, %y
3040 ret i64 %a
3141 }
3242
33 ; CHECK-LABEL: (func $mul64
34 ; CHECK-NEXT: (param i64) (param i64) (result i64)
35 ; CHECK-NEXT: (set_local @0 (argument 1))
36 ; CHECK-NEXT: (set_local @1 (argument 0))
37 ; CHECK-NEXT: (set_local @2 (mul @1 @0))
38 ; CHECK-NEXT: (return @2)
43 ; CHECK-LABEL: mul64:
44 ; CHECK-NEXT: .param i64{{$}}
45 ; CHECK-NEXT: .param i64{{$}}
46 ; CHECK-NEXT: .result i64{{$}}
47 ; CHECK-NEXT: @1{{$}}
48 ; CHECK-NEXT: set_local @2, pop{{$}}
49 ; CHECK-NEXT: @0{{$}}
50 ; CHECK-NEXT: set_local @3, pop{{$}}
51 ; CHECK-NEXT: mul @3, @2{{$}}
52 ; CHECK-NEXT: set_local @4, pop{{$}}
53 ; CHECK-NEXT: return @4{{$}}
3954 define i64 @mul64(i64 %x, i64 %y) {
4055 %a = mul i64 %x, %y
4156 ret i64 %a
4257 }
4358
44 ; CHECK-LABEL: (func $sdiv64
45 ; CHECK-NEXT: (param i64) (param i64) (result i64)
46 ; CHECK-NEXT: (set_local @0 (argument 1))
47 ; CHECK-NEXT: (set_local @1 (argument 0))
48 ; CHECK-NEXT: (set_local @2 (sdiv @1 @0))
49 ; CHECK-NEXT: (return @2)
59 ; CHECK-LABEL: sdiv64:
60 ; CHECK-NEXT: .param i64{{$}}
61 ; CHECK-NEXT: .param i64{{$}}
62 ; CHECK-NEXT: .result i64{{$}}
63 ; CHECK-NEXT: @1{{$}}
64 ; CHECK-NEXT: set_local @2, pop{{$}}
65 ; CHECK-NEXT: @0{{$}}
66 ; CHECK-NEXT: set_local @3, pop{{$}}
67 ; CHECK-NEXT: sdiv @3, @2{{$}}
68 ; CHECK-NEXT: set_local @4, pop{{$}}
69 ; CHECK-NEXT: return @4{{$}}
5070 define i64 @sdiv64(i64 %x, i64 %y) {
5171 %a = sdiv i64 %x, %y
5272 ret i64 %a
5373 }
5474
55 ; CHECK-LABEL: (func $udiv64
56 ; CHECK-NEXT: (param i64) (param i64) (result i64)
57 ; CHECK-NEXT: (set_local @0 (argument 1))
58 ; CHECK-NEXT: (set_local @1 (argument 0))
59 ; CHECK-NEXT: (set_local @2 (udiv @1 @0))
60 ; CHECK-NEXT: (return @2)
75 ; CHECK-LABEL: udiv64:
76 ; CHECK-NEXT: .param i64{{$}}
77 ; CHECK-NEXT: .param i64{{$}}
78 ; CHECK-NEXT: .result i64{{$}}
79 ; CHECK-NEXT: @1{{$}}
80 ; CHECK-NEXT: set_local @2, pop{{$}}
81 ; CHECK-NEXT: @0{{$}}
82 ; CHECK-NEXT: set_local @3, pop{{$}}
83 ; CHECK-NEXT: udiv @3, @2{{$}}
84 ; CHECK-NEXT: set_local @4, pop{{$}}
85 ; CHECK-NEXT: return @4{{$}}
6186 define i64 @udiv64(i64 %x, i64 %y) {
6287 %a = udiv i64 %x, %y
6388 ret i64 %a
6489 }
6590
66 ; CHECK-LABEL: (func $srem64
67 ; CHECK-NEXT: (param i64) (param i64) (result i64)
68 ; CHECK-NEXT: (set_local @0 (argument 1))
69 ; CHECK-NEXT: (set_local @1 (argument 0))
70 ; CHECK-NEXT: (set_local @2 (srem @1 @0))
71 ; CHECK-NEXT: (return @2)
91 ; CHECK-LABEL: srem64:
92 ; CHECK-NEXT: .param i64{{$}}
93 ; CHECK-NEXT: .param i64{{$}}
94 ; CHECK-NEXT: .result i64{{$}}
95 ; CHECK-NEXT: @1{{$}}
96 ; CHECK-NEXT: set_local @2, pop{{$}}
97 ; CHECK-NEXT: @0{{$}}
98 ; CHECK-NEXT: set_local @3, pop{{$}}
99 ; CHECK-NEXT: srem @3, @2{{$}}
100 ; CHECK-NEXT: set_local @4, pop{{$}}
101 ; CHECK-NEXT: return @4{{$}}
72102 define i64 @srem64(i64 %x, i64 %y) {
73103 %a = srem i64 %x, %y
74104 ret i64 %a
75105 }
76106
77 ; CHECK-LABEL: (func $urem64
78 ; CHECK-NEXT: (param i64) (param i64) (result i64)
79 ; CHECK-NEXT: (set_local @0 (argument 1))
80 ; CHECK-NEXT: (set_local @1 (argument 0))
81 ; CHECK-NEXT: (set_local @2 (urem @1 @0))
82 ; CHECK-NEXT: (return @2)
107 ; CHECK-LABEL: urem64:
108 ; CHECK-NEXT: .param i64{{$}}
109 ; CHECK-NEXT: .param i64{{$}}
110 ; CHECK-NEXT: .result i64{{$}}
111 ; CHECK-NEXT: @1{{$}}
112 ; CHECK-NEXT: set_local @2, pop{{$}}
113 ; CHECK-NEXT: @0{{$}}
114 ; CHECK-NEXT: set_local @3, pop{{$}}
115 ; CHECK-NEXT: urem @3, @2{{$}}
116 ; CHECK-NEXT: set_local @4, pop{{$}}
117 ; CHECK-NEXT: return @4{{$}}
83118 define i64 @urem64(i64 %x, i64 %y) {
84119 %a = urem i64 %x, %y
85120 ret i64 %a
86121 }
87122
88 ; CHECK-LABEL: (func $and64
89 ; CHECK-NEXT: (param i64) (param i64) (result i64)
90 ; CHECK-NEXT: (set_local @0 (argument 1))
91 ; CHECK-NEXT: (set_local @1 (argument 0))
92 ; CHECK-NEXT: (set_local @2 (and @1 @0))
93 ; CHECK-NEXT: (return @2)
123 ; CHECK-LABEL: and64:
124 ; CHECK-NEXT: .param i64{{$}}
125 ; CHECK-NEXT: .param i64{{$}}
126 ; CHECK-NEXT: .result i64{{$}}
127 ; CHECK-NEXT: @1{{$}}
128 ; CHECK-NEXT: set_local @2, pop{{$}}
129 ; CHECK-NEXT: @0{{$}}
130 ; CHECK-NEXT: set_local @3, pop{{$}}
131 ; CHECK-NEXT: and @3, @2{{$}}
132 ; CHECK-NEXT: set_local @4, pop{{$}}
133 ; CHECK-NEXT: return @4{{$}}
94134 define i64 @and64(i64 %x, i64 %y) {
95135 %a = and i64 %x, %y
96136 ret i64 %a
97137 }
98138
99 ; CHECK-LABEL: (func $ior64
100 ; CHECK-NEXT: (param i64) (param i64) (result i64)
101 ; CHECK-NEXT: (set_local @0 (argument 1))
102 ; CHECK-NEXT: (set_local @1 (argument 0))
103 ; CHECK-NEXT: (set_local @2 (ior @1 @0))
104 ; CHECK-NEXT: (return @2)
139 ; CHECK-LABEL: ior64:
140 ; CHECK-NEXT: .param i64{{$}}
141 ; CHECK-NEXT: .param i64{{$}}
142 ; CHECK-NEXT: .result i64{{$}}
143 ; CHECK-NEXT: @1{{$}}
144 ; CHECK-NEXT: set_local @2, pop{{$}}
145 ; CHECK-NEXT: @0{{$}}
146 ; CHECK-NEXT: set_local @3, pop{{$}}
147 ; CHECK-NEXT: ior @3, @2{{$}}
148 ; CHECK-NEXT: set_local @4, pop{{$}}
149 ; CHECK-NEXT: return @4{{$}}
105150 define i64 @ior64(i64 %x, i64 %y) {
106151 %a = or i64 %x, %y
107152 ret i64 %a
108153 }
109154
110 ; CHECK-LABEL: (func $xor64
111 ; CHECK-NEXT: (param i64) (param i64) (result i64)
112 ; CHECK-NEXT: (set_local @0 (argument 1))
113 ; CHECK-NEXT: (set_local @1 (argument 0))
114 ; CHECK-NEXT: (set_local @2 (xor @1 @0))
115 ; CHECK-NEXT: (return @2)
155 ; CHECK-LABEL: xor64:
156 ; CHECK-NEXT: .param i64{{$}}
157 ; CHECK-NEXT: .param i64{{$}}
158 ; CHECK-NEXT: .result i64{{$}}
159 ; CHECK-NEXT: @1{{$}}
160 ; CHECK-NEXT: set_local @2, pop{{$}}
161 ; CHECK-NEXT: @0{{$}}
162 ; CHECK-NEXT: set_local @3, pop{{$}}
163 ; CHECK-NEXT: xor @3, @2{{$}}
164 ; CHECK-NEXT: set_local @4, pop{{$}}
165 ; CHECK-NEXT: return @4{{$}}
116166 define i64 @xor64(i64 %x, i64 %y) {
117167 %a = xor i64 %x, %y
118168 ret i64 %a
119169 }
120170
121 ; CHECK-LABEL: (func $shl64
122 ; CHECK-NEXT: (param i64) (param i64) (result i64)
123 ; CHECK-NEXT: (set_local @0 (argument 1))
124 ; CHECK-NEXT: (set_local @1 (argument 0))
125 ; CHECK-NEXT: (set_local @2 (shl @1 @0))
126 ; CHECK-NEXT: (return @2)
171 ; CHECK-LABEL: shl64:
172 ; CHECK-NEXT: .param i64{{$}}
173 ; CHECK-NEXT: .param i64{{$}}
174 ; CHECK-NEXT: .result i64{{$}}
175 ; CHECK-NEXT: @1{{$}}
176 ; CHECK-NEXT: set_local @2, pop{{$}}
177 ; CHECK-NEXT: @0{{$}}
178 ; CHECK-NEXT: set_local @3, pop{{$}}
179 ; CHECK-NEXT: shl @3, @2{{$}}
180 ; CHECK-NEXT: set_local @4, pop{{$}}
181 ; CHECK-NEXT: return @4{{$}}
127182 define i64 @shl64(i64 %x, i64 %y) {
128183 %a = shl i64 %x, %y
129184 ret i64 %a
130185 }
131186
132 ; CHECK-LABEL: (func $shr64
133 ; CHECK-NEXT: (param i64) (param i64) (result i64)
134 ; CHECK-NEXT: (set_local @0 (argument 1))
135 ; CHECK-NEXT: (set_local @1 (argument 0))
136 ; CHECK-NEXT: (set_local @2 (shr_u @1 @0))
137 ; CHECK-NEXT: (return @2)
187 ; CHECK-LABEL: shr64:
188 ; CHECK-NEXT: .param i64{{$}}
189 ; CHECK-NEXT: .param i64{{$}}
190 ; CHECK-NEXT: .result i64{{$}}
191 ; CHECK-NEXT: @1{{$}}
192 ; CHECK-NEXT: set_local @2, pop{{$}}
193 ; CHECK-NEXT: @0{{$}}
194 ; CHECK-NEXT: set_local @3, pop{{$}}
195 ; CHECK-NEXT: shr_u @3, @2{{$}}
196 ; CHECK-NEXT: set_local @4, pop{{$}}
197 ; CHECK-NEXT: return @4{{$}}
138198 define i64 @shr64(i64 %x, i64 %y) {
139199 %a = lshr i64 %x, %y
140200 ret i64 %a
141201 }
142202
143 ; CHECK-LABEL: (func $sar64
144 ; CHECK-NEXT: (param i64) (param i64) (result i64)
145 ; CHECK-NEXT: (set_local @0 (argument 1))
146 ; CHECK-NEXT: (set_local @1 (argument 0))
147 ; CHECK-NEXT: (set_local @2 (shr_s @1 @0))
148 ; CHECK-NEXT: (return @2)
203 ; CHECK-LABEL: sar64:
204 ; CHECK-NEXT: .param i64{{$}}
205 ; CHECK-NEXT: .param i64{{$}}
206 ; CHECK-NEXT: .result i64{{$}}
207 ; CHECK-NEXT: @1{{$}}
208 ; CHECK-NEXT: set_local @2, pop{{$}}
209 ; CHECK-NEXT: @0{{$}}
210 ; CHECK-NEXT: set_local @3, pop{{$}}
211 ; CHECK-NEXT: shr_s @3, @2{{$}}
212 ; CHECK-NEXT: set_local @4, pop{{$}}
213 ; CHECK-NEXT: return @4{{$}}
149214 define i64 @sar64(i64 %x, i64 %y) {
150215 %a = ashr i64 %x, %y
151216 ret i64 %a
152217 }
153218
154 ; CHECK-LABEL: (func $clz64
155 ; CHECK-NEXT: (param i64) (result i64)
156 ; CHECK-NEXT: (set_local @0 (argument 0))
157 ; CHECK-NEXT: (set_local @1 (clz @0))
158 ; CHECK-NEXT: (return @1)
219 ; CHECK-LABEL: clz64:
220 ; CHECK-NEXT: .param i64{{$}}
221 ; CHECK-NEXT: .result i64{{$}}
222 ; CHECK-NEXT: @0{{$}}
223 ; CHECK-NEXT: set_local @1, pop{{$}}
224 ; CHECK-NEXT: clz @1{{$}}
225 ; CHECK-NEXT: set_local @2, pop{{$}}
226 ; CHECK-NEXT: return @2{{$}}
159227 define i64 @clz64(i64 %x) {
160228 %a = call i64 @llvm.ctlz.i64(i64 %x, i1 false)
161229 ret i64 %a
162230 }
163231
164 ; CHECK-LABEL: (func $clz64_zero_undef
165 ; CHECK-NEXT: (param i64) (result i64)
166 ; CHECK-NEXT: (set_local @0 (argument 0))
167 ; CHECK-NEXT: (set_local @1 (clz @0))
168 ; CHECK-NEXT: (return @1)
232 ; CHECK-LABEL: clz64_zero_undef:
233 ; CHECK-NEXT: .param i64{{$}}
234 ; CHECK-NEXT: .result i64{{$}}
235 ; CHECK-NEXT: @0{{$}}
236 ; CHECK-NEXT: set_local @1, pop{{$}}
237 ; CHECK-NEXT: clz @1{{$}}
238 ; CHECK-NEXT: set_local @2, pop{{$}}
239 ; CHECK-NEXT: return @2{{$}}
169240 define i64 @clz64_zero_undef(i64 %x) {
170241 %a = call i64 @llvm.ctlz.i64(i64 %x, i1 true)
171242 ret i64 %a
172243 }
173244
174 ; CHECK-LABEL: (func $ctz64
175 ; CHECK-NEXT: (param i64) (result i64)
176 ; CHECK-NEXT: (set_local @0 (argument 0))
177 ; CHECK-NEXT: (set_local @1 (ctz @0))
178 ; CHECK-NEXT: (return @1)
245 ; CHECK-LABEL: ctz64:
246 ; CHECK-NEXT: .param i64{{$}}
247 ; CHECK-NEXT: .result i64{{$}}
248 ; CHECK-NEXT: @0{{$}}
249 ; CHECK-NEXT: set_local @1, pop{{$}}
250 ; CHECK-NEXT: ctz @1{{$}}
251 ; CHECK-NEXT: set_local @2, pop{{$}}
252 ; CHECK-NEXT: return @2{{$}}
179253 define i64 @ctz64(i64 %x) {
180254 %a = call i64 @llvm.cttz.i64(i64 %x, i1 false)
181255 ret i64 %a
182256 }
183257
184 ; CHECK-LABEL: (func $ctz64_zero_undef
185 ; CHECK-NEXT: (param i64) (result i64)
186 ; CHECK-NEXT: (set_local @0 (argument 0))
187 ; CHECK-NEXT: (set_local @1 (ctz @0))
188 ; CHECK-NEXT: (return @1)
258 ; CHECK-LABEL: ctz64_zero_undef:
259 ; CHECK-NEXT: .param i64{{$}}
260 ; CHECK-NEXT: .result i64{{$}}
261 ; CHECK-NEXT: @0{{$}}
262 ; CHECK-NEXT: set_local @1, pop{{$}}
263 ; CHECK-NEXT: ctz @1{{$}}
264 ; CHECK-NEXT: set_local @2, pop{{$}}
265 ; CHECK-NEXT: return @2{{$}}
189266 define i64 @ctz64_zero_undef(i64 %x) {
190267 %a = call i64 @llvm.cttz.i64(i64 %x, i1 true)
191268 ret i64 %a
192269 }
193270
194 ; CHECK-LABEL: (func $popcnt64
195 ; CHECK-NEXT: (param i64) (result i64)
196 ; CHECK-NEXT: (set_local @0 (argument 0))
197 ; CHECK-NEXT: (set_local @1 (popcnt @0))
198 ; CHECK-NEXT: (return @1)
271 ; CHECK-LABEL: popcnt64:
272 ; CHECK-NEXT: .param i64{{$}}
273 ; CHECK-NEXT: .result i64{{$}}
274 ; CHECK-NEXT: @0{{$}}
275 ; CHECK-NEXT: set_local @1, pop{{$}}
276 ; CHECK-NEXT: popcnt @1{{$}}
277 ; CHECK-NEXT: set_local @2, pop{{$}}
278 ; CHECK-NEXT: return @2{{$}}
199279 define i64 @popcnt64(i64 %x) {
200280 %a = call i64 @llvm.ctpop.i64(i64 %x)
201281 ret i64 %a
44 target datalayout = "e-p:32:32-i64:64-n32:64-S128"
55 target triple = "wasm32-unknown-unknown"
66
7 ; CHECK-LABEL: (func $zero_i32
8 ; CHECK-NEXT: (result i32)
9 ; CHECK-NEXT: (set_local @0 (immediate 0))
10 ; CHECK-NEXT: (return @0)
7 ; CHECK-LABEL: zero_i32:
8 ; CHECK-NEXT: .result i32{{$}}
9 ; CHECK-NEXT: i32.const 0{{$}}
10 ; CHECK-NEXT: set_local @0, pop{{$}}
11 ; CHECK-NEXT: return @0{{$}}
1112 define i32 @zero_i32() {
1213 ret i32 0
1314 }
1415
15 ; CHECK-LABEL: (func $one_i32
16 ; CHECK-NEXT: (result i32)
17 ; CHECK-NEXT: (set_local @0 (immediate 1))
18 ; CHECK-NEXT: (return @0)
16 ; CHECK-LABEL: one_i32:
17 ; CHECK-NEXT: .result i32{{$}}
18 ; CHECK-NEXT: i32.const 1{{$}}
19 ; CHECK-NEXT: set_local @0, pop{{$}}
20 ; CHECK-NEXT: return @0{{$}}
1921 define i32 @one_i32() {
2022 ret i32 1
2123 }
2224
23 ; CHECK-LABEL: (func $max_i32
24 ; CHECK-NEXT: (result i32)
25 ; CHECK-NEXT: (set_local @0 (immediate 2147483647))
26 ; CHECK-NEXT: (return @0)
25 ; CHECK-LABEL: max_i32:
26 ; CHECK-NEXT: .result i32{{$}}
27 ; CHECK-NEXT: i32.const 2147483647{{$}}
28 ; CHECK-NEXT: set_local @0, pop{{$}}
29 ; CHECK-NEXT: return @0{{$}}
2730 define i32 @max_i32() {
2831 ret i32 2147483647
2932 }
3033
31 ; CHECK-LABEL: (func $min_i32
32 ; CHECK-NEXT: (result i32)
33 ; CHECK-NEXT: (set_local @0 (immediate -2147483648))
34 ; CHECK-NEXT: (return @0)
34 ; CHECK-LABEL: min_i32:
35 ; CHECK-NEXT: .result i32{{$}}
36 ; CHECK-NEXT: i32.const -2147483648{{$}}
37 ; CHECK-NEXT: set_local @0, pop{{$}}
38 ; CHECK-NEXT: return @0{{$}}
3539 define i32 @min_i32() {
3640 ret i32 -2147483648
3741 }
3842
39 ; CHECK-LABEL: (func $zero_i64
40 ; CHECK-NEXT: (result i64)
41 ; CHECK-NEXT: (set_local @0 (immediate 0))
42 ; CHECK-NEXT: (return @0)
43 ; CHECK-LABEL: zero_i64:
44 ; CHECK-NEXT: .result i64{{$}}
45 ; CHECK-NEXT: i64.const 0{{$}}
46 ; CHECK-NEXT: set_local @0, pop{{$}}
47 ; CHECK-NEXT: return @0{{$}}
4348 define i64 @zero_i64() {
4449 ret i64 0
4550 }
4651
47 ; CHECK-LABEL: (func $one_i64
48 ; CHECK-NEXT: (result i64)
49 ; CHECK-NEXT: (set_local @0 (immediate 1))
50 ; CHECK-NEXT: (return @0)
52 ; CHECK-LABEL: one_i64:
53 ; CHECK-NEXT: .result i64{{$}}
54 ; CHECK-NEXT: i64.const 1{{$}}
55 ; CHECK-NEXT: set_local @0, pop{{$}}
56 ; CHECK-NEXT: return @0{{$}}
5157 define i64 @one_i64() {
5258 ret i64 1
5359 }
5460
55 ; CHECK-LABEL: (func $max_i64
56 ; CHECK-NEXT: (result i64)
57 ; CHECK-NEXT: (set_local @0 (immediate 9223372036854775807))
58 ; CHECK-NEXT: (return @0)
61 ; CHECK-LABEL: max_i64:
62 ; CHECK-NEXT: .result i64{{$}}
63 ; CHECK-NEXT: i64.const 9223372036854775807{{$}}
64 ; CHECK-NEXT: set_local @0, pop{{$}}
65 ; CHECK-NEXT: return @0{{$}}
5966 define i64 @max_i64() {
6067 ret i64 9223372036854775807
6168 }
6269
63 ; CHECK-LABEL: (func $min_i64
64 ; CHECK-NEXT: (result i64)
65 ; CHECK-NEXT: (set_local @0 (immediate -9223372036854775808))
66 ; CHECK-NEXT: (return @0)
70 ; CHECK-LABEL: min_i64:
71 ; CHECK-NEXT: .result i64{{$}}
72 ; CHECK-NEXT: i64.const -9223372036854775808{{$}}
73 ; CHECK-NEXT: set_local @0, pop{{$}}
74 ; CHECK-NEXT: return @0{{$}}
6775 define i64 @min_i64() {
6876 ret i64 -9223372036854775808
6977 }
7078
71 ; CHECK-LABEL: (func $negzero_f32
72 ; CHECK-NEXT: (result f32)
73 ; CHECK-NEXT: (set_local @0 (immediate -0x0p0))
74 ; CHECK-NEXT: (return @0)
79 ; CHECK-LABEL: negzero_f32:
80 ; CHECK-NEXT: .result f32{{$}}
81 ; CHECK-NEXT: f32.const -0x0p0{{$}}
82 ; CHECK-NEXT: set_local @0, pop{{$}}
83 ; CHECK-NEXT: return @0{{$}}
7584 define float @negzero_f32() {
7685 ret float -0.0
7786 }
7887
79 ; CHECK-LABEL: (func $zero_f32
80 ; CHECK-NEXT: (result f32)
81 ; CHECK-NEXT: (set_local @0 (immediate 0x0p0))
82 ; CHECK-NEXT: (return @0)
88 ; CHECK-LABEL: zero_f32:
89 ; CHECK-NEXT: .result f32{{$}}
90 ; CHECK-NEXT: f32.const 0x0p0{{$}}
91 ; CHECK-NEXT: set_local @0, pop{{$}}
92 ; CHECK-NEXT: return @0{{$}}
8393 define float @zero_f32() {
8494 ret float 0.0
8595 }
8696
87 ; CHECK-LABEL: (func $one_f32
88 ; CHECK-NEXT: (result f32)
89 ; CHECK-NEXT: (set_local @0 (immediate 0x1p0))
90 ; CHECK-NEXT: (return @0)
97 ; CHECK-LABEL: one_f32:
98 ; CHECK-NEXT: .result f32{{$}}
99 ; CHECK-NEXT: f32.const 0x1p0{{$}}
100 ; CHECK-NEXT: set_local @0, pop{{$}}
101 ; CHECK-NEXT: return @0{{$}}
91102 define float @one_f32() {
92103 ret float 1.0
93104 }
94105
95 ; CHECK-LABEL: (func $two_f32
96 ; CHECK-NEXT: (result f32)
97 ; CHECK-NEXT: (set_local @0 (immediate 0x1p1))
98 ; CHECK-NEXT: (return @0)
106 ; CHECK-LABEL: two_f32:
107 ; CHECK-NEXT: .result f32{{$}}
108 ; CHECK-NEXT: f32.const 0x1p1{{$}}
109 ; CHECK-NEXT: set_local @0, pop{{$}}
110 ; CHECK-NEXT: return @0{{$}}
99111 define float @two_f32() {
100112 ret float 2.0
101113 }
102114
103 ; CHECK-LABEL: (func $nan_f32
104 ; CHECK-NEXT: (result f32)
105 ; CHECK-NEXT: (set_local @0 (immediate nan))
106 ; CHECK-NEXT: (return @0)
115 ; CHECK-LABEL: nan_f32:
116 ; CHECK-NEXT: .result f32{{$}}
117 ; CHECK-NEXT: f32.const nan
118 ; CHECK-NEXT: set_local @0, pop{{$}}
119 ; CHECK-NEXT: return @0{{$}}
107120 define float @nan_f32() {
108121 ret float 0x7FF8000000000000
109122 }
110123
111 ; CHECK-LABEL: (func $negnan_f32
112 ; CHECK-NEXT: (result f32)
113 ; CHECK-NEXT: (set_local @0 (immediate -nan))
114 ; CHECK-NEXT: (return @0)
124 ; CHECK-LABEL: negnan_f32:
125 ; CHECK-NEXT: .result f32{{$}}
126 ; CHECK-NEXT: f32.const -nan
127 ; CHECK-NEXT: set_local @0, pop{{$}}
128 ; CHECK-NEXT: return @0{{$}}
115129 define float @negnan_f32() {
116130 ret float 0xFFF8000000000000
117131 }
118132
119 ; CHECK-LABEL: (func $inf_f32
120 ; CHECK-NEXT: (result f32)
121 ; CHECK-NEXT: (set_local @0 (immediate infinity))
122 ; CHECK-NEXT: (return @0)
133 ; CHECK-LABEL: inf_f32:
134 ; CHECK-NEXT: .result f32{{$}}
135 ; CHECK-NEXT: f32.const infinity
136 ; CHECK-NEXT: set_local @0, pop{{$}}
137 ; CHECK-NEXT: return @0{{$}}
123138 define float @inf_f32() {
124139 ret float 0x7FF0000000000000
125140 }
126141
127 ; CHECK-LABEL: (func $neginf_f32
128 ; CHECK-NEXT: (result f32)
129 ; CHECK-NEXT: (set_local @0 (immediate -infinity))
130 ; CHECK-NEXT: (return @0)
142 ; CHECK-LABEL: neginf_f32:
143 ; CHECK-NEXT: .result f32{{$}}
144 ; CHECK-NEXT: f32.const -infinity
145 ; CHECK-NEXT: set_local @0, pop{{$}}
146 ; CHECK-NEXT: return @0{{$}}
131147 define float @neginf_f32() {
132148 ret float 0xFFF0000000000000
133149 }
134150
135 ; CHECK-LABEL: (func $negzero_f64
136 ; CHECK-NEXT: (result f64)
137 ; CHECK-NEXT: (set_local @0 (immediate -0x0p0))
138 ; CHECK-NEXT: (return @0)
151 ; CHECK-LABEL: negzero_f64:
152 ; CHECK-NEXT: .result f64{{$}}
153 ; CHECK-NEXT: f64.const -0x0p0{{$}}
154 ; CHECK-NEXT: set_local @0, pop{{$}}
155 ; CHECK-NEXT: return @0{{$}}
139156 define double @negzero_f64() {
140157 ret double -0.0
141158 }
142159
143 ; CHECK-LABEL: (func $zero_f64
144 ; CHECK-NEXT: (result f64)
145 ; CHECK-NEXT: (set_local @0 (immediate 0x0p0))
146 ; CHECK-NEXT: (return @0)
160 ; CHECK-LABEL: zero_f64:
161 ; CHECK-NEXT: .result f64{{$}}
162 ; CHECK-NEXT: f64.const 0x0p0{{$}}
163 ; CHECK-NEXT: set_local @0, pop{{$}}
164 ; CHECK-NEXT: return @0{{$}}
147165 define double @zero_f64() {
148166 ret double 0.0
149167 }
150168
151 ; CHECK-LABEL: (func $one_f64
152 ; CHECK-NEXT: (result f64)
153 ; CHECK-NEXT: (set_local @0 (immediate 0x1p0))
154 ; CHECK-NEXT: (return @0)
169 ; CHECK-LABEL: one_f64:
170 ; CHECK-NEXT: .result f64{{$}}
171 ; CHECK-NEXT: f64.const 0x1p0{{$}}
172 ; CHECK-NEXT: set_local @0, pop{{$}}
173 ; CHECK-NEXT: return @0{{$}}
155174 define double @one_f64() {
156175 ret double 1.0
157176 }
158177
159 ; CHECK-LABEL: (func $two_f64
160 ; CHECK-NEXT: (result f64)
161 ; CHECK-NEXT: (set_local @0 (immediate 0x1p1))
162 ; CHECK-NEXT: (return @0)
178 ; CHECK-LABEL: two_f64:
179 ; CHECK-NEXT: .result f64{{$}}
180 ; CHECK-NEXT: f64.const 0x1p1{{$}}
181 ; CHECK-NEXT: set_local @0, pop{{$}}
182 ; CHECK-NEXT: return @0{{$}}
163183 define double @two_f64() {
164184 ret double 2.0
165185 }
166186
167 ; CHECK-LABEL: (func $nan_f64
168 ; CHECK-NEXT: (result f64)
169 ; CHECK-NEXT: (set_local @0 (immediate nan))
170 ; CHECK-NEXT: (return @0)
187 ; CHECK-LABEL: nan_f64:
188 ; CHECK-NEXT: .result f64{{$}}
189 ; CHECK-NEXT: f64.const nan
190 ; CHECK-NEXT: set_local @0, pop{{$}}
191 ; CHECK-NEXT: return @0{{$}}
171192 define double @nan_f64() {
172193 ret double 0x7FF8000000000000
173194 }
174195
175 ; CHECK-LABEL: (func $negnan_f64
176 ; CHECK-NEXT: (result f64)
177 ; CHECK-NEXT: (set_local @0 (immediate -nan))
178 ; CHECK-NEXT: (return @0)
196 ; CHECK-LABEL: negnan_f64:
197 ; CHECK-NEXT: .result f64{{$}}
198 ; CHECK-NEXT: f64.const -nan
199 ; CHECK-NEXT: set_local @0, pop{{$}}
200 ; CHECK-NEXT: return @0{{$}}
179201 define double @negnan_f64() {
180202 ret double 0xFFF8000000000000
181203 }
182204
183 ; CHECK-LABEL: (func $inf_f64
184 ; CHECK-NEXT: (result f64)
185 ; CHECK-NEXT: (set_local @0 (immediate infinity))
186 ; CHECK-NEXT: (return @0)
205 ; CHECK-LABEL: inf_f64:
206 ; CHECK-NEXT: .result f64{{$}}
207 ; CHECK-NEXT: f64.const infinity
208 ; CHECK-NEXT: set_local @0, pop{{$}}
209 ; CHECK-NEXT: return @0{{$}}
187210 define double @inf_f64() {
188211 ret double 0x7FF0000000000000
189212 }
190213
191 ; CHECK-LABEL: (func $neginf_f64
192 ; CHECK-NEXT: (result f64)
193 ; CHECK-NEXT: (set_local @0 (immediate -infinity))
194 ; CHECK-NEXT: (return @0)
214 ; CHECK-LABEL: neginf_f64:
215 ; CHECK-NEXT: .result f64{{$}}
216 ; CHECK-NEXT: f64.const -infinity
217 ; CHECK-NEXT: set_local @0, pop{{$}}
218 ; CHECK-NEXT: return @0{{$}}
195219 define double @neginf_f64() {
196220 ret double 0xFFF0000000000000
197221 }
44 target datalayout = "e-p:32:32-i64:64-n32:64-S128"
55 target triple = "wasm32-unknown-unknown"
66