Skip to content

Commit 1a234ec

Browse files
committed
rebase
Change-Id: I77f0f79e2c1057fa48db53be37e8a74af50c42e8
1 parent b523352 commit 1a234ec

File tree

2 files changed

+23
-19
lines changed

2 files changed

+23
-19
lines changed

llvm/lib/CodeGen/CodeGenPrepare.cpp

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6431,8 +6431,10 @@ bool CodeGenPrepare::optimizeUMulWithOverflow(Instruction *I) {
64316431
unsigned VTHalfBitWidth = VTBitWidth / 2;
64326432
auto *LegalTy = IntegerType::getIntNTy(I->getContext(), VTHalfBitWidth);
64336433

6434-
// Skip the optimizaiton if the type with HalfBitWidth is not legal for the target.
6435-
if (TLI->getTypeAction(I->getContext(), TLI->getValueType(*DL, LegalTy)) != TargetLowering::TypeLegal)
6434+
// Skip the optimizaiton if the type with HalfBitWidth is not legal for the
6435+
// target.
6436+
if (TLI->getTypeAction(I->getContext(), TLI->getValueType(*DL, LegalTy)) !=
6437+
TargetLowering::TypeLegal)
64366438
return false;
64376439

64386440
I->getParent()->setName("overflow.res");
@@ -6463,9 +6465,9 @@ bool CodeGenPrepare::optimizeUMulWithOverflow(Instruction *I) {
64636465
auto *HiLHS = Builder.CreateTrunc(ShrHiLHS, LegalTy, "hi.lhs.trunc");
64646466

64656467
auto *CmpLHS = Builder.CreateCmp(ICmpInst::ICMP_NE, HiLHS,
6466-
ConstantInt::getNullValue(LegalTy));
6468+
ConstantInt::getNullValue(LegalTy));
64676469
auto *CmpRHS = Builder.CreateCmp(ICmpInst::ICMP_NE, HiRHS,
6468-
ConstantInt::getNullValue(LegalTy));
6470+
ConstantInt::getNullValue(LegalTy));
64696471
auto *Or = Builder.CreateOr(CmpLHS, CmpRHS, "or.lhs.rhs");
64706472
Builder.CreateCondBr(Or, OverflowBB, NoOverflowBB);
64716473
OverflowoEntryBB->getTerminator()->eraseFromParent();
@@ -6476,14 +6478,14 @@ bool CodeGenPrepare::optimizeUMulWithOverflow(Instruction *I) {
64766478
auto *ExtLoLHS = Builder.CreateZExt(LoLHS, Ty, "lo.lhs.ext");
64776479
auto *ExtLoRHS = Builder.CreateZExt(LoRHS, Ty, "lo.rhs.ext");
64786480
auto *Mul = Builder.CreateMul(ExtLoLHS, ExtLoRHS, "mul.no.overflow");
6479-
StructType *STy = StructType::get(I->getContext(),
6480-
{Ty, IntegerType::getInt1Ty(I->getContext())});
6481+
StructType *STy = StructType::get(
6482+
I->getContext(), {Ty, IntegerType::getInt1Ty(I->getContext())});
64816483
Value *StructValNoOverflow = PoisonValue::get(STy);
64826484
StructValNoOverflow =
6483-
Builder.CreateInsertValue(StructValNoOverflow, Mul, {0});
6485+
Builder.CreateInsertValue(StructValNoOverflow, Mul, {0});
64846486
StructValNoOverflow = Builder.CreateInsertValue(
64856487
StructValNoOverflow, ConstantInt::getFalse(I->getContext()), {1});
6486-
Builder.CreateBr(OverflowResBB);
6488+
Builder.CreateBr(OverflowResBB);
64876489

64886490
//------------------------------------------------------------------------------
64896491
// BB overflow.res:
@@ -6528,8 +6530,10 @@ bool CodeGenPrepare::optimizeSMulWithOverflow(Instruction *I) {
65286530
unsigned VTHalfBitWidth = VTBitWidth / 2;
65296531
auto *LegalTy = IntegerType::getIntNTy(I->getContext(), VTHalfBitWidth);
65306532

6531-
// Skip the optimizaiton if the type with HalfBitWidth is not legal for the target.
6532-
if (TLI->getTypeAction(I->getContext(), TLI->getValueType(*DL, LegalTy)) != TargetLowering::TypeLegal)
6533+
// Skip the optimizaiton if the type with HalfBitWidth is not legal for the
6534+
// target.
6535+
if (TLI->getTypeAction(I->getContext(), TLI->getValueType(*DL, LegalTy)) !=
6536+
TargetLowering::TypeLegal)
65336537
return false;
65346538

65356539
I->getParent()->setName("overflow.res");
@@ -6554,13 +6558,13 @@ bool CodeGenPrepare::optimizeSMulWithOverflow(Instruction *I) {
65546558
IRBuilder<> Builder(OverflowoEntryBB->getTerminator());
65556559
auto *LoRHS = Builder.CreateTrunc(RHS, LegalTy, "lo.rhs");
65566560
auto *SignLoRHS =
6557-
Builder.CreateAShr(LoRHS, VTHalfBitWidth - 1, "sign.lo.rhs");
6561+
Builder.CreateAShr(LoRHS, VTHalfBitWidth - 1, "sign.lo.rhs");
65586562
auto *HiRHS = Builder.CreateLShr(RHS, VTHalfBitWidth, "rhs.lsr");
65596563
HiRHS = Builder.CreateTrunc(HiRHS, LegalTy, "hi.rhs");
65606564

65616565
auto *LoLHS = Builder.CreateTrunc(LHS, LegalTy, "lo.lhs");
65626566
auto *SignLoLHS =
6563-
Builder.CreateAShr(LoLHS, VTHalfBitWidth - 1, "sign.lo.lhs");
6567+
Builder.CreateAShr(LoLHS, VTHalfBitWidth - 1, "sign.lo.lhs");
65646568
auto *HiLHS = Builder.CreateLShr(LHS, VTHalfBitWidth, "lhs.lsr");
65656569
HiLHS = Builder.CreateTrunc(HiLHS, LegalTy, "hi.lhs");
65666570

@@ -6576,14 +6580,14 @@ bool CodeGenPrepare::optimizeSMulWithOverflow(Instruction *I) {
65766580
auto *ExtLoLHS = Builder.CreateSExt(LoLHS, Ty, "lo.lhs.ext");
65776581
auto *ExtLoRHS = Builder.CreateSExt(LoRHS, Ty, "lo.rhs.ext");
65786582
auto *Mul = Builder.CreateMul(ExtLoLHS, ExtLoRHS, "mul.no.overflow");
6579-
StructType * STy = StructType::get(I->getContext(),
6580-
{Ty, IntegerType::getInt1Ty(I->getContext())});
6583+
StructType *STy = StructType::get(
6584+
I->getContext(), {Ty, IntegerType::getInt1Ty(I->getContext())});
65816585
Value *StructValNoOverflow = PoisonValue::get(STy);
65826586
StructValNoOverflow =
6583-
Builder.CreateInsertValue(StructValNoOverflow, Mul, {0});
6587+
Builder.CreateInsertValue(StructValNoOverflow, Mul, {0});
65846588
StructValNoOverflow = Builder.CreateInsertValue(
65856589
StructValNoOverflow, ConstantInt::getFalse(I->getContext()), {1});
6586-
Builder.CreateBr(OverflowResBB);
6590+
Builder.CreateBr(OverflowResBB);
65876591

65886592
//------------------------------------------------------------------------------
65896593
// BB overflow.res:

llvm/test/CodeGen/X86/umulo-128-legalisation-lowering.ll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ define { i128, i8 } @muloti_test(i128 %l, i128 %r) unnamed_addr #0 {
3838
; X86-NEXT: .cfi_def_cfa_offset 16
3939
; X86-NEXT: pushl %esi
4040
; X86-NEXT: .cfi_def_cfa_offset 20
41-
; X86-NEXT: subl $24, %esp
42-
; X86-NEXT: .cfi_def_cfa_offset 44
41+
; X86-NEXT: subl $28, %esp
42+
; X86-NEXT: .cfi_def_cfa_offset 48
4343
; X86-NEXT: .cfi_offset %esi, -20
4444
; X86-NEXT: .cfi_offset %edi, -16
4545
; X86-NEXT: .cfi_offset %ebx, -12
@@ -147,7 +147,7 @@ define { i128, i8 } @muloti_test(i128 %l, i128 %r) unnamed_addr #0 {
147147
; X86-NEXT: andb $1, %al
148148
; X86-NEXT: movb %al, 16(%ecx)
149149
; X86-NEXT: movl %ecx, %eax
150-
; X86-NEXT: addl $24, %esp
150+
; X86-NEXT: addl $28, %esp
151151
; X86-NEXT: .cfi_def_cfa_offset 20
152152
; X86-NEXT: popl %esi
153153
; X86-NEXT: .cfi_def_cfa_offset 16

0 commit comments

Comments
 (0)