[cfe-commits] r162766 - in /cfe/trunk: lib/CodeGen/CGExprScalar.cpp test/CodeGen/pr13704.c
Michael Liao
michael.liao at intel.com
Tue Aug 28 09:55:13 PDT 2012
Author: hliao
Date: Tue Aug 28 11:55:13 2012
New Revision: 162766
URL: http://llvm.org/viewvc/llvm-project?rev=162766&view=rev
Log:
Fix PR13704
- The increment needs to be signed value to preserve the original value when
its data type is larger than 64-bit integer.
Added:
cfe/trunk/test/CodeGen/pr13704.c
Modified:
cfe/trunk/lib/CodeGen/CGExprScalar.cpp
Modified: cfe/trunk/lib/CodeGen/CGExprScalar.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprScalar.cpp?rev=162766&r1=162765&r2=162766&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExprScalar.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprScalar.cpp Tue Aug 28 11:55:13 2012
@@ -1306,7 +1306,7 @@
// Most common case by far: integer increment.
} else if (type->isIntegerType()) {
- llvm::Value *amt = llvm::ConstantInt::get(value->getType(), amount);
+ llvm::Value *amt = llvm::ConstantInt::get(value->getType(), amount, true);
// Note that signed integer inc/dec with width less than int can't
// overflow because of promotion rules; we're just eliding a few steps here.
Added: cfe/trunk/test/CodeGen/pr13704.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/pr13704.c?rev=162766&view=auto
==============================================================================
--- cfe/trunk/test/CodeGen/pr13704.c (added)
+++ cfe/trunk/test/CodeGen/pr13704.c Tue Aug 28 11:55:13 2012
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
+extern void foo(__int128);
+
+void bar() {
+ __int128 x = 2;
+ x--;
+ foo(x);
+// CHECK: add nsw i128 %0, -1
+}
More information about the cfe-commits
mailing list