History

arm64: Optimise some integer operations with a constant operand.

Edmund Grimley Evans committed 11 years ago

Commit d854ded1 parent ac70e6b3 files · +243 −2Browse files

Showing the changes to tests (2 of 3 files). Show all

Unified · Split

2 files
  1. tests/tests2/73_arm64.c +83 −0
  2. tests/tests2/73_arm64.expect +36 −0
tests/tests2/73_arm64.c+83−0
@@ -2,6 +2,7 @@ · 1 unmodified line
22 // calling convention, but should give the same results on any architecture.
33
44 #include <stdarg.h>
5+#include <stdint.h>
56 #include <stdio.h>
67
78 struct s1 { char x[1]; } s1 = { "0" };
@@ -429,12 +430,94 @@ void movi(void) · 421 unmodified lines
429430 pll(0xabcdef0123456789);
430431 }
431432
433+static uint32_t addip0(uint32_t x) { return x + 0; }
434+static uint64_t sublp0(uint64_t x) { return x - 0; }
435+static uint32_t addip123(uint32_t x) { return x + 123; }
436+static uint64_t addlm123(uint64_t x) { return x + -123; }
437+static uint64_t sublp4095(uint64_t x) { return x - 4095; }
438+static uint32_t subim503808(uint32_t x) { return x - -503808; }
439+static uint64_t addp12345(uint64_t x) { return x + 12345; }
440+static uint32_t subp12345(uint32_t x) { return x - 12345; }
441+
442+static uint32_t mvni(uint32_t x) { return 0xffffffff - x; }
443+static uint64_t negl(uint64_t x) { return 0 - x; }
444+static uint32_t rsbi123(uint32_t x) { return 123 - x; }
445+static uint64_t rsbl123(uint64_t x) { return 123 - x; }
446+
447+static uint32_t andi0(uint32_t x) { return x & 0; }
448+static uint64_t andlm1(uint64_t x) { return x & -1; }
449+static uint64_t orrl0(uint64_t x) { return x | 0; }
450+static uint32_t orrim1(uint32_t x) { return x | -1; }
451+static uint32_t eori0(uint32_t x) { return x ^ 0; }
452+static uint64_t eorlm1(uint64_t x) { return x ^ -1; }
453+static uint32_t and0xf0(uint32_t x) { return x & 0xf0; }
454+static uint64_t orr0xf0(uint64_t x) { return x | 0xf0; }
455+static uint64_t eor0xf0(uint64_t x) { return x ^ 0xf0; }
456+
457+static uint32_t lsli0(uint32_t x) { return x << 0; }
458+static uint32_t lsri0(uint32_t x) { return x >> 0; }
459+static int64_t asrl0(int64_t x) { return x >> 0; }
460+static uint32_t lsli1(uint32_t x) { return x << 1; }
461+static uint32_t lsli31(uint32_t x) { return x << 31; }
462+static uint64_t lsll1(uint64_t x) { return x << 1; }
463+static uint64_t lsll63(uint64_t x) { return x << 63; }
464+static uint32_t lsri1(uint32_t x) { return x >> 1; }
465+static uint32_t lsri31(uint32_t x) { return x >> 31; }
466+static uint64_t lsrl1(uint64_t x) { return x >> 1; }
467+static uint64_t lsrl63(uint64_t x) { return x >> 63; }
468+static int32_t asri1(int32_t x) { return x >> 1; }
469+static int32_t asri31(int32_t x) { return x >> 31; }
470+static int64_t asrl1(int64_t x) { return x >> 1; }
471+static int64_t asrl63(int64_t x) { return x >> 63; }
472+
473+void opi(void)
474+{
475+ int x = 1000;
476+ pll(addip0(x));
477+ pll(sublp0(x));
478+ pll(addip123(x));
479+ pll(addlm123(x));
480+ pll(sublp4095(x));
481+ pll(subim503808(x));
482+ pll(addp12345(x));
483+ pll(subp12345(x));
484+ pll(mvni(x));
485+ pll(negl(x));
486+ pll(rsbi123(x));
487+ pll(rsbl123(x));
488+ pll(andi0(x));
489+ pll(andlm1(x));
490+ pll(orrl0(x));
491+ pll(orrim1(x));
492+ pll(eori0(x));
493+ pll(eorlm1(x));
494+ pll(and0xf0(x));
495+ pll(orr0xf0(x));
496+ pll(eor0xf0(x));
497+ pll(lsli0(x));
498+ pll(lsri0(x));
499+ pll(asrl0(x));
500+ pll(lsli1(x));
501+ pll(lsli31(x));
502+ pll(lsll1(x));
503+ pll(lsll63(x));
504+ pll(lsri1(x));
505+ pll(lsri31(x));
506+ pll(lsrl1(x));
507+ pll(lsrl63(x));
508+ pll(asri1(x));
509+ pll(asri31(x));
510+ pll(asrl1(x));
511+ pll(asrl63(x));
512+}
513+
432514 void pcs(void)
433515 {
434516 arg();
435517 ret();
436518 stdarg();
437519 movi();
520+ opi();
438521 }
439522
440523 int main()
tests/tests2/73_arm64.expect+36−0
@@ -136,3 +136,39 @@ abcd1234ffffffff · 135 unmodified lines
136136 ffffef0123456789
137137 abcdef012345ffff
138138 abcdef0123456789
139+3e8
140+3e8
141+463
142+36d
143+fffffffffffff3e9
144+7b3e8
145+3421
146+ffffd3af
147+fffffc17
148+fffffffffffffc18
149+fffffc93
150+fffffffffffffc93
151+0
152+3e8
153+3e8
154+ffffffff
155+3e8
156+fffffffffffffc17
157+e0
158+3f8
159+318
160+3e8
161+3e8
162+3e8
163+7d0
164+0
165+7d0
166+0
167+1f4
168+0
169+1f4
170+0
171+1f4
172+0
173+1f4
174+0

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t