[PATCH] D155028: [ConstantHoisting] add XFAIL test case

Nick Desaulniers via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 11 16:08:52 PDT 2023


nickdesaulniers created this revision.
Herald added a reviewer: ributzka.
Herald added a project: All.
nickdesaulniers requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

As reported by Linus Torvalds:
https://lore.kernel.org/lkml/CAHk-=wg9p+oJtzC0582vke8whcWPNSC9eq0Z6kdnSqWMEpah7g@mail.gmail.com/


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D155028

Files:
  llvm/test/Transforms/ConstantHoisting/X86/bad-cases.ll


Index: llvm/test/Transforms/ConstantHoisting/X86/bad-cases.ll
===================================================================
--- llvm/test/Transforms/ConstantHoisting/X86/bad-cases.ll
+++ llvm/test/Transforms/ConstantHoisting/X86/bad-cases.ll
@@ -12,9 +12,9 @@
 ; CHECK-NEXT:    [[L1:%.*]] = phi i64 [ [[RES1:%.*]], [[LOOP]] ], [ [[IN1:%.*]], [[ENTRY:%.*]] ]
 ; CHECK-NEXT:    [[L2:%.*]] = phi i64 [ [[RES2:%.*]], [[LOOP]] ], [ [[IN2:%.*]], [[ENTRY]] ]
 ; CHECK-NEXT:    [[RES1]] = sdiv i64 [[L1]], 4294967296
-; CHECK-NEXT:    store volatile i64 [[RES1]], ptr [[ADDR:%.*]]
+; CHECK-NEXT:    store volatile i64 [[RES1]], ptr [[ADDR:%.*]], align 4
 ; CHECK-NEXT:    [[RES2]] = srem i64 [[L2]], 4294967296
-; CHECK-NEXT:    store volatile i64 [[RES2]], ptr [[ADDR]]
+; CHECK-NEXT:    store volatile i64 [[RES2]], ptr [[ADDR]], align 4
 ; CHECK-NEXT:    [[AGAIN:%.*]] = icmp eq i64 [[RES1]], [[RES2]]
 ; CHECK-NEXT:    br i1 [[AGAIN]], label [[LOOP]], label [[END:%.*]]
 ; CHECK:       end:
@@ -45,9 +45,9 @@
 ; CHECK-NEXT:    [[L1:%.*]] = phi i64 [ [[RES1:%.*]], [[LOOP]] ], [ [[IN1:%.*]], [[ENTRY:%.*]] ]
 ; CHECK-NEXT:    [[L2:%.*]] = phi i64 [ [[RES2:%.*]], [[LOOP]] ], [ [[IN2:%.*]], [[ENTRY]] ]
 ; CHECK-NEXT:    [[RES1]] = udiv i64 [[L1]], 4294967296
-; CHECK-NEXT:    store volatile i64 [[RES1]], ptr [[ADDR:%.*]]
+; CHECK-NEXT:    store volatile i64 [[RES1]], ptr [[ADDR:%.*]], align 4
 ; CHECK-NEXT:    [[RES2]] = urem i64 [[L2]], 4294967296
-; CHECK-NEXT:    store volatile i64 [[RES2]], ptr [[ADDR]]
+; CHECK-NEXT:    store volatile i64 [[RES2]], ptr [[ADDR]], align 4
 ; CHECK-NEXT:    [[AGAIN:%.*]] = icmp eq i64 [[RES1]], [[RES2]]
 ; CHECK-NEXT:    br i1 [[AGAIN]], label [[LOOP]], label [[END:%.*]]
 ; CHECK:       end:
@@ -125,3 +125,37 @@
 }
 
 declare i32 @c(...)
+
+; The intent of this test is to verify that 68719476705 does not get
+; transformed into 68719476704 + 1 in basic block %d.
+define i1 @foo (ptr %bar) {
+; CHECK-LABEL: @foo(
+; CHECK-NEXT:    br i1 false, label [[A:%.*]], label [[B:%.*]]
+; CHECK:       a:
+; CHECK-NEXT:    [[CONST1:%.*]] = bitcast i64 68719476704 to i64
+; CHECK-NEXT:    [[UNUSED:%.*]] = icmp eq i64 0, [[CONST1]]
+; CHECK-NEXT:    ret i1 false
+; CHECK:       b:
+; CHECK-NEXT:    br i1 false, label [[C:%.*]], label [[D:%.*]]
+; CHECK:       c:
+; CHECK-NEXT:    ret i1 false
+; CHECK:       d:
+; CHECK-NEXT:    [[CONST:%.*]] = bitcast i64 68719476704 to i64
+; FIXME: this add is unnecessary and results in bad code gen. We should instead
+; have just emitted the bitcast to 68719476705 rather than 68719476704 + 1.
+; CHECK-NEXT:    [[CONST_MAT:%.*]] = add i64 [[CONST]], 1
+; CHECK-NEXT:    store i64 [[CONST_MAT]], ptr [[BAR:%.*]], align 4
+; CHECK-NEXT:    ret i1 false
+;
+  br i1 false, label %a, label %b
+a:
+  %unused = icmp eq i64 0, 68719476704
+  ret i1 false
+b:
+  br i1 false, label %c, label %d
+c:
+  ret i1 false
+d:
+  store i64 68719476705, ptr %bar
+  ret i1 false
+}


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D155028.539321.patch
Type: text/x-patch
Size: 2952 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230711/b9e40b7a/attachment.bin>


More information about the llvm-commits mailing list