diff options
-rw-r--r-- | clang/lib/CodeGen/CGExprScalar.cpp | 2 | ||||
-rw-r--r-- | clang/test/CodeGen/pr13704.c | 9 |
2 files changed, 10 insertions, 1 deletions
diff --git a/clang/lib/CodeGen/CGExprScalar.cpp b/clang/lib/CodeGen/CGExprScalar.cpp index f304317756b..58692f5cb35 100644 --- a/clang/lib/CodeGen/CGExprScalar.cpp +++ b/clang/lib/CodeGen/CGExprScalar.cpp @@ -1306,7 +1306,7 @@ ScalarExprEmitter::EmitScalarPrePostIncDec(const UnaryOperator *E, LValue LV, // 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. diff --git a/clang/test/CodeGen/pr13704.c b/clang/test/CodeGen/pr13704.c new file mode 100644 index 00000000000..41b8b2cc710 --- /dev/null +++ b/clang/test/CodeGen/pr13704.c @@ -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 +} |