Skip to content

Commit cd23298

Browse files
committed
rebase
Change-Id: I77f0f79e2c1057fa48db53be37e8a74af50c42e8
1 parent cd2815f commit cd23298

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
@@ -6417,8 +6417,10 @@ bool CodeGenPrepare::optimizeUMulWithOverflow(Instruction *I) {
64176417
unsigned VTHalfBitWidth = VTBitWidth / 2;
64186418
auto *LegalTy = IntegerType::getIntNTy(I->getContext(), VTHalfBitWidth);
64196419

6420-
// Skip the optimizaiton if the type with HalfBitWidth is not legal for the target.
6421-
if (TLI->getTypeAction(I->getContext(), TLI->getValueType(*DL, LegalTy)) != TargetLowering::TypeLegal)
6420+
// Skip the optimizaiton if the type with HalfBitWidth is not legal for the
6421+
// target.
6422+
if (TLI->getTypeAction(I->getContext(), TLI->getValueType(*DL, LegalTy)) !=
6423+
TargetLowering::TypeLegal)
64226424
return false;
64236425

64246426
I->getParent()->setName("overflow.res");
@@ -6449,9 +6451,9 @@ bool CodeGenPrepare::optimizeUMulWithOverflow(Instruction *I) {
64496451
auto *HiLHS = Builder.CreateTrunc(ShrHiLHS, LegalTy, "hi.lhs.trunc");
64506452

64516453
auto *CmpLHS = Builder.CreateCmp(ICmpInst::ICMP_NE, HiLHS,
6452-
ConstantInt::getNullValue(LegalTy));
6454+
ConstantInt::getNullValue(LegalTy));
64536455
auto *CmpRHS = Builder.CreateCmp(ICmpInst::ICMP_NE, HiRHS,
6454-
ConstantInt::getNullValue(LegalTy));
6456+
ConstantInt::getNullValue(LegalTy));
64556457
auto *Or = Builder.CreateOr(CmpLHS, CmpRHS, "or.lhs.rhs");
64566458
Builder.CreateCondBr(Or, OverflowBB, NoOverflowBB);
64576459
OverflowoEntryBB->getTerminator()->eraseFromParent();
@@ -6462,14 +6464,14 @@ bool CodeGenPrepare::optimizeUMulWithOverflow(Instruction *I) {
64626464
auto *ExtLoLHS = Builder.CreateZExt(LoLHS, Ty, "lo.lhs.ext");
64636465
auto *ExtLoRHS = Builder.CreateZExt(LoRHS, Ty, "lo.rhs.ext");
64646466
auto *Mul = Builder.CreateMul(ExtLoLHS, ExtLoRHS, "mul.no.overflow");
6465-
StructType *STy = StructType::get(I->getContext(),
6466-
{Ty, IntegerType::getInt1Ty(I->getContext())});
6467+
StructType *STy = StructType::get(
6468+
I->getContext(), {Ty, IntegerType::getInt1Ty(I->getContext())});
64676469
Value *StructValNoOverflow = PoisonValue::get(STy);
64686470
StructValNoOverflow =
6469-
Builder.CreateInsertValue(StructValNoOverflow, Mul, {0});
6471+
Builder.CreateInsertValue(StructValNoOverflow, Mul, {0});
64706472
StructValNoOverflow = Builder.CreateInsertValue(
64716473
StructValNoOverflow, ConstantInt::getFalse(I->getContext()), {1});
6472-
Builder.CreateBr(OverflowResBB);
6474+
Builder.CreateBr(OverflowResBB);
64736475

64746476
//------------------------------------------------------------------------------
64756477
// BB overflow.res:
@@ -6514,8 +6516,10 @@ bool CodeGenPrepare::optimizeSMulWithOverflow(Instruction *I) {
65146516
unsigned VTHalfBitWidth = VTBitWidth / 2;
65156517
auto *LegalTy = IntegerType::getIntNTy(I->getContext(), VTHalfBitWidth);
65166518

6517-
// Skip the optimizaiton if the type with HalfBitWidth is not legal for the target.
6518-
if (TLI->getTypeAction(I->getContext(), TLI->getValueType(*DL, LegalTy)) != TargetLowering::TypeLegal)
6519+
// Skip the optimizaiton if the type with HalfBitWidth is not legal for the
6520+
// target.
6521+
if (TLI->getTypeAction(I->getContext(), TLI->getValueType(*DL, LegalTy)) !=
6522+
TargetLowering::TypeLegal)
65196523
return false;
65206524

65216525
I->getParent()->setName("overflow.res");
@@ -6540,13 +6544,13 @@ bool CodeGenPrepare::optimizeSMulWithOverflow(Instruction *I) {
65406544
IRBuilder<> Builder(OverflowoEntryBB->getTerminator());
65416545
auto *LoRHS = Builder.CreateTrunc(RHS, LegalTy, "lo.rhs");
65426546
auto *SignLoRHS =
6543-
Builder.CreateAShr(LoRHS, VTHalfBitWidth - 1, "sign.lo.rhs");
6547+
Builder.CreateAShr(LoRHS, VTHalfBitWidth - 1, "sign.lo.rhs");
65446548
auto *HiRHS = Builder.CreateLShr(RHS, VTHalfBitWidth, "rhs.lsr");
65456549
HiRHS = Builder.CreateTrunc(HiRHS, LegalTy, "hi.rhs");
65466550

65476551
auto *LoLHS = Builder.CreateTrunc(LHS, LegalTy, "lo.lhs");
65486552
auto *SignLoLHS =
6549-
Builder.CreateAShr(LoLHS, VTHalfBitWidth - 1, "sign.lo.lhs");
6553+
Builder.CreateAShr(LoLHS, VTHalfBitWidth - 1, "sign.lo.lhs");
65506554
auto *HiLHS = Builder.CreateLShr(LHS, VTHalfBitWidth, "lhs.lsr");
65516555
HiLHS = Builder.CreateTrunc(HiLHS, LegalTy, "hi.lhs");
65526556

@@ -6562,14 +6566,14 @@ bool CodeGenPrepare::optimizeSMulWithOverflow(Instruction *I) {
65626566
auto *ExtLoLHS = Builder.CreateSExt(LoLHS, Ty, "lo.lhs.ext");
65636567
auto *ExtLoRHS = Builder.CreateSExt(LoRHS, Ty, "lo.rhs.ext");
65646568
auto *Mul = Builder.CreateMul(ExtLoLHS, ExtLoRHS, "mul.no.overflow");
6565-
StructType * STy = StructType::get(I->getContext(),
6566-
{Ty, IntegerType::getInt1Ty(I->getContext())});
6569+
StructType *STy = StructType::get(
6570+
I->getContext(), {Ty, IntegerType::getInt1Ty(I->getContext())});
65676571
Value *StructValNoOverflow = PoisonValue::get(STy);
65686572
StructValNoOverflow =
6569-
Builder.CreateInsertValue(StructValNoOverflow, Mul, {0});
6573+
Builder.CreateInsertValue(StructValNoOverflow, Mul, {0});
65706574
StructValNoOverflow = Builder.CreateInsertValue(
65716575
StructValNoOverflow, ConstantInt::getFalse(I->getContext()), {1});
6572-
Builder.CreateBr(OverflowResBB);
6576+
Builder.CreateBr(OverflowResBB);
65736577

65746578
//------------------------------------------------------------------------------
65756579
// 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)