Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(842)

Unified Diff: tests_lit/llvm2ice_tests/div_legalization.ll

Issue 339643003: Legalize div/idiv operands to avoid immediates. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: default args Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/IceTargetLoweringX8632.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests_lit/llvm2ice_tests/div_legalization.ll
diff --git a/tests_lit/llvm2ice_tests/div_legalization.ll b/tests_lit/llvm2ice_tests/div_legalization.ll
new file mode 100644
index 0000000000000000000000000000000000000000..2088eff679920b6b5151c00d7369b55e3d283190
--- /dev/null
+++ b/tests_lit/llvm2ice_tests/div_legalization.ll
@@ -0,0 +1,68 @@
+; This is a regression test that idiv and div operands are legalized
+; (they cannot be constants and can only be reg/mem for x86).
+
+; RUN: %llvm2ice -O2 --verbose none %s | FileCheck %s
+; RUN: %llvm2ice -Om1 --verbose none %s | FileCheck %s
+; RUN: %llvm2ice --verbose none %s | FileCheck --check-prefix=ERRORS %s
+; RUN: %llvm2iceinsts %s | %szdiff %s | FileCheck --check-prefix=DUMP %s
+; RUN: %llvm2iceinsts --pnacl %s | %szdiff %s \
+; RUN: | FileCheck --check-prefix=DUMP %s
+
+define i32 @Sdiv_const8_b(i8 %a) {
+; CHECK-LABEL: Sdiv_const8_b
+entry:
+ %div = sdiv i8 %a, 12
+; CHECK: mov {{.*}}, 12
+; CHECK-NOT: idiv 12
+ %div_ext = sext i8 %div to i32
+ ret i32 %div_ext
+}
+
+define i32 @Sdiv_const16_b(i16 %a) {
+; CHECK-LABEL: Sdiv_const16_b
+entry:
+ %div = sdiv i16 %a, 1234
+; CHECK: mov {{.*}}, 1234
+; CHECK-NOT: idiv 1234
+ %div_ext = sext i16 %div to i32
+ ret i32 %div_ext
+}
+
+define i32 @Sdiv_const32_b(i32 %a) {
+; CHECK-LABEL: Sdiv_const32_b
+entry:
+ %div = sdiv i32 %a, 1234
+; CHECK: mov {{.*}}, 1234
+; CHECK-NOT: idiv 1234
+ ret i32 %div
+}
+
+define i32 @Srem_const_b(i32 %a) {
+; CHECK-LABEL: Srem_const_b
+entry:
+ %rem = srem i32 %a, 2345
+; CHECK: mov {{.*}}, 2345
+; CHECK-NOT: idiv 2345
+ ret i32 %rem
+}
+
+define i32 @Udiv_const_b(i32 %a) {
+; CHECK-LABEL: Udiv_const_b
+entry:
+ %div = udiv i32 %a, 3456
+; CHECK: mov {{.*}}, 3456
+; CHECK-NOT: div 3456
+ ret i32 %div
+}
+
+define i32 @Urem_const_b(i32 %a) {
+; CHECK-LABEL: Urem_const_b
+entry:
+ %rem = urem i32 %a, 4567
+; CHECK: mov {{.*}}, 4567
+; CHECK-NOT: div 4567
+ ret i32 %rem
+}
+
+; ERRORS-NOT: ICE translation error
+; DUMP-NOT: SZ
« no previous file with comments | « src/IceTargetLoweringX8632.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698