[pkg-d-commits] [ldc] 48/74: Zero-extend Boolean parameters and return values

Matthias Klumpp mak at moszumanska.debian.org
Thu Jul 13 20:54:18 UTC 2017


This is an automated email from the git hooks/post-receive script.

mak pushed a commit to annotated tag v1.3.0-beta2
in repository ldc.

commit c9b2571a442ab961011a3770977adab7cb455479
Author: Martin <noone at nowhere.com>
Date:   Thu May 25 02:45:24 2017 +0200

    Zero-extend Boolean parameters and return values
---
 gen/tollvm.cpp         | 19 ++-----------------
 tests/codegen/gh2131.d | 18 ++++++++----------
 2 files changed, 10 insertions(+), 27 deletions(-)

diff --git a/gen/tollvm.cpp b/gen/tollvm.cpp
index c76c890..3e87c7d 100644
--- a/gen/tollvm.cpp
+++ b/gen/tollvm.cpp
@@ -56,24 +56,9 @@ bool DtoIsReturnInArg(CallExp *ce) {
 
 LLAttribute DtoShouldExtend(Type *type) {
   type = type->toBasetype();
-  if (type->isintegral()) {
-    switch (type->ty) {
-    case Tint8:
-    case Tint16:
-      return LLAttribute::SExt;
-
-    case Tuns8:
-    case Tuns16:
-    case Tchar:
-    case Twchar:
-      return LLAttribute::ZExt;
-
-    default:
-      // Do not extend.
-      break;
-    }
+  if (type->isintegral() && type->ty != Tvector && type->size() <= 2) {
+    return type->isunsigned() ? LLAttribute::ZExt : LLAttribute::SExt;
   }
-
   return LLAttribute::None;
 }
 
diff --git a/tests/codegen/gh2131.d b/tests/codegen/gh2131.d
index bd58b79..ae49ca6 100644
--- a/tests/codegen/gh2131.d
+++ b/tests/codegen/gh2131.d
@@ -1,17 +1,15 @@
-// RUN: %ldc -O3 -enable-cross-module-inlining -output-ll -of=%t.ll %s && FileCheck %s < %t.ll
+// RUN: %ldc -O3 -output-ll -of=%t.ll %s && FileCheck %s < %t.ll
 
-import core.checkedint;
-
-alias T = size_t;
-
-// CHECK: define {{.*}}@{{.*}}_D6gh21313foo
-T foo(T x, T y, ref bool overflow)
+// CHECK:      define {{.*}}zeroext {{.*}}@{{.*}}_D6gh21313foo
+// CHECK-SAME: i1 zeroext %x_arg
+bool foo(bool x, ref bool o)
 {
     // CHECK-NOT: and i8
-    // CHECK: load i8{{.*}}, !range ![[META:[0-9]+]]
+    // CHECK:     load i8{{.*}}, !range ![[META:[0-9]+]]
     // CHECK-NOT: and i8
-    // CHECK: ret
-    return mulu(x, y, overflow);
+    o |= x;
+    // CHECK:     ret
+    return o;
 }
 
 // CHECK: ![[META]] = {{.*}}!{i8 0, i8 2}

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-d/ldc.git



More information about the pkg-d-commits mailing list