From 911cfcd7f591b945369de3fca37dace71ae6054d Mon Sep 17 00:00:00 2001 From: Alexander Shaposhnikov Date: Sun, 3 Apr 2022 03:26:47 +0000 Subject: [PATCH] [InstCombine][NFC] Add baseline tests for folds of srem(X, PowerOf2) == C Extracted from: https://reviews.llvm.org/D122942 Test plan: make check-all --- llvm/test/Transforms/InstCombine/rem.ll | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/llvm/test/Transforms/InstCombine/rem.ll b/llvm/test/Transforms/InstCombine/rem.ll index f9439b2..b52803a 100644 --- a/llvm/test/Transforms/InstCombine/rem.ll +++ b/llvm/test/Transforms/InstCombine/rem.ll @@ -740,8 +740,8 @@ define i1 @test28(i32 %A) { ret i1 %C } -define i1 @positive_and_odd(i32 %A) { -; CHECK-LABEL: @positive_and_odd( +define i1 @positive_and_odd_eq(i32 %A) { +; CHECK-LABEL: @positive_and_odd_eq( ; CHECK-NEXT: [[B:%.*]] = srem i32 [[A:%.*]], 2 ; CHECK-NEXT: [[C:%.*]] = icmp eq i32 [[B]], 1 ; CHECK-NEXT: ret i1 [[C]] @@ -751,8 +751,8 @@ define i1 @positive_and_odd(i32 %A) { ret i1 %C } -define i1 @negative_and_odd(i32 %A) { -; CHECK-LABEL: @negative_and_odd( +define i1 @negative_and_odd_eq(i32 %A) { +; CHECK-LABEL: @negative_and_odd_eq( ; CHECK-NEXT: [[B:%.*]] = srem i32 [[A:%.*]], 2 ; CHECK-NEXT: [[C:%.*]] = icmp eq i32 [[B]], -1 ; CHECK-NEXT: ret i1 [[C]] @@ -762,6 +762,28 @@ define i1 @negative_and_odd(i32 %A) { ret i1 %C } +define i1 @positive_and_odd_ne(i32 %A) { +; CHECK-LABEL: @positive_and_odd_ne( +; CHECK-NEXT: [[B:%.*]] = srem i32 [[A:%.*]], 2 +; CHECK-NEXT: [[C:%.*]] = icmp ne i32 [[B]], 1 +; CHECK-NEXT: ret i1 [[C]] +; + %B = srem i32 %A, 2 + %C = icmp ne i32 %B, 1 + ret i1 %C +} + +define i1 @negative_and_odd_ne(i32 %A) { +; CHECK-LABEL: @negative_and_odd_ne( +; CHECK-NEXT: [[B:%.*]] = srem i32 [[A:%.*]], 2 +; CHECK-NEXT: [[C:%.*]] = icmp ne i32 [[B]], -1 +; CHECK-NEXT: ret i1 [[C]] +; + %B = srem i32 %A, 2 + %C = icmp ne i32 %B, -1 + ret i1 %C +} + ; FP division-by-zero is not UB. define double @PR34870(i1 %cond, double %x, double %y) { -- 2.7.4