aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/Transforms/NaCl/PromoteIntegers.cpp6
-rw-r--r--test/Transforms/NaCl/promote-integers.ll17
2 files changed, 20 insertions, 3 deletions
diff --git a/lib/Transforms/NaCl/PromoteIntegers.cpp b/lib/Transforms/NaCl/PromoteIntegers.cpp
index 017e4976f2..97fb08fb55 100644
--- a/lib/Transforms/NaCl/PromoteIntegers.cpp
+++ b/lib/Transforms/NaCl/PromoteIntegers.cpp
@@ -19,7 +19,7 @@
// Limitations:
// 1) It can't change function signatures or global variables
// 2) It won't promote (and can't expand) types larger than i64
-// 3) Doesn't support mul/div operators
+// 3) Doesn't support div operators
// 4) Doesn't handle arrays or structs (or GEPs) with illegal types
// 5) Doesn't handle constant expressions
//
@@ -517,6 +517,7 @@ static void convertInstruction(Instruction *Inst, ConversionState &State) {
// overflow. So clear them now.
case Instruction::Add:
case Instruction::Sub:
+ case Instruction::Mul:
if (!(Binop->hasNoUnsignedWrap() && Binop->hasNoSignedWrap()))
NewInst = getClearUpper(NewInst, Binop->getType(), Binop);
break;
@@ -529,10 +530,9 @@ static void convertInstruction(Instruction *Inst, ConversionState &State) {
NewInst = getClearUpper(NewInst, Binop->getType(), Binop);
break;
// We should not see FP operators here.
- // We don't handle mul/div.
+ // We don't handle div.
case Instruction::FAdd:
case Instruction::FSub:
- case Instruction::Mul:
case Instruction::FMul:
case Instruction::UDiv:
case Instruction::SDiv:
diff --git a/test/Transforms/NaCl/promote-integers.ll b/test/Transforms/NaCl/promote-integers.ll
index 7fca6e1078..8d7ebac28e 100644
--- a/test/Transforms/NaCl/promote-integers.ll
+++ b/test/Transforms/NaCl/promote-integers.ll
@@ -168,6 +168,23 @@ define void @add1(i16 %a) {
ret void
}
+; CHECK: @mul1
+define void @mul1(i32 %a, i32 %b) {
+; CHECK-NEXT: %a33.sext = sext i32 %a to i64
+; CHECK-NEXT: %a33 = and i64 %a33.sext, 8589934591
+ %a33 = sext i32 %a to i33
+; CHECK-NEXT: %b33.sext = sext i32 %b to i64
+; CHECK-NEXT: %b33 = and i64 %b33.sext, 8589934591
+ %b33 = sext i32 %b to i33
+; CHECK-NEXT: %product.result = mul i64 %a33, %b33
+; CHECK-NEXT: %product = and i64 %product.result, 8589934591
+ %product = mul i33 %a33, %b33
+; CHECK-NEXT: %prodnw = mul nuw nsw i64 %a33, %b33
+; CHECK-NOT: and
+ %prodnw = mul nuw nsw i33 %a33, %b33
+ ret void
+}
+
; CHECK: @shl1
define void @shl1(i16 %a) {
%a24 = zext i16 %a to i24