[PATCH] D123174: [TypePromotion] Promote undef by converting to 0.

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu May 12 09:10:19 PDT 2022


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGcec249c60dad: [TypePromotion] Promote undef by converting to 0. (authored by craig.topper).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D123174/new/

https://reviews.llvm.org/D123174

Files:
  llvm/lib/CodeGen/TypePromotion.cpp
  llvm/test/CodeGen/AArch64/typepromotion-phisret.ll
  llvm/test/Transforms/TypePromotion/AArch64/trunc-zext-chain.ll
  llvm/test/Transforms/TypePromotion/ARM/phis-ret.ll


Index: llvm/test/Transforms/TypePromotion/ARM/phis-ret.ll
===================================================================
--- llvm/test/Transforms/TypePromotion/ARM/phis-ret.ll
+++ llvm/test/Transforms/TypePromotion/ARM/phis-ret.ll
@@ -227,7 +227,7 @@
 ; CHECK-NEXT:  entry:
 ; CHECK-NEXT:    br label [[LOOP:%.*]]
 ; CHECK:       loop:
-; CHECK-NEXT:    [[VAL:%.*]] = phi i32 [ undef, [[ENTRY:%.*]] ], [ [[INC2:%.*]], [[IF_END:%.*]] ]
+; CHECK-NEXT:    [[VAL:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[INC2:%.*]], [[IF_END:%.*]] ]
 ; CHECK-NEXT:    [[CMP:%.*]] = icmp ult i32 [[VAL]], 128
 ; CHECK-NEXT:    br i1 [[CMP]], label [[IF_THEN:%.*]], label [[IF_ELSE:%.*]]
 ; CHECK:       if.then:
Index: llvm/test/Transforms/TypePromotion/AArch64/trunc-zext-chain.ll
===================================================================
--- llvm/test/Transforms/TypePromotion/AArch64/trunc-zext-chain.ll
+++ llvm/test/Transforms/TypePromotion/AArch64/trunc-zext-chain.ll
@@ -140,7 +140,7 @@
 ; CHECK:       bb3:
 ; CHECK-NEXT:    [[VAR4:%.*]] = phi i64 [ [[VAR33:%.*]], [[BB31:%.*]] ], [ undef, [[BB:%.*]] ]
 ; CHECK-NEXT:    [[VAR5:%.*]] = phi %struct.wobble* [ [[VAR38:%.*]], [[BB31]] ], [ [[VAR]], [[BB]] ]
-; CHECK-NEXT:    [[VAR6:%.*]] = phi i32 [ [[VAR32:%.*]], [[BB31]] ], [ undef, [[BB]] ]
+; CHECK-NEXT:    [[VAR6:%.*]] = phi i32 [ [[VAR32:%.*]], [[BB31]] ], [ 0, [[BB]] ]
 ; CHECK-NEXT:    [[VAR7:%.*]] = icmp eq %struct.wobble* [[VAR5]], null
 ; CHECK-NEXT:    br i1 [[VAR7]], label [[BB8:%.*]], label [[BB9:%.*]]
 ; CHECK:       bb8:
Index: llvm/test/CodeGen/AArch64/typepromotion-phisret.ll
===================================================================
--- llvm/test/CodeGen/AArch64/typepromotion-phisret.ll
+++ llvm/test/CodeGen/AArch64/typepromotion-phisret.ll
@@ -180,14 +180,14 @@
 define i16 @phi_multiple_undefs(i16 zeroext %arg) {
 ; CHECK-LABEL: phi_multiple_undefs:
 ; CHECK:       // %bb.0: // %entry
-; CHECK-NEXT:    mov w8, #1
-; CHECK-NEXT:    // implicit-def: $w9
+; CHECK-NEXT:    mov w8, wzr
+; CHECK-NEXT:    mov w9, #1
 ; CHECK-NEXT:  .LBB4_1: // %loop
 ; CHECK-NEXT:    // =>This Inner Loop Header: Depth=1
-; CHECK-NEXT:    cmp w9, #128
-; CHECK-NEXT:    cinc w10, w8, lo
-; CHECK-NEXT:    add w9, w9, w10
-; CHECK-NEXT:    cmp w9, #253
+; CHECK-NEXT:    cmp w8, #128
+; CHECK-NEXT:    cinc w10, w9, lo
+; CHECK-NEXT:    add w8, w8, w10
+; CHECK-NEXT:    cmp w8, #253
 ; CHECK-NEXT:    b.lo .LBB4_1
 ; CHECK-NEXT:  // %bb.2: // %exit
 ; CHECK-NEXT:    ret
Index: llvm/lib/CodeGen/TypePromotion.cpp
===================================================================
--- llvm/lib/CodeGen/TypePromotion.cpp
+++ llvm/lib/CodeGen/TypePromotion.cpp
@@ -489,7 +489,7 @@
                                  : ConstantExpr::getZExt(Const, ExtTy);
         I->setOperand(i, NewConst);
       } else if (isa<UndefValue>(Op))
-        I->setOperand(i, UndefValue::get(ExtTy));
+        I->setOperand(i, ConstantInt::get(ExtTy, 0));
     }
 
     // Mutate the result type, unless this is an icmp or switch.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D123174.428965.patch
Type: text/x-patch
Size: 3031 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220512/672290ec/attachment.bin>


More information about the llvm-commits mailing list